コード例 #1
0
ファイル: lib.php プロジェクト: jamesmcq/elis
/**
 * Callback that performs the appropriate sync when the configured student
 * or instructor role changes
 *
 * @param string $name The full name of the setting that's changed
 */
function enrolment_role_sync_updatedcallback($name)
{
    if ($name == 's_elisprogram_enrolrolesync_student_role') {
        //student role has changed
        enrolment_role_sync::student_sync_role_set();
    } else {
        if ($name == 's_elisprogram_enrolrolesync_instructor_role') {
            //instructor role has changed
            enrolment_role_sync::instructor_sync_role_set();
        } else {
            //this should never happen
        }
    }
}
コード例 #2
0
 /**
  * Test contexts in enrolment_role_sync
  *
  * Covers:
  * local/elisprogram/plugins/enrolrolesync/lib.php:101
  * local/elisprogram/plugins/enrolrolesync/lib.php:150
  */
 public function test_enrolrolesync()
 {
     require_once elispm::file('plugins/enrolrolesync/lib.php');
     set_config('student_role', 9, 'elisprogram_enrolrolesync');
     enrolment_role_sync::student_sync_role_set();
     set_config('instructor_role', 9, 'elisprogram_enrolrolesync');
     enrolment_role_sync::instructor_sync_role_set();
 }
コード例 #3
0
 function action_default()
 {
     global $CFG, $CURMAN;
     require_once $CFG->dirroot . '/curriculum/form/configform.class.php';
     $configform = new cmconfigform('index.php', $this);
     $configform->set_data($CURMAN->config);
     if ($configdata = $configform->get_data()) {
         $old_cluster_groups = $CURMAN->config->cluster_groups;
         $old_site_course_cluster_groups = $CURMAN->config->site_course_cluster_groups;
         $old_cluster_groupings = $CURMAN->config->cluster_groupings;
         // Track settings
         self::config_set_value($configdata, 'userdefinedtrack', 0);
         // Course catalog / Learning plan settings
         self::config_set_value($configdata, 'disablecoursecatalog', 0);
         self::config_set_value($configdata, 'catalog_collapse_count');
         // Curriculum expiration settings (ELIS-1172)
         $curassupdate = false;
         // We need to check for an required update before setting the variable as the API call requires the
         // variable to be set before the changes can take place.
         if (isset($configdata->curriculum_expiration_start) && $configdata->curriculum_expiration_start != $CURMAN->config->curriculum_expiration_start) {
             $curassupdate = true;
         }
         self::config_set_value($configdata, 'enable_curriculum_expiration', 0);
         self::config_set_value($configdata, 'curriculum_expiration_start', '');
         // If this setting is changed, we need to update the existing curriclum expiration values
         if ($curassupdate) {
             if ($rs = get_recordset(CURASSTABLE, '', '', '', 'id, userid, curriculumid')) {
                 $timenow = time();
                 while ($curass = rs_fetch_next_record($rs)) {
                     $update = new stdClass();
                     $update->id = $curass->id;
                     $update->timeexpired = calculate_curriculum_expiry(false, $curass->curriculumid, $curass->userid);
                     $update->timemodified = $timenow;
                     update_record(CURASSTABLE, $update);
                 }
                 rs_close($rs);
             }
         }
         // Certificate settings
         self::config_set_value($configdata, 'disablecertificates', 0);
         self::config_set_value($configdata, 'certificate_border_image', 'Fancy1-blue.jpg');
         self::config_set_value($configdata, 'certificate_seal_image', 'none');
         self::config_set_value($configdata, 'certificate_template_file', 'default.php');
         // Interface settings
         self::config_set_value($configdata, 'time_format_12h', 0);
         self::config_set_value($configdata, 'mymoodle_redirect', 0);
         // User settings
         self::config_set_value($configdata, 'auto_assign_user_idnumber', 0);
         $old_cfg = $CURMAN->config->auto_assign_user_idnumber;
         // if this setting is changed to true, synchronize the users
         if (isset($configdata->auto_assign_user_idnumber) && $configdata->auto_assign_user_idnumber != 0 && $old_cfg == 0) {
             cm_migrate_moodle_users(true, 0);
         }
         self::config_set_value($configdata, 'default_instructor_role', 0);
         self::config_set_value($configdata, 'restrict_to_elis_enrolment_plugin', 0);
         // Cluster settings
         self::config_set_value($configdata, 'cluster_groups', 0);
         self::config_set_value($configdata, 'site_course_cluster_groups', 0);
         self::config_set_value($configdata, 'cluster_groupings', 0);
         //settings specifically for the curriculum administration block
         self::config_set_value($configdata, 'num_block_icons', 5);
         self::config_set_value($configdata, 'display_clusters_at_top_level', 1);
         self::config_set_value($configdata, 'display_curricula_at_top_level', 0);
         //default role assignments on cm entities
         self::config_set_value($configdata, 'default_cluster_role_id', 0);
         self::config_set_value($configdata, 'default_curriculum_role_id', 0);
         self::config_set_value($configdata, 'default_course_role_id', 0);
         self::config_set_value($configdata, 'default_class_role_id', 0);
         self::config_set_value($configdata, 'default_track_role_id', 0);
         //enrolment synchronization roles
         $old_role_sync = $CURMAN->config->enrolment_role_sync_student_role;
         self::config_set_value($configdata, 'enrolment_role_sync_student_role', 0);
         if (isset($configdata->enrolment_role_sync_student_role) && $configdata->enrolment_role_sync_student_role != 0 && $configdata->enrolment_role_sync_student_role != $old_role_sync) {
             require_once CURMAN_DIRLOCATION . '/plugins/enrolment_role_sync/lib.php';
             enrolment_role_sync::student_sync_role_set();
         }
         $old_role_sync = $CURMAN->config->enrolment_role_sync_instructor_role;
         self::config_set_value($configdata, 'enrolment_role_sync_instructor_role', 0);
         if (isset($configdata->enrolment_role_sync_instructor_role) && $configdata->enrolment_role_sync_instructor_role != 0 && $configdata->enrolment_role_sync_instructor_role != $old_role_sync) {
             require_once CURMAN_DIRLOCATION . '/plugins/enrolment_role_sync/lib.php';
             enrolment_role_sync::instructor_sync_role_set();
         }
         // autocreate settings
         self::config_set_value($configdata, 'autocreated_unknown_is_yes', 0);
         // legacy settings
         self::config_set_value($configdata, 'legacy_show_inactive_users', 0);
         //trigger events
         if (!empty($configdata->cluster_groups) && empty($old_cluster_groups)) {
             events_trigger('crlm_cluster_groups_enabled', 0);
         }
         if (!empty($configdata->site_course_cluster_groups) && empty($old_site_course_cluster_groups)) {
             events_trigger('crlm_site_course_cluster_groups_enabled', 0);
         }
         if (!empty($configdata->cluster_groupings) && empty($old_cluster_groupings)) {
             events_trigger('crlm_cluster_groupings_enabled', 0);
         }
     }
     $configform->display();
 }