/** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package elis * @subpackage curriculummanagement * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * */ function archive_install() { global $CFG; require_once $CFG->dirroot . '/curriculum/config.php'; require_once CURMAN_DIRLOCATION . '/lib/customfield.class.php'; // setup archive field $field = new field(); $field->shortname = '_elis_curriculum_archive'; $field->name = get_string('archive_field_name', 'crlm_archive'); $field->datatype = 'bool'; $category = new field_category(); $category->name = get_string('archive_category_name', 'crlm_archive'); $field = field::ensure_field_exists_for_context_level($field, 'curriculum', $category); // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = ''; $owner->param_control = 'menu'; $owner->param_options_source = ''; $owner->add(); } $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'crlm_archive/archive_curriculum'); field_owner::ensure_field_owner_exists($field, 'manual', $owner_options); return true; }
/** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package elis * @subpackage curriculummanagement * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * */ function xmldb_crlm_cluster_classification_upgrade($oldversion = 0) { global $CFG, $THEME, $db; $result = true; if ($result && $oldversion < 2010080502) { /// Define table crlm_cluster_classification to be created $table = new XMLDBTable('crlm_cluster_classification'); /// Adding fields to table crlm_cluster_classification $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); $table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null); $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null); $table->addFieldInfo('params', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null); /// Adding keys to table crlm_cluster_classification $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); $table->addKeyInfo('shortname_idx', XMLDB_KEY_UNIQUE, array('shortname')); /// Launch create table for crlm_cluster_classification $result = $result && create_table($table); } if ($result && $oldversion < 2010080503) { require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php'; require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php'; require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php'; $field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD)); // make sure we're set as owner if (!isset($field->owners['cluster_classification'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'cluster_classification'; $owner->add(); } // make sure we have a default value set if (!field_data::get_for_context_and_field(NULL, $field)) { field_data::set_for_context_and_field(NULL, $field, 'regular'); } $default = new clusterclassification(); $default->shortname = 'regular'; $default->name = get_string('cluster', 'block_curr_admin'); $default->param_autoenrol_curricula = 1; $default->param_autoenrol_tracks = 1; $default->add(); } // make sure 'manual' is an owner if ($result && $oldversion < 2010080504) { require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php'; require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php'; require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php'; $field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD)); $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = 'moodle/user:update'; $owner->param_control = 'menu'; $owner->param_options_source = 'cluster_classifications'; $owner->add(); } return $result; }
/** * ELIS(TM): Enterprise Learning Intelligence Suite * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package elis * @subpackage curriculummanagement * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * */ function pre_post_test_install() { global $CFG; require_once $CFG->dirroot . '/curriculum/config.php'; require_once CURMAN_DIRLOCATION . '/lib/customfield.class.php'; $course_ctx_lvl = context_level_base::get_custom_context_level('course', 'block_curr_admin'); // Pre-test field $field = new field(); $field->shortname = '_elis_course_pretest'; $field->name = get_string('pre_test_field_name', 'crlm_pre_post_test'); $field->datatype = 'char'; $category = new field_category(); $category->name = get_string('pre_post_test_category_name', 'crlm_pre_post_test'); $field = field::ensure_field_exists_for_context_level($field, 'course', $category); // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = ''; $owner->param_control = 'menu'; $owner->param_options_source = 'completion_elements'; $owner->add(); } // Post-test field $field = new field(); $field->shortname = '_elis_course_posttest'; $field->name = get_string('post_test_field_name', 'crlm_pre_post_test'); $field->datatype = 'char'; $category = new field_category(); $category->name = get_string('pre_post_test_category_name', 'crlm_pre_post_test'); $field = field::ensure_field_exists_for_context_level($field, 'course', $category); // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = ''; $owner->param_control = 'menu'; $owner->param_options_source = 'completion_elements'; $owner->add(); } return true; }
function cluster_classification_install() { global $CFG; require_once $CFG->dirroot . '/curriculum/config.php'; require_once CURMAN_DIRLOCATION . '/lib/customfield.class.php'; require_once CURMAN_DIRLOCATION . '/plugins/cluster_classification/clusterclassification.class.php'; $cluster_ctx_lvl = context_level_base::get_custom_context_level('cluster', 'block_curr_admin'); $field = new field(); $field->shortname = CLUSTER_CLASSIFICATION_FIELD; $field->name = get_string('classification_field_name', 'crlm_cluster_classification'); $field->datatype = 'char'; $category = new field_category(); $category->name = get_string('classification_category_name', 'crlm_cluster_classification'); $field = field::ensure_field_exists_for_context_level($field, 'cluster', $category); // make sure we're set as owner if (!isset($field->owners['cluster_classification'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'cluster_classification'; $owner->add(); } // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = 'moodle/user:update'; $owner->param_control = 'menu'; $owner->param_options_source = 'cluster_classifications'; $owner->add(); } // make sure we have a default value set if (!field_data::get_for_context_and_field(NULL, $field)) { field_data::set_for_context_and_field(NULL, $field, 'regular'); } $default = new clusterclassification(); $default->shortname = 'regular'; $default->name = get_string('cluster', 'block_curr_admin'); $default->param_autoenrol_curricula = 1; $default->param_autoenrol_tracks = 1; $default->add(); return true; }
/** * Install function for this plugin * * @return boolean true Returns true to satisfy install procedure */ function cluster_display_priority_install() { //context level at which we are creating the new field(s) $cluster_ctx_lvl = context_level_base::get_custom_context_level('cluster', 'block_curr_admin'); $field = new field(); $field->shortname = CLUSTER_DISPLAY_PRIORITY_FIELD; $field->name = get_string('display_priority_field_name', 'crlm_cluster_display_priority'); $field->datatype = 'int'; $category = new field_category(); $category->name = get_string('display_settings_category_name', 'crlm_cluster_display_priority'); $field = field::ensure_field_exists_for_context_level($field, 'cluster', $category); // make sure 'manual' is an owner if (!isset($field->owners['manual'])) { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'manual'; $owner->param_view_capability = ''; $owner->param_edit_capability = ''; $owner->param_control = 'text'; $owner->param_options_source = 'cluster_display_priority'; $owner->add(); } return true; }
/** * Creates the owner record corresponding to the supplied field if it does not already exist * * @param field $field The field to create the owner for * @param string $plugin The plugin used for the owner field * @param array $params Any additional parameters to pass to the owner record */ static function ensure_field_owner_exists($field, $plugin, $params = array()) { $owners = $field->owners; if (!empty($owners[$plugin])) { return; } $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = $plugin; $owner->params = serialize($params); $owner->add(); }
function moodle_profile_field_save_form_data($form, $field, $data) { $level = $form->_customdata->required_param('level', PARAM_ACTION); if ($level != 'user') { return; } global $CURMAN; if ($data->moodle_profile_exclusive == cm_moodle_profile::sync_to_moodle || $data->moodle_profile_exclusive == cm_moodle_profile::sync_from_moodle) { if (isset($field->owners['moodle_profile'])) { $owner = new field_owner($field->owners['moodle_profile']); $owner->exclude = $data->moodle_profile_exclusive; $owner->update(); } else { $owner = new field_owner(); $owner->fieldid = $field->id; $owner->plugin = 'moodle_profile'; $owner->exclude = $data->moodle_profile_exclusive; $owner->add(); } unset($field->owners); // force reload of owners field sync_profile_field_with_moodle($field); } else { $CURMAN->db->delete_records(FIELDOWNERTABLE, 'fieldid', $field->id, 'plugin', 'moodle_profile'); } }
function manual_field_save_form_data($form, $field, $data) { if (isset($data->manual_field_enabled) && $data->manual_field_enabled) { if (isset($field->owners['manual'])) { $manual = new field_owner($field->owners['manual']); } else { $manual = new field_owner(); $manual->fieldid = $field->id; $manual->plugin = 'manual'; } if (isset($data->manual_field_required)) { $manual->param_required = $data->manual_field_required; } else { $manual->param_required = false; } $parameters = array('edit_capability', 'view_capability', 'control', 'options_source', 'options', 'columns', 'rows', 'maxlength', 'help_file'); foreach ($parameters as $param) { $dataname = "manual_field_{$param}"; if (isset($data->{$dataname})) { $manual->{"param_{$param}"} = stripslashes($data->{$dataname}); } } $manual->params = addslashes($manual->params); if (empty($manual->id)) { $manual->add(); } else { $manual->update(); } } else { global $CURMAN; $CURMAN->db->delete_records(FIELDOWNERTABLE, 'fieldid', $field->id, 'plugin', 'manual'); } }