Ejemplo n.º 1
0
 public function dashboard($f3, $params)
 {
     $issue = new \Model\Issue\Detail();
     // Add user's group IDs to owner filter
     $owner_ids = array($this->_userId);
     $groups = new \Model\User\Group();
     foreach ($groups->find(array("user_id = ?", $this->_userId)) as $r) {
         $owner_ids[] = $r->group_id;
     }
     $owner_ids = implode(",", $owner_ids);
     $order = "priority DESC, has_due_date ASC, due_date ASC";
     $projects = $issue->find(array("owner_id IN ({$owner_ids}) AND type_id=:type AND deleted_date IS NULL AND closed_date IS NULL AND status_closed = 0", ":type" => $f3->get("issue_type.project")), array("order" => $order));
     $subprojects = array();
     foreach ($projects as $i => $project) {
         if ($project->parent_id) {
             $subprojects[] = $project;
             unset($projects[$i]);
         }
     }
     $f3->set("projects", $projects);
     $f3->set("subprojects", $subprojects);
     $f3->set("bugs", $issue->find(array("owner_id IN ({$owner_ids}) AND type_id=:type AND deleted_date IS NULL AND closed_date IS NULL AND status_closed = 0", ":type" => $f3->get("issue_type.bug")), array("order" => $order)));
     $f3->set("repeat_issues", $issue->find(array("owner_id IN ({$owner_ids}) AND deleted_date IS NULL AND closed_date IS NULL AND status_closed = 0 AND repeat_cycle NOT IN ('none', '')", ":type" => $f3->get("issue_type.bug")), array("order" => $order)));
     $watchlist = new \Model\Issue\Watcher();
     $f3->set("watchlist", $watchlist->findby_watcher($this->_userId, $order));
     $tasks = new \Model\Issue\Detail();
     $f3->set("tasks", $tasks->find(array("owner_id IN ({$owner_ids}) AND type_id=:type AND deleted_date IS NULL AND closed_date IS NULL AND status_closed = 0", ":type" => $f3->get("issue_type.task")), array("order" => $order)));
     // Get current sprint if there is one
     $sprint = new \Model\Sprint();
     $sprint->load("NOW() BETWEEN start_date AND end_date");
     $f3->set("sprint", $sprint);
     $f3->set("menuitem", "index");
     $this->_render("user/dashboard.html");
 }
