コード例 #1
0
 public function process(TrackerManager $tracker_manager, $request, $current_user)
 {
     if ($request->get('submit')) {
         if ($request->exist('stop_notification')) {
             if ($this->tracker->stop_notification != $request->get('stop_notification')) {
                 $this->tracker->stop_notification = $request->get('stop_notification') ? 1 : 0;
                 $dao = new TrackerDao();
                 if ($dao->save($this->tracker)) {
                     $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_admin_notification', 'successfully_updated'));
                 }
             }
         }
         if ($global_notification_data = $request->get('global_notification')) {
             if (!empty($global_notification_data)) {
                 $this->processGlobalNotificationData($global_notification_data);
             }
         }
     } else {
         if ($request->get('action') == 'remove_global') {
             $this->removeGlobalNotification($request->get('global_notification_id'));
         }
     }
     $this->displayAdminNotifications($tracker_manager, $request, $current_user);
     $reminderRenderer = new Tracker_DateReminderRenderer($this->tracker);
     if ($this->tracker->userIsAdmin($current_user)) {
         $reminderRenderer->displayDateReminders($request);
     }
     $reminderRenderer->displayFooter($tracker_manager);
 }
コード例 #2
0
 /**
  * Edit a given date reminder
  *
  * @param HTTPRequest $request Reminder edit request
  *
  * @return Boolean
  */
 public function editTrackerReminder($request)
 {
     $this->csrf->check();
     $reminderRenderer = new Tracker_DateReminderRenderer($this->getTracker());
     try {
         $reminderId = $reminderRenderer->validateReminderId($request);
         $notificationType = $reminderRenderer->validateNotificationType($request);
         $distance = $reminderRenderer->validateDistance($request);
         $status = $reminderRenderer->validateStatus($request);
         $notified = $reminderRenderer->scindReminderNotifiedPeople($request);
         $ugroups = $reminderRenderer->validateReminderUgroups($notified[0]);
         $roles = $reminderRenderer->validateReminderRoles($notified[1]);
         if (!empty($ugroups)) {
             $ugroups = join(",", $ugroups);
         } else {
             $ugroups = "";
         }
         $fieldId = $reminderRenderer->validateFieldId($request);
         if ($status == 1) {
             $this->checkDuplicatedReminders($this->getTracker()->getId(), $fieldId, $notificationType, $distance, $reminderId);
             $this->isReminderBeforeOpenDate($fieldId, $notificationType);
         }
     } catch (Tracker_DateReminderException $e) {
         $GLOBALS['Response']->addFeedback('error', $e->getMessage());
         $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?func=admin-notifications&tracker=' . $this->getTracker()->id);
     }
     $updateReminder = $this->getDao()->updateDateReminder($reminderId, $ugroups, $roles, $notificationType, $distance, $status);
     if ($updateReminder) {
         $roles = implode(",", $roles);
         $historyDao = new ProjectHistoryDao(CodendiDataAccess::instance());
         $historyDao->groupAddHistory("tracker_date_reminder_edit", $this->getTracker()->getName() . ":" . $reminderId, $this->getTracker()->getGroupId(), array("Id: " . $reminderId . ", Type: " . $notificationType . ", ProjectUGroup(s): " . $ugroups . ", Tracker Role(s): " . $roles . ", Day(s): " . $distance . ", Status: " . $status));
         return $updateReminder;
     } else {
         $errorMessage = $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'tracker_date_reminder_update_failure', array($reminderId));
         throw new Tracker_DateReminderException($errorMessage);
     }
 }