public function executeUpdate() { $jira = new sfJiraPlugin($this->getUser()->getProfile()->getJiraLogin(), $this->getUser()->getProfile()->getJiraPassword()); $aProjects = $jira->getProjects(); foreach ($aProjects as $project) { #var_dump( $project ); $c = new Criteria(); $c->add(ProjectPeer::USER_ID, $this->getUser()->getProfile()->getId()); $c->add(ProjectPeer::KEY, $project->key); $p = ProjectPeer::doSelectOne($c); $c = new Criteria(); $c->add(UserPeer::JIRA_LOGIN, $project->lead); $u = UserPeer::doSelectOne($c); if (empty($p)) { $p = new Project(); $p->setKey($project->key); $p->setLeadId(!empty($u) ? $u->getId() : null); $p->setUserId($this->getUser()->getProfile()->getId()); $p->setName($project->name); $p->setUpdated(date('r')); $p->save(); } $issues = $jira->getIssuesForProject($p->getKey()); foreach ($issues as $issue) { #die($p->getKey()); if ($issue->assignee == $this->getUser()->getProfile()->getJiraLogin()) { $c = new Criteria(); $c->add(TaskPeer::KEY, $issue->key); $t = TaskPeer::doSelectOne($c); if (empty($t)) { $c = new Criteria(); $c->add(UserPeer::JIRA_LOGIN, $issue->reporter); $u = UserPeer::doSelectOne($c); $t = new Task(); $t->setProjectId($p->getId()); $t->setTitle($issue->summary); $t->setDescription($issue->description); $t->setKey($issue->key); $t->setUpdated(date('r')); $t->setStatusId($issue->status); $t->setPriorityId($issue->priority); $t->setLeadId(!empty($u) ? $u->getId() : null); $t->save(); } } } } $this->redirect('@homepage'); return sfView::NONE; }
/** * Get the associated Project object * * @param PropelPDO Optional Connection object. * @return Project The associated Project object. * @throws PropelException */ public function getProject(PropelPDO $con = null) { if ($this->aProject === null && $this->project_id !== null) { $c = new Criteria(ProjectPeer::DATABASE_NAME); $c->add(ProjectPeer::ID, $this->project_id); $this->aProject = ProjectPeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aProject->addJobs($this); */ } return $this->aProject; }
public static function retrieveByTag($tag) { $c = new Criteria(); $c->add(ProjectPeer::TAG, $tag); return ProjectPeer::doSelectOne($c); }