Example #1
0
 protected function user_array(\Model\User $user)
 {
     $group_id = $user->id;
     if ($user->role == 'group') {
         $group = new \Model\Custom("user_group");
         $man = $group->find(array("group_id = ? AND manager = 1", $user->id));
         $man = array_filter($man);
         if (!empty($man) && $man[0]->user_id > 0) {
             $group_id = $man[0]->user_id;
         }
     }
     $result = array("id" => $group_id, "name" => $user->name, "username" => $user->username, "email" => $user->email);
     return $result;
 }
Example #2
0
 /**
  * Send an email to watchers detailing the updated fields
  * @param  int $issue_id
  * @param  int $update_id
  */
 public function issue_update($issue_id, $update_id)
 {
     $f3 = \Base::instance();
     if ($f3->get("mail.from")) {
         $log = new \Log("mail.log");
         // Get issue and update data
         $issue = new \Model\Issue();
         $issue->load($issue_id);
         $f3->set("issue", $issue);
         $update = new \Model\Custom("issue_update_detail");
         $update->load($update_id);
         // Get issue parent if set
         if ($issue->parent_id) {
             $parent = new \Model\Issue();
             $parent->load($issue->parent_id);
             $f3->set("parent", $parent);
         }
         // Avoid errors from bad calls
         if (!$issue->id || !$update->id) {
             return false;
         }
         $changes = new \Model\Issue\Update\Field();
         $f3->set("changes", $changes->find(array("issue_update_id = ?", $update->id)));
         // Get recipient list and remove update user
         $recipients = $this->_issue_watchers($issue_id);
         $recipients = array_diff($recipients, array($update->user_email));
         // Render message body
         $f3->set("issue", $issue);
         $f3->set("update", $update);
         $text = $this->_render("notification/update.txt");
         $body = $this->_render("notification/update.html");
         $changes->load(array("issue_update_id = ? AND `field` = 'closed_date' AND old_value = '' and new_value != ''", $update->id));
         if ($changes && $changes->id) {
             $subject = "[#{$issue->id}] - {$issue->name} closed";
         } else {
             $subject = "[#{$issue->id}] - {$issue->name} updated";
         }
         // Send to recipients
         foreach ($recipients as $recipient) {
             $this->utf8mail($recipient, $subject, $body, $text);
             $log->write("Sent update notification to: " . $recipient);
         }
     }
 }
Example #3
0
 public function group_edit($f3, $params)
 {
     $f3->set("title", $f3->get("dict.groups"));
     $group = new \Model\User();
     $group->load(array("id = ? AND deleted_date IS NULL AND role = 'group'", $params["id"]));
     $f3->set("group", $group);
     $members = new \Model\Custom("user_group_user");
     $f3->set("members", $members->find(array("group_id = ? AND deleted_date IS NULL", $group->id)));
     $users = new \Model\User();
     $f3->set("users", $users->find("deleted_date IS NULL AND role != 'group'", array("order" => "name ASC")));
     $this->_render("admin/groups/edit.html");
 }
Example #4
0
 /**
  * GET /issues/@id/watchers
  * AJAX call for issue watchers
  *
  * @param \Base $f3
  * @param array $params
  */
 public function single_watchers($f3, $params)
 {
     $watchers = new \Model\Custom("issue_watcher_user");
     $f3->set("watchers", $watchers->find(array("issue_id = ?", $params["id"])));
     $users = new \Model\User();
     $f3->set("users", $users->find("deleted_date IS NULL AND role != 'group'", array("order" => "name ASC")));
     $this->_printJson(array("total" => count($f3->get("watchers")), "html" => $this->_cleanJson(\Helper\View::instance()->render("issues/single/watchers.html"))));
 }