Пример #1
0
 function delete()
 {
     // delete associated data
     require_once elis::lib('data/data_filter.class.php');
     //filter specific for tracks, due to different field name
     $filter = new field_filter('curid', $this->id);
     track::delete_records($filter, $this->_db);
     //filter for all other associations
     $filter = new field_filter('curriculumid', $this->id);
     clustercurriculum::delete_records($filter, $this->_db);
     curriculumcourse::delete_records($filter, $this->_db);
     curriculumstudent::delete_records($filter, $this->_db);
     parent::delete();
     //clean up the curriculum context instance
     $context = \local_elisprogram\context\program::instance($this->id);
     $context->delete();
 }
Пример #2
0
 /**
  * Removes all associations with a track, this entails removing
  * user track, cluster track and class track associations
  * @param none
  * @return none
  */
 function delete()
 {
     // Cascade
     //clean make the delete cascade into association records
     $filter = new field_filter('trackid', $this->id);
     usertrack::delete_records($filter, $this->_db);
     clustertrack::delete_records($filter, $this->_db);
     trackassignment::delete_records($filter, $this->_db);
     parent::delete();
     //Delete this leve's context
     $context = \local_elisprogram\context\track::instance($this->id);
     $context->delete();
 }
Пример #3
0
 public function delete()
 {
     global $CFG;
     $muser = $this->get_moodleuser();
     if (empty($muser) || !is_primary_admin($muser->id)) {
         // delete associated data
         require_once elis::lib('data/data_filter.class.php');
         $filter = new field_filter('userid', $this->id);
         curriculumstudent::delete_records($filter, $this->_db);
         student::delete_records($filter, $this->_db);
         student_grade::delete_records($filter, $this->_db);
         waitlist::delete_records($filter, $this->_db);
         instructor::delete_records($filter, $this->_db);
         usertrack::delete_records($filter, $this->_db);
         clusterassignment::delete_records($filter, $this->_db);
         //delete association to Moodle user, if applicable
         require_once elispm::lib('data/usermoodle.class.php');
         $filter = new field_filter('cuserid', $this->id);
         usermoodle::delete_records($filter, $this->_db);
         // Delete Moodle user.
         if (!empty($muser)) {
             delete_user($muser);
         }
         parent::delete();
         $context = \local_elisprogram\context\user::instance($this->id);
         $context->delete();
     }
 }
Пример #4
0
 public function delete()
 {
     //delete associated classes
     $filter = new field_filter('courseid', $this->id);
     pmclass::delete_records($filter, $this->_db);
     //clean up associated records
     curriculumcourse::delete_records($filter, $this->_db);
     coursetemplate::delete_records($filter, $this->_db);
     // ELIS-8528: Remove LOs/completion elements.
     coursecompletion::delete_records($filter, $this->_db);
     parent::delete();
     $context = \local_elisprogram\context\course::instance($this->id);
     $context->delete();
 }
Пример #5
0
 /**
  * Perform the necessary actions required to "delete" a cluster from the system.
  *
  * @param none
  * @return bool True on success, False otherwise.
  */
 function delete()
 {
     require_once elis::lib('data/data_filter.class.php');
     if ($this->deletesimple) {
         //core delete method, not including recursion (entered once for each
         //individual userset being delete)
         //clean make the delete cascade into association records
         $filter = new field_filter('clusterid', $this->id);
         clustercurriculum::delete_records($filter, $this->_db);
         clustertrack::delete_records($filter, $this->_db);
         clusterassignment::delete_records($filter, $this->_db);
         //cluster plugin cleanup
         $plugins = get_plugin_list(self::ENROL_PLUGIN_TYPE);
         foreach ($plugins as $plugin => $plugindir) {
             require_once elis::plugin_file(self::ENROL_PLUGIN_TYPE . '_' . $plugin, 'lib.php');
             call_user_func('cluster_' . $plugin . '_delete_for_cluster', $this->id);
         }
         //delete the userset record
         parent::delete();
         //delete this cluster's context
         //get a new context instance,
         $contextclass = \local_eliscore\context\helper::get_class_for_level(CONTEXT_ELIS_USERSET);
         $userset_context = $contextclass::instance($this->id);
         $userset_context->delete();
         events_trigger('cluster_deleted', $this->id);
         return;
     }
     $result = true;
     $children = array();
     $delete_ids = array();
     $promote_ids = array();
     /// Figure out all the sub-clusters
     $cluster_context_instance = \local_elisprogram\context\userset::instance($this->id);
     $instance_id = $cluster_context_instance->id;
     $instance_path = $cluster_context_instance->path;
     $children = userset::find(new join_filter('id', 'context', 'instanceid', new AND_filter(array(new field_filter('path', "{$instance_path}/%", field_filter::LIKE), new field_filter('contextlevel', CONTEXT_ELIS_USERSET)))), array('depth' => 'ASC'), 0, 0, $this->_db);
     $children = $children->to_array();
     if ($this->deletesubs) {
         $todelete = $children;
         $todelete[] = $this;
         // The specified cluster always gets deleted
     } else {
         $todelete = array($this);
     }
     foreach ($todelete as $userset) {
         //delete without recursion
         $userset->deletesimple = true;
         $userset->delete();
     }
     if (!$this->deletesubs && !empty($children)) {
         foreach ($children as $child) {
             $lower_depth = $child->depth - 1;
             if (userset::exists(new field_filter('id', $child->parent))) {
                 /// A parent found so lets lower the depth
                 $child->depth = 0;
             } else {
                 /// Parent not found so this cluster will be top-level
                 $child->parent = 0;
                 $child->depth = 1;
             }
             $child->save();
             $sql = "UPDATE {context}\n                        SET depth=0, path=NULL\n                        WHERE contextlevel=? AND instanceid=?";
             $this->_db->execute($sql, array(CONTEXT_ELIS_USERSET, $child->id));
         }
         \local_eliscore\context\helper::build_all_paths(false, array(CONTEXT_ELIS_USERSET));
         // Re-build the context table for all sub-clusters
     }
     return $result;
 }
Пример #6
0
 function delete()
 {
     if (!empty($this->id)) {
         //clean make the delete cascade into association records
         $filter = new field_filter('classid', $this->id);
         instructor::delete_records($filter, $this->_db);
         student::delete_records($filter, $this->_db);
         trackassignment::delete_records($filter, $this->_db);
         classmoodlecourse::delete_records($filter, $this->_db);
         student_grade::delete_records($filter, $this->_db);
         waitlist::delete_records($filter, $this->_db);
         parent::delete();
         $context = \local_elisprogram\context\pmclass::instance($this->id);
         $context->delete();
     }
 }