Skip to content

Commit

Permalink
Merge pull request #1 from Alanaktion/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
lgg authored Jan 8, 2017
2 parents 78bc3d8 + 12ac67c commit 7540fe8
Show file tree
Hide file tree
Showing 143 changed files with 5,645 additions and 16,450 deletions.
13 changes: 12 additions & 1 deletion app/controller/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ public function index($f3) {
$f3->set("menuitem", "admin");

if($f3->get("POST.action") == "clearcache") {
\Cache::instance()->reset();
$cache = \Cache::instance();

// Clear configured cache
$cache->reset();

// Clear filesystem cache (thumbnails, etc.)
$cache->load("folder=tmp/cache/");
$cache->reset();

// Reset cache configuration
$cache->load($f3->get("CACHE"));

$f3->set("success", "Cache cleared successfully.");
}

Expand Down
188 changes: 84 additions & 104 deletions app/controller/backlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,94 +12,60 @@ public function __construct() {

/**
* GET /backlog
* GET /backlog/@filter
* GET /backlog/@filter/@groupid
*
* @param \Base $f3
* @param array $params
*/
public function index($f3, $params) {

if(empty($params["filter"])) {
$params["filter"] = "groups";
}

if(empty($params["groupid"])) {
$params["groupid"] = "";
}

// Get list of all users in the user's groups
if($params["filter"] == "groups") {
$group_model = new \Model\User\Group();
if(!empty($params["groupid"]) && is_numeric($params["groupid"])) {
//Get users list from a specific Group
$users_result = $group_model->find(array("group_id = ?", $params["groupid"]));

} else {
//Get users list from all groups that you are in
$groups_result = $group_model->find(array("user_id = ?", $this->_userId));
$filter_users = array($this->_userId);
foreach($groups_result as $g) {
$filter_users[] = $g["group_id"];
}
$groups = implode(",", $filter_users);
$users_result = $group_model->find("group_id IN ({$groups})");
}

foreach($users_result as $u) {
$filter_users[] = $u["user_id"];
}
} elseif($params["filter"] == "me") {
//Just get your own id
$filter_users = array($this->_userId);
}

$filter_string = empty($filter_users) ? "" : "AND owner_id IN (" . implode(",", $filter_users) . ")";
$f3->set("filter", $params["filter"]);

public function index($f3) {
$sprint_model = new \Model\Sprint();
$sprints = $sprint_model->find(array("end_date >= ?", $this->now(false)), array("order" => "start_date ASC"));

$type = new \Model\Issue\Type;
$projectTypes = $type->find(["role = ?", "project"]);
$f3->set("project_types", $projectTypes);
$typeIds = [];
foreach($projectTypes as $type) {
$typeIds[] = $type->id;
}
$typeStr = implode(",", $typeIds);

$issue = new \Model\Issue\Detail();

$sprint_details = array();
$sprint_details = [];
foreach($sprints as $sprint) {
$projects = $issue->find(array("deleted_date IS NULL AND sprint_id = ? AND type_id = ? $filter_string", $sprint->id, $f3->get("issue_type.project")),
array('order' => 'priority DESC, due_date')
);

if(!empty($params["groupid"])) {
// Add sorted projects
$sprintBacklog = array();
$sortModel = new \Model\Issue\Backlog;
$sortModel->load(array("user_id = ? AND sprint_id = ?", $params["groupid"], $sprint->id));
$sortArray = array();
if($sortModel->id) {
$sortArray = json_decode($sortModel->issues);
foreach($sortArray as $id) {
foreach($projects as $p) {
if($p->id == $id) {
$sprintBacklog[] = $p;
}
$projects = $issue->find(
array("deleted_date IS NULL AND sprint_id = ? AND type_id IN ($typeStr)", $sprint->id),
array('order' => 'priority DESC, due_date')
);

// Add sorted projects
$sprintBacklog = [];
$sortOrder = new \Model\Issue\Backlog;
$sortOrder->load(array("sprint_id = ?", $sprint->id));
$sortArray = [];
if($sortOrder->id) {
$sortArray = json_decode($sortOrder->issues) ?: [];
$sortArray = array_unique($sortArray);
foreach($sortArray as $id) {
foreach($projects as $p) {
if($p->id == $id) {
$sprintBacklog[] = $p;
}
}
}
}

// Add remaining projects
foreach($projects as $p) {
if(!in_array($p->id, $sortArray)) {
$sprintBacklog[] = $p;
}
// Add remaining projects
foreach($projects as $p) {
if(!in_array($p->id, $sortArray)) {
$sprintBacklog[] = $p;
}
} else {
$sprintBacklog = $projects;
}

$sprint_details[] = $sprint->cast() + array("projects" => $sprintBacklog);
}

$large_projects = $f3->get("db.instance")->exec("SELECT parent_id FROM issue WHERE parent_id IS NOT NULL AND type_id = ?", $f3->get("issue_type.project"));
$large_project_ids = array();
$large_projects = $f3->get("db.instance")->exec("SELECT i.parent_id FROM issue i JOIN issue_type t ON t.id = i.type_id WHERE i.parent_id IS NOT NULL AND t.role = 'project'");
$large_project_ids = [];
foreach($large_projects as $p) {
$large_project_ids[] = $p["parent_id"];
}
Expand All @@ -108,48 +74,46 @@ public function index($f3, $params) {
if(!empty($large_project_ids)) {
$large_project_ids = implode(",", $large_project_ids);
$unset_projects = $issue->find(
array("deleted_date IS NULL AND sprint_id IS NULL AND type_id = ? AND status_closed = '0' AND id NOT IN ({$large_project_ids}) $filter_string", $f3->get("issue_type.project")),
array("deleted_date IS NULL AND sprint_id IS NULL AND type_id IN ($typeStr) AND status_closed = '0' AND id NOT IN ({$large_project_ids})"),
array('order' => 'priority DESC, due_date')
);
} else {
$unset_projects = $issue->find(
array("deleted_date IS NULL AND sprint_id IS NULL AND type_id = ? AND status_closed = '0' $filter_string", $f3->get("issue_type.project")),
array("deleted_date IS NULL AND sprint_id IS NULL AND type_id IN ($typeStr) AND status_closed = '0'"),
array('order' => 'priority DESC, due_date')
);
}

// Filter projects into sorted and unsorted arrays if filtering by group
if(!empty($params["groupid"])) {
// Add sorted projects
$backlog = array();
$sortModel = new \Model\Issue\Backlog;
$sortModel->load(array("user_id = ? AND sprint_id IS NULL", $params["groupid"]));
$sortArray = array();
if($sortModel->id) {
$sortArray = json_decode($sortModel->issues);
foreach($sortArray as $id) {
foreach($unset_projects as $p) {
if($p->id == $id) {
$backlog[] = $p;
}
// Add sorted projects
$backlog = [];
$sortOrder = new \Model\Issue\Backlog;
$sortOrder->load(array("sprint_id IS NULL"));
$sortArray = [];
if($sortOrder->id) {
$sortArray = json_decode($sortOrder->issues) ?: [];
$sortArray = array_unique($sortArray);
foreach($sortArray as $id) {
foreach($unset_projects as $p) {
if($p->id == $id) {
$backlog[] = $p;
}
}
}
}

// Add remaining projects
$unsorted = array();
foreach($unset_projects as $p) {
if(!in_array($p->id, $sortArray)) {
$unsorted[] = $p;
}
// Add remaining projects
$unsorted = [];
foreach($unset_projects as $p) {
if(!in_array($p->id, $sortArray)) {
$unsorted[] = $p;
}
} else {
$backlog = $unset_projects;
}

$groups = new \Model\User();
$f3->set("groups", $groups->getAllGroups());
$f3->set("groupid", $params["groupid"]);
$user = new \Model\User();
$f3->set("groups", $user->getAllGroups());

$f3->set("groupid", $groupId);
$f3->set("type_ids", $typeIds);
$f3->set("sprints", $sprint_details);
$f3->set("backlog", $backlog);
$f3->set("unsorted", $unsorted);
Expand All @@ -159,6 +123,16 @@ public function index($f3, $params) {
$this->_render("backlog/index.html");
}

/**
* GET /backlog/@filter
* GET /backlog/@filter/@groupid
* @param \Base $f3
* @param array $params
*/
public function redirect(\Base $f3, array $params) {
$f3->reroute("/backlog");
}

/**
* POST /edit
* @param \Base $f3
Expand All @@ -167,8 +141,8 @@ public function index($f3, $params) {
public function edit($f3) {
$post = $f3->get("POST");
$issue = new \Model\Issue();
$issue->load($post["itemId"]);
$issue->sprint_id = empty($post["reciever"]["receiverId"]) ? null : $post["reciever"]["receiverId"];
$issue->load($post["id"]);
$issue->sprint_id = empty($post["sprint_id"]) ? null : $post["sprint_id"];
$issue->save();
$this->_printJson($issue);
}
Expand All @@ -182,12 +156,11 @@ public function sort($f3) {
$this->_requireLogin(\Model\User::RANK_MANAGER);
$backlog = new \Model\Issue\Backlog;
if($f3->get("POST.sprint_id")) {
$backlog->load(array("user_id = ? AND sprint_id = ?", $f3->get("POST.user"), $f3->get("POST.sprint_id")));
$backlog->load(array("sprint_id = ?", $f3->get("POST.sprint_id")));
$backlog->sprint_id = $f3->get("POST.sprint_id");
} else {
$backlog->load(array("user_id = ? AND sprint_id IS NULL", $f3->get("POST.user")));
$backlog->load(array("sprint_id IS NULL"));
}
$backlog->user_id = $f3->get("POST.user");
$backlog->issues = $f3->get("POST.items");
$backlog->save();
}
Expand All @@ -197,15 +170,22 @@ public function sort($f3) {
* @param \Base $f3
*/
public function index_old($f3) {

$sprint_model = new \Model\Sprint();
$sprints = $sprint_model->find(array("end_date < ?", $this->now(false)), array("order" => "start_date ASC"));

$issue = new \Model\Issue\Detail();
$type = new \Model\Issue\Type;
$projectTypes = $type->find(["role = ?", "project"]);
$f3->set("project_types", $projectTypes);
$typeIds = [];
foreach($projectTypes as $type) {
$typeIds[] = $type->id;
}
$typeStr = implode(",", $typeIds);

$issue = new \Model\Issue\Detail();
$sprint_details = array();
foreach($sprints as $sprint) {
$projects = $issue->find(array("deleted_date IS NULL AND sprint_id = ? AND type_id = ?", $sprint->id, $f3->get("issue_type.project")));
$projects = $issue->find(array("deleted_date IS NULL AND sprint_id = ? AND type_id IN ($typeStr)", $sprint->id));
$sprint_details[] = $sprint->cast() + array("projects" => $projects);
}

Expand Down
4 changes: 3 additions & 1 deletion app/controller/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ public function thumb($f3, $params) {
}

// Render and cache image
$data = call_user_func_array('image' . $params["format"], array($frame));
ob_start();
call_user_func_array('image' . $params["format"], array($frame));
$data = ob_get_clean();
if($f3->get("DEBUG") < 2) {
$cache->set($hash, $data, $f3->get("cache_expire.attachments"));
}
Expand Down
Loading

0 comments on commit 7540fe8

Please sign in to comment.