public function execute() { $issues = $this->issueService->getIssues(array('status=' => 'Open')); // Get the project for each issue $group = $this->groupService->getGroupByField('title', za()->getConfig('issue_group')); if ($group) { $users = $this->groupService->getUsersInGroup($group); $msg = new TemplatedMessage('open-issues.php', array('issues' => $issues)); $this->notificationService->notifyUser('Open Requests', $users, $msg); } else { za()->log()->warn("Could not find group for sending issues to"); } }
public function viewgroupAction() { $group = $this->byId($this->_getParam('id'), 'UserGroup'); $users = $this->groupService->getUsersInGroup($group, true); $groupUsers = array(); foreach ($users as $user) { $groupUsers[$user->id] = $user; } $this->view->groupusers = $groupUsers; $this->view->users = $this->userService->getUserList(); $this->view->group = $group; $this->renderView('admin/view-group.php'); }
public function projectgroupAction() { $project = $this->projectService->getProject((int) $this->_getParam('id')); if ($project == null) { $this->flash("Project not found"); $this->renderView('error.php'); return; } $group = $this->groupService->getGroup($project->ownerid); if ($group == null) { throw new Exception("Invalid group #{$group->ownerid}"); } $users = $this->groupService->getUsersInGroup($group, true); $groupUsers = new ArrayObject(); foreach ($users as $user) { $groupUsers[$user->id] = $user; } $this->view->groupusers = $groupUsers; $this->view->users = $this->userService->getUserList(); $this->view->group = $group; $this->view->model = $project; $this->renderRawView('project/group-list.php'); }
/** * Save a project * * @param array|Project $params */ public function saveProject($params) { $this->dbService->beginTransaction(); // Double check to see whether the children projects are actually // a parent of the selected parent $pid = 0; $parent = 0; $project = null; $clientid = 0; if (is_array($params)) { $pid = ifset($params, 'id'); $parent = ifset($params, 'parentid'); if ($pid) { $project = $this->getProject($pid); $clientid = ifset($params, 'clientid', $project->clientid); } } else { $pid = $params->id; $parent = $params->parentid; $project = $params; $clientid = $project->clientid; } if ($pid) { // check the current parent client, if it's changed we need to update all our // child projects as well to let them know that the parent is now different $proj = $this->dbService->getById($pid, 'Project'); $updateChildren = false; if ($proj->clientid != $clientid) { // update all the children too $updateChildren = true; } // get all the children (including grandchildren and milestones) /* @var $project Project */ $children = $project->getContainedMilestones(); // see if the selected parent is in the list of children at all foreach ($children as $childProject) { if ($childProject->id == $parent) { throw new Exception("Cannot create recursive project hierarchy"); } $this->log->debug("Updating project " . $childProject->title . " to client {$clientid}"); if ($updateChildren) { $childProject->clientid = $clientid; $this->dbService->saveObject($childProject, 'Project'); } } } else { // we're creating a new project, so lets update the cache list $this->cacheService->expire($this->clientProjectsCacheKey($clientid)); } if ($params instanceof Project) { $this->updateProjectEstimate($params); } $savedProject = $this->dbService->saveObject($params, 'Project'); // If this project's due date is greater than the parent's due date, // then update that parent's due date if ($savedProject && $savedProject->parentid) { $parentProject = $this->dbService->getById($savedProject->parentid, 'Project'); $parentEnd = strtotime($parentProject->due); $thisEnd = strtotime($savedProject->due); if ($thisEnd > $parentEnd) { $parentProject->due = $savedProject->due; $this->saveProject($parentProject); $group = $this->groupService->getGroup($parentProject->ownerid); // Only send if the group exists if ($group) { $users = $this->groupService->getUsersInGroup($group); $msg = new TemplatedMessage('project-end-updated.php', array('model' => $parentProject)); try { $this->notificationService->notifyUser("Project due date changed", $users, $msg); } catch (Exception $e) { $this->log->warn("Failed sending project update email"); } } } if (mb_strlen($savedProject->actualstart) && !mb_strlen($parentProject->actualstart)) { $parentProject->actualstart = $savedProject->actualstart; $this->saveProject($parentProject); } } $this->dbService->commit(); return $savedProject; }