Пример #1
0
 public function update()
 {
     $result = parent::update();
     if (isset($this->curriculum)) {
         $this->add_course_to_curricula($this->curriculum);
     }
     // Add moodle course template
     if (isset($this->location)) {
         $template = new coursetemplate($this->id);
         $template->location = $this->location;
         $template->templateclass = $this->templateclass;
         $template->courseid = $this->id;
         $template->data_update_record(true);
     } else {
         coursetemplate::delete_for_course($this->id);
     }
     $result = $result && field_data::set_for_context_from_datarecord('course', $this);
     return $result;
 }
Пример #2
0
 public function update()
 {
     $result = parent::update();
     $result = $result && field_data::set_for_context_from_datarecord('curriculum', $this);
     // If this setting is changed, we need to update the existing curriclum expiration values (ELIS-1172)
     if ($rs = get_recordset_select(CURASSTABLE, "timeexpired != 0 AND curriculumid = {$this->id}", '', 'id, userid')) {
         $timenow = time();
         while ($curass = rs_fetch_next_record($rs)) {
             $update = new stdClass();
             $update->id = $curass->id;
             $update->timeexpired = calculate_curriculum_expiry(NULL, $this->id, $curass->userid);
             $update->timemodified = $timenow;
             update_record(CURASSTABLE, $update);
         }
         rs_close($rs);
     }
     return $result;
 }
Пример #3
0
 public function update()
 {
     $status = parent::update();
     if ($this->moodlecourseid || $this->autocreate) {
         moodle_attach_class($this->id, $this->moodlecourseid, '', true, true, $this->autocreate);
     }
     if (!empty($this->oldmax) && $this->oldmax < $this->maxstudents && waitlist::count_records($this->id) > 0) {
         for ($i = $this->oldmax; $i < $this->maxstudents; $i++) {
             $next_student = waitlist::get_next($this->id);
             if (!empty($next_student)) {
                 $next_student->enrol();
             } else {
                 break;
             }
         }
     }
     $status = $status && field_data::set_for_context_from_datarecord('class', $this);
     return $status;
 }
Пример #4
0
 function update()
 {
     global $CFG;
     global $CURMAN;
     $old = new cluster($this->id);
     $parent_obj = new cluster($this->parent);
     $this->depth = empty($parent_obj->depth) ? 1 : $parent_obj->depth + 1;
     $result = parent::update();
     if ($this->parent != $old->parent) {
         $cluster_context_level = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
         $cluster_context_instance = get_context_instance($cluster_context_level, $this->id);
         // find all subclusters and adjust their depth
         $delta_depth = $this->depth - $old->depth;
         $sql = "UPDATE {$CURMAN->db->prefix_table(CLSTTABLE)}\n                       SET depth = depth + {$delta_depth}\n                     WHERE id IN (SELECT instanceid\n                                    FROM {$CURMAN->db->prefix_table('context')}\n                                   WHERE contextlevel = {$cluster_context_level}\n                                     AND path LIKE '{$cluster_context_instance->path}/%')";
         execute_sql($sql, false);
         // Blank out the depth and path for associated records and child records in context table
         $sql = "UPDATE {$CFG->prefix}context\n                       SET depth=0, path=NULL\n                     WHERE id={$cluster_context_instance->id} OR path LIKE '{$cluster_context_instance->path}/%'";
         execute_sql($sql, false);
         // Rebuild any blanked out records in context table
         build_context_path();
     }
     $plugins = cluster::get_plugins();
     foreach ($plugins as $plugin) {
         require_once CURMAN_DIRLOCATION . '/cluster/' . $plugin . '/lib.php';
         call_user_func('cluster_' . $plugin . '_update', $this);
     }
     $result = $result && field_data::set_for_context_from_datarecord('cluster', $this);
     events_trigger('crlm_cluster_updated', $this);
     return $result;
 }
Пример #5
0
 function update()
 {
     $result = parent::update();
     $result = $result && field_data::set_for_context_from_datarecord('track', $this);
     return $result;
 }