/** * Add an artefact in the tracker * * @param Tracker_IDisplayTrackerLayout $layout * @param Codendi_Request $request * @param PFUser $user * * @return Tracker_Artifact the new artifact */ private function createArtifact(Tracker_IDisplayTrackerLayout $layout, $request, $user) { $email = null; if ($user->isAnonymous()) { $email = $request->get('email'); } $fields_data = $request->get('artifact'); $this->tracker->augmentDataFromRequest($fields_data); return $this->artifact_factory->createArtifact($this->tracker, $fields_data, $user, $email); }
private function createArtifact(PFUser $current_user) { $email = null; if ($current_user->isAnonymous()) { $email = $this->request->get('email'); } $fields_data = $this->request->get('artifact'); $this->tracker->augmentDataFromRequest($fields_data); return $this->tracker_artifact_factory->createArtifact($this->tracker, $fields_data, $current_user, $email); }
private function doesRequestAppearToBeValid(Tracker_Artifact $artifact, array $fields_data, PFUser $submitter) { if ($submitter->isAnonymous() && !trim($submitter->getEmail())) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_artifact', 'email_required')); return false; } if (!$this->fields_validator->validate($artifact, $fields_data)) { return false; } return true; }
private function getSwitchDisplayAvatarsURL() { if ($this->user->isAnonymous()) { return false; } $group_id = $this->milestone->getGroupId(); $planning_id = $this->milestone->getPlanningId(); $tracker_id = $this->milestone->getTrackerId(); $artifact_id = $this->milestone->getArtifactId(); $action = 'toggle_user_display_avatar'; $switch_display_username_url = CARDWALL_BASE_URL . '/?group_id=' . $group_id . '&planning_id=' . $planning_id . '&tracker_id=' . $tracker_id . '&aid=' . $artifact_id . '&action=' . $action; return $switch_display_username_url; }
private function getSaveOrRevert(PFUser $current_user, Tracker_Report $report, array $options_params, $report_can_be_modified) { if ($current_user->isAnonymous() || !$report_can_be_modified) { return false; } if ($report->userCanUpdate($current_user)) { $default_save = new Templating_Presenter_ButtonDropdownsOption('tracker_report_updater_save', $GLOBALS['Language']->getText('plugin_tracker_report', 'save'), false, '?' . http_build_query(array_merge($options_params, array('func' => Tracker_Report::ACTION_SAVE)))); $extra_save = array(new Templating_Presenter_ButtonDropdownsOptionWithModal('tracker_report_updater_saveas', $GLOBALS['Language']->getText('plugin_tracker_report', 'save_as'), false, '?' . http_build_query(array_merge($options_params, array('func' => Tracker_Report::ACTION_SAVEAS))) . '#tracker_report_updater_saveas-modal')); } elseif (!$current_user->isAnonymous()) { $default_save = new Templating_Presenter_ButtonDropdownsOptionWithModal('tracker_report_updater_saveas', $GLOBALS['Language']->getText('plugin_tracker_report', 'save_as'), false, '?' . http_build_query(array_merge($options_params, array('func' => Tracker_Report::ACTION_SAVEAS))) . '#tracker_report_updater_saveas-modal'); $extra_save = array(); } return new Templating_Presenter_SplitButtonDropdowns('tracker_report_save_dropdown', 'btn-primary', $default_save, $extra_save); }
/** * @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 process(Tracker_IDisplayTrackerLayout $layout, Codendi_Request $request, PFUser $current_user) { //TODO : check permissions on this action? $comment_format = $this->artifact->validateCommentFormat($request, 'comment_formatnew'); $this->artifact->setUseArtifactPermissions($request->get('use_artifact_permissions') ? 1 : 0); $fields_data = $request->get('artifact'); $fields_data['request_method_called'] = 'artifact-update'; $this->artifact->getTracker()->augmentDataFromRequest($fields_data); unset($fields_data['request_method_called']); try { if ($current_user->isAnonymous()) { $current_user->setEmail($request->get('email')); } $this->artifact->createNewChangeset($fields_data, $request->get('artifact_followup_comment'), $current_user, true, $comment_format); $art_link = $this->artifact->fetchDirectLinkToArtifact(); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_index', 'update_success', array($art_link)), CODENDI_PURIFIER_LIGHT); $redirect = $this->getRedirectUrlAfterArtifactUpdate($request); $this->artifact->summonArtifactRedirectors($request, $redirect); if ($request->isAjax()) { $this->sendAjaxCardsUpdateInfo($current_user, $this->artifact, $this->form_element_factory); } elseif ($request->existAndNonEmpty('from_overlay')) { echo '<script>window.parent.tuleap.cardwall.cardsEditInPlace.validateEdition(' . $this->artifact->getId() . ')</script>'; return; } else { $GLOBALS['Response']->redirect($redirect->toUrl()); } } catch (Tracker_NoChangeException $e) { if ($request->isAjax()) { $this->sendAjaxCardsUpdateInfo($current_user, $this->artifact, $this->form_element_factory); } else { $GLOBALS['Response']->addFeedback('info', $e->getMessage(), CODENDI_PURIFIER_LIGHT); $render = new Tracker_Artifact_ReadOnlyRenderer($this->event_manager, $this->artifact, $this->form_element_factory, $layout); $render->display($request, $current_user); } } catch (Tracker_Exception $e) { if ($request->isAjax()) { $this->sendAjaxCardsUpdateInfo($current_user, $this->artifact, $this->form_element_factory); } else { $GLOBALS['Response']->addFeedback('error', $e->getMessage()); $render = new Tracker_Artifact_ReadOnlyRenderer($this->event_manager, $this->artifact, $this->form_element_factory, $layout); $render->display($request, $current_user); } } }
/** * Fetch content of the renderer * @param array $matching_ids * @param Request $request * @return string */ public function fetch($matching_ids, $request, $report_can_be_modified, PFUser $user) { $html = ''; $this->initiateSession(); $readonly = !$report_can_be_modified || $user->isAnonymous(); if (!$readonly && $this->chart_to_edit) { $html .= '<script type="text/javascript" src="/plugins/graphontrackersv5/dependencies.js"></script>'; $url = '?' . http_build_query(array('report' => $this->report->id, 'renderer' => $this->id)); $html .= '<p><a href="' . $url . '">« ' . $GLOBALS['Language']->getText('plugin_graphontrackersv5_include_report', 'return_renderer') . '</a></p>'; $html .= '<form action="' . $url . '" name="edit_chart_form" method="post">'; $html .= '<input type="hidden" name="func" VALUE="renderer" />'; $html .= '<input type="hidden" name="renderer_plugin_graphontrackersv5[edit_chart]" VALUE="' . $this->chart_to_edit->getId() . '" />'; $html .= '<table>'; $html .= '<thead> <tr class="boxtable"> <th class="boxtitle">' . $GLOBALS['Language']->getText('plugin_graphontrackersv5_boxtable', 'chart_properties') . '</th> <th class="boxtitle">' . $GLOBALS['Language']->getText('plugin_graphontrackersv5_boxtable', 'preview') . '</th> </tr> </thead>'; $html .= '<tbody><tr valign="top"><td>'; //{{{ Chart Properties foreach ($this->chart_to_edit->getProperties() as $prop) { $html .= '<p>' . $prop->render() . "</p>\n"; } $html .= '<p style="text-align:center;"><input type="submit" name="renderer_plugin_graphontrackersv5[update_chart]" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" /></p>'; //}}} $html .= '</td><td style="text-align:center">'; //{{{ Chart Preview $html .= $this->chart_to_edit->getContent(); //}}} $html .= '</tr>'; if ($help = $this->chart_to_edit->getHelp()) { $html .= '<tr><td colspan="2" class="inline_help">' . $help . '</td></tr>'; } $html .= '</tbody></table>'; $html .= '</form>'; } else { $in_dashboard = false; $html .= $this->fetchCharts($this->report->getMatchingIds(), $user, $in_dashboard, $readonly); } return $html; }
/** * Add an artefact in the tracker * * @param Tracker $tracker The tracker this artifact belongs to * @param array $fields_data The data of the artifact to create * @param PFUser $user The user that want to create the artifact * @param string $email The email if the user is anonymous (null if anonymous) * @param boolean $send_notification true if a notification must be sent, false otherwise * * @return Tracker_Artifact or false if an error occured */ public function createArtifact(Tracker $tracker, $fields_data, PFUser $user, $email, $send_notification = true) { $formelement_factory = Tracker_FormElementFactory::instance(); $fields_validator = new Tracker_Artifact_Changeset_InitialChangesetFieldsValidator($formelement_factory); $changeset_creator = new Tracker_Artifact_Changeset_InitialChangesetCreator($fields_validator, $formelement_factory, new Tracker_Artifact_ChangesetDao(), $this, EventManager::instance()); $creator = new Tracker_ArtifactCreator($this, $fields_validator, $changeset_creator); if ($user->isAnonymous()) { $user->setEmail($email); } $submitted_on = $_SERVER['REQUEST_TIME']; return $creator->create($tracker, $fields_data, $user, $submitted_on, $send_notification); }
/** * Get LDAPResult object corresponding to a User object * * @param PFUser $user * @return LDAPResult */ function getLdapFromUser($user) { if ($user && !$user->isAnonymous()) { return $this->getLdapFromLdapId($user->getLdapId()); } else { return false; } }
private function fetchFormattedMailUserInfo(PFUser $user) { $hp = Codendi_HTMLPurifier::instance(); if ($user && !$user->isAnonymous()) { $user_info = '<a href="mailto:' . $hp->purify($user->getEmail()) . '">' . $hp->purify($user->getRealName()) . ' (' . $hp->purify($user->getUserName()) . ') </a>'; } else { $user = UserManager::instance()->getUserAnonymous(); $user->setEmail($this->changeset->getEmail()); $user_info = $GLOBALS['Language']->getText('tracker_include_artifact', 'anon_user'); } return $user_info; }
/** * Test the status of the ugroup & the user * * @param PFUser $user User to test * * @return Void */ private function assertProjectUGroupAndUserValidity($user) { if (!$this->group_id) { throw new Exception('Invalid group_id'); } if (!$this->id) { throw new UGroup_Invalid_Exception(); } if ($user->isAnonymous()) { throw new Exception('Invalid user'); } }
/** * Update db entry of 'user' table with values in object * @param PFUser $user */ public function updateDb(PFUser $user) { if (!$user->isAnonymous()) { $old_user = $this->getUserByIdWithoutCache($user->getId()); $userRow = $user->toRow(); if ($user->getPassword() != '') { $password_handler = PasswordHandlerFactory::getPasswordHandler(); if (!$password_handler->verifyHashPassword($user->getPassword(), $user->getUserPw()) || $password_handler->isPasswordNeedRehash($user->getUserPw())) { // Update password $userRow['clear_password'] = $user->getPassword(); } } if ($user->getLegacyUserPw() !== '' && !ForgeConfig::get('sys_keep_md5_hashed_password')) { $userRow['user_pw'] = ''; } $result = $this->getDao()->updateByRow($userRow); if ($result) { if ($user->isSuspended() || $user->isDeleted()) { $this->getDao()->deleteAllUserSessions($user->getId()); } $this->_getEventManager()->processEvent(Event::USER_MANAGER_UPDATE_DB, array('old_user' => $old_user, 'new_user' => &$user)); } return $result; } return false; }
public function userCanUpdate(PFUser $user) { if ($user->isAnonymous() || !$this->userCanView($user)) { return false; } return true; }
public function userCanUpdate(PFUser $user) { if ($user->isAnonymous()) { return false; } return true; }
/** * This method will add missing permissions for a user * */ private function addGroupsAccordingToMapping(MediawikiGroups $mediawiki_groups, PFUser $user, Group $project) { $mediawiki_groups->add('*'); if ($user->isAnonymous()) { return; } if ($this->doesUserHaveSpecialAdminPermissions($user)) { $dar = $this->dao->getAllMediawikiGroups($project); } else { $dar = $this->dao->getMediawikiGroupsMappedForUGroups($user, $project); } foreach ($dar as $row) { $mediawiki_groups->add($row['real_name']); } }
/** * 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); }
public function fetchDisplayQuery(array $criteria, array $additional_criteria, $report_can_be_modified, PFUser $current_user) { $hp = Codendi_HTMLPurifier::instance(); $html = ''; $html .= '<div id="tracker_report_query" data-report-id="' . $this->id . '">'; $html .= '<form action="" method="POST" id="tracker_report_query_form">'; $html .= '<input type="hidden" name="report" value="' . $this->id . '" />'; $id = 'tracker_report_query_' . $this->id; $html .= '<h4 class="backlog-planning-search-title ' . Toggler::getClassname($id, $this->is_query_displayed ? true : false) . '" id="' . $id . '">'; // Query title $html .= $GLOBALS['Language']->getText('plugin_tracker_report', 'search') . '</h4>'; $used = array(); $criteria_fetched = array(); foreach ($criteria as $criterion) { if ($criterion->field->isUsed()) { $li = '<li id="tracker_report_crit_' . $criterion->field->getId() . '">'; if ($current_user->isAnonymous()) { $li .= $criterion->fetchWithoutExpandFunctionnality(); } else { $li .= $criterion->fetch(); } $li .= '</li>'; $criteria_fetched[] = $li; $used[$criterion->field->getId()] = $criterion->field; } } if ($report_can_be_modified && !$current_user->isAnonymous()) { $html .= '<div class="pull-right">'; $html .= $this->getAddCriteriaDropdown($used); $html .= '</div>'; } $array_of_html_criteria = array(); EventManager::instance()->processEvent(TRACKER_EVENT_REPORT_DISPLAY_ADDITIONAL_CRITERIA, array('array_of_html_criteria' => &$array_of_html_criteria, 'tracker' => $this->getTracker(), 'additional_criteria' => $additional_criteria, 'user' => $current_user)); foreach ($array_of_html_criteria as $additional_criteria) { $criteria_fetched[] = '<li>' . $additional_criteria . '</li>'; } $html .= '<ul id="tracker_query">' . implode('', $criteria_fetched) . '</ul>'; $html .= '<div align="center">'; $html .= '<button type="submit" name="tracker_query_submit" class="btn btn-primary">'; $html .= '<i class="icon-search"></i> '; $html .= $GLOBALS['Language']->getText('global', 'btn_search'); $html .= '</button>'; $html .= '</div>'; $html .= '</form>'; $html .= '</div>'; return $html; }
private function container(array $params, ProjectManager $project_manager, PFUser $current_user) { $project_tabs = null; $project_name = null; $project_link = null; $project_is_public = null; $project_privacy = null; $sidebar_collapsable = false; if (!empty($params['group'])) { $this->show_sidebar = true; $project = ProjectManager::instance()->getProject($params['group']); $project_tabs = $this->getProjectTabs($params, $project); $project_name = $project->getPublicName(); $project_link = $this->getProjectLink($project); $project_is_public = $project->isPublic(); $project_privacy = $this->getProjectPrivacy($project); $sidebar_collapsable = !$current_user->isAnonymous() && $current_user->isLoggedIn() ? true : false; } $this->render('container', new FlamingParrot_ContainerPresenter($this->breadcrumbs, $this->force_breadcrumbs, $this->toolbar, $project_name, $project_link, $project_is_public, $project_privacy, $project_tabs, $this->_feedback, $this->_getFeedback(), $this->getForgeVersion(), $sidebar_collapsable)); $this->keyboardModal(); }
/** * Test is user can read the content of this repository and metadata * * @param PFUser $user The user to test * @param GitRepository $repository The repository to test * * @return Boolean */ public function userCanRead($user, $repository) { if ($repository->isPrivate() && $user->isMember($repository->getProjectId())) { return true; } if ($repository->isPublic()) { if ($user->isRestricted() && $user->isMember($repository->getProjectId())) { return true; } if (!$user->isAnonymous()) { return true; } } return false; }
private function validateNewChangeset(Tracker_Artifact $artifact, array $fields_data, $comment, PFUser $submitter, $email) { if ($submitter->isAnonymous() && ($email == null || $email == '')) { $message = $GLOBALS['Language']->getText('plugin_tracker_artifact', 'email_required'); throw new Tracker_Exception($message); } if (!$this->fields_validator->validate($artifact, $fields_data)) { $message = $GLOBALS['Language']->getText('plugin_tracker_artifact', 'fields_not_valid'); throw new Tracker_Exception($message); } $last_changeset = $artifact->getLastChangeset(); if (!$comment && !$last_changeset->hasChanges($fields_data)) { throw new Tracker_NoChangeException($artifact->getId(), $artifact->getXRef()); } $workflow = $artifact->getWorkflow(); $fields_data = $this->field_initializator->process($artifact, $fields_data); if ($workflow) { $workflow->validate($fields_data, $artifact); /* * We need to run the post actions to validate the data */ $workflow->before($fields_data, $submitter, $artifact); $workflow->checkGlobalRules($fields_data, $this->formelement_factory); //$GLOBALS['Language']->getText('plugin_tracker_artifact', 'global_rules_not_valid'); } return true; }
private function graphCanBeUpdated($readonly, PFUser $current_user) { return !$readonly && !$current_user->isAnonymous(); }
private function fetchViewButtons($report_can_be_modified, PFUser $current_user) { $html = ''; $html .= '<div id="tracker_report_renderer_view_controls">'; if ($this->sortHasUsedField()) { //reset sort $reset_sort_params = array('report' => $this->report->id, 'renderer' => $this->id, 'func' => 'renderer', 'renderer_table[resetsort]' => 1); $html .= '<div class="btn-group"><a class="btn btn-mini" href="?' . http_build_query($reset_sort_params) . '">' . '<i class="icon-reply"></i> ' . $GLOBALS['Language']->getText('plugin_tracker_report', 'reset_sort') . '</a></div> '; //toggle multisort $multisort_params = array('report' => $this->report->id, 'renderer' => $this->id, 'func' => 'renderer', 'renderer_table[multisort]' => 1); $multisort_label = $GLOBALS['Language']->getText('plugin_tracker_report', 'enable_multisort'); if ($this->multisort) { $multisort_label = $GLOBALS['Language']->getText('plugin_tracker_report', 'disable_multisort'); } $html .= '<div class="btn-group"><a class="btn btn-mini" href="?' . http_build_query($multisort_params) . '">' . '<i class="icon-sort"></i> ' . $multisort_label . '</a></div> '; } if ($report_can_be_modified && !$current_user->isAnonymous()) { $html .= $this->fetchAddColumn(); } $html .= '</div>'; return $html; }