public function getVariantForUser(PFUser $user) { $variant = $user->getPreference(self::PREFERENCE_NAME); if (!$variant) { return $this->default; } if (!$this->isAllowed($variant)) { return $this->default; } return $variant; }
/** * @return string */ public function getDeprecatedMessage() { if ($this->user->getPreference(PFUser::PREFERENCE_DISABLE_IE7_WARNING)) { return; } $warning_message = $GLOBALS['Language']->getText('include_browser', 'ie7_deprecated'); if ($this->user->isAnonymous()) { return $warning_message; } $url = '/account/disable_ie7_warning.php'; $csrf = new CSRFSynchronizerToken($url); $form = '<form action="' . $url . '" method="POST" style="margin: 0">'; $form .= $csrf->fetchHTMLInput(); $form .= $warning_message; $form .= '<button type="submit" class="btn btn-small btn-inverse" > ' . $GLOBALS['Language']->getText('include_browser', 'ie7_deprecated_button') . ' </button> </form>'; return $form; }
public function isBacklogOpen(AgileDashboard_Kanban $kanban, PFUser $user) { $user_preference = $user->getPreference(self::COLLAPSE_BACKLOG_PREFERENCE_PREFIX . $kanban->getId()); return $user_preference === self::EXPAND; }
/** * Returns whether the user wants an HTML or a Text notification * * @param PFUser $user * * @return String */ public function getMailPreferencesByUser(PFUser $user) { if ($user->getPreference(Codendi_Mail_Interface::PREF_FORMAT) == Codendi_Mail_Interface::FORMAT_TEXT) { return Codendi_Mail_Interface::FORMAT_TEXT; } return Codendi_Mail_Interface::FORMAT_HTML; }
private function addBodyClassDependingUserPreference(PFUser $user, array &$body_class) { $edition_default_format = $user->getPreference(PFUser::EDITION_DEFAULT_FORMAT); if ($edition_default_format && $edition_default_format === 'text') { $body_class[] = 'default_format_' . $edition_default_format; } }
/** * Display a report. Choose the report among * - the requested 'select_report' * - the last viewed report (stored in preferences) * - the default report of this tracker * * If the user request a 'link-artifact-id' then display also manual and recent * panels to ease the selection of artifacts to link * * @param Tracker_IDisplayTrackerLayout $layout Displays the page header and footer * @param Codendi_Request $request The request * @param PFUser $current_user The user who made the request * * @return void */ public function displayAReport(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { $report = null; //Does the user wants to change its report? if ($request->get('select_report')) { //Is the report id valid if ($report = $this->getReportFactory()->getReportById($request->get('select_report'), $current_user->getid())) { $current_user->setPreference('tracker_' . $this->id . '_last_report', $report->id); } } //If no valid report found. Search the last viewed report for the user if (!$report) { if ($report_id = $current_user->getPreference('tracker_' . $this->id . '_last_report')) { $report = $this->getReportFactory()->getReportById($report_id, $current_user->getid()); } } //If no valid report found. Take the default one if (!$report) { $report = $this->getReportFactory()->getDefaultReportsByTrackerId($this->id); } //If no default one, take the first private one if (!$report) { $report_for_user = $this->getReportFactory()->getReportsByTrackerId($this->id, $current_user->getid()); $report = array_shift($report_for_user); } $link_artifact_id = (int) $request->get('link-artifact-id'); if ($link_artifact_id && !$request->get('report-only')) { $linked_artifact = Tracker_ArtifactFactory::instance()->getArtifactById($link_artifact_id); if (!$linked_artifact) { $err = "Linked artifact not found or doesn't exist"; if (!$request->isAjax()) { $GLOBALS['Response']->addFeedback('error', $err); $GLOBALS['Response']->redirect('/'); } die($err); } if (!$request->isAjax()) { //screwed up $GLOBALS['Response']->addFeedback('error', 'Something is wrong with your request'); $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?aid=' . $linked_artifact->getId()); } echo $linked_artifact->fetchTitleWithoutUnsubscribeButton($GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'title_prefix')); echo '<input type="hidden" id="link-artifact-id" value="' . (int) $link_artifact_id . '" />'; echo '<table id="tracker-link-artifact-different-ways" cellpadding="0" cellspacing="0" border="0"><tbody><tr>'; //the fast ways echo '<td id="tracker-link-artifact-fast-ways">'; //Manual echo '<div id="tracker-link-artifact-manual-way">'; echo '<div class="boxtitle">'; echo $GLOBALS['HTML']->getImage('ic/lightning-white.png', array('style' => 'vertical-align:middle')) . ' '; echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_title'); echo '</div>'; echo '<div class="tracker-link-artifact-manual-way-content">'; echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_desc'); echo '<p><label for="link-artifact-manual-field">'; echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_label'); echo '</label><br />'; echo '<input type="text" name="link-artifact[manual]" value="" id="link-artifact-manual-field" />'; echo '</p>'; echo '</div>'; echo '</div>'; //History echo '<div id="tracker-link-artifact-recentitems-way">'; echo '<div class="boxtitle">'; echo $GLOBALS['HTML']->getImage('ic/star-white.png', array('style' => 'vertical-align:middle')) . ' '; echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'recent_panel_title'); echo '</div>'; echo '<div class="tracker-link-artifact-recentitems-way-content">'; if ($recent_items = $current_user->getRecentElements()) { echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'recent_panel_desc'); echo '<ul>'; foreach ($recent_items as $item) { if ($item['id'] != $link_artifact_id) { echo '<li>'; echo '<input type="checkbox" name="link-artifact[recent][]" value="' . (int) $item['id'] . '" /> '; echo $item['link']; echo '</li>'; } } echo '</ul>'; } echo '</div>'; echo '</div>'; //end of fast ways echo '</td>'; //And the slow way (aka need to search) if ($report) { echo '<td><div id="tracker-link-artifact-slow-way">'; echo '<div class="boxtitle">'; echo $GLOBALS['HTML']->getImage('ic/magnifier-white.png', array('style' => 'vertical-align:middle')) . ' '; echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'search_panel_title'); echo '</div>'; echo '<div id="tracker-link-artifact-slow-way-content">'; } } if ($report) { $report->process($layout, $request, $current_user); } elseif (!$link_artifact_id) { $this->displayHeader($layout, $this->name, array()); echo $GLOBALS['Language']->getText('plugin_tracker', 'no_reports_available'); if ($this->userIsAdmin($current_user)) { $action = '?tracker=' . (int) $this->getID() . '&func=create_new_public_report'; echo '<form class="form-inline" action="' . $action . '" method="POST">' . '<fieldset>' . '<legend>' . $GLOBALS['Language']->getText('plugin_tracker', 'create_new_report') . '</legend>' . '<input required type="text" name="new_report_name" placeholder="' . $GLOBALS['Language']->getText('plugin_tracker', 'create_new_report_name') . '" />' . '<button type="submit" class="btn">' . $GLOBALS['Language']->getText('plugin_tracker', 'create_new_report_submit') . '</button>' . '</fieldset></form>'; } $this->displayFooter($layout); } if ($link_artifact_id && !$request->get('report-only')) { if ($report) { echo '</div></div></td>'; //end of slow } echo '</tr></tbody></table>'; //end of ways echo '<div class="tracker-link-artifact-controls">'; echo '<a href="#cancel" onclick="myLightWindow.deactivate(); return false;">« ' . $GLOBALS['Language']->getText('global', 'btn_cancel') . '</a>'; echo ' '; echo '<button name="link-artifact-submit">' . $GLOBALS['Language']->getText('global', 'btn_submit') . '</button>'; echo '</div>'; } }
private function getValue(Cardwall_Column $column) { return $this->user->getPreference($this->getName($column)); }
/** * Get the display preferences of a user for a given milestone * * @param Planning_Milestone $milestone * @param PFUser $user * * @return Cardwall_UserPreferences_UserPreferencesDisplayUser */ public function getDisplayPreferences(Planning_Milestone $milestone, PFUser $user) { $pref_name = Cardwall_UserPreferences_UserPreferencesDisplayUser::ASSIGNED_TO_USERNAME_PREFERENCE_NAME . $milestone->getTrackerId(); $display_avatars = $user->isAnonymous() || !$user->getPreference($pref_name); return new Cardwall_UserPreferences_UserPreferencesDisplayUser($display_avatars); }
/** * Toggle the preference. * Should not be called directly unless you know what you do * * @param PFUser $current_user The user * @param string $id the id of the toggler */ public static function togglePreference(PFUser $current_user, $id) { $current_user->setPreference('toggle_' . $id, 1 - (int) $current_user->getPreference('toggle_' . $id)); }
private function getDefaultFormatForUser(PFUser $user) { $user_preference = $user->getPreference(PFUser::EDITION_DEFAULT_FORMAT); if (!$user_preference || $user_preference === Tracker_Artifact_ChangesetValue_Text::HTML_CONTENT) { return Tracker_Artifact_ChangesetValue_Text::HTML_CONTENT; } return Tracker_Artifact_ChangesetValue_Text::TEXT_CONTENT; }