/**
  * @see sfTask
  */
 protected function executeTask($env, $arguments = array(), $options = array())
 {
     $tasks = PcTaskPeer::doSelect(new Criteria());
     foreach ($tasks as $task) {
         $contextsBlob = $task->getContexts();
         if (strlen($contextsBlob) > 0) {
             $contextIds = explode(',', $contextsBlob);
             foreach ($contextIds as $contextId) {
                 // checking the context exists
                 $context = PcUsersContextsPeer::retrieveByPK($contextId);
                 if (is_object($context)) {
                     $tasksContextsEntry = new PcTasksContexts();
                     $tasksContextsEntry->setTaskId($task->getId())->setUsersContextsId($contextId)->save();
                 }
             }
         }
     }
     echo "\nDone migration to 1.6.7 \n\n";
 }
Esempio n. 2
0
 /**
  * It is called by the save() method.
  * It populates the pc_tasks_contexts table.
  *
  * @return void
  */
 public function alignTasksContextsTable()
 {
     $contexts = $this->getContexts();
     // first, let's delete all the pre-existing contexts from this task
     $c = new Criteria();
     $c->add(PcTasksContextsPeer::TASK_ID, $this->getId());
     PcTasksContextsPeer::doDelete($c);
     $contexts = $this->getContexts();
     $contextIds = PcUtils::explodeWithEmptyInputDetection(',', $contexts);
     if (count($contextIds)) {
         foreach ($contextIds as $contextId) {
             if (is_numeric($contextId)) {
                 $record = new PcTasksContexts();
                 $record->setTaskId($this->getId())->setUsersContextsId($contextId)->save();
             }
         }
     }
 }