/** * Projects Arhive * * @param void * @return null */ function archive() { if ($this->request->isApiCall()) { $this->serveData(Projects::findByUser($this->logged_user), 'projects'); } // if $per_page = 10; $page = (int) $this->request->get('page'); if ($page < 1) { $page = 1; } // if if (!$this->logged_user->isOwner()) { $group_by = 'group'; } else { $group_by = $this->request->get('group_by'); if ($group_by != 'client') { $group_by = 'group'; } // if } // if $filter_by_status = $this->request->get('filter'); if (is_null($filter_by_status)) { $filter_by_status = 'all'; } // if switch ($filter_by_status) { case 'all': $statuses = array(PROJECT_STATUS_COMPLETED, PROJECT_STATUS_CANCELED, PROJECT_STATUS_PAUSED); break; case 'completed': $statuses = array(PROJECT_STATUS_COMPLETED); break; case 'paused': $statuses = array(PROJECT_STATUS_PAUSED); break; case 'canceled': $statuses = array(PROJECT_STATUS_CANCELED); break; default: $statuses = array(PROJECT_STATUS_COMPLETED, PROJECT_STATUS_CANCELED, PROJECT_STATUS_PAUSED); break; } // switch project status filter $this->smarty->assign(array('group_by' => $group_by, 'filter' => $filter_by_status)); if ($group_by == 'group') { $group = null; $group_id = $this->request->getId('group_id'); if ($group_id) { $group = ProjectGroups::findById($group_id); } // if if (instance_of($group, 'ProjectGroup')) { list($projects, $pagination) = Projects::paginateByUserAndGroup($this->logged_user, $group, $statuses, $page, $per_page, true); } else { list($projects, $pagination) = Projects::paginateByUser($this->logged_user, $statuses, $page, $per_page, true); } // if $this->smarty->assign(array('projects' => $projects, 'pagination' => $pagination, 'groups' => ProjectGroups::findAll($this->logged_user), 'selected_group' => $group)); } else { $company = null; $company_id = $this->request->getId('company_id'); if ($company_id) { $company = Companies::findById($company_id); } // if if (!instance_of($company, 'Company')) { $company = $this->owner_company; } // if list($projects, $pagination) = Projects::paginateByUserAndCompany($this->logged_user, $company, $statuses, $page, $per_page, true); $this->smarty->assign(array('projects' => $projects, 'pagination' => $pagination, 'companies' => Companies::findClients($this->logged_user), 'selected_company' => $company)); } // if }
/** * Return all active project this user is involved in * * @param boolean $pinned_first * @return array */ function getActiveProjects($pinned_first = false) { if ($this->active_projects === false) { $this->active_projects = Projects::findByUser($this, PROJECT_STATUS_ACTIVE); } // if if ($pinned_first) { if (is_foreachable($this->active_projects)) { $pinned = array(); $not_pinned = array(); foreach ($this->active_projects as $active_project) { if (PinnedProjects::isPinned($active_project, $this)) { $pinned[] = $active_project; } else { $not_pinned[] = $active_project; } // if } // foreach if (count($pinned) && count($not_pinned)) { return array_merge($pinned, $not_pinned); } elseif (count($pinned)) { return $pinned; } elseif (count($not_pinned)) { return $not_pinned; } else { return null; } // if } else { return null; } // if } else { return $this->active_projects; } // if }
/** * Show active projects list - all projects in a brief view * * @param void * @return null */ function active_projects() { if (!$this->request->isAsyncCall()) { $this->redirectTo('projects'); } // if $this->skip_layout = true; $this->smarty->assign('projects', Projects::findByUser($this->logged_user, array(PROJECT_STATUS_ACTIVE))); }