예제 #1
0
 /**
  * Constructor.
  *
  * @param $clusterdata int/object/array The data id of a data record or data elements to load manually.
  *
  */
 function cluster($clusterdata = false)
 {
     global $CURMAN;
     parent::datarecord();
     $this->set_table(CLSTTABLE);
     $this->add_property('id', 'int');
     $this->add_property('name', 'string');
     $this->add_property('display', 'string');
     $this->add_property('leader', 'int');
     $this->add_property('parent', 'int');
     $this->add_property('depth', 'int');
     if (is_numeric($clusterdata)) {
         $this->data_load_record($clusterdata);
     } else {
         if (is_array($clusterdata)) {
             $this->data_load_array($clusterdata);
         } else {
             if (is_object($clusterdata)) {
                 $this->data_load_array(get_object_vars($clusterdata));
             }
         }
     }
     if (!empty($this->id)) {
         // custom fields
         $level = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
         if ($level) {
             $fielddata = field_data::get_for_context(get_context_instance($level, $this->id));
             $fielddata = $fielddata ? $fielddata : array();
             foreach ($fielddata as $name => $value) {
                 $this->{"field_{$name}"} = $value;
             }
         }
     }
     /*
      * profile_field1 -select box
      * profile_value1 -select box corresponding to profile_field1
      *
      * profile_field2 -select box
      * profile_value2 -select box corresponding to profile_field2
      */
     $prof_fields = $CURMAN->db->get_records(CLSTPROFTABLE, 'clusterid', $this->id, '', '*', 0, 2);
     if (!empty($prof_fields)) {
         foreach (range(1, 2) as $i) {
             $profile = pos($prof_fields);
             if (!empty($profile)) {
                 $field = 'profile_field' . $i;
                 $value = 'profile_value' . $i;
                 $this->{$field} = $profile->fieldid;
                 $this->{$value} = $profile->value;
             }
             next($prof_fields);
         }
     }
 }
예제 #2
0
 function track($track = false)
 {
     parent::datarecord();
     $this->set_table(TRACKTABLE);
     $this->add_property('id', 'int');
     $this->add_property('curid', 'int', true);
     $this->add_property('idnumber', 'string', true);
     $this->add_property('name', 'string', true);
     $this->add_property('description', 'string');
     $this->add_property('startdate', 'int');
     $this->add_property('enddate', 'int');
     $this->add_property('defaulttrack', 'int');
     if (is_numeric($track)) {
         $this->data_load_record($track);
     } else {
         if (is_array($track)) {
             $this->data_load_array($track);
         } else {
             if (is_object($track)) {
                 $this->data_load_array(get_object_vars($track));
             }
         }
     }
     if (!empty($this->curid)) {
         $this->curriculum = new curriculum($this->curid);
     }
     if (!empty($this->id)) {
         // custom fields
         $level = context_level_base::get_custom_context_level('track', 'block_curr_admin');
         if ($level) {
             $fielddata = field_data::get_for_context(get_context_instance($level, $this->id));
             $fielddata = $fielddata ? $fielddata : array();
             foreach ($fielddata as $name => $value) {
                 $this->{"field_{$name}"} = $value;
             }
         }
     }
 }
예제 #3
0
 /**
  * Contructor.
  *
  * @param $coursedata int/object/array The data id of a data record or data elements to load manually.
  *
  */
 function course($coursedata = false)
 {
     parent::datarecord();
     $this->set_table(CRSTABLE);
     $this->add_property('id', 'int');
     $this->add_property('name', 'string', true);
     $this->add_property('code', 'string');
     $this->add_property('idnumber', 'string', true);
     $this->add_property('syllabus', 'string');
     $this->add_property('documents', 'string');
     $this->add_property('lengthdescription', 'string');
     $this->add_property('length', 'int');
     $this->add_property('credits', 'string');
     $this->add_property('completion_grade', 'int');
     $this->add_property('environmentid', 'int');
     $this->add_property('cost', 'string');
     $this->add_property('timecreated', 'int');
     $this->add_property('timemodified', 'int');
     $this->add_property('version', 'string');
     if (is_numeric($coursedata)) {
         $this->data_load_record($coursedata);
     } else {
         if (is_array($coursedata)) {
             $this->data_load_array($coursedata);
         } else {
             if (is_object($coursedata)) {
                 $this->data_load_array(get_object_vars($coursedata));
             }
         }
     }
     if (!empty($this->environmentid)) {
         $this->environment = new environment($this->environmentid);
     }
     // FIXME: this should be done every time the template is updated, i.e. through getter/setter methods
     global $CURMAN;
     if (!empty($this->id)) {
         $template = new coursetemplate($this->id);
         $course = $CURMAN->db->get_record('course', 'id', $template->location);
         if (!empty($course)) {
             $this->locationlabel = $course->fullname . ' ' . $course->shortname;
             $this->locationid = $template->location;
         }
         // custom fields
         $level = context_level_base::get_custom_context_level('course', 'block_curr_admin');
         if ($level) {
             $fielddata = field_data::get_for_context(get_context_instance($level, $this->id));
             $fielddata = $fielddata ? $fielddata : array();
             foreach ($fielddata as $name => $value) {
                 $this->{"field_{$name}"} = $value;
             }
         }
     }
 }
