当前位置: 首页>>代码示例>>PHP>>正文


PHP field::ensure_field_exists_for_context_level方法代码示例

本文整理汇总了PHP中field::ensure_field_exists_for_context_level方法的典型用法代码示例。如果您正苦于以下问题:PHP field::ensure_field_exists_for_context_level方法的具体用法?PHP field::ensure_field_exists_for_context_level怎么用?PHP field::ensure_field_exists_for_context_level使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在field的用法示例。


在下文中一共展示了field::ensure_field_exists_for_context_level方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmldb_elisprogram_usetgroups_install

/**
 * Sets up the fields necessary for enabling cluster groups
 *
 * @return  boolean  Returns true to indicate success
 */
function xmldb_elisprogram_usetgroups_install()
{
    // Migrate component.
    $oldcmp = 'pmplugins_userset_groups';
    $newcmp = 'elisprogram_usetgroups';
    $upgradestepfuncname = 'elisprogram_usetgroups_pre26upgradesteps';
    $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname);
    if ($migrator->old_component_installed() === true) {
        $migrator->migrate();
    }
    //set up the cluster group category
    $group_category = new field_category();
    $group_category->name = get_string('userset_group_category', 'elisprogram_usetgroups');
    //set up the field that allows users to turn the groupings on
    $group_field = new field();
    $group_field->shortname = 'userset_group';
    $group_field->name = get_string('userset_group', 'elisprogram_usetgroups');
    $group_field->datatype = 'bool';
    //set up the field and category
    $group_field = field::ensure_field_exists_for_context_level($group_field, CONTEXT_ELIS_USERSET, $group_category);
    //set up the field owner
    $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'elisprogram_usetgroups/userset_group');
    field_owner::ensure_field_owner_exists($group_field, 'manual', $owner_options);
    $field = new field();
    $field->shortname = 'userset_groupings';
    $field->name = get_string('autoenrol_groupings', 'elisprogram_usetclassify');
    $field->datatype = 'bool';
    $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USERSET, $group_category);
    $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'elisprogram_usetgroups/autoenrol_groupings');
    field_owner::ensure_field_owner_exists($field, 'manual', $owner_options);
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:37,代码来源:install.php

示例2: cluster_themes_install

/**
 * Sets up the fields necessary for enabling cluster theming
 *
 * @return  boolean  Returns true to indicate success
 */
function cluster_themes_install()
{
    //retrieve the cluster context
    $cluster_context = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
    //set up the cluster theme category
    $theme_category = new field_category();
    $theme_category->name = get_string('cluster_theme_category', 'crlm_cluster_themes');
    //set up the theme priority field
    $theme_priority_field = new field();
    $theme_priority_field->shortname = 'cluster_themepriority';
    $theme_priority_field->name = get_string('cluster_theme_priority', 'crlm_cluster_themes');
    $theme_priority_field->datatype = 'int';
    //set up the field and category
    $theme_priority_field = field::ensure_field_exists_for_context_level($theme_priority_field, $cluster_context, $theme_category);
    $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'text', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'crlm_cluster_themes/cluster_themepriority');
    field_owner::ensure_field_owner_exists($theme_priority_field, 'manual', $owner_options);
    //set up the field for selecting the applicable theme
    $theme_field = new field();
    $theme_field->shortname = 'cluster_theme';
    $theme_field->name = get_string('cluster_theme', 'crlm_cluster_themes');
    $theme_field->datatype = 'char';
    //set up the field and category
    $theme_field = field::ensure_field_exists_for_context_level($theme_field, $cluster_context, $theme_category);
    $owner_options = array('control' => 'menu', 'options_source' => 'themes', 'required' => 0, 'edit_capability' => '', 'view_capability' => '', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'crlm_cluster_themes/cluster_theme');
    field_owner::ensure_field_owner_exists($theme_field, 'manual', $owner_options);
    return true;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:32,代码来源:lib.php

示例3: xmldb_elisprogram_usetthemes_install

/**
 * Install function for this plugin
 *
 * @return  boolean  true  Returns true to satisfy install procedure
 */
