示例#1
0
 /**
  * POST /issues/@id/dependencies/delete
  * Delete a dependency
  *
  * @param \Base $f3
  * @param array $params
  */
 public function delete_dependency($f3, $params)
 {
     $issue = new \Model\Issue();
     $issue->load(array("id=?", $params["id"]));
     if (!$issue->id) {
         $f3->error(404);
     }
     $dependency = new \Model\Issue\Dependency();
     $dependency->load($f3->get("POST.id"));
     $dependency->delete();
 }
示例#2
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");
 }