예제 #4
0
 public function default_custom_fields()
 {
     $fields = array();
     $level = context_level_base::get_custom_context_level('curriculum', 'block_curr_admin');
     $fielddata = field_data::get_for_context(get_context_instance($level));
     $fielddata = $fielddata ? $fielddata : array();
     foreach ($fielddata as $name => $value) {
         $fields["field_{$name}"] = $value;
     }
     return $fields;
 }
예제 #5
0
 /**
  * Contructor.
  *
  * @param $userdata int/object/array The data id of a data record or data elements to load manually.
  *
  */
 function user($userdata = false)
 {
     parent::datarecord();
     $this->set_table(USRTABLE);
     $this->add_property('id', 'int');
     $this->add_property('idnumber', 'string', true);
     $this->add_property('username', 'string', true);
     $this->add_property('password', 'string', true);
     $this->add_property('firstname', 'string', true);
     $this->add_property('lastname', 'string', true);
     $this->add_property('mi', 'string');
     $this->add_property('email', 'string', true);
     $this->add_property('email2', 'string');
     $this->add_property('address', 'string');
     $this->add_property('address2', 'string');
     $this->add_property('city', 'string');
     $this->add_property('state', 'string');
     $this->add_property('country', 'string', true);
     $this->add_property('phone', 'string');
     $this->add_property('phone2', 'string');
     $this->add_property('fax', 'string');
     $this->add_property('postalcode', 'string');
     $this->add_property('birthdate', 'string');
     $this->add_property('gender', 'string');
     $this->add_property('language', 'string');
     $this->add_property('transfercredits', 'string');
     $this->add_property('comments', 'string');
     $this->add_property('notes', 'string');
     $this->add_property('timecreated', 'int');
     $this->add_property('timeapproved', 'int');
     $this->add_property('timemodified', 'int');
     $this->add_property('inactive', 'int');
     if (is_numeric($userdata) || is_string($userdata)) {
         $this->data_load_record($userdata);
     } else {
         if (is_array($userdata)) {
             $this->data_load_array($userdata);
         } else {
             if (is_object($userdata)) {
                 $this->data_load_array(get_object_vars($userdata));
             }
         }
     }
     if (!empty($this->id)) {
         /// Load any other data we may want that is associated with the id number...
         if ($clusters = cluster_get_user_clusters($this->id)) {
             $this->load_cluster_info($clusters);
         }
         // custom fields
         $level = context_level_base::get_custom_context_level('user', 'block_curr_admin');
         if ($level) {
             $fielddata = field_data::get_for_context(get_context_instance($level, $this->id));
             $fielddata = $fielddata ? $fielddata : array();
             foreach ($fielddata as $name => $value) {
                 $this->{"field_{$name}"} = $value;
             }
         }
     }
     // TODO: move this to accessors (set or get) so that birthdate and birthday/month/year are always in sync
     if (isset($this->birthdate)) {
         $birthdateparts = explode('/', $this->birthdate);
         if (!empty($birthdateparts[1])) {
             $this->birthday = $birthdateparts[2];
             $this->birthmonth = $birthdateparts[1];
             $this->birthyear = $birthdateparts[0];
         } else {
             $this->birthday = 0;
             $this->birthmonth = 0;
             $this->birthyear = 0;
         }
     }
 }
예제 #6
0
파일: lib.php 프로젝트: jamesmcq/elis
/**
 * Sets up a grouping based on a particular cluster
 *
 * @param  int     $clusterid  The id of the chosen cluster
 * @param  string  $name       The name of the cluster
 */