function xmldb_elisprogram_usetthemes_install()
{
    // Migrate component.
    $oldcmp = 'pmplugins_userset_themes';
    $newcmp = 'elisprogram_usetthemes';
    $upgradestepfuncname = 'elisprogram_usetthemes_pre26upgradesteps';
    $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname);
    if ($migrator->old_component_installed() === true) {
        $migrator->migrate();
    }
    //set up the cluster theme category
    $theme_category = new field_category();
    $theme_category->name = get_string('userset_theme_category', 'elisprogram_usetthemes');
    //set up the theme priority field
    $theme_priority_field = new field();
    $theme_priority_field->shortname = '_elis_userset_themepriority';
    $theme_priority_field->name = get_string('userset_theme_priority', 'elisprogram_usetthemes');
    $theme_priority_field->datatype = 'int';
    //set up the field and category
    $theme_priority_field = field::ensure_field_exists_for_context_level($theme_priority_field, CONTEXT_ELIS_USERSET, $theme_category);
    $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'text', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'elisprogram_usetthemes/_elis_userset_themepriority');
    field_owner::ensure_field_owner_exists($theme_priority_field, 'manual', $owner_options);
    //set up the field for selecting the applicable theme
    $theme_field = new field();
    $theme_field->shortname = '_elis_userset_theme';
    $theme_field->name = get_string('userset_theme', 'elisprogram_usetthemes');
    $theme_field->datatype = 'char';
    //set up the field and category
    $theme_field = field::ensure_field_exists_for_context_level($theme_field, CONTEXT_ELIS_USERSET, $theme_category);
    $owner_options = array('control' => 'menu', 'options_source' => 'themes', 'required' => 0, 'edit_capability' => '', 'view_capability' => '', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'elisprogram_usetthemes/_elis_userset_theme');
    field_owner::ensure_field_owner_exists($theme_field, 'manual', $owner_options);
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:38,代码来源:install.php

示例4: xmldb_elisprogram_usetdisppriority_install

/**
 * Install function for this plugin
 *
 * @return  boolean  true  Returns true to satisfy install procedure
 */
function xmldb_elisprogram_usetdisppriority_install()
{
    global $CFG;
    require_once elispm::lib('setup.php');
    // Migrate component.
    $oldcmp = 'pmplugins_userset_display_priority';
    $newcmp = 'elisprogram_usetdisppriority';
    $upgradestepfuncname = 'elisprogram_usetdisppriority_pre26upgradesteps';
    $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname);
    if ($migrator->old_component_installed() === true) {
        $migrator->migrate();
    }
    $field = new field();
    $field->shortname = USERSET_DISPLAY_PRIORITY_FIELD;
    $field->name = get_string('display_priority_field_name', 'elisprogram_usetdisppriority');
    $field->datatype = 'int';
    $category = new field_category();
    $category->name = get_string('display_settings_category_name', 'elisprogram_usetdisppriority');
    $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USERSET, $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 = 'userset_display_priority';
        $owner->param_help_file = 'elisprogram_usetdisppriority/display_priority';
        $owner->save();
    }
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:38,代码来源:install.php

示例5: archive_install

/**
 * 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;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:52,代码来源:lib.php

示例6: init_custom_field

 /**
  * Initialize our custom field data, and persist in the database.
  *
  * @param  mixed  $cl optional contextlevel to use, default null for self::contextlevel
  * @return object The custom field created
  */
 protected function init_custom_field($cl = null)
 {
     // Set up our custom field.
     $field = new field(array('name' => 'testcustomfieldname', 'datatype' => 'char', 'multivalued' => 1));
     $fieldcategory = new field_category(array('name' => 'testcategoryname'));
     $field = field::ensure_field_exists_for_context_level($field, $cl ? $cl : self::CONTEXTLEVEL, $fieldcategory);
     field_data::set_for_context_and_field(null, $field, array('value1'));
     return $field;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:15,代码来源:custom_field_data_access_test.php

示例7: xmldb_elisprogram_preposttest_install

/**
 * Install function for this plugin
 *
 * @return  boolean  true  Returns true to satisfy install procedure
 */
function xmldb_elisprogram_preposttest_install()
{
    global $CFG;
    require_once elispm::lib('setup.php');
    require_once elis::lib('data/customfield.class.php');
    // Migrate component.
    $oldcmp = 'pmplugins_pre_post_test';
    $newcmp = 'elisprogram_preposttest';
    $upgradestepfuncname = 'elisprogram_preposttest_pre26upgradesteps';
    $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname);
    if ($migrator->old_component_installed() === true) {
        $migrator->migrate();
    }
    // Pre-test field
    $field = new field();
    $field->shortname = PRE_TEST_FIELD;
    $field->name = get_string('pre_test_field_name', 'elisprogram_preposttest');
    $field->datatype = 'char';
    $category = new field_category();
    $category->name = get_string('pre_post_test_category_name', 'elisprogram_preposttest');
    $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_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 = 'learning_objectives';
        $owner->param_help_file = 'elisprogram_preposttest/pre_test';
        $owner->save();
    }
    // Post-test field
    $field = new field();
    $field->shortname = POST_TEST_FIELD;
    $field->name = get_string('post_test_field_name', 'elisprogram_preposttest');
    $field->datatype = 'char';
    $category = new field_category();
    $category->name = get_string('pre_post_test_category_name', 'elisprogram_preposttest');
    $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_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 = 'learning_objectives';
        $owner->param_help_file = 'elisprogram_preposttest/post_test';
        $owner->save();
    }
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:60,代码来源:install.php

