function updatePreferences($request) { $request->valid(new Valid_String('cancel')); $vShow = new Valid_WhiteList('show', array('A', 'S', 'N', 'AS')); $vShow->required(); if (!$request->exist('cancel')) { if ($request->valid($vShow)) { switch ($request->get('show')) { case 'A': $this->_artifact_show = 'A'; break; case 'S': $this->_artifact_show = 'S'; break; case 'N': $this->_artifact_show = 'N'; break; case 'AS': default: $this->_artifact_show = 'AS'; } user_set_preference('my_artifacts_show', $this->_artifact_show); } } return true; }
/** * Generate url to Expend/Collapse a part of a page * @see my_hide_url */ function hide_url($svc, $db_item_id, $defaultHide = false, $hide = null) { $pref_name = 'hide_' . $svc . $db_item_id; if (empty($hide)) { $hide = $_REQUEST['hide_' . $svc]; } $noPref = false; $old_hide = user_get_preference($pref_name); // Make sure they are both 0 if never set before if ($old_hide == false) { $noPref = true; $old_hide = 0; } // If no given value for hide, keep the old one if (!isset($hide)) { $hide = $old_hide; } // Update pref value if needed if ($old_hide != $hide) { user_set_preference($pref_name, $hide); } if ($hide == 2 || $noPref && $defaultHide) { $hide_url = 'hide_' . $svc . '=1&hide_item_id=' . $db_item_id; $hide_img = '<img src="' . util_get_image_theme("pointer_right.png") . '" align="middle" border="0" alt="Expand">'; $hide_now = true; } else { $hide_url = 'hide_' . $svc . '=2&hide_item_id=' . $db_item_id; $hide_img = '<img src="' . util_get_image_theme("pointer_down.png") . '" align="middle" border="0" alt="Collapse">'; $hide_now = false; } return array($hide_now, $hide_url, $hide_img); }
/** * Permit CSV file input,parse the CSV file and show the parse report * * */ function displayParse($csv_filename) { global $Language; if (!file_exists($csv_filename) || !is_readable($csv_filename)) { exit_missing_param(); } $is_tmp = false; //} if (array_key_exists('notify', $_REQUEST) && $_REQUEST['notify']) { user_set_preference('tracker_import_notify_' . $this->ath->getID(), 1); } else { user_set_preference('tracker_import_notify_' . $this->ath->getID(), 0); } $ok = $this->parse($csv_filename, $is_tmp, $artifacts_data, $number_inserts, $number_updates); $this->ath->header(array('title' => $Language->getText('tracker_import', 'art_import') . $this->ath->getID() . ' - ' . $this->ath->getName(), 'pagename' => 'tracker', 'atid' => $this->ath->getID(), 'sectionvals' => array($this->group->getPublicName()), 'help' => 'tracker-v3.html#tracker-artifact-import')); echo '<div id="tracker_toolbar_clear"></div>' . PHP_EOL; echo '<h2>' . $Language->getText('tracker_import', 'parse_report') . '</h2>'; if (!$ok) { $this->showErrors(); } else { echo $Language->getText('tracker_import', 'ready', array($number_inserts + $number_updates, $number_inserts, $number_updates)) . "<br><br>\n"; echo $Language->getText('tracker_import', 'check_data'); $this->showParseResults($this->parsed_labels, $artifacts_data); } $this->ath->footer(array()); }
function _content($params) { if (isset($params['redirect_to'])) { $url = $params['redirect_to']; } else { if (isset($params['default_url_params'])) { $url = $this->buildUrl($params['default_url'], $params['default_url_params'], false); } else { $url = $params['default_url']; } } user_set_preference('plugin_docman_flash', serialize($this->_controller->feedback)); $GLOBALS['Response']->redirect($url); }
function my_hide_url($svc, $db_item_id, $item_id, $count, $hide) { global $Language; $pref_name = 'my_hide_' . $svc . $db_item_id; $old_hide = $old_count = $old_pref_value = user_get_preference($pref_name); if ($old_pref_value) { list($old_hide, $old_count) = explode('|', $old_pref_value); } // Make sure they are both 0 if never set before if ($old_count == false) { $old_count = 0; } if ($old_hide == false) { $old_hide = 0; } if ($item_id == $db_item_id) { if (isset($hide)) { $pref_value = "{$hide}|{$count}"; } else { $pref_value = "{$old_hide}|{$count}"; $hide = $old_hide; } } else { if ($old_hide) { // if items are hidden keep the old count and keep pref as is $pref_value = $old_pref_value; } else { // only update the item count if the items are visible // if they are hidden keep reporting the old count $pref_value = "{$old_hide}|{$count}"; } $hide = $old_hide; } // Update pref value if needed if ($old_pref_value != $pref_value) { user_set_preference($pref_name, $pref_value); } if ($hide) { $hide_url = '<a href="?hide_' . $svc . '=0&hide_item_id=' . $db_item_id . '"><img src="' . util_get_image_theme("pointer_right.png") . '" align="middle" border="0" title="' . $Language->getText('my_utils', 'expand') . '" alt="' . $Language->getText('my_utils', 'expand') . '"></a> '; $hide_now = true; } else { $hide_url = '<a href="?hide_' . $svc . '=1&hide_item_id=' . $db_item_id . '"><img src="' . util_get_image_theme("pointer_down.png") . '" align="middle" border="0" title="' . $Language->getText('my_utils', 'collapse') . '" alt="' . $Language->getText('my_utils', 'collapse') . '"></a> '; $hide_now = false; } return array($hide_now, $count - $old_count, $hide_url); }
/** * Hook to set all user preferences . * * @param params:hook parameters */ function tracker_user_pref($params) { if ($this->isAllowed()) { $this->group_id = $params['group_id']; $this->atid = $params['atid']; $this->report_id = $params['report_id']; $this->prefs = $params['prefs']; $this->morder = $params['morder']; $this->chunksz = $params['chunksz']; $this->advsrch = $params['advsrch']; $this->msort = $params['msort']; $this->offset = $params['offset']; $this->set = $params['set']; $request =& HTTPRequest::instance(); $func = $request->get('func'); $set = $request->get('set'); if ($request->get('report_graphic_id') !== false && $request->valid(new Valid_UInt('report_graphic_id'))) { $this->report_graphic_id = $request->get('report_graphic_id'); $trackerGraphsPrefs = "&report_graphic_id=" . $this->report_graphic_id; if ($trackerGraphsPrefs != user_get_preference('tracker_graph_brow_cust' . $request->get('atid'))) { user_set_preference('tracker_graph_brow_cust' . $request->get('atid'), $trackerGraphsPrefs); } } else { if (user_isloggedin()) { $custom_pref = user_get_preference('tracker_graph_brow_cust' . $this->atid); if ($custom_pref) { $pref_arr = explode('&', substr($custom_pref, 1)); while (list(, $expr) = each($pref_arr)) { list($field, $value_id) = explode('=', $expr); $field = str_replace('[]', '', $field); if ($field == 'report_graphic_id') { $this->report_graphic_id = $value_id; } } } } } } }
function _adminPageUpdate_Service($_REQUEST) { global $Language, $feedback; $group_id = (int) $_REQUEST['group_id']; switch ($_REQUEST['func']) { case 'pl_config_update': if (isset($_REQUEST['EnableProjectLink'])) { user_set_preference("pl_GroupId_master", $group_id); } else { user_del_preference("pl_GroupId_master"); } $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_ok'); break; case 'pl_link_delete': // delete project link $link_id = (int) $_REQUEST['link_id']; // NB: use group_id to defend against malicious use if (db_query("DELETE FROM plugin_projectlinks_relationship\n WHERE (master_group_id=" . db_ei($group_id) . ")\n AND (link_id=" . db_ei($link_id) . ");")) { $feedback .= ' ' . $Language->getText('plugin_plinks', 'project_link_deleted_OK'); } else { $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_failed', db_error()); } break; case 'pl_type_delete': // delete project link type and all links using the type $link_type_id = (int) $_REQUEST['link_type_id']; // delete project relationship instances // NB: use group_id to defend against malicious use if (!db_query("DELETE FROM plugin_projectlinks_relationship\n WHERE (master_group_id=" . db_ei($group_id) . ")\n AND (link_type_id=" . db_ei($link_type_id) . ");")) { $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_failed', db_error()); } else { //delete the relationship type if no error deleting instances if (!db_query("DELETE FROM plugin_projectlinks_link_type\n WHERE (group_id=" . db_ei($group_id) . ")\n AND (link_type_id=" . db_ei($link_type_id) . ");")) { $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_failed', db_error()); } else { $feedback .= ' ' . $Language->getText('plugin_plinks', 'project_link_deleted_OK'); } if (user_get_preference("pl_GroupId_master") == $group_id) { // switch off linking to this project - it would be better // to check if no types left, but this works well user_del_preference("pl_GroupId_master"); } } break; case 'pl_type_update': $q_name = "'" . db_es($_REQUEST['name']) . "'"; $q_reverse_name = "'" . db_es(nz($_REQUEST['reverse_name'], $_REQUEST['name'])) . "'"; $q_description = "'" . db_es($_REQUEST['description']) . "'"; /** **1 commented out for now - until we can decide how to deal with project links functionality $q_uri_plus = db_es($_REQUEST['uri_plus']); **/ $q_uri_plus = "'" . db_es('/projects/$projname/') . "'"; // $link_type_id is not set when submitting a new link if (isset($_REQUEST['link_type_id'])) { $link_type_id = (int) $_REQUEST['link_type_id']; } else { $link_type_id = NULL; } // check the change would not create a duplicate $pfcheck = db_query("SELECT name\n FROM plugin_projectlinks_link_type\n WHERE (((name=" . $q_name . ")\n OR (reverse_name=" . $q_reverse_name . "))\n AND ((group_id=" . db_ei($group_id) . ")" . (is_null($link_type_id) ? "" : " AND (link_type_id<>" . db_ei($link_type_id) . ")") . ")\n );"); if (db_numrows($pfcheck) > 0) { $feedback .= ' ' . $Language->getText('plugin_plinks', 'project_link_type_change_makes_duplicate'); } elseif (update_database("plugin_projectlinks_link_type", array("name" => $q_name, "reverse_name" => $q_reverse_name, "description" => $q_description, "uri_plus" => $q_uri_plus, "group_id" => $group_id), is_null($link_type_id) ? NULL : "link_type_id={$link_type_id}")) { $this->addWidgetOnSummaryPage($group_id); $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_ok') . ' '; } else { $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_failed', db_error()); } break; case 'pl_link_update': $link_type_id = (int) $_REQUEST['link_type_id']; if (isset($_REQUEST['target_group_id'])) { $target_group_id = (int) $_REQUEST['target_group_id']; } else { $prjManager = ProjectManager::instance(); $trgProject = $prjManager->getProjectFromAutocompleter($_REQUEST['target_group']); if ($trgProject !== false) { $target_group_id = $trgProject->getId(); } else { return; } } $group_id = (int) $_REQUEST['group_id']; // NB: $link_id is not set when submitting a new link if (isset($_REQUEST['link_id'])) { $link_id = (int) $_REQUEST['link_id']; } else { $link_id = NULL; // if this is a new link to a template: // add links to all projects already created from the template $db_res = db_query("SELECT group_id\n FROM groups\n WHERE (built_from_template = " . db_ei($target_group_id) . ");"); while ($row = db_fetch_array($db_res)) { $feedback .= ' ' . $this->_link_unique_update($group_id, $row['group_id'], $link_type_id); } } $feedback .= ' ' . $this->_link_unique_update($group_id, $target_group_id, $link_type_id, $link_id); break; case 'template_sync_type_add': $template_type_id = (int) $_REQUEST['template_type_id']; $db_res = db_query("SELECT * FROM plugin_projectlinks_link_type\n WHERE (link_type_id = " . db_ei($template_type_id) . ");"); if (db_numrows($db_res) == 1) { $row = db_fetch_array($db_res); if (db_query("INSERT INTO plugin_projectlinks_link_type (\n group_id,\n name,\n reverse_name,\n description,\n uri_plus\n ) VALUES (\n {$group_id},\n '" . db_es($row['name']) . "',\n '" . db_es($row['reverse_name']) . "',\n '" . db_es($row['description']) . "',\n '" . db_es($row['uri_plus']) . "'\n );")) { $feedback .= ' ' . $Language->getText('plugin_plinks', 'update_ok'); } } break; default: $feedback .= " not implemented: '{$_REQUEST['func']}'"; break; } }
function request() { if ($this->request->exist('action') && ($this->request->get('action') == 'plugin_docman_approval_reviewer' || $this->request->get('action') == 'plugin_docman_approval_requester')) { if ($this->request->get('hide')) { user_set_preference('hide_' . $this->request->get('action'), 1); } else { user_del_preference('hide_' . $this->request->get('action')); } exit; } if (!$this->request->exist('group_id')) { $this->feedback->log('error', 'Project is missing.'); $this->_setView('Error'); } else { $_groupId = (int) $this->request->get('group_id'); $pm = ProjectManager::instance(); $project = $pm->getProject($_groupId); if ($project == false) { $this->feedback->log('error', 'Project is missing.'); $this->_setView('Error'); return; } // Browser alert $this->_checkBrowserCompliance(); //token for redirection $tok =& new Docman_Token(); $this->_viewParams['docman'] =& $this; $this->_viewParams['user'] =& $this->getUser(); $this->_viewParams['token'] = $tok->getToken(); $this->_viewParams['default_url'] = $this->getDefaultUrl(); $this->_viewParams['theme_path'] = $this->getThemePath(); $this->_viewParams['group_id'] = (int) $this->request->get('group_id'); if ($this->request->exist('version_number')) { $this->_viewParams['version_number'] = (int) $this->request->get('version_number'); } if ($this->request->exist('section')) { $this->_viewParams['section'] = $this->request->get('section'); } else { if ($this->request->get('action') == 'permissions') { $this->_viewParams['section'] = 'permissions'; } } $view = $this->request->exist('action') ? $this->request->get('action') : 'show'; $this->_viewParams['action'] = $view; // Start is used by Table view (like LIMIT start,offset) if ($this->request->exist('start')) { $this->_viewParams['start'] = (int) $this->request->get('start'); } if ($this->request->exist('pv')) { $this->_viewParams['pv'] = (int) $this->request->get('pv'); } if ($this->request->exist('report')) { $this->_viewParams['report'] = $this->request->get('report'); $views = Docman_View_Browse::getDefaultViews(); $validator = new Valid_WhiteList('report', $views); $views_keys = array_keys($views); $default_view = $views[$views_keys[0]]; $this->_viewParams['report'] = $this->request->getValidated('report', $validator, $default_view); } $item_factory =& $this->_getItemFactory(); $root =& $item_factory->getRoot($this->request->get('group_id')); if (!$root) { // Install $_gid = (int) $this->request->get('group_id'); $pm = ProjectManager::instance(); $project = $pm->getProject($_gid); $tmplGroupId = (int) $project->getTemplate(); $this->_cloneDocman($tmplGroupId, $_gid, false); if (!$item_factory->getRoot($_gid)) { $item_factory->createRoot($_gid, 'roottitle_lbl_key'); } $this->_viewParams['redirect_to'] = $_SERVER['REQUEST_URI']; $this->view = 'Redirect'; } else { $id = $this->request->get('id'); if (!$id && $this->request->exist('item')) { $i = $this->request->get('item'); if (isset($i['id'])) { $id = $i['id']; } } if ($id) { $item =& $item_factory->getItemFromDb($id); if (!$item) { $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_item_deleted')); $this->_setView('DocmanError'); } } else { $item =& $root; } if ($item) { // Load report // If the item (folder) defined in the report is not the // same than the current one, replace it. $this->_initReport($item); if ($this->_viewParams['filter'] !== null && $this->_viewParams['filter']->getItemId() !== null && $this->_viewParams['filter']->getItemId() != $item->getId()) { $reportItem = $item_factory->getItemFromDb($this->_viewParams['filter']->getItemId()); // If item defined in the report exists, use it // otherwise raise an error if (!$reportItem) { $this->feedback->log('warning', $GLOBALS['Language']->getText('plugin_docman', 'error_report_baditemid')); } else { unset($item); $item = $reportItem; } } if ($this->request->get('action') == 'ajax_reference_tooltip') { $this->groupId = $item->getGroupId(); } if ($item->getGroupId() != $this->getGroupId()) { $pm = ProjectManager::instance(); $g = $pm->getProject($this->getGroupId()); $this->_set_doesnot_belong_to_project_error($item, $g); } else { $user = $this->getUser(); $dpm = $this->_getPermissionsManager(); $can_read = $dpm->userCanAccess($user, $item->getId()); $folder_or_document = is_a($item, 'Docman_Folder') ? 'folder' : 'document'; if (!$can_read) { if ($this->request->get('action') == 'ajax_reference_tooltip') { $this->_setView('AjaxReferenceTooltipError'); } else { $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_view')); $this->_setView('PermissionDeniedError'); } } else { $mdFactory = new Docman_MetadataFactory($this->_viewParams['group_id']); $mdFactory->appendItemMetadataList($item); $get_show_view =& new Docman_View_GetShowViewVisitor(); $this->_viewParams['item'] =& $item; if (strpos($view, 'admin') === 0 && !$this->userCanAdmin()) { $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_admin')); $this->view = $item->accept($get_show_view, $this->request->get('report')); } else { if ($item->isObsolete()) { $this->feedback->log('warning', $this->txt('warning_obsolete')); } $this->_dispatch($view, $item, $root, $get_show_view); } } } } } } }
} if ($set == 'my') { /* My patches - backwards compat can be removed 9/10 */ $_status = 1; $_assigned_to = user_getid(); } else { if ($set == 'custom') { /* if this custom set is different than the stored one, reset preference */ $pref_ = $_assigned_to . '|' . $_status . '|' . $_category; if ($pref_ != user_get_preference('patch_browcust' . $group_id)) { //echo 'setting pref'; user_set_preference('patch_browcust' . $group_id, $pref_); } } else { if ($set == 'postponed') { /* postponed patches */ $_assigned_to = 0; $_status = '4'; } else { if ($set == 'closed') { /* Closed patches - backwards compat can be removed 9/10 */ $_assigned_to = 0; $_status = '2';
if ($set == 'my') { /* My commits - backwards compat can be removed 9/10 */ $_tag = 100; $_commiter = user_getname(); $_branch = 100; } else { if ($set == 'custom') { /* if this custom set is different than the stored one, reset preference */ $pref_ = $_commit_id . '|' . $_commiter . '|' . $_tag . '|' . $_branch . '|' . $_srch . '|' . $chunksz; if ($pref_ != user_get_preference('commits_browcust' . $group_id)) { //echo 'setting pref'; user_set_preference('commits_browcust' . $group_id, $pref_); } } else { if ($set == 'any') { /* Closed commits - backwards compat can be removed 9/10 */ $tag = $branch = $_commiter = 100; } } } /* Display commits based on the form post - by user or status or both */ $_tag = isset($_tag) ? $_tag : 100; $_branch = isset($_branch) ? $_branch : 100;
} if ($set == 'my') { /* My requests - backwards compat can be removed 9/10 */ $_status = 1; $_assigned_to = user_getid(); } else { if ($set == 'custom') { /* if this custom set is different than the stored one, reset preference */ $pref_ = $_assigned_to . '|' . $_status . '|' . $_category; if ($pref_ != user_get_preference('sup_brow_cust' . $group_id)) { //echo 'setting pref'; user_set_preference('sup_brow_cust' . $group_id, $pref_); } } else { if ($set == 'closed') { /* Closed requests - backwards compat can be removed 9/10 */ $_assigned_to = 0; $_status = '2'; } else { /* Open requests - backwards compat can be removed 9/10 */ $_assigned_to = 0; $_status = '1'; }
function updatePreferences(&$request) { $request->valid(new Valid_String('cancel')); if (!$request->exist('cancel')) { $monitored_jobs = $request->get('myhudsonjobs'); $user = UserManager::instance()->getCurrentUser(); $job_dao = new PluginHudsonJobDao(CodendiDataAccess::instance()); $dar = $job_dao->searchByUserID($user->getId()); $not_monitored_jobs = array(); while ($dar->valid()) { $row = $dar->current(); if (!in_array($row['job_id'], $monitored_jobs)) { $not_monitored_jobs[] = $row['job_id']; } $dar->next(); } $this->_not_monitored_jobs = $not_monitored_jobs; user_set_preference('plugin_hudson_my_not_monitored_jobs', implode(",", $this->_not_monitored_jobs)); $use_global_status = $request->get('use_global_status'); $this->_use_global_status = $use_global_status !== false ? "true" : "false"; user_set_preference('plugin_hudson_use_global_status', $this->_use_global_status); } return true; }
/** * Set a expand preference for given folder for current user. * * @param Folder */ function expand($folder) { user_set_preference(PLUGIN_DOCMAN_EXPAND_FOLDER_PREF . '_' . $folder->getGroupId() . '_' . $folder->getId(), PLUGIN_DOCMAN_EXPAND_FOLDER); }
$pref_stg .= '&' . $field . '[]=' . $value_id; } } // build part of the HTML title of this page for more friendly bookmarking // Do not add the criteria in the header if value is "Any" if ($value_id != 0) { $hdr .= $Language->getText('global', 'by') . $field->getLabel() . ': ' . $field->getValue($group_id, $value_id); } } $pref_stg .= '&advsrch=' . ($advsrch ? 1 : 0); $pref_stg .= '&msort=' . ($msort ? 1 : 0); $pref_stg .= '&chunksz=' . (int) $chunksz; $pref_stg .= '&report_id=' . (int) $report_id; if ($pref_stg != user_get_preference('artifact_brow_cust' . $atid)) { //echo "<br> DBG setting pref = $pref_stg"; user_set_preference('artifact_brow_cust' . $atid, $pref_stg); } } else { if ($set == 'all') { // Any value for very field $prefs['status_id'][] = 0; $prefs['assigned_to'][] = 0; $prefs['multi_assigned_to'][] = 0; } else { // Open artifacts - backwards compat can be removed 9/10 $prefs['status_id'][] = 1; // Any value for assigned to $prefs['assigned_to'][] = 0; $prefs['multi_assigned_to'][] = 0; } }
if it was a custom set just posted && logged in, set pref if it's changed */ if (user_isloggedin()) { $_pref = $style . '|' . $max_rows; if (isset($set) && $set == 'custom') { if (user_get_preference('forum_style')) { $_pref = $style . '|' . $max_rows; if ($_pref == user_get_preference('forum_style')) { //do nothing - pref already stored } else { //set the pref user_set_preference('forum_style', $_pref); } } else { //set the pref user_set_preference('forum_style', $_pref); } } else { if (user_get_preference('forum_style')) { $_pref_arr = explode('|', user_get_preference('forum_style')); $style = $_pref_arr[0]; $max_rows = $_pref_arr[1]; } else { //no saved pref and we're not setting //one because this is all default settings } } } /* Set up navigation vars */
function updatePreferences(&$request) { $request->valid(new Valid_String('cancel')); $nbShow = new Valid_UInt('nb_svn_commits'); $nbShow->required(); if (!$request->exist('cancel')) { if ($request->valid($nbShow)) { $this->_nb_svn_commits = $request->get('nb_svn_commits'); } else { $this->_nb_svn_commits = self::NB_COMMITS_TO_DISPLAY; } user_set_preference('my_latests_svn_commits_nb_display', $this->_nb_svn_commits); } return true; }
$user_tracker_mailformat = $request->get(Codendi_Mail_Interface::PREF_FORMAT); } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('account_preferences', 'error_user_tracker_mailformat')); } } // // Perform the update // // User db_query("UPDATE user SET " . "mail_siteupdates=" . $form_mail_site . "," . "mail_va=" . $form_mail_va . "," . "theme='" . db_es($user_theme) . "'," . "sticky_login="******"," . "language_id='" . db_es($language_id) . "' WHERE " . "user_id=" . user_getid()); // Preferences user_set_preference("user_csv_separator", $user_csv_separator); user_set_preference("user_csv_dateformat", $user_csv_dateformat); user_set_preference(Codendi_Mail_Interface::PREF_FORMAT, $user_tracker_mailformat); if ($username_display !== null) { user_set_preference("username_display", $username_display); } $user->setLabFeatures($request->existAndNonEmpty('form_lab_features')); if ($user_theme_variant) { $user->setPreference('theme_variant', $user_theme_variant); } if ($user_edition_default_format) { $user->setPreference(PFUser::EDITION_DEFAULT_FORMAT, $user_edition_default_format); } //plugins specific preferences $em = EventManager::instance(); $em->processEvent('update_user_preferences_appearance', array('request' => $request)); // // Output // session_redirect("/account/index.php");
function setCopyPreference($item) { user_set_preference(PLUGIN_DOCMAN_PREF . '_item_copy', $item->getId()); }
<?php require_once 'pre.php'; $valid = new Valid_UInt('tracker_id'); $valid->required(); if ($request->valid($valid)) { if (user_get_preference('tracker_comment_invertorder_' . $request->get('tracker_id'))) { user_del_preference('tracker_comment_invertorder_' . $request->get('tracker_id')); } else { user_set_preference('tracker_comment_invertorder_' . $request->get('tracker_id'), '1'); } }
function updatePreferences(&$request) { $request->valid(new Valid_String('cancel')); if (!$request->exist('cancel')) { $use_global_status = $request->get('use_global_status'); $this->_use_global_status = $use_global_status !== false ? "true" : "false"; user_set_preference('plugin_hudson_use_global_status' . $this->group_id, $this->_use_global_status); } return true; }
/** * Update preferences * * @param Array $request HTTP request * * @return Boolean */ function updatePreferences($request) { $request->valid(new Valid_String('cancel')); $vOffset = new Valid_UInt('plugin_git_user_pushes_offset'); $vOffset->required(); $vDays = new Valid_UInt('plugin_git_user_pushes_past_days'); $vDays->required(); if (!$request->exist('cancel')) { if ($request->valid($vOffset)) { $this->offset = $request->get('plugin_git_user_pushes_offset'); } else { $this->offset = 5; } if ($request->valid($vDays)) { $this->pastDays = $request->get('plugin_git_user_pushes_past_days'); } else { $this->pastDays = 30; } user_set_preference('plugin_git_user_pushes_offset', $this->offset); user_set_preference('plugin_git_user_pushes_past_days', $this->pastDays); } return true; }
function change_view() { $request =& HTTPRequest::instance(); $group_id = (int) $request->get('group_id'); if ($request->exist('selected_view')) { if (is_numeric($request->get('selected_view'))) { $this->_controler->setReportId($request->get('selected_view')); $this->_controler->forceView('Table'); } else { if (is_array($request->get('selected_view')) && count($request->get('selected_view'))) { list($selected_view, ) = each($request->get('selected_view')); if (Docman_View_Browse::isViewAllowed($selected_view)) { $item_factory =& $this->_getItemFactory(); $folder = $item_factory->getItemFromDb($request->get('id')); if ($folder) { user_set_preference(PLUGIN_DOCMAN_VIEW_PREF . '_' . $folder->getGroupId(), $selected_view); $this->_controler->forceView($selected_view); } } } } } }
/** * Display the artifact * * @param ro: read only parameter - Display mode or update mode * @param pv: printer version * * @return void */ function display($ro, $pv, $user_id) { global $art_field_fact, $art_fieldset_fact, $sys_max_size_attachment, $Language; $hp = Codendi_HTMLPurifier::instance(); $fields_per_line = 2; // the column number is the number of field per line * 2 (label + value) // + the number of field per line -1 (a blank column between each pair "label-value" to give more space) $columns_number = $fields_per_line * 2 + ($fields_per_line - 1); $max_size = 40; $group = $this->ArtifactType->getGroup(); $group_artifact_id = $this->ArtifactType->getID(); $group_id = $group->getGroupId(); $result_fields = $art_field_fact->getAllUsedFields(); $result_fieldsets = $art_fieldset_fact->getAllFieldSetsContainingUsedFields(); $summary = $this->getValue('summary'); echo '<div id="tracker_toolbar_specific">'; if ($this->ArtifactType->allowsCopy()) { echo "<A HREF='?func=copy&aid=" . (int) $this->getID() . "&group_id=" . (int) $group_id . "&atid=" . (int) $group_artifact_id . "'><img src=\"" . util_get_image_theme("ic/copy.png") . "\" /> " . $Language->getText('tracker_include_artifact', 'copy_art') . "</A>"; } echo " <A HREF='?func=detail&aid=" . (int) $this->getID() . "&group_id=" . (int) $group_id . "&atid=" . (int) $group_artifact_id . "&pv=1' target='_blank'><img src='" . util_get_image_theme("ic/printer.png") . "' border='0'> " . $Language->getText('global', 'printer_version') . "</A>"; echo '</div>' . PHP_EOL; echo '<div id="tracker_toolbar_clear"></div>' . PHP_EOL; $artTitle = '[ ' . $hp->purify($this->ArtifactType->getItemName(), CODENDI_PURIFIER_CONVERT_HTML); $field_artifact_id = $result_fields['artifact_id']; if ($field_artifact_id->userCanRead($group_id, $group_artifact_id, $user_id)) { $artTitle .= " #" . $hp->purify($this->getID(), CODENDI_PURIFIER_CONVERT_HTML); } $artTitle .= ' ] ' . $hp->purify(util_unconvert_htmlspecialchars($summary), CODENDI_PURIFIER_CONVERT_HTML); // First display some internal fields echo ' <FORM ACTION="" METHOD="POST" enctype="multipart/form-data" NAME="artifact_form"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="' . $sys_max_size_attachment . '">'; if ($ro) { echo '<INPUT TYPE="HIDDEN" NAME="func" VALUE="postaddcomment">'; } else { echo '<INPUT TYPE="HIDDEN" NAME="func" VALUE="postmod">'; } echo ' <INPUT TYPE="HIDDEN" NAME="artifact_timestamp" VALUE="' . time() . '"> <INPUT TYPE="HIDDEN" NAME="group_id" VALUE="' . (int) $group_id . '"> <INPUT TYPE="HIDDEN" NAME="group_artifact_id" VALUE="' . (int) $group_artifact_id . '"> <INPUT TYPE="HIDDEN" NAME="atid" VALUE="' . (int) $group_artifact_id . '"> <INPUT TYPE="HIDDEN" NAME="artifact_id" VALUE="' . (int) $this->getID() . '"> <INPUT TYPE="HIDDEN" NAME="aid" VALUE="' . (int) $this->getID() . '">'; echo '<TABLE><TR><TD class="artifact">'; $html = ''; $html .= '<TABLE width="100%"><TR>'; $pm = ProjectManager::instance(); // Now display the variable part of the field list (depend on the project) foreach ($result_fieldsets as $fieldset_id => $result_fieldset) { // this variable will tell us if we have to display the fieldset or not (if there is at least one field to display or not) $display_fieldset = false; $fieldset_html = ''; $i = 0; $fields_in_fieldset = $result_fieldset->getAllUsedFields(); while (list($key, $field) = each($fields_in_fieldset)) { if ($field->getName() != 'comment_type_id' && $field->getName() != 'artifact_id') { $field_html = $this->_getFieldLabelAndValueForUser($group_id, $group_artifact_id, $field, $user_id, $pv); if ($field_html) { // if the user can read at least one field, we can display the fieldset this field is within $display_fieldset = true; list($sz, ) = explode("/", $field->getDisplaySize()); // Details field must be on one row if ($sz > $max_size || $field->getName() == 'details') { $fieldset_html .= "\n<TR>" . '<TD align="left" valign="top" width="10%" nowrap="nowrap">' . $field_html['label'] . '</td>' . '<TD valign="top" width="90%" colspan="' . ($columns_number - 1) . '">' . $field_html['value'] . '</TD>' . "\n</TR>"; $i = 0; } else { $fieldset_html .= $i % $fields_per_line ? '' : "\n<TR>"; $fieldset_html .= '<TD align="left" valign="top" width="10%" nowrap="nowrap">' . $field_html['label'] . '</td>' . '<TD width="38%" valign="top">' . $field_html['value'] . '</TD>'; $i++; // if the line is not full, we add a additional column to give more space $fieldset_html .= $i % $fields_per_line ? '<td class="artifact_spacer" width="4%"> </td>' : "\n</TR>"; } } } } // while // We display the fieldset only if there is at least one field inside that we can display if ($display_fieldset) { //$html .= '<TR><TD COLSPAN="'.(int)$columns_number.'"> </TD></TR>'; $html .= '<TR class="boxtitle artifact_fieldset"><TD class="left" COLSPAN="' . (int) $columns_number . '"> <span title="' . $hp->purify(SimpleSanitizer::unsanitize($result_fieldset->getDescriptionText()), CODENDI_PURIFIER_CONVERT_HTML) . '">' . $hp->purify(SimpleSanitizer::unsanitize($result_fieldset->getLabel()), CODENDI_PURIFIER_CONVERT_HTML) . '</span></TD></TR>'; $html .= $fieldset_html; } } $html .= '<tr><td><font color="red">*</font>: ' . $Language->getText('tracker_include_type', 'fields_requ') . '</td></tr></TABLE>'; echo $this->_getSection('artifact_section_details', $artTitle, $html, true); if (!$ro) { echo '<div style="text-align:center"><INPUT CLASS="btn btn-primary" TYPE="SUBMIT" NAME="SUBMIT" VALUE="' . $Language->getText('tracker_include_artifact', 'submit') . '"></div>'; } // // Followups comments // $html = ''; $html .= '<script type="text/javascript">'; $html .= "var tracker_comment_togglers = {};\n function tracker_reorder_followups() {\n var element = \$('artifact_section_followups');\n if (element) {\n element.cleanWhitespace();\n var elements = [];\n var len = element.childNodes.length;\n for(var i = len - 1 ; i >= 0 ; --i) {\n elements.push(Element.remove(element.childNodes[i]));\n }\n for(var i = 0 ; i < len ; ++i) {\n element.appendChild(elements[i]);\n }\n }\n }"; $html .= '</script>'; $html .= '<div>'; if (!$ro) { if (db_numrows($this->ArtifactType->getCannedResponses())) { $html .= '<p><b>' . $Language->getText('tracker_include_artifact', 'use_canned') . '</b> '; $html .= $this->ArtifactType->cannedResponseBox(); $html .= '</p>'; } $field = $art_field_fact->getFieldFromName('comment_type_id'); if ($field && $field->isUsed() && db_numrows($field->getFieldPredefinedValues($group_artifact_id)) > 1) { $field_html = new ArtifactFieldHtml($field); $html .= '<P><B>' . $Language->getText('tracker_include_artifact', 'comment_type') . '</B>' . $field_html->fieldBox('', $group_artifact_id, $field->getDefaultValue(), true, $Language->getText('global', 'none')) . '<BR>'; } $html .= '<b>' . $Language->getText('tracker_include_artifact', 'add_comment') . '</b>'; $html .= '<DIV ID="tracker_artifact_comment_label"></DIV>'; $html .= '<TEXTAREA NAME="comment" id="tracker_artifact_comment" ROWS="10" style="width:700px;" WRAP="SOFT"></TEXTAREA>'; } else { if ($pv == 0) { $html .= '<b>' . $Language->getText('tracker_include_artifact', 'add_comment') . '</b>'; // Non authenticated user can submit only in text format //$html .= '<DIV ID="tracker_artifact_comment_label"></DIV>'; $html .= '<TEXTAREA NAME="comment" id="tracker_artifact_comment" ROWS="10" style="width:700px" WRAP="SOFT"></TEXTAREA>'; } } if (!user_isloggedin() && $pv == 0) { $html .= $Language->getText('tracker_include_artifact', 'not_logged_in', '/account/login.php?return_to=' . urlencode($_SERVER['REQUEST_URI'])); $html .= '<br><input type="text" name="email" maxsize="100" size="50"/><p>'; } $html .= '</div>'; $html .= $this->showFollowUpComments($group_id, $pv); $title = $Language->getText('tracker_include_artifact', 'follow_ups') . ' '; $title .= '<script type="text/javascript">'; $title .= 'document.write(\'<a href="#reorder" onclick="tracker_reorder_followups();new Ajax.Request(\\\'invert_comments_order.php\\\'); return false;" title="Invert order of the follow-ups">[↓↑]</a>\');'; $title .= '</script>'; $title .= ' <a href="/tracker/?func=rss&aid=' . (int) $this->getId() . '&atid=' . (int) $this->ArtifactType->getID() . '&group_id=' . (int) $this->ArtifactType->getGroupId() . '" '; $hp =& Codendi_HTMLPurifier::instance(); $title .= ' title="' . $hp->purify(util_unconvert_htmlspecialchars($group->getPublicName()) . ' ' . SimpleSanitizer::unsanitize($this->ArtifactType->getName()) . ' #' . $this->getId() . ' - ' . util_unconvert_htmlspecialchars($this->getValue('summary')), CODENDI_PURIFIER_CONVERT_HTML) . ' - ' . $Language->getText('tracker_include_artifact', 'follow_ups') . '">'; $title .= '[xml]</a> '; if ($pv == 0) { $title .= help_button('tracker-v3.html#comments') . ' '; } echo $this->_getSection('artifact_section_followups', $title, $html, true); if (user_get_preference('tracker_comment_invertorder')) { echo '<script type="text/javascript">tracker_reorder_followups();</script>'; } // // CC List // $html = ''; if ($pv == 0) { $html .= $Language->getText('tracker_include_artifact', 'fill_cc_list_msg'); $html .= $Language->getText('tracker_include_artifact', 'fill_cc_list_lbl'); $html .= '<textarea type="text" name="add_cc" id="tracker_cc" rows="2" cols="60" wrap="soft"></textarea>'; $html .= '<B> ' . $Language->getText('tracker_include_artifact', 'fill_cc_list_cmt') . ": </b>"; $html .= '<input type="text" name="cc_comment" size="40" maxlength="255">'; } $html .= $this->showCCList($group_id, $group_artifact_id, false, $pv); echo $this->_getSection('artifact_section_cc', $Language->getText('tracker_include_artifact', 'cc_list') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#cc-list') : ''), $html, db_numrows($this->getCCList()), db_numrows($this->getCCList()) ? '' : '<div>' . $GLOBALS['Language']->getText('tracker_include_artifact', 'cc_empty') . '</div>'); // // File attachments // $html = ''; if ($pv == 0) { $html .= '<input type="file" name="input_file" size="40">'; $html .= $Language->getText('tracker_include_artifact', 'upload_file_msg', formatByteToMb($sys_max_size_attachment)); $html .= $Language->getText('tracker_include_artifact', 'upload_file_desc'); $html .= '<input type="text" name="file_description" size="60" maxlength="255">'; } $html .= $this->showAttachedFiles($group_id, $group_artifact_id, false, $pv); echo $this->_getSection('artifact_section_attachments', $Language->getText('tracker_include_artifact', 'attachment') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#artifact-attachments') : ''), $html, db_numrows($this->getAttachedFiles()), db_numrows($this->getAttachedFiles()) ? '' : '<div>' . $GLOBALS['Language']->getText('tracker_include_artifact', 'no_file_attached') . '</div>'); // // Artifact dependencies // $html = '<B>' . $Language->getText('tracker_include_artifact', 'depend_on') . '</B><BR><P>'; if (!$ro) { $html .= ' <B>' . $Language->getText('tracker_include_artifact', 'aids') . '</B> <input type="text" name="artifact_id_dependent" size="20" maxlength="255"> <span style="color:#666">' . $Language->getText('tracker_include_artifact', 'fill') . '</span><p>'; } $html .= $this->showDependencies($group_id, $group_artifact_id, false, $pv); $html .= ' <P><B>' . $Language->getText('tracker_include_artifact', 'dependent_on') . '</B><BR> <P>'; $html .= $this->showInverseDependencies($group_id, $group_artifact_id); echo $this->_getSection('artifact_section_dependencies', $Language->getText('tracker_include_artifact', 'dependencies') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#artifact-dependencies') : ''), $html, db_numrows($this->getDependencies()) || db_numrows($this->getInverseDependencies()), db_numrows($this->getDependencies()) || db_numrows($this->getInverseDependencies()) ? '' : '<div>' . $Language->getText('tracker_include_artifact', 'dep_list_empty') . '</div>'); // // Artifact Cross References // $html = ''; $crossref_fact = new CrossReferenceFactory($this->getID(), ReferenceManager::REFERENCE_NATURE_ARTIFACT, $group_id); $crossref_fact->fetchDatas(); $html .= $crossref_fact->getHTMLDisplayCrossRefs(); echo $this->_getSection('artifact_section_references', $Language->getText('cross_ref_fact_include', 'references') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#artifact-cross-referencing') : ''), $html, $crossref_fact->getNbReferences(), $crossref_fact->getNbReferences() ? '' : '<div>' . $Language->getText('tracker_include_artifact', 'ref_list_empty') . '</div>'); // // Artifact permissions // if ($this->ArtifactType->userIsAdmin()) { $checked = ''; if ($this->useArtifactPermissions()) { $checked = 'checked="checked"'; } $html = ''; $html .= '<p>'; $html .= '<label class="checkbox" for="use_artifact_permissions"><input type="hidden" name="use_artifact_permissions_name" value="0" />'; $html .= '<input type="checkbox" name="use_artifact_permissions_name" id="use_artifact_permissions" value="1" ' . $checked . ' />'; $html .= $GLOBALS['Language']->getText('tracker_include_artifact', 'permissions_label') . '</label>'; $html .= '</p>'; $html .= permission_fetch_selection_field('TRACKER_ARTIFACT_ACCESS', $this->getId(), $group_id); $html .= '<script type="text/javascript">'; $html .= "\n document.observe('dom:loaded', function() {\n if ( ! \$('use_artifact_permissions').checked) {\n \$('ugroups').disable();\n }\n \$('use_artifact_permissions').observe('click', function(evt) {\n if (this.checked) {\n \$('ugroups').enable();\n } else {\n \$('ugroups').disable();\n }\n });\n });\n </script>"; echo $this->_getSection('artifact_section_permissions', $Language->getText('tracker_include_artifact', 'permissions') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#permissions-on-artifacts') : ''), $html, $checked, $checked ? '' : $GLOBALS['Language']->getText('tracker_include_artifact', 'permissions_not_restricted')); } // // History // $is_there_history = db_numrows($this->getHistory()); echo $this->_getSection('artifact_section_history', $Language->getText('tracker_include_artifact', 'change_history') . ' ' . ($pv == 0 ? help_button('tracker-v3.html#artifact-history') : ''), $this->showHistory($group_id, $group_artifact_id), !$is_there_history); // // Final submit button // if ($pv == 0) { echo '<div style="text-align:center"><INPUT CLASS="btn btn-primary" TYPE="SUBMIT" NAME="SUBMIT" VALUE="' . $Language->getText('tracker_include_artifact', 'submit') . '"></div>'; } echo '</td></tr>'; echo '</table>'; echo '</form>'; user_set_preference('tracker_' . $this->ArtifactType->getId() . '_artifact_' . $this->getId() . '_last_visit', time()); }
<?php require_once 'pre.php'; if (user_get_preference('tracker_comment_invertorder')) { user_del_preference('tracker_comment_invertorder'); } else { user_set_preference('tracker_comment_invertorder', '1'); }