Ejemplo n.º 2
0
     $issue = \Model\Issue::create(array('name' => $header->subject, 'description' => $text, 'author_id' => $from_user->id, 'owner_id' => $owner, 'status' => 1, 'type_id' => 1));
     $log->write(sprintf("Created issue #%s - %s", $issue->id, $issue->name));
 }
 // Add other recipients as watchers
 if (!empty($header->cc) || count($header->to) > 1) {
     if (!empty($header->cc)) {
         $watchers = array_merge($header->to, $header->cc);
     } else {
         $watchers = $header->to;
     }
     foreach ($watchers as $more_people) {
         $watcher_email = $more_people->mailbox . '@' . $more_people->host;
         $watcher = new \Model\User();
         $watcher->load(array('email=? AND deleted_date IS NULL', $watcher_email));
         if (!empty($watcher->id)) {
             $watching = new \Model\Issue\Watcher();
             // Loads just in case the user is already a watcher
             $watching->load(array("issue_id = ? AND user_id = ?", $issue->id, $watcher->id));
             $watching->issue_id = $issue->id;
             $watching->user_id = $watcher->id;
             $watching->save();
         }
     }
 }
 foreach ($attachments as $item) {
     // Skip big files
     if ($item['size'] > $f3->get("files.maxsize")) {
         continue;
     }
     // Load file contents
     $data = imap_fetchbody($inbox, $msg_number, $item['part_number'] + 1);
Ejemplo n.º 3
0
 /**
  * POST /issues/@id/watchers/delete
  * Delete a watcher
  *
  * @param \Base $f3
  * @param array $params
  */
 public function delete_watcher($f3, $params)
 {
     $issue = new \Model\Issue();
     $issue->load(array("id=?", $params["id"]));
     if (!$issue->id) {
         $f3->error(404);
     }
     $watcher = new \Model\Issue\Watcher();
     $watcher->load(array("issue_id = ? AND user_id = ?", $issue->id, $f3->get("POST.user_id")));
     $watcher->delete();
 }
Ejemplo n.º 4
0
 public function watchlist()
 {
     $f3 = \Base::instance();
     $watchlist = new \Model\Issue\Watcher();
     return $watchlist->findby_watcher($f3->get("user.id"), $this->_order);
 }
Ejemplo n.º 5
0
 /**
  * @param \Base $f3
  * @param array $params
  * @throws \Exception
  */
 public function single($f3, $params)
 {
     $issue = new \Model\Issue\Detail();
     $issue->load(array("id=?", $f3->get("PARAMS.id")));
     $user = $f3->get("user_obj");
     if (!$issue->id || $issue->deleted_date && !($user->role == 'admin' || $user->rank >= \Model\User::RANK_MANAGER || $issue->author_id == $user->id)) {
         $f3->error(404);
         return;
     }
     $type = new \Model\Issue\Type();
     $type->load($issue->type_id);
     // Run actions if passed
     $post = $f3->get("POST");
     if (!empty($post)) {
         switch ($post["action"]) {
             case "add_watcher":
                 $watching = new \Model\Issue\Watcher();
                 // Loads just in case the user is already a watcher
                 $watching->load(array("issue_id = ? AND user_id = ?", $issue->id, $post["user_id"]));
                 if (!$watching->id) {
                     $watching->issue_id = $issue->id;
                     $watching->user_id = $post["user_id"];
                     $watching->save();
                 }
                 if ($f3->get("AJAX")) {
                     return;
                 }
                 break;
             case "remove_watcher":
                 $watching = new \Model\Issue\Watcher();
                 $watching->load(array("issue_id = ? AND user_id = ?", $issue->id, $post["user_id"]));
                 $watching->delete();
                 if ($f3->get("AJAX")) {
                     return;
                 }
                 break;
             case "add_dependency":
                 $dependencies = new \Model\Issue\Dependency();
                 // Loads just in case the task  is already a dependency
                 $dependencies->load(array("issue_id = ? AND dependency_id = ?", $issue->id, $post["id"]));
                 $dependencies->issue_id = $issue->id;
                 $dependencies->dependency_id = $post["id"];
                 $dependencies->dependency_type = $post["type_id"];
                 $dependencies->save();
                 if ($f3->get("AJAX")) {
                     return;
                 }
                 break;
             case "add_dependent":
                 $dependencies = new \Model\Issue\Dependency();
                 // Loads just in case the task  is already a dependency
                 $dependencies->load(array("issue_id = ? AND dependency_id = ?", $post["id"], $issue->id));
                 $dependencies->dependency_id = $issue->id;
                 $dependencies->issue_id = $post["id"];
                 $dependencies->dependency_type = $post["type_id"];
                 $dependencies->save();
                 if ($f3->get("AJAX")) {
                     return;
                 }
                 break;
             case "remove_dependency":
                 $dependencies = new \Model\Issue\Dependency();
                 $dependencies->load($post["id"]);
                 $dependencies->delete();
                 if ($f3->get("AJAX")) {
                     return;
                 }
                 break;
         }
     }
     $f3->set("title", $type->name . " #" . $issue->id . ": " . $issue->name);
     $f3->set("menuitem", "browse");
     $author = new \Model\User();
     $author->load($issue->author_id);
     $owner = new \Model\User();
     if ($issue->owner_id) {
         $owner->load($issue->owner_id);
     }
     $files = new \Model\Issue\File\Detail();
     $f3->set("files", $files->find(array("issue_id = ? AND deleted_date IS NULL", $issue->id)));
     if ($issue->sprint_id) {
         $sprint = new \Model\Sprint();
         $sprint->load($issue->sprint_id);
         $f3->set("sprint", $sprint);
     }
     $watching = new \Model\Issue\Watcher();
     $watching->load(array("issue_id = ? AND user_id = ?", $issue->id, $this->_userId));
     $f3->set("watching", !!$watching->id);
     $f3->set("issue", $issue);
     $f3->set("ancestors", $issue->getAncestors());
     $f3->set("type", $type);
     $f3->set("author", $author);
     $f3->set("owner", $owner);
     $comments = new \Model\Issue\Comment\Detail();
     $f3->set("comments", $comments->find(array("issue_id = ?", $issue->id), array("order" => "created_date DESC")));
     // Extra data needed for inline edit form
     $status = new \Model\Issue\Status();
     $f3->set("statuses", $status->find(null, null, $f3->get("cache_expire.db")));
     $priority = new \Model\Issue\Priority();
     $f3->set("priorities", $priority->find(null, array("order" => "value DESC"), $f3->get("cache_expire.db")));
     $sprint = new \Model\Sprint();
     $f3->set("sprints", $sprint->find(array("end_date >= ? OR id = ?", $this->now(false), $issue->sprint_id), array("order" => "start_date ASC")));
     $users = new \Model\User();
     $f3->set("users", $users->find("deleted_date IS NULL AND role != 'group'", array("order" => "name ASC")));
     $f3->set("groups", $users->find("deleted_date IS NULL AND role = 'group'", array("order" => "name ASC")));
     $this->_render("issues/single.html");
 }