Exemple #1
0
 public function hydrate(ResultSet $rs, $startcol = 1)
 {
     parent::hydrate($rs, $startcol);
     $culture = sfContext::getInstance()->getUser()->getCulture();
     if ($culture == '' || $culture == null) {
         $culture = 'en';
     }
     $this->setCulture($culture);
 }
 /**
  * @see parent::resolveJobsForQueue()
  */
 public static function resolveJobsForQueue()
 {
     parent::resolveJobsForQueue();
     $pageSize = static::JOB_QUEUE_PAGE_SIZE;
     $offset = 0;
     $timeStamp = time();
     do {
         $queueModels = static::getModelsTResolveToJobQueue($pageSize, $offset, static::getType(), $timeStamp);
         $offset = $offset + $pageSize;
         if (is_array($queueModels) && count($queueModels) > 0) {
             foreach ($queueModels as $queueModel) {
                 InQueueUtil::resolveToAddJobToQueueAfterSaveOfModel($queueModel, static::getType());
             }
         }
     } while (is_array($queueModels) && count($queueModels) > 0);
 }
Exemple #3
0
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     JobPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new JobPeer();
     }
     return self::$peer;
 }
Exemple #4
0
 public function getParameter()
 {
     return json_decode(parent::getParameter(), true);
 }
Exemple #5
0
 public function save(PropelPDO $con = null)
 {
     $isNew = $this->isNew();
     // see if we need to do revision control on the notes
     $updateNotes = in_array(JobPeer::NOTES, $this->modifiedColumns) && strlen($this->getNotes() > 1);
     if (is_null($con)) {
         $con = Propel::getConnection(JobPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = parent::save($con);
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
     $arr = $this->createCalendarArray();
     if (!is_null(sfContext::getInstance()->getUser())) {
         $uid = sfContext::getInstance()->getUser()->getUserId();
     } else {
         $uid = 1;
     }
     if ($isNew) {
         $logEntry = new Log();
         $logEntry->setWhen(time());
         $logEntry->setPropelClass("Job");
         $logEntry->setSfGuardUserProfileId($uid);
         $logEntry->setMessage("Job created.");
         $logEntry->setLogMessageTypeId(sfConfig::get("app_log_type_create"));
         $logEntry->setPropelId($this->getId());
         $logEntry->save();
         if ($this->getDate("U") > 0) {
             $event = sfGCalendar::createJobEvent($arr);
             $this->setGCalId($event->id);
             parent::save($con);
         }
     } else {
         if ($this->getDate("U") > 0) {
             if (is_null($this->getGCalId())) {
                 $event = sfGCalendar::createJobEvent($arr);
                 $this->setGCalId($event->id);
                 parent::save($con);
             } else {
                 sfGCalendar::updateJobEventById($this->getGCalId(), $arr);
             }
             if (!is_null($this->getGCalIdCustomUrl())) {
                 if (!is_null($this->getGCalIdCustom())) {
                     $arr["calUrl"] = $this->getGCalIdCustomUrl();
                     sfGCalendar::updateJobEventById($this->getGCalIdCustom(), $arr);
                 } else {
                     $arr["calUrl"] = $url;
                     $event = sfGCalendar::createJobEvent($arr);
                     $this->setGCalIdCustom($event->id);
                 }
             }
         }
     }
     if ($updateNotes) {
         $c = new Criteria();
         $c->add(JobNotesPeer::JOB_ID, $this->getId());
         $c->addDescendingOrderByColumn(JobNotesPeer::ID);
         $old = JobNotesPeer::doSelectOne($c);
         $rev = !is_null($old) ? $old->getRevision() + 1 : 1;
         $jn = new JobNotes();
         $jn->setJobId($this->getId());
         $jn->setNotes($this->getNotes());
         $jn->setRevision($rev);
         $jn->setUserId(sfContext::getInstance()->getUser()->getUserId());
         $jn->save();
     }
 }