|
From: Benjamin C. <bc...@us...> - 2002-04-03 01:01:06
|
Update of /cvsroot/phpbt/phpbt/inc
In directory usw-pr-cvs1:/tmp/cvs-serv15790
Modified Files:
auth.php functions.php
Log Message:
Switching to smarty templates. Updating copyright notices
Index: auth.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/inc/auth.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- auth.php 27 Mar 2002 20:48:32 -0000 1.13
+++ auth.php 3 Apr 2002 01:01:04 -0000 1.14
@@ -2,7 +2,7 @@
// auth.php - Authentication and permission objects
// ------------------------------------------------------------------------
-// Copyright (c) 2001 The phpBugTracker Group
+// Copyright (c) 2001, 2002 The phpBugTracker Group
// ------------------------------------------------------------------------
// This file is part of phpBugTracker
//
@@ -30,16 +30,6 @@
function uauth() {
global $HTTP_SESSION_VARS;
- #if (!session_is_registered('auth')) {
- # session_register('auth');
- # $HTTP_SESSION_VARS['auth'] = array();
- #}
-
- #$a =& $HTTP_SESSION_VARS['auth'];
- #$this->auth =& $a->auth;
- #$this->auth =& $HTTP_SESSION_VARS['auth'];
-
-
if (!isset($HTTP_SESSION_VARS['group_ids'])) {
$HTTP_SESSION_VARS['group_ids'] = array(0);
}
@@ -163,17 +153,15 @@
function perm_invalid($actual_perms, $required_perms) {
global $t;
- $t->set_file('content','badperm.html');
- $t->pparse('main',array('content','wrap','main'));
+ $t->display('badperm.html');
}
function check_group($group) {
global $t;
if (!$this->check_auth('group', $group)) {
- $t->set_file('content', 'badgroup.html');
- $t->set_var('group', $group);
- $t->pparse('main',array('content','wrap','main'));
+ $t->assign('group', $group);
+ $t->display('badgroup.html');
exit();
}
}
Index: functions.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/inc/functions.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- functions.php 1 Apr 2002 15:42:41 -0000 1.15
+++ functions.php 3 Apr 2002 01:01:04 -0000 1.16
@@ -2,7 +2,7 @@
// functions.php - Set up global functions
// ------------------------------------------------------------------------
-// Copyright (c) 2001 The phpBugTracker Group
+// Copyright (c) 2001, 2002 The phpBugTracker Group
// ------------------------------------------------------------------------
// This file is part of phpBugTracker
//
@@ -27,9 +27,11 @@
function show_text($text, $iserror = false) {
global $t;
- $t->set_file('content','error.html');
- if (!$iserror) $t->set_var('text',$text);
- else $t->set_var('text',"<font color=red>$text</font>");
+ $t->assign(array(
+ 'text' => $text,
+ 'iserror' => $iserror
+ ));
+ $t->display('error.html');
}
$select['priority'] = array(
@@ -42,10 +44,13 @@
///
/// Build a select box with the item matching $value selected
-function build_select($box, $value = '', $project = 0) {
+function build_select($params) {
global $db, $select, $perm, $STRING, $restricted_projects, $QUERY;
- //create hash to map tablenames
+ extract($params);
+ if (!isset($selected)) $selected = '';
+
+ //create hash to map tablenames
$cfgDatabase = array(
'group' => TBL_AUTH_GROUP,
'project' => TBL_PROJECT,
@@ -77,12 +82,12 @@
case 'user_filter' :
foreach ($STRING['user_filter'] as $k => $v) {
$text .= sprintf("<option value=\"%d\"%s>%s</option>",
- $k, ($k == $value ? ' selected' : ''), $v);
+ $k, ($k == $selected ? ' selected' : ''), $v);
}
break;
case 'group' :
if ($project) { // If we are building for project admin page
- if (!count($value) or (count($value) && in_array(0, $value))) {
+ if (!count($selected) or (count($selected) && in_array(0, $selected))) {
$sel = ' selected';
} else {
$sel = '';
@@ -91,7 +96,7 @@
}
$rs = $db->query($queries[$box]);
while ($rs->fetchInto($row)) {
- if (count($value) && in_array($row[$box.'_id'], $value)) $sel = ' selected';
+ if (count($selected) && in_array($row[$box.'_id'], $selected)) $sel = ' selected';
else $sel = '';
$text .= '<option value="'.
$row[$box.'_id']."\"$sel>".$row[$box.'_name'].'</option>';
@@ -105,7 +110,7 @@
case 'version' :
$rs = $db->query($queries[$box]);
while ($rs->fetchInto($row)) {
- if ($value == $row[$box.'_id'] and $value != '') $sel = ' selected';
+ if ($selected == $row[$box.'_id'] and $selected != '') $sel = ' selected';
else $sel = '';
$text .= '<option value="'.
$row[$box.'_id']."\"$sel>".$row[$box.'_name'].'</option>';
@@ -114,9 +119,9 @@
case 'os' :
$rs = $db->query("select {$box}_id, {$box}_name, regex from ".TBL_OS." where sort_order > 0 order by sort_order");
while ($rs->fetchInto($row)) {
- if ($value == '' and isset($row['Regex']) and
+ if ($selected == '' and isset($row['Regex']) and
preg_match($row['Regex'],$GLOBALS['HTTP_USER_AGENT'])) $sel = ' selected';
- elseif ($value == $row[$box.'_id']) $sel = ' selected';
+ elseif ($selected == $row[$box.'_id']) $sel = ' selected';
else $sel = '';
$text .= '<option value="'.
$row[$box.'_id']."\"$sel>".$row[$box.'_name']."</option>";
@@ -125,13 +130,13 @@
case 'owner' :
$rs = $db->query("select u.user_id, login from ".TBL_AUTH_USER." u, ".TBL_USER_GROUP." ug, ".TBL_AUTH_GROUP." g where u.active > 0 and u.user_id = ug.user_id and ug.group_id = g.group_id and group_name = 'Developer' order by login");
while ($rs->fetchInto($row)) {
- if ($value == $row['user_id']) $sel = ' selected';
+ if ($selected == $row['user_id']) $sel = ' selected';
else $sel = '';
$text .= "<option value=\"{$row['user_id']}\"$sel>{$row['login']}</option>";
}
break;
case 'bug_cc' :
- $rs = $db->query(sprintf($QUERY['functions-bug-cc'], $value));
+ $rs = $db->query(sprintf($QUERY['functions-bug-cc'], $selected));
while (list($uid, $user) = $rs->fetchRow(DB_FETCHMODE_ORDERED)) {
$text .= "<option value=\"$uid\">".maskemail($user).'</option>';
}
@@ -153,7 +158,7 @@
closedir($dir);
sort($filelist);
foreach ($filelist as $file) {
- if ($file == $value) {
+ if ($file == $selected) {
$sel = ' selected';
} else {
$sel = '';
@@ -171,7 +176,7 @@
closedir($dir);
sort($filelist);
foreach ($filelist as $file) {
- if ($file == $value) {
+ if ($file == $selected) {
$sel = ' selected';
} else {
$sel = '';
@@ -182,19 +187,19 @@
default :
$deadarray = $select[$box];
while(list($val,$item) = each($deadarray)) {
- if ($value == $val and $value != '') $sel = ' selected';
+ if ($selected == $val and $selected != '') $sel = ' selected';
else $sel = '';
$text .= "<option value=\"$val\"$sel>$item</option>";
}
break;
}
- return $text;
+ echo $text;
}
///
/// Divide the results of a database query into multiple pages
function multipages($nr, $page, $urlstr) {
- global $me, $selrange;
+ global $me, $selrange, $t;
$pages = '';
if (!$page) $page = 1;
@@ -215,7 +220,14 @@
$pages .= $i != $npages ? '|' : '';
}
}
- return array($selrange, $llimit, $npages, $pages);
+ $t->assign(array(
+ 'pages' => $pages,
+ 'first' => $llimit+1,
+ 'last' => $llimit+$selrange > $nr ? $nr : $llimit+$selrange,
+ 'total' => $nr
+ ));
+
+ return array($selrange, $llimit);
}
///
@@ -224,12 +236,13 @@
global $t;
while(list($k, $v) = each($headers)) {
- $t->set_var($k.'url', "$url?order=$v&sort=".
+ $theader[$k]['url'] = "$url?order=$v&sort=".
($order == $v ? ($sort == 'asc' ? 'desc' : 'asc') : 'asc').
- ($urlstr ? '&'.$urlstr : ''));
- $t->set_var($k.'color', $order == $v ? '#bbbbbb' : '#eeeeee');
- $t->set_var($k.'class', $order == $v ? 'head-selected' : 'head');
+ ($urlstr ? '&'.$urlstr : '');
+ $theader[$k]['color'] = $order == $v ? '#bbbbbb' : '#eeeeee';
+ $theader[$k]['class'] = $order == $v ? 'selected' : '';
}
+ $t->assign('headers', $theader);
}
///
@@ -349,7 +362,7 @@
if (substr($js,-1) == ',') $js = substr($js,0,-1);
$js .= ");\n";
}
- return $js;
+ echo $js;
}
///
@@ -382,6 +395,11 @@
// Handle a database error
function handle_db_error(&$obj) {
die($obj->message.'<br>'.$obj->userinfo);
+}
+
+// Date() wrapper for smarty
+function bt_date($string, $format) {
+ return date($format, $string);
}
?>
|