Esempio n. 1
0
 /**
  * Associate the student with the provided terms.
  *
  * @since 0.1
  *
  * @param array $terms
  *
  * @return bool
  */
 public function associateWithTerms(array $terms)
 {
     $dbw = wfGetDB(DB_MASTER);
     $success = true;
     $dbw->begin();
     foreach ($terms as $term) {
         $success = $dbw->insert('ep_students_per_term', array('spt_student_id' => $this->getId(), 'spt_term_id' => $term->getId())) && $success;
     }
     $dbw->commit();
     foreach ($terms as $term) {
         EPCourse::updateSummaryFields('students', array('id' => $term->getField('course_id')));
         EPOrg::updateSummaryFields('students', array('id' => $term->getField('org_id')));
         EPTerm::updateSummaryFields('students', array('id' => $this->getId()));
     }
     return $success;
 }
Esempio n. 2
0
 /**
  * (non-PHPdoc)
  * @see EPDBObject::updateInDB()
  */
 protected function updateInDB()
 {
     $oldOrgId = $this->hasField('org_id') ? self::selectFieldsRow('org_id', array('id' => $this->getId())) : false;
     $success = parent::updateInDB();
     if ($this->updateSummaries && $success && $oldOrgId !== false && $oldOrgId !== $this->getField('org_id')) {
         $conds = array('id' => array($oldOrgId, $this->getField('org_id')));
         EPTerm::updateSummaryFields('org_id', array('course_id' => $this->getId()));
         EPOrg::updateSummaryFields(array('terms', 'students', 'courses', 'active'), $conds);
     }
     return $success;
 }