示例8: pre_post_test_install

/**
 * 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;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:70,代码来源:lib.php

示例9: cluster_classification_install

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;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:44,代码来源:lib.php

示例10: xmldb_elisprogram_archive_install

/**
 * Install function for this plugin
 *
 * @return  boolean  true  Returns true to satisfy install procedure
 */
function xmldb_elisprogram_archive_install()
{
    global $CFG;
    require_once elispm::lib('setup.php');
    require_once elis::lib('data/customfield.class.php');
    // Migrate component.
    $oldcmp = 'pmplugins_archive';
    $newcmp = 'elisprogram_archive';
    $upgradestepfuncname = 'elisprogram_archive_pre26upgradesteps';
    $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname);
    if ($migrator->old_component_installed() === true) {
        $migrator->migrate();
    }
    // Archive field
    $field = new field();
    $field->shortname = ARCHIVE_FIELD;
    $field->name = get_string('archive_field_name', 'elisprogram_archive');
    $field->datatype = 'bool';
    $category = new field_category();
    $category->name = get_string('archive_category_name', 'elisprogram_archive');
    $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_PROGRAM, $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_required = 0;
        $owner->param_view_capability = '';
        $owner->param_edit_capability = '';
        $owner->param_control = 'checkbox';
        $owner->param_options_source = '';
        $owner->param_help_file = 'elisprogram_archive/archive_program';
        $owner->save();
    }
    $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'elisprogram_archive/archive_program');
    field_owner::ensure_field_owner_exists($field, 'manual', $owner_options);
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:43,代码来源:install.php

示例11: xmldb_crlm_cluster_groups_upgrade

/**
 * 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_groups_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010080602) {
        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_group'));
        if (isset($field->owners['manual'])) {
            $owner = new field_owner($field->owners['manual']);
            $owner->param_help_file = 'crlm_cluster_groups/cluster_groups';
            $owner->update();
        }
    }
    if ($result && $oldversion < 2010080603) {
        //retrieve the cluster context
        $context = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
        //get the cluster classification category
        $category = new field_category();
        $category->name = get_string('cluster_group_category', 'crlm_cluster_groups');
        $field = new field();
        $field->shortname = 'cluster_groupings';
        $field->name = get_string('autoenrol_groupings', 'crlm_cluster_classification');
        $field->datatype = 'bool';
        $field = field::ensure_field_exists_for_context_level($field, $context, $category);
        $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'crlm_cluster_groups/cluster_groupings');
        field_owner::ensure_field_owner_exists($field, 'manual', $owner_options);
    }
    if ($result && $oldversion < 2010080604) {
        if ($field = new field(field::get_for_context_level_with_name('cluster', 'cluster_site_course_group'))) {
            $field->shortname = 'cluster_groupings';
            $field->update();
        }
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:61,代码来源:upgrade.php

示例12: cluster_display_priority_install

/**
 * 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;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:29,代码来源:lib.php

示例13: elisprogram_usetclassify_pre26upgradesteps

/**
 * Run all upgrade steps from before elis 2.6.
 *
 * @param int $oldversion The currently installed version of the old component.
 * @return bool Success/Failure.
 */
