public function save(PropelPDO $con = null) { parent::save($con); $photoId = $this->getPhotographerId(); switch ($photoId) { case 5: // Joanie $url = "http://www.google.com/calendar/feeds/" . urlencode(sfConfig::get("app_joanie_calendar_id")) . "/private/full"; $this->getJob()->setGCalIdCustomUrl($url); $this->getJob()->save(); if (!$this->getJob()->getDate("U") > 0) { return; } $arr = $this->getJob()->createCalendarArray(); $arr["calUrl"] = $url; $event = sfGCalendar::createJobEvent($arr); $this->getJob()->setGCalIdCustom($event->id); $this->getJob()->setGCalIdCustomUrl($arr["calUrl"]); $this->getJob()->save(); break; case 25: // Alonso $url = "http://www.google.com/calendar/feeds/" . sfConfig::get("app_alonso_calendar_id") . "/private/full"; $this->getJob()->setGCalIdCustomUrl($url); $this->getJob()->save(); if (!$this->getJob()->getDate("U") > 0) { return; } $arr = $this->getJob()->createCalendarArray(); $arr["calUrl"] = $url; $event = sfGCalendar::createJobEvent($arr); $this->getJob()->setGCalIdCustom($event->id); $this->getJob()->setGCalIdCustomUrl($arr["calUrl"]); $this->getJob()->save(); break; default: break; } }
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(); } }