function userset_groups_grouping_helper($clusterid, $name)
{
    global $CFG, $DB;
    $enabled = get_config('elisprogram_usetgroups', 'userset_groupings');
    if (!empty($enabled) && userset_groups_grouping_allowed($clusterid)) {
        //determine if flagged as grouping
        $contextinstance = \local_elisprogram\context\userset::instance($clusterid);
        $data = field_data::get_for_context($contextinstance);
        //retrieve grouping
        $grouping = groups_get_grouping_by_name(SITEID, $name);
        //obtain the grouping record
        if (empty($grouping)) {
            $grouping = new stdClass();
            $grouping->courseid = SITEID;
            $grouping->name = $name;
            $grouping->id = groups_create_grouping($grouping);
        } else {
            $grouping = groups_get_grouping($grouping);
        }
        //obtain the child cluster ids
        $child_clusters = userset_groups_get_child_usersets($clusterid);
        //add appropriate cluster-groups to the grouping
        foreach ($child_clusters as $child_cluster) {
            if ($cluster_record = $DB->get_record(userset::TABLE, array('id' => $child_cluster))) {
                if ($child_cluster_group = groups_get_group_by_name(SITEID, $cluster_record->name)) {
                    if (userset_groups_grouping_allowed($cluster_record->id)) {
                        groups_assign_grouping($grouping->id, $child_cluster_group);
                    }
                }
            }
        }
    }
}
예제 #7
0
 /**
  * Contructor.
  *
  * @param $cmclassdata int/object/array The data id of a data record or data elements to load manually.
  *
  */
 public function cmclass($cmclassdata = false)
 {
     global $CURMAN;
     parent::datarecord();
     $this->set_table(CLSTABLE);
     $this->add_property('id', 'int');
     $this->add_property('idnumber', 'string', true);
     $this->add_property('courseid', 'int', true);
     $this->add_property('startdate', 'int');
     $this->add_property('enddate', 'int');
     $this->add_property('duration', 'int');
     $this->add_property('starttimehour', 'int');
     $this->add_property('starttimeminute', 'int');
     $this->add_property('endtimehour', 'int');
     $this->add_property('endtimeminute', 'int');
     $this->add_property('maxstudents', 'int');
     $this->add_property('environmentid', 'int');
     $this->add_property('enrol_from_waitlist', 'int');
     if (is_numeric($cmclassdata)) {
         $this->data_load_record($cmclassdata);
     } else {
         if (is_array($cmclassdata)) {
             $this->data_load_array($cmclassdata);
         } else {
             if (is_object($cmclassdata)) {
                 $this->data_load_array(get_object_vars($cmclassdata));
             }
         }
     }
     if (!empty($this->id)) {
         // custom fields
         $level = context_level_base::get_custom_context_level('class', 'block_curr_admin');
         if ($level) {
             $fielddata = field_data::get_for_context(get_context_instance($level, $this->id));
             $fielddata = $fielddata ? $fielddata : array();
             foreach ($fielddata as $name => $value) {
                 $this->{"field_{$name}"} = $value;
             }
         }
     }
     if (!empty($this->courseid)) {
         $this->course = new course($this->courseid);
     }
     if (!empty($this->environmentid)) {
         $this->environment = new environment($this->environmentid);
     }
     $this->moodlecourseid = $this->get_moodle_course_id();
 }
예제 #8
0
/**
 * Sets up a grouping based on a particular cluster
 *
 * @param  int     $clusterid  The id of the chosen cluster
 * @param  string  $name       The name of the cluster
 */
function cluster_groups_grouping_helper($clusterid, $name)
{
    global $CFG, $CURMAN;
    if (!empty($CFG->enablegroupings) && !empty($CURMAN->config->cluster_groupings) && cluster_groups_grouping_allowed($clusterid)) {
        //determine if flagged as grouping
        $contextlevel = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
        $contextinstance = get_context_instance($contextlevel, $clusterid);
        $data = field_data::get_for_context($contextinstance);
        //retrieve grouping
        $grouping = groups_get_grouping_by_name(SITEID, $name);
        //obtain the grouping record
        if (empty($grouping)) {
            $grouping = new stdClass();
            $grouping->courseid = SITEID;
            $grouping->name = addslashes($name);
            $grouping->id = groups_create_grouping($grouping);
        } else {
            $grouping = groups_get_grouping($grouping);
        }
        //obtain the child cluster ids
        $child_clusters = cluster_groups_get_child_clusters($clusterid);
        //add appropriate cluster-groups to the grouping
        foreach ($child_clusters as $child_cluster) {
            if ($cluster_record = get_record(CLSTTABLE, 'id', $child_cluster)) {
                if ($child_cluster_group = groups_get_group_by_name(SITEID, $cluster_record->name)) {
                    if (cluster_groups_grouping_allowed($cluster_record->id)) {
                        groups_assign_grouping($grouping->id, $child_cluster_group);
                    }
                }
            }
        }
    }
}
 /**
  * Load the custom field values from the database.
  */
 private function _load_field_data()
 {
     if (!empty($this->id) && !$this->_fields_loaded) {
         $this->_load_context();
         $this->_load_fields();
         $data = field_data::get_for_context($this->_context);
         foreach (self::$_fields[$this->_context->contextlevel] as $name => $field) {
             if (empty($this->_field_changed[$name]) && isset($data[$name])) {
                 // only set the field data if it hasn't been changed
                 $this->_field_data[$name] = $data[$name];
             }
         }
         $this->_fields_loaded = true;
     }
 }