Exemplo n.º 1
0
 /**
  * Adds a user $user_id to the assignees of one or more $tasks
  * @param integer $user_id
  * @param array $tasks
  * @param bool $do Force execution independent of user permissions
  * @access public
  * @return void
  * @version 1.0
  */
 public static function add_to_assignees($user_id, $tasks, $do = false)
 {
     global $db, $notify;
     settype($tasks, 'array');
     $user = $GLOBALS['user'];
     if ($user_id != $user->id) {
         $user = new User($user_id);
     }
     settype($tasks, 'array');
     if (!count($tasks)) {
         return;
     }
     $sql = $db->Query(' SELECT *
                           FROM {tasks}
                          WHERE ' . substr(str_repeat(' task_id = ? OR ', count($tasks)), 0, -3), $tasks);
     while ($row = $db->FetchRow($sql)) {
         if (!$user->can_add_to_assignees($row) && !$do) {
             continue;
         }
         $db->Replace('{assigned}', array('user_id' => $user->id, 'task_id' => $row['task_id']), array('user_id', 'task_id'));
         if ($db->affectedRows()) {
             $current_proj = new Project($row['project_id']);
             Flyspray::logEvent($row['task_id'], 29, $user->id, implode(' ', Flyspray::GetAssignees($row['task_id'])));
             $notify->Create(NOTIFY_ADDED_ASSIGNEES, $row['task_id'], null, null, NOTIFY_BOTH, $current_proj->prefs['lang_code']);
         }
         if ($row['item_status'] == STATUS_UNCONFIRMED || $row['item_status'] == STATUS_NEW) {
             $db->Query('UPDATE {tasks} SET item_status = 3 WHERE task_id = ?', array($row['task_id']));
             Flyspray::logEvent($row['task_id'], 3, 3, 1, 'item_status');
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Adds a user $user_id to the assignees of one or more $tasks
  * @param integer $user_id
  * @param array $tasks
  * @param bool $do Force execution independent of user permissions
  * @access public
  * @return void
  * @version 1.0
  */
 function add_to_assignees($user_id, $tasks, $do = false)
 {
     global $db;
     $user = $GLOBALS['user'];
     if ($user_id != $user->id) {
         $user = new User($user_id);
     }
     settype($tasks, 'array');
     if (!count($tasks)) {
         return;
     }
     $sql = $db->query(' SELECT *
                           FROM {tasks}
                          WHERE task_id IN (' . implode(',', array_map('intval', $tasks)) . ')');
     while ($row = $sql->FetchRow()) {
         if (!$user->can_add_to_assignees($row) && !$do) {
             continue;
         }
         $fields = array('user_id' => array('value' => $user->id, 'key' => true), 'task_id' => array('value' => $row['task_id'], 'key' => true));
         $r = $db->Replace('{assigned}', $fields);
         if ($r > 0) {
             Flyspray::logEvent($row['task_id'], 29, $user->id, implode(' ', Flyspray::GetAssignees($row['task_id'])));
             Notifications::send($row['task_id'], ADDRESS_TASK, NOTIFY_ADDED_ASSIGNEES);
         }
     }
 }