function elisprogram_usetclassify_pre26upgradesteps($oldversion)
{
    global $CFG, $THEME, $DB;
    $dbman = $DB->get_manager();
    $result = true;
    if ($oldversion < 2011071400) {
        // Rename field.
        $field = field::find(new field_filter('shortname', '_elis_cluster_classification'));
        if ($field->valid()) {
            $field = $field->current();
            $field->shortname = USERSET_CLASSIFICATION_FIELD;
            if ($field->name == 'Cluster classification') {
                // Rhe field name hasn't been changed from the old default.
                $field->name = get_string('classification_field_name', 'elisprogram_usetclassify');
            }
            $field->save();
            $category = $field->category;
            if ($category->name == 'Cluster classification') {
                // The field name hasn't been changed from the old default.
                $category->name = get_string('classification_category_name', 'elisprogram_usetclassify');
                $category->save();
            }
        }
        upgrade_plugin_savepoint($result, 2011071400, 'pmplugins', 'userset_classification');
    }
    if ($result && $oldversion < 2011101200) {
        $field = field::find(new field_filter('shortname', USERSET_CLASSIFICATION_FIELD));
        if ($field->valid()) {
            $field = $field->current();
            if ($owner = new field_owner(!isset($field->owners) || !isset($field->owners['manual']) ? false : $field->owners['manual'])) {
                $owner->fieldid = $field->id;
                $owner->plugin = 'manual';
                //$owner->exclude = 0; // TBD
                $owner->param_help_file = 'elisprogram_usetclassify/cluster_classification';
                $owner->save();
            }
        }
        upgrade_plugin_savepoint($result, 2011101200, 'pmplugins', 'userset_classification');
    }
    if ($result && $oldversion < 2011101800) {
        // Userset -> 'User Set'.
        $field = field::find(new field_filter('shortname', USERSET_CLASSIFICATION_FIELD));
        if ($field->valid()) {
            $field = $field->current();
            if (stripos($field->name, 'Userset') !== false) {
                $field->name = str_ireplace('Userset', 'User Set', $field->name);
                $field->save();
            }
            $category = $field->category;
            if (stripos($category->name, 'Userset') !== false) {
                $category->name = str_ireplace('Userset', 'User Set', $category->name);
                $category->save();
            }
        }
        upgrade_plugin_savepoint($result, 2011101800, 'pmplugins', 'userset_classification');
    }
    if ($result && $oldversion < 2011110300) {
        // Make sure to rename the default classification name from "Cluster" to "User set".
        require_once elispm::file('plugins/usetclassify/usersetclassification.class.php');
        // Make sure there are no custom fields with invalid categories.
        pm_fix_orphaned_fields();
        $field = field::find(new field_filter('shortname', USERSET_CLASSIFICATION_FIELD));
        if ($field->valid()) {
            $field = $field->current();
            $category = $field->category;
            $default = usersetclassification::find(new field_filter('shortname', 'regular'));
            if ($default->valid()) {
                $default = $default->current();
                $default->name = get_string('cluster', 'local_elisprogram');
                $default->save();
            }
            // Upgrade field owner data for the default User Set field.
            $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USERSET, $category);
            $owners = field_owner::find(new field_filter('fieldid', $field->id));
            if ($owners->valid()) {
                foreach ($owners as $owner) {
                    if ($owner->plugin == 'cluster_classification') {
                        $owner->plugin = 'userset_classification';
                        $owner->save();
                    } else {
                        if ($owner->plugin == 'manual') {
                            $owner->param_options_source = 'userset_classifications';
                            $owner->param_help_file = 'elisprogram_usetclassify/cluster_classification';
                            $owner->save();
                        }
                    }
                }
            }
            upgrade_plugin_savepoint($result, 2011110300, 'pmplugins', 'userset_classification');
        }
    }
    return $result;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:99,代码来源:install.php

示例14: cluster_groups_install

/**
 * Sets up the fields necessary for enabling cluster groups
 *
 * @return  boolean  Returns true to indicate success
 */
