Esempio n. 1
0
 public function recent_comments()
 {
     $f3 = \Base::instance();
     $issue = new \Model\Issue();
     $ownerString = implode(",", $this->getOwnerIds());
     $issues = $issue->find(array("owner_id IN ({$ownerString}) OR author_id = ?", $f3->get("user.id")));
     $ids = array();
     foreach ($issues as $item) {
         $ids[] = $item->id;
     }
     $comment = new \Model\Issue\Comment\Detail();
     $issueIds = implode(",", $ids);
     return $comment->find(array("issue_id IN ({$issueIds}) AND user_id != ?", $f3->get("user.id")), array("order" => "created_date DESC", "limit" => 15));
 }
Esempio n. 2
0
 /**
  * Reassign assigned issues
  * @param  int $user_id
  * @return int Number of issues affected
  */
 public function reassignIssues($user_id)
 {
     if (!$this->id) {
         throw new \Exception("User is not initialized.");
     }
     $issue_model = new \Model\Issue();
     $issues = $issue_model->find(array("owner_id = ? AND deleted_date IS NULL AND closed_date IS NULL", $this->id));
     foreach ($issues as $issue) {
         $issue->owner_id = $user_id;
         $issue->save();
     }
     return count($issues);
 }
Esempio n. 3
0
 /**
  * GET /issues/parent_ajax
  * Load all matching issues
  *
  * @param  \Base $f3
  */
 public function parent_ajax($f3)
 {
     if (!$f3->get("AJAX")) {
         $f3->error(400);
     }
     $term = trim($f3->get('GET.q'));
     $results = array();
     $issue = new \Model\Issue();
     if (substr($term, 0, 1) == '#' && is_numeric(substr($term, 1))) {
         $id = (int) substr($term, 1);
         $issues = $issue->find(array('id LIKE ?', $id . '%'), array('limit' => 20));
         foreach ($issues as $row) {
             $results[] = array('id' => $row->get('id'), 'text' => $row->get('name'));
         }
     } elseif (is_numeric($term)) {
         $id = (int) $term;
         $issues = $issue->find(array('(id LIKE ?) OR (name LIKE ?)', $id . '%', '%' . $id . '%'), array('limit' => 20));
         foreach ($issues as $row) {
             $results[] = array('id' => $row->get('id'), 'text' => $row->get('name'));
         }
     } else {
         $issues = $issue->find(array('name LIKE ?', '%' . addslashes($term) . '%'), array('limit' => 20));
         foreach ($issues as $row) {
             $results[] = array('id' => $row->get('id'), 'text' => $row->get('name'));
         }
     }
     $this->_printJson(array('results' => $results));
 }
Esempio n. 4
0
 **/
require_once "base.php";
$issue_type_project = $f3->get("issue_type.project");
// Get all current and future sprints
$sprint = new \Model\Sprint();
$sprints = $sprint->find(array("start_date >= :now OR end_date <= :now", ":now" => date("Y-m-d")));
echo "Using " . count($sprints) . " sprints.\n";
// Get all top level projects
$project_model = new \Model\Issue();
$projects = $project_model->find(array("type_id = ? AND parent_id IS NULL AND sprint_id IS NULL", $issue_type_project));
if ($projects && $sprints) {
    foreach ($projects as $project) {
        echo "\nBreaking project {$project->id}:\n";
        // Get all tasks with due dates directly under project
        $due_date_tasks = new \Model\Issue();
        $tasks = $due_date_tasks->find(array("parent_id = :project AND due_date >= :now AND type_id != :type", ":project" => $project->id, ":now" => date("Y-m-d"), ":type" => $issue_type_project));
        if ($tasks) {
            foreach ($sprints as $sprint) {
                echo "Using sprint {$sprint->id}\n";
                $start = strtotime($sprint->start_date);
                $end = strtotime($sprint->end_date);
                $tasks_for_this_sprint = array();
                // Find tasks that fit into this sprint
                foreach ($tasks as $task) {
                    echo "Using task {$task->id}\n";
                    $due = strtotime($task->due_date);
                    if ($due >= $start && $due <= $end) {
                        echo "Task marked for move {$task->id}\n";
                        $tasks_for_this_sprint[] = $task;
                    }
                }
Esempio n. 5
0
 /**
  * Replaces IDs with links to their corresponding issues
  * @param  string $str
  * @return string
  */
 protected function _parseIds($str)
 {
     $url = \Base::instance()->get("site.url");
     // Find all IDs
     $count = preg_match_all("/(?<=[^a-z\\/&]#|^#)[0-9]+(?=[^a-z\\/]|\$)/i", $str, $matches);
     if (!$count) {
         return $str;
     }
     // Load IDs
     $ids = array();
     foreach ($matches[0] as $match) {
         $ids[] = $match;
     }
     $idsStr = implode(",", array_unique($ids));
     $issue = new \Model\Issue();
     $issues = $issue->find(array("id IN ({$idsStr})"));
     return preg_replace_callback("/(?<=[^a-z\\/&]|^)#[0-9]+(?=[^a-z\\/]|\$)/i", function ($matches) use($url, $issues) {
         $id = ltrim($matches[0], "#");
         foreach ($issues as $i) {
             if ($i->id == $id) {
                 $issue = $i;
             }
         }
         if ($issue) {
             if ($issue->deleted_date) {
                 $f3 = \Base::instance();
                 if ($f3->get("user.role") == "admin" || $f3->get("user.rank") >= \Model\User::RANK_MANAGER || $f3->get("user.id") == $issue->author_id) {
                     return "<a href=\"{$url}issues/{$id}\" style=\"text-decoration: line-through;\">#{$id} &ndash; " . htmlspecialchars($issue->name) . "</a>";
                 } else {
                     return "#{$id}";
                 }
             }
             return "<a href=\"{$url}issues/{$id}\">#{$id} &ndash; " . htmlspecialchars($issue->name) . "</a>";
         }
         return "<a href=\"{$url}issues/{$id}\">#{$id}</a>";
     }, $str);
 }