Ejemplo n.º 1
0
 /**
  * (non-PHPdoc)
  * @see EPDBObject::removeFromDB()
  */
 public function removeFromDB()
 {
     $id = $this->getId();
     if ($this->updateSummaries) {
         $this->loadFields(array('org_id'));
         $orgId = $this->getField('org_id', false);
     }
     $success = parent::removeFromDB();
     if ($success) {
         foreach (EPTerm::select('id', array('course_id' => $id)) as $term) {
             $term->setUpdateSummaries(false);
             $success = $term->removeFromDB() && $success;
         }
     }
     if ($this->updateSummaries && $orgId !== false) {
         EPOrg::updateSummaryFields(array('terms', 'students', 'courses', 'active'), array('id' => $orgId));
     }
     return $success;
 }
Ejemplo n.º 2
0
 /**
  * Returns the terms this student is enrolled in.
  *
  * @since 0.1
  *
  * @param string|array|null $fields
  * @param array $conditions
  *
  * @return array of EPTerm
  */
 protected function doGetTerms($fields, array $conditions)
 {
     $conditions[] = array(array('ep_students', 'id'), $this->getId());
     return EPTerm::select($fields, $conditions, array(), array('ep_students_per_term' => array('INNER JOIN', array(array(array('ep_students_per_term', 'term_id'), array('ep_terms', 'id')))), 'ep_students' => array('INNER JOIN', array(array(array('ep_students_per_term', 'student_id'), array('ep_students', 'id'))))));
 }
Ejemplo n.º 3
0
 /**
  * Retruns the terms linked to this org.
  *
  * @since 0.1
  *
  * @param array|null $fields
  *
  * @return array of EPTerm
  */
 public function getTerms(array $fields = null)
 {
     if ($this->terms === false) {
         $this->terms = EPTerm::select($fields, array('org_id' => $this->getId()));
     }
     return $this->terms;
 }