function cluster_groups_install()
{
    //retrieve the cluster context
    $cluster_context = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
    //set up the cluster group category
    $group_category = new field_category();
    $group_category->name = get_string('cluster_group_category', 'crlm_cluster_groups');
    //set up the field that allows users to turn the groupings on
    $group_field = new field();
    $group_field->shortname = 'cluster_group';
    $group_field->name = get_string('cluster_group', 'crlm_cluster_groups');
    $group_field->datatype = 'bool';
    //set up the field and category
    $group_field = field::ensure_field_exists_for_context_level($group_field, $cluster_context, $group_category);
    //set up the field owner
    $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'crlm_cluster_groups/cluster_groups');
    field_owner::ensure_field_owner_exists($group_field, 'manual', $owner_options);
    //retrieve the cluster context
    $context = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
    $field = new field();
    $field->shortname = 'cluster_groupings';
    $field->name = get_string('autoenrol_groupings', 'crlm_cluster_classification');
    $field->datatype = 'bool';
    $field = field::ensure_field_exists_for_context_level($field, $context, $group_category);
    $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'crlm_cluster_groups/cluster_groupings');
    field_owner::ensure_field_owner_exists($field, 'manual', $owner_options);
    return true;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:33,代码来源:lib.php

示例15: test_version1importsyncsusertoelisonupdate

 /**
  * Validate that the import performs user synchronization on user update
  */
 public function test_version1importsyncsusertoelisonupdate()
 {
     global $CFG, $DB;
     if (!file_exists($CFG->dirroot . '/local/elisprogram/lib/setup.php')) {
         $this->markTestIncomplete('This test depends on the PM system');
     }
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once $CFG->dirroot . '/user/profile/definelib.php';
     require_once elis::lib('data/customfield.class.php');
     require_once elispm::lib('data/user.class.php');
     // Make sure we are not auto-assigning idnumbers.
     set_config('auto_assign_user_idnumber', 0, 'local_elisprogram');
     elis::$config = new elis_config();
     // Create Moodle custom field category.
     $category = new stdClass();
     $category->sortorder = $DB->count_records('user_info_category') + 1;
     $category->id = $DB->insert_record('user_info_category', $category);
     // Create Moodle custom profile field.
     $this->create_profile_field('rliptext', 'text', $category->id);
     // Obtain the PM user context level.
     $contextlevel = CONTEXT_ELIS_USER;
     // Make sure the PM category and field exist.
     $category = new field_category(array('name' => 'rlipcategory'));
     $field = new field(array('shortname' => 'rliptext', 'name' => 'rliptext', 'datatype' => 'text', 'multivalued' => 0));
     $field = field::ensure_field_exists_for_context_level($field, $contextlevel, $category);
     // Make sure the field owner is setup.
     field_owner::ensure_field_owner_exists($field, 'manual');
     $ownerid = $DB->get_field(field_owner::TABLE, 'id', array('fieldid' => $field->id, 'plugin' => 'manual'));
     $owner = new field_owner($ownerid);
     $owner->param_control = 'text';
     $owner->save();
     // Make sure the field is set up for synchronization.
     field_owner::ensure_field_owner_exists($field, 'moodle_profile');
     $ownerid = $DB->get_field(field_owner::TABLE, 'id', array('fieldid' => $field->id, 'plugin' => 'moodle_profile'));
     $owner = new field_owner($ownerid);
     $owner->exclude = pm_moodle_profile::sync_from_moodle;
     $owner->save();
     // Update the user class's static cache of define user custom fields.
     $tempuser = new user();
     $tempuser->reset_custom_field_list();
     // Create the user.
     $this->run_core_user_import(array('idnumber' => 'rlipidnumber', 'profile_field_rliptext' => 'rliptext'));
     // Make sure PM user was created correctly.
     $this->assert_record_exists(user::TABLE, array('username' => 'rlipusername', 'idnumber' => 'rlipidnumber'));
     // Run the import, updating the user.
     $this->run_core_user_import(array('action' => 'update', 'username' => 'rlipusername', 'profile_field_rliptext' => 'rliptextupdated'));
     // Make sure the PM custom field data was set.
     $sql = "SELECT 'x'\n                  FROM {" . field::TABLE . "} f\n                  JOIN {" . field_data_text::TABLE . "} d ON f.id = d.fieldid\n                 WHERE f.shortname = ? AND d.data = ?";
     $params = array('rliptext', 'rliptextupdated');
     $exists = $DB->record_exists_sql($sql, $params);
     $this->assertEquals($exists, true);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:55,代码来源:version1_user_import_test.php


注:本文中的field::ensure_field_exists_for_context_level方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。