Exemplo n.º 1
0
 public static function setJobProjectIds($jobs, $projectId)
 {
     $c1 = new Criteria();
     $c2 = new Criteria();
     $c1->add(JobPeer::ID, $jobs, Criteria::IN);
     $c2->add(JobPeer::PROJECT_ID, $projectId);
     BasePeer::doUpdate($c1, $c2, Propel::getConnection());
     $project = ProjectPeer::retrieveByPK($projectId);
     foreach ($jobs as $id) {
         $logEntry = new Log();
         $logEntry->setWhen(time());
         $logEntry->setPropelClass("Job");
         $logEntry->setSfGuardUserProfileId(sfContext::getInstance()->getUser()->getUserId());
         $logEntry->setMessage("Moved job to project" . $project->getName());
         $logEntry->setLogMessageTypeId(sfConfig::get("app_log_type_move_to_project"));
         $logEntry->setPropelId($id);
         $logEntry->save();
     }
 }
Exemplo n.º 2
0
 public function getProject($con = null)
 {
     if ($this->aProject === null && $this->project_id !== null) {
         include_once 'lib/model/om/BaseProjectPeer.php';
         $this->aProject = ProjectPeer::retrieveByPK($this->project_id, $con);
     }
     return $this->aProject;
 }
Exemplo n.º 3
0
 public function executeAddProject(sfWebRequest $request)
 {
     $obj = json_decode($request->getParameter("obj"), true);
     $jobs = $obj["jobs"];
     $addProjectId = $obj["addProjectId"];
     $projectName = $obj["projectName"];
     $createNew = $obj["createNew"];
     $removeFromProject = $obj["removeFromProject"];
     if (!$removeFromProject) {
         if ($createNew) {
             $project = new Project();
             $project->setName($projectName);
             $project->save();
         } else {
             $project = ProjectPeer::retrieveByPK($addProjectId);
         }
         $projectId = $project->getId();
     } else {
         $projectId = null;
     }
     if ($removeFromProject || !is_null($projectId)) {
         JobPeer::setJobProjectIds($jobs, $projectId);
     }
     $this->setTemplate("reload");
     if ($this->createCriteria() == sfView::NONE) {
         return sfView::NONE;
     }
 }