|
From: Benjamin C. <bc...@us...> - 2003-08-30 22:10:55
|
Update of /cvsroot/phpbt/phpbt/inc
In directory sc8-pr-cvs1:/tmp/cvs-serv22871
Modified Files:
Tag: htmltemplates
functions.php
Log Message:
Switching to html templates and gettext
Index: functions.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/inc/functions.php,v
retrieving revision 1.44
retrieving revision 1.44.2.1
diff -u -r1.44 -r1.44.2.1
--- functions.php 24 Jul 2003 04:57:00 -0000 1.44
+++ functions.php 30 Aug 2003 22:10:52 -0000 1.44.2.1
@@ -44,14 +44,9 @@
///
/// Build a select box with the item matching $value selected
-function build_select($params) {
+function build_select($box, $selected = '', $project = 0) {
global $db, $select, $perm, $STRING, $restricted_projects, $QUERY;
- extract($params);
- if (!isset($selected)) {
- $selected = '';
- }
-
// create hash to map tablenames
$cfgDatabase = array(
'group' => TBL_AUTH_GROUP,
@@ -163,6 +158,20 @@
maskemail($row['login'])."</option>";
}
break;
+ case 'reporter':
+ global $u;
+ $rs = $db->query("select u.user_id, login from ".TBL_AUTH_USER." u where u.active > 0 order by login");
+ while ($rs->fetchInto($row)) {
+ // either singular matches, or array matches are acceptable
+ if ($u == $row['user_id']) {
+ $sel = ' selected';
+ } else {
+ $sel = '';
+ }
+ $text .= "<option value=\"{$row['user_id']}\"$sel>".
+ maskemail($row['login'])."</option>";
+ }
+ break;
case 'bug_cc':
$rs = $db->query(sprintf($QUERY['functions-bug-cc'], $selected));
while (list($uid, $user) = $rs->fetchRow(DB_FETCHMODE_ORDERED)) {
@@ -273,6 +282,19 @@
}
///
+/// Return human-friendly text for a value
+function lookup($var, $val) {
+ global $db;
+
+ switch($var) {
+ case 'assigned_to' :
+ return maskemail($db->getOne("select login from ".TBL_AUTH_USER." where user_id = $val"));
+ break;
+ }
+}
+
+
+///
/// Divide the results of a database query into multiple pages
function multipages($nr, $page, $urlstr) {
global $me, $selrange, $t, $u, $db, $perm;
@@ -402,10 +424,9 @@
///
/// Build the javascript for the dynamic project -> component -> version select boxes
-function build_project_js($params) {
+function build_project_js($no_all = false) {
global $db, $u, $perm, $_sv, $QUERY;
- extract($params);
$js = ''; $js2 = '';
// Build the javascript-powered select boxes
@@ -571,17 +592,25 @@
return ($retval);
}
+function translate($string, $plural = false) {
+ if (USE_GETTEXT) {
+ return $plural ? ngettext($string) : gettext($string);
+ } else {
+ return $string;
+ }
+}
+
// Generate a testable WHERE expression for closed bugs
function in_closed($column) {
global $db;
- $closed_statuses = array();
+ $closed_statuses = array(0);
foreach($db->getAll('SELECT status_id FROM '.TBL_STATUS.' WHERE bug_open = 0') as $row) {
$closed_statuses[] = (int)$row['status_id'];
}
- return '('.$column.' = '.(count($closed_statuses ? join(' OR '.$column.' = ', $closed_statuses) : '1')).')';
+ return '('.$column.' in ('.(@join(', ', $closed_statuses)).'))';
}
// Check whether or not a status-id means BUG_CLOSED
@@ -594,4 +623,5 @@
return false;
}
}
+
?>
|