From 74471f71973b3a02733a3df744b8b11a9de48be3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 22 Jul 2006 19:10:41 +0000 Subject: [PATCH] r935: - Adding user.hidestatuses - Updating construct_datastore_select() so that the $includeblank acts like construct_option_select() - Users can now override the admin setting for hiding statuses --- admin/user.php | 4 ++++ docs/schema_changes.sql | 2 ++ includes/api_user.php | 19 ++++++++++++++++++- includes/functions.php | 29 ++++++++++++++++++++++------- index.php | 8 ++++---- templates/userctrl.tpl | 20 ++++++++++++++++++++ userctrl.php | 5 +++++ 7 files changed, 75 insertions(+), 12 deletions(-) diff --git a/admin/user.php b/admin/user.php index ca01a4b..c635630 100644 --- a/admin/user.php +++ b/admin/user.php @@ -73,6 +73,7 @@ if ($_POST['do'] == 'insert') $user->set('timezone', $bugsys->in['timezone']); $user->set('usedst', $bugsys->in['usedst']); $user->set('password', $bugsys->in['password']); + $user->set('hidestatuses', $bugsys->in['hidestatuses']); $user->insert(); $admin->redirect('user.php?do=edit&userid=' . $user->insertid); @@ -94,6 +95,7 @@ if ($_POST['do'] == 'update') $user->set('timezone', $bugsys->in['timezone']); $user->set('usedst', $bugsys->in['usedst']); $user->set('password', $bugsys->in['password']); + $user->set('hidestatuses', $bugsys->in['hidestatuses']); $user->update(); $admin->redirect('user.php?do=edit&userid=' . $user->objdata['userid']); @@ -160,7 +162,9 @@ if ($_REQUEST['do'] == 'edit' OR $_REQUEST['do'] == 'add') $admin->list_item($string, $value, ($user['timezone'] == $value)); } $admin->row_list($lang->string('Timezone'), 'timezone'); + $admin->row_yesno($lang->string('Observe Daylight Savings Time (DST)'), 'usedst', $user['usedst']); + $admin->row_text($lang->string('Hidden Statuses on Bug Listing'), construct_option_select('hidestatuses', $bugsys->datastore['status'], $user['hidestatuses'], 'statusid', 'status', 0, true)); $admin->row_submit(); diff --git a/docs/schema_changes.sql b/docs/schema_changes.sql index 9c8368d..ac6e27f 100644 --- a/docs/schema_changes.sql +++ b/docs/schema_changes.sql @@ -16,3 +16,5 @@ CREATE TABLE useremail DROP TABLE dependency; ALTER TABLE user ADD usedst BOOL NOT NULL; + +ALTER TABLE user ADD hidestatuses mediumtext NOT NULL; diff --git a/includes/api_user.php b/includes/api_user.php index a4c7e94..d457a33 100644 --- a/includes/api_user.php +++ b/includes/api_user.php @@ -51,7 +51,8 @@ class UserAPI extends API 'showcolours' => array(TYPE_BOOL, REQ_NO), 'languageid' => array(TYPE_UINT, REQ_NO), 'timezone' => array(TYPE_INT, REQ_NO), - 'usedst' => array(TYPE_BOOL, REQ_NO) + 'usedst' => array(TYPE_BOOL, REQ_NO), + 'hidestatuses' => array(TYPE_STR, REQ_NO, ':self') ); /** @@ -243,6 +244,22 @@ class UserAPI extends API build_assignedto(); } + + // ################################################################### + /** + * Verify: hidestatuses + * + * @access public + */ + function verify_hidestatuses() + { + if (is_array($this->values['hidestatuses'])) + { + $this->set('hidestatuses', implode(',', $this->values['hidestatuses'])); + } + + return true; + } } /*=====================================================================*\ diff --git a/includes/functions.php b/includes/functions.php index 2207ae9..8eb4641 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -119,8 +119,22 @@ function can_perform($bitmask, $productid = 0, $userinfo = null) return ($userinfo['permissions'] & $bugsys->permissions["$bitmask"]); } -// ################# Start construct_datastore_select ################ -// loops through the specified datastore to create +* options. +* +* @access public +* +* @param string Datastore name +* @param string Array index for the label +* @param string Array index for the value +* @param mixed The selected value(s) +* @param bool Include a blank option? TRUE will set a null value, FALSE turns it off, anything else is used as the value for the blank option +* @param bool Generate it using admin printers? +* +* @return string Unelss in admin mode, returns the constructed options +*/ function construct_datastore_select($datastore, $labelname, $valuename, $selectedvalue = 0, $includeblank = false, $adminmode = false) { global $bugsys; @@ -132,17 +146,18 @@ function construct_datastore_select($datastore, $labelname, $valuename, $selecte $select = ''; - if ($includeblank) + if ($includeblank === true OR $includeblank !== false) { + $newval = ($inclueblank === true ? '' : $includeblank); if ($adminmode) { - $admin->list_item('', '', ((!$selectedvalue) ? true : false)); + $admin->list_item('', '', ((!$selectedvalue OR (is_array($selectedvalue) AND in_array($newval, $selectedvalue))) ? true : false)); } else { $label = ''; - $value = ''; - $selected = ((!$selectedvalue) ? true : false); + $value = $newval; + $selected = ((!$selectedvalue OR (is_array($selectedvalue) AND in_array($newval, $selectedvalue))) ? true : false); eval('$select .= "' . $bugsys->template->fetch('selectoption') . '";'); } } @@ -151,7 +166,7 @@ function construct_datastore_select($datastore, $labelname, $valuename, $selecte { $label = $item["$labelname"]; $value = $item["$valuename"]; - $selected = (($value == $selectedvalue) ? true : false); + $selected = (($value == $selectedvalue OR (is_array($selectedvalue) AND in_array($value, $selectedvalue))) ? true : false); if ($adminmode) { diff --git a/index.php b/index.php index 845c8f2..e28b052 100644 --- a/index.php +++ b/index.php @@ -45,8 +45,8 @@ $count = $db->query_first(" SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "bug WHERE (!hidden OR (hidden AND productid IN (" . fetch_on_bits('canviewhidden') . "))) - AND productid IN (" . fetch_on_bits('canviewbugs') . ")" . ($bugsys->options['hidestatuses'] ? " - AND status NOT IN (" . $bugsys->options['hidestatuses'] . ")" : "") + AND productid IN (" . fetch_on_bits('canviewbugs') . ")" . (($bugsys->options['hidestatuses'] OR isset($bugsys->userinfo['hidestatuses'])) ? " + AND status NOT IN (" . (isset($bugsys->userinfo['hidestatuses']) ? $bugsys->userinfo['hidestatuses'] : $bugsys->options['hidestatuses']) . ")" : "") ); $pagination->total = $count['count']; @@ -55,8 +55,8 @@ $pagination->split_pages(); $bugs_fetch = $db->query(" SELECT * FROM " . TABLE_PREFIX . "bug WHERE productid IN (" . fetch_on_bits('canviewbugs') . ") - AND (!hidden OR (hidden AND productid IN (" . fetch_on_bits('canviewhidden') . ")))" . ($bugsys->options['hidestatuses'] ? " - AND status NOT IN (" . $bugsys->options['hidestatuses'] . ")" : "") . " + AND (!hidden OR (hidden AND productid IN (" . fetch_on_bits('canviewhidden') . ")))" . (($bugsys->options['hidestatuses'] OR isset($bugsys->userinfo['hidestatuses'])) ? " + AND status NOT IN (" . (isset($bugsys->userinfo['hidestatuses']) ? $bugsys->userinfo['hidestatuses'] : $bugsys->options['hidestatuses']) . ")" : "") . " ORDER BY " . (can_perform('canviewhidden') ? "lastposttime" : "hiddenlastposttime") . " DESC LIMIT " . $pagination->fetch_limit($pagination->page - 1) . ", " . $pagination->perpage ); diff --git a/templates/userctrl.tpl b/templates/userctrl.tpl index 2bf3688..36c3784 100644 --- a/templates/userctrl.tpl +++ b/templates/userctrl.tpl @@ -190,6 +190,26 @@ $header +
+ +
+
{@"Bug List Display Options"}
+ +
+
+ {@"Hidden Statuses on Bug Listing"} + +
+
+
+ +
+ +
+ + +
+ diff --git a/userctrl.php b/userctrl.php index 6955222..3dbc09f 100644 --- a/userctrl.php +++ b/userctrl.php @@ -114,6 +114,7 @@ if ($_POST['do'] == 'update') $userapi->set('languageid', $bugsys->in['languageid']); $userapi->set('timezone', $bugsys->in['timezone']); $userapi->set('usedst', $bugsys->in['usedst']); + $userapi->set('hidestatuses', $bugsys->in['hidestatuses']); // ------------------------------------------------------------------- // copy fields @@ -123,6 +124,7 @@ if ($_POST['do'] == 'update') $userinfo['languageid'] = $bugsys->in['languageid']; $userinfo['timezone'] = $bugsys->in['timezone']; $userinfo['usedst'] = $bugsys->in['usedst']; + $userinfo['hidestatuses'] = $bugsys->in['hidestatuses']; $email = $bugsys->in['email']; $email_confirm = $bugsys->in['email_confirm']; @@ -168,6 +170,9 @@ if ($_REQUEST['do'] == 'modify') { $langselect = construct_datastore_select('language', 'title', 'languageid', $userinfo['languageid']); + $hidestatuses = construct_datastore_select('status', 'status', 'statusid', (!is_array($userinfo['hidestatuses']) ? explode(',', $userinfo['hidestatuses']) : $userinfo['hidestatuses']), 0); + $hidestatusesnum = (sizeof($bugsys->datastore['status']) < 8 ? sizeof($bugsys->datastore['status']) + 1 : 8); + foreach ($datef->fetch_timezone_list() AS $value => $label) { $selected = ($value == $userinfo['timezone']); -- 2.22.5