Example #1
0
 public static function tests_pchart1()
 {
     $projectUser = Project_User::getByUser($GLOBALS['project'], $GLOBALS['user']);
     $n = new NotificationSettings();
     $projectUser->setNotifications($n);
     var_dump($projectUser);
     exit;
 }
Example #2
0
 public static function project_notificationsSave()
 {
     SystemEvent::raise(SystemEvent::DEBUG, "Called.", __METHOD__);
     if (empty($GLOBALS['project']) || !$GLOBALS['project'] instanceof Project) {
         $msg = 'Invalid request';
         SystemEvent::raise(SystemEvent::INFO, $msg, __METHOD__);
         echo json_encode(array('success' => false, 'error' => $msg));
         exit;
     }
     if (!$GLOBALS['project']->userHasAccessLevel($GLOBALS['user'], Access::WRITE) && !$GLOBALS['user']->hasCos(UserCos::ROOT)) {
         $msg = 'Not authorized';
         SystemEvent::raise(SystemEvent::INFO, $msg, __METHOD__);
         echo json_encode(array('success' => false, 'error' => $msg));
         exit;
     }
     // Pull up the user's notifications
     $projectUser = Project_User::getByUser($GLOBALS['project'], $GLOBALS['user']);
     $notificationSettings = $projectUser->getNotifications();
     $newNotificationSettings = array();
     foreach ($_POST['notificationsForm'] as $key => $value) {
         $keyParts = explode('_', $key);
         $event = $keyParts[0];
         $handler = 'Notification_' . $keyParts[1];
         if (!isset($newNotificationSettings[$handler])) {
             $newNotificationSettings[$handler] = array();
         }
         $newNotificationSettings[$handler][$event] = (bool) $value['value'];
     }
     $projectUser->setNotifications(new NotificationSettings($GLOBALS['project'], $GLOBALS['user'], $newNotificationSettings));
     $GLOBALS['project']->log("Notification settings changed.", $GLOBALS['user']->getUsername());
     SystemEvent::raise(SystemEvent::DEBUG, "Project notification settings changed for user {$GLOBALS['user']->getUsername()}.", __METHOD__);
     echo json_encode(array('success' => true));
     exit;
 }
Example #3
0
 public function loadUsers()
 {
     $ret = Project_User::getList($this);
     $this->setUsers($ret);
 }