Beispiel #1
0
 public function addPhotographer($photographer)
 {
     $c = new Criteria();
     $c->add(JobPhotographerPeer::JOB_ID, $this->getId());
     $c->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $photographer->getId());
     if (JobPhotographerPeer::doCount($c) > 0) {
         return false;
     }
     $jp = new JobPhotographer();
     $jp->setPhotographerId($photographer->getId());
     $jp->setJobId($this->getId());
     $jp->save();
     $logEntry = new Log();
     $logEntry->setWhen(time());
     $logEntry->setPropelClass("Job");
     $logEntry->setSfGuardUserProfileId(sfContext::getInstance()->getUser()->getUserId());
     $logEntry->setMessage($photographer->getName() . " added to job.");
     $logEntry->setLogMessageTypeId(sfConfig::get("app_log_type_add_photographer"));
     $logEntry->setPropelId($this->getId());
     $logEntry->save();
     return true;
 }
Beispiel #2
0
 public function getNumberOfJobs()
 {
     $c = new Criteria();
     $c->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $this->getId());
     return JobPhotographerPeer::doCount($c);
 }
 /**
  * Returns the number of related JobPhotographer objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related JobPhotographer objects.
  * @throws     PropelException
  */
 public function countJobPhotographers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PhotographerPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collJobPhotographers === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $this->id);
             $count = JobPhotographerPeer::doCount($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(JobPhotographerPeer::PHOTOGRAPHER_ID, $this->id);
             if (!isset($this->lastJobPhotographerCriteria) || !$this->lastJobPhotographerCriteria->equals($criteria)) {
                 $count = JobPhotographerPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collJobPhotographers);
             }
         } else {
             $count = count($this->collJobPhotographers);
         }
     }
     return $count;
 }