public function canBeEditedByPreceptorUser($preceptor_user) { $criteria = new Criteria(); PersonalPeer::joinWithCourse($criteria, $preceptor_user->getId()); return CoursePeer::doCount($criteria); }
/** * This Function returns true if the school year is active and all the courses are closed. * * @return boolean */ public function canClose(PropelPDO $con = null) { if ($this->getIsProcessed()) { return false; } $c = new Criteria(); $c->add(CareerSchoolYearPeer::ID, $this->getId()); $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID); $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID); $c->addJoin(CoursePeer::ID, CourseSubjectPeer::COURSE_ID); $c->add(CoursePeer::SCHOOL_YEAR_ID, $this->getSchoolYear()->getId()); $courses_actives = CoursePeer::doCount($c); if ($courses_actives == 0) { return false; } $c->add(CoursePeer::IS_CLOSED, false); return CoursePeer::doCount($c) == 0; }
/** * Returns the number of related Course objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Course objects. * @throws PropelException */ public function countCourses(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(DepartmentPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collCourses === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(CoursePeer::DEPT_ID, $this->id); $count = CoursePeer::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(CoursePeer::DEPT_ID, $this->id); if (!isset($this->lastCourseCriteria) || !$this->lastCourseCriteria->equals($criteria)) { $count = CoursePeer::doCount($criteria, $con); } else { $count = count($this->collCourses); } } else { $count = count($this->collCourses); } } return $count; }