|
From: Ulf E. <ulf...@us...> - 2005-10-02 21:04:58
|
Update of /cvsroot/phpbt/phpbt/inc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv485/inc Modified Files: functions.php Log Message: RFE #618641 - Stricter editing RFE #579407 - Guest login Index: functions.php =================================================================== RCS file: /cvsroot/phpbt/phpbt/inc/functions.php,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- functions.php 1 Oct 2005 15:19:55 -0000 1.66 +++ functions.php 2 Oct 2005 21:04:50 -0000 1.67 @@ -52,7 +52,7 @@ /// /// Build a select box with the item matching $value selected function build_select($box, $selected = '', $project = 0) { - global $db, $select, $perm, $restricted_projects, $QUERY; + global $db, $select, $perm, $restricted_projects, $QUERY, $u; // create hash to map tablenames $cfgDatabase = array( @@ -194,9 +194,12 @@ } break; case 'bug_cc': + $may_edit = (isset($perm) && $perm->have_perm('EditBug', $project)); $rs = $db->query(sprintf($QUERY['functions-bug-cc'], $db->quote($selected))); while (list($uid, $user) = $rs->fetchRow(DB_FETCHMODE_ORDERED)) { - $text .= "<option value=\"$uid\">".maskemail($user).'</option>'; + if ($may_edit or $uid == $u) { + $text .= "<option value=\"$uid\">".maskemail($user).'</option>'; + } } // Pad the sucker $text .= '<option value="" disabled>'; @@ -304,14 +307,36 @@ /// /// Return human-friendly text for a value -function lookup($var, $val) { +function lookup($var, $val, $project = 0) { global $db; + // create hash to map tablenames + $cfgDatabase = array( + 'group' => TBL_AUTH_GROUP, + 'project' => TBL_PROJECT, + 'component' => TBL_COMPONENT, + 'status' => TBL_STATUS, + 'resolution' => TBL_RESOLUTION, + 'severity' => TBL_SEVERITY, + 'priority' => TBL_PRIORITY, + 'version' => TBL_VERSION, + 'database' => TBL_DATABASE, + 'site' => TBL_SITE, + 'os' => TBL_OS + ); + switch($var) { case 'reporter' : case 'assigned_to' : return maskemail($db->getOne("select login from ".TBL_AUTH_USER." where user_id = ".$db->quote($val))); break; + case 'version' : + return $db->getOne("select {$var}_name from ".$cfgDatabase[$var]." where project_id = ".$db->quote($project)." and {$var}_id = ".$db->quote($val)); + break; + default: + return $db->getOne("select {$var}_name from ".$cfgDatabase[$var]." where {$var}_id = ".$db->quote($val)); + break; + } } |