本文整理汇总了PHP中elis类的典型用法代码示例。如果您正苦于以下问题:PHP elis类的具体用法?PHP elis怎么用?PHP elis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了elis类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: definition
/**
* items in the form
*/
public function definition()
{
global $CURMAN, $CFG;
parent::definition();
$mform =& $this->_form;
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('text', 'name', get_string('userset_name', 'local_elisprogram'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', get_string('required'), 'required', NULL, 'client');
$mform->addHelpButton('name', 'userset_name', 'local_elisprogram');
$mform->addElement('textarea', 'display', get_string('userset_description', 'local_elisprogram'), array('cols' => 40, 'rows' => 2));
$mform->setType('display', PARAM_CLEAN);
$mform->addHelpButton('display', 'userset_description', 'local_elisprogram');
$current_cluster_id = isset($this->_customdata['obj']->id) ? $this->_customdata['obj']->id : '';
//obtain the non-child clusters that we could become the child of, with availability
//determined based on the edit capability
$contexts = usersetpage::get_contexts('local/elisprogram:userset_edit');
$non_child_clusters = cluster_get_non_child_clusters($current_cluster_id, $contexts);
//parent dropdown
$mform->addElement('select', 'parent', get_string('userset_parent', 'local_elisprogram'), $non_child_clusters);
$mform->addHelpButton('parent', 'userset_parent', 'local_elisprogram');
// allow plugins to add their own fields
$mform->addElement('header', 'userassociationfieldset', get_string('userset_userassociation', 'local_elisprogram'));
$plugins = get_plugin_list(userset::ENROL_PLUGIN_TYPE);
foreach ($plugins as $plugin => $plugindir) {
require_once elis::plugin_file(userset::ENROL_PLUGIN_TYPE . '_' . $plugin, 'lib.php');
call_user_func('cluster_' . $plugin . '_edit_form', $this, $mform, $current_cluster_id);
}
// custom fields
$this->add_custom_fields('cluster', 'local/elisprogram:userset_edit', 'local/elisprogram:userset_view', 'cluster');
$this->add_action_buttons();
}
开发者ID:jamesmcq,项目名称:elis,代码行数:36,代码来源:usersetform.class.php
示例2: xmldb_elisprogram_usetclassify_install
/**
* Install function for this plugin
*
* @return boolean true Returns true to satisfy install procedure
*/
function xmldb_elisprogram_usetclassify_install()
{
global $CFG, $DB;
require_once elispm::lib('setup.php');
require_once elis::lib('data/customfield.class.php');
require_once elispm::file('plugins/usetclassify/usersetclassification.class.php');
// Migrate component.
$oldcmp = 'pmplugins_userset_classification';
$newcmp = 'elisprogram_usetclassify';
$upgradestepfuncname = 'elisprogram_usetclassify_pre26upgradesteps';
$tablechanges = array('crlm_cluster_classification' => 'elisprogram_usetclassify');
$migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname, $tablechanges);
if ($migrator->old_component_installed() === true) {
$migrator->migrate();
}
$field = new field();
$field->shortname = USERSET_CLASSIFICATION_FIELD;
$field->name = get_string('classification_field_name', 'elisprogram_usetclassify');
$field->datatype = 'char';
$category = new field_category();
$category->name = get_string('classification_category_name', 'elisprogram_usetclassify');
$field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USERSET, $category);
// make sure we're set as owner
if (!isset($field->owners['userset_classifications'])) {
$owner = new field_owner();
$owner->fieldid = $field->id;
$owner->plugin = 'userset_classifications';
$owner->save();
}
// 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 = 'userset_classifications';
$owner->param_help_file = 'elisprogram_usetclassify/cluster_classification';
$owner->save();
}
// 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');
}
$regclassify = $DB->get_record(usersetclassification::TABLE, array('shortname' => 'regular'));
if (empty($regclassify)) {
$default = new usersetclassification();
$default->shortname = 'regular';
$default->name = get_string('cluster', 'local_elisprogram');
$default->param_autoenrol_curricula = 1;
$default->param_autoenrol_tracks = 1;
$default->save();
}
return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:61,代码来源:install.php
示例3: 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
示例4: test_elis_tasks_get_cached
/**
* Validate scheduled tasks.
*/
public function test_elis_tasks_get_cached()
{
$dataset = $this->createCsvDataSet(array('local_eliscore_sched_tasks' => elis::component_file('eliscore', 'tests/fixtures/elis_scheduled_tasks.csv')));
$this->loadDataSet($dataset);
$cachedtasks = elis_tasks_get_cached('elis_program');
$this->assertNotEmpty($cachedtasks);
$this->assertInternalType('array', $cachedtasks);
$this->assertArrayHasKey('s:7:"pm_cron";', $cachedtasks);
$this->assertNotEmpty($cachedtasks['s:7:"pm_cron";']);
$this->assertInternalType('array', $cachedtasks['s:7:"pm_cron";']);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:14,代码来源:scheduled_tasks_test.php
示例5: test_elis_config
/**
* Validate ELIS config settings.
*/
public function test_elis_config()
{
$dataset = $this->createCsvDataSet(array('config_plugins' => elis::component_file('eliscore', 'tests/fixtures/config_plugins.csv')));
$this->loadDataSet($dataset);
$elisconfig = new elis_config();
$pluginconfig = $elisconfig->testplugin;
$this->assertNotEmpty($pluginconfig);
$this->assertInternalType('object', $pluginconfig);
$this->assertObjectHasAttribute('testconfigkey', $pluginconfig);
$this->assertEquals('testconfigvalue', $pluginconfig->testconfigkey);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:14,代码来源:setup_test.php
示例6: get_overlay_tables
/**
* Return the list of tables that should be overlayed.
*/
protected static function get_overlay_tables()
{
global $CFG;
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once elis::lib('data/customfield.class.php');
require_once elispm::lib('data/course.class.php');
require_once elispm::lib('data/curriculum.class.php');
require_once elispm::lib('data/curriculumcourse.class.php');
require_once elispm::lib('data/pmclass.class.php');
require_once elispm::lib('data/track.class.php');
return array(course::TABLE => 'local_elisprogram', curriculum::TABLE => 'local_elisprogram', curriculumcourse::TABLE => 'local_elisprogram', field::TABLE => 'local_eliscore', pmclass::TABLE => 'local_elisprogram', track::TABLE => 'local_elisprogram', trackassignment::TABLE => 'local_elisprogram');
}
开发者ID:jamesmcq,项目名称:elis,代码行数:15,代码来源:class_associate_track_test.php
示例7: test_method_returns_correct_userid
/**
* Validate that the given user name is converted to the provided user id.
* @dataProvider folder_to_userid_provider
* @param string $foldername The name of the ELIS Files folder
* @param mixed $expecteduserid The userid the method should return (or false if no valid user exists)
* @param string $adminusername The config value to use for the admin username setting
*/
public function test_method_returns_correct_userid($foldername, $expecteduserid, $adminusername) {
$this->resetAfterTest(true);
$this->setup_test_data_xml();
// Set up the configured admin username
set_config('admin_username', $adminusername, 'elisfiles');
set_config('mnethostid', 1);
elis::$config = new elis_config();
// Validate method output
$userid = elis_files_folder_to_userid($foldername);
$this->assertEquals($expecteduserid, $userid);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:20,代码来源:folder_to_userid_test.php
示例8: checkbox_control_display
/**
* Adds an appropriate editing control to the provided form
*
* @param moodleform or HTML_QuickForm $form The form to add the appropriate element to
* @param field $field The definition of the field defining the controls
* @param boolean $as_filter Whether to display a "choose" message
* @param string $contextname Optional context name/entity
*/
function checkbox_control_display($form, $mform, $customdata, $field, $as_filter = false, $contextname = 'system')
{
if (!$form instanceof moodleform) {
$mform = $form;
$form->_customdata = null;
}
$manual = new field_owner($field->owners['manual']);
$manual_params = unserialize($manual->params);
if (!empty($manual_params['options_source']) || !empty($manual_params['options'])) {
if ($as_filter || $field->multivalued) {
// require_once(CURMAN_DIRLOCATION.'/plugins/manual/field_controls/menu.php');
require_once elis::plugin_file('elisfields_manual', 'field_controls/menu.php');
return menu_control_display($form, $mform, $customdata, $field, $as_filter);
}
$options = array();
if (!empty($manual_params['options'])) {
$options = explode("\n", $manual_params['options']);
}
$source = '';
if (!empty($manual_params['options_source'])) {
$source = $manual_params['options_source'];
}
if (!empty($source)) {
$srcfile = elis::plugin_file('elisfields_manual', "sources/{$source}.php");
if (file_exists($srcfile)) {
require_once elis::plugin_file('elisfields_manual', 'sources.php');
require_once $srcfile;
$classname = "manual_options_{$source}";
$plugin = new $classname();
if ($plugin && $plugin->is_applicable($contextname)) {
$options = $plugin->get_options($customdata);
}
}
}
$controls = array();
foreach ($options as $option) {
$option = trim($option);
if ($field->multivalued) {
// FIXME: this doesn't work
$cb = $controls[] =& $mform->createElement('checkbox', "field_{$field->shortname}", null, $option);
$cb->updateAttributes(array('value' => $option));
} else {
$controls[] =& $mform->createElement('radio', "field_{$field->shortname}", null, $option, $option);
}
}
$mform->addGroup($controls, "field_{$field->shortname}", $field->name, '<br />', false);
} else {
$checkbox = $mform->addElement('advcheckbox', "field_{$field->shortname}", $field->name);
}
manual_field_add_help_button($mform, "field_{$field->shortname}", $field);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:59,代码来源:checkbox.php
示例9: get_class_custom_fields
/**
* Get custom fields for classes.
* @return array An Array of class custom fields.
*/
public static function get_class_custom_fields()
{
global $DB, $CFG;
if (static::require_elis_dependencies() === true) {
require_once elis::lib('data/customfield.class.php');
$sql = 'SELECT shortname, name, datatype, multivalued
FROM {' . field::TABLE . '} f
JOIN {' . field_contextlevel::TABLE . '} fctx ON f.id = fctx.fieldid AND fctx.contextlevel = ?';
$sqlparams = array(CONTEXT_ELIS_CLASS);
return $DB->get_records_sql($sql, $sqlparams);
} else {
return array();
}
}
开发者ID:jamesmcq,项目名称:elis,代码行数:18,代码来源:class_create.class.php
示例10: require_elis_dependencies
/**
* Require ELIS dependencies if ELIS is installed, otherwise return false.
* @return bool Whether ELIS dependencies were successfully required.
*/
public static function require_elis_dependencies()
{
global $CFG;
if (file_exists($CFG->dirroot . '/local/elisprogram/lib/setup.php')) {
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once elispm::lib('data/pmclass.class.php');
require_once elispm::lib('data/user.class.php');
require_once elis::lib('data/customfield.class.php');
require_once dirname(__FILE__) . '/../../importplugins/version1elis/version1elis.class.php';
return true;
} else {
return false;
}
}
开发者ID:jamesmcq,项目名称:elis,代码行数:18,代码来源:class_update.class.php
示例11: add_custom_fields
/**
* Method to add ELIS entity's custom fields to entity forms
*
* @param string $entity ELIS entity name: Eg. 'curriculum', 'track', 'course', 'class', 'cluster', 'user'
* @param string $editcap The required edit capability
* @param string $viewcap The required view capability
* @param string $parententity The entity name of the parent object (optional)
*/
function add_custom_fields($entity, $editcap, $viewcap, $parententity = '')
{
$mform =& $this->_form;
$fields = field::get_for_context_level($entity);
$fields = $fields ? $fields : array();
if (isset($this->_customdata['obj'])) {
if (isset($this->_customdata['obj']->id)) {
// Use the current (existing) entity's context instance
$contextlevel = \local_eliscore\context\helper::get_level_from_name($entity);
$contextclass = \local_eliscore\context\helper::get_class_for_level($contextlevel);
$context = $contextclass::instance($this->_customdata['obj']->id);
} else {
if (isset($this->_customdata['obj']->parent) && $parententity != '') {
// ELIS-6498 -- Specify the parent entity type to get the correct parent context instance as we are
// adding a new "child" entity
$contextlevel = \local_eliscore\context\helper::get_level_from_name($parententity);
$contextclass = \local_eliscore\context\helper::get_class_for_level($contextlevel);
$context = $contextclass::instance($this->_customdata['obj']->parent);
} else {
if (isset($this->_customdata['obj']->courseid) && $parententity == 'course') {
// ELIS-6498 -- Special handling of the course -> class hierarchy is required here
$context = \local_elisprogram\context\course::instance($this->_customdata['obj']->courseid);
} else {
$context = context_system::instance();
}
}
}
} else {
$context = context_system::instance();
}
require_once elis::plugin_file('elisfields_manual', 'custom_fields.php');
$lastcat = null;
$entityid = isset($this->_customdata['obj']->id) ? $this->_customdata['obj']->id : 0;
foreach ($fields as $rec) {
$field = new field($rec);
if (!isset($field->owners['manual'])) {
continue;
}
// Capabilities for editing / viewing this context
if (manual_field_is_view_or_editable($field, $context, $editcap, $viewcap, $entity, $entityid) != MANUAL_FIELD_NO_VIEW_OR_EDIT) {
if ($lastcat != $rec->categoryid) {
$lastcat = $rec->categoryid;
$mform->addElement('header', "category_{$lastcat}", htmlspecialchars($rec->categoryname));
}
manual_field_add_form_element($this, $mform, $context, $this->_customdata, $field, true, $editcap, $viewcap, $entity, $entityid);
}
}
}
开发者ID:jamesmcq,项目名称:elis,代码行数:56,代码来源:cmform.class.php
示例12: delete
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();
}
开发者ID:jamesmcq,项目名称:elis,代码行数:17,代码来源:curriculum.class.php
示例13: init_required_data
/**
* Set up necessary data
*
* @param int $numfields The number of custom fields used in auto-association
*/
private function init_required_data($numfields = 1)
{
global $CFG, $DB;
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php');
require_once elis::lib('data/customfield.class.php');
require_once elispm::file('accesslib.php');
require_once elispm::lib('data/userset.class.php');
require_once $CFG->dirroot . '/user/profile/definelib.php';
require_once $CFG->dirroot . '/user/profile/field/checkbox/define.class.php';
// Set up the category only once.
$fieldcategory = new field_category(array('name' => 'testcategoryname'));
$fieldcategory->save();
// Ste up the target userset only once.
$userset = new userset(array('name' => 'testusersetname'));
$userset->save();
for ($i = 1; $i <= $numfields; $i++) {
// Custom field.
$field = new field(array('categoryid' => $fieldcategory->id, 'shortname' => 'testfieldshortname' . $i, 'name' => 'testfieldname' . $i, 'datatype' => 'bool'));
$field->save();
// Ensure manual field owner exists for syncing.
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 = 'checkbox';
$owner->save();
// Ensure moodle profile field owner exists.
field_owner::ensure_field_owner_exists($field, 'moodle_profile');
$DB->execute("UPDATE {" . field_owner::TABLE . "} SET exclude = ?", array(pm_moodle_profile::sync_to_moodle));
// Field context level assocation.
$fieldcontextlevel = new field_contextlevel(array('fieldid' => $field->id, 'contextlevel' => CONTEXT_ELIS_USER));
$fieldcontextlevel->save();
// The associated Moodle user profile field.
$profiledefinecheckbox = new profile_define_checkbox();
$data = new stdClass();
$data->datatype = 'checkbox';
$data->categoryid = 99999;
$data->shortname = 'testfieldshortname' . $i;
$data->name = 'testfieldname' . $i;
$profiledefinecheckbox->define_save($data);
$mfield = $DB->get_record('user_info_field', array('shortname' => 'testfieldshortname' . $i));
// The "cluster-profile" association.
$usersetprofile = new userset_profile(array('clusterid' => $userset->id, 'fieldid' => $mfield->id, 'value' => 1));
$usersetprofile->save();
}
}
开发者ID:jamesmcq,项目名称:elis,代码行数:51,代码来源:elis_cluster_profile_import_test.php
示例14: menu_control_display
/**
* Adds an appropriate editing control to the provided form
*
* @param moodleform or HTML_QuickForm $form The form to add the appropriate element to
* @param field $field The definition of the field defining the controls
* @param boolean $as_filter Whether to display a "choose" message
* @param string $contextname Optional context name/entity
*/
function menu_control_display($form, $mform, $customdata, $field, $as_filter = false, $contextname = 'system')
{
if (!$form instanceof moodleform) {
$mform = $form;
$form->_customdata = null;
$customdata = null;
}
$manual = new field_owner($field->owners['manual']);
if ($field->datatype != 'bool') {
if (!isset($manual->param_options_source) || $manual->param_options_source == '') {
$tmpoptions = explode("\n", $manual->param_options);
if ($as_filter) {
$options = array('' => get_string("choose"));
}
foreach ($tmpoptions as $key => $option) {
$option = trim($option, "\n\r");
$options[$option] = format_string($option);
// multilang formatting
}
} else {
$options = array();
$source = $manual->param_options_source;
$srcfile = elis::plugin_file('elisfields_manual', "sources/{$source}.php");
if (file_exists($srcfile)) {
require_once elis::plugin_file('elisfields_manual', 'sources.php');
require_once $srcfile;
$classname = "manual_options_{$source}";
$plugin = new $classname();
if ($plugin && $plugin->is_applicable($contextname)) {
$options = $plugin->get_options($customdata);
}
}
}
} else {
if ($as_filter) {
$options = array('' => get_string("choose"), 0 => get_string('no'), 1 => get_string('yes'));
} else {
$options = array(0 => get_string('no'), 1 => get_string('yes'));
}
}
$menu = $mform->addElement('select', "field_{$field->shortname}", $field->name, $options);
if ($field->multivalued && !$as_filter) {
$menu->setMultiple(true);
}
manual_field_add_help_button($mform, "field_{$field->shortname}", $field);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:54,代码来源:menu.php
示例15: test_usercountexcludesinactivewhenexcludinginactive
/**
* Validate that the enrolment count excludes inactive users when the site is not configured to show inactive users
*/
public function test_usercountexcludesinactivewhenexcludinginactive()
{
require_once elispm::lib('lib.php');
// Set up all the data needed for the listing.
$this->load_csv_data();
// Disable showing of inactive users.
pm_set_config('legacy_show_inactive_users', 0);
elis::$config = new elis_config();
// Obtain the listing.
$listing = track_assignment_get_listing(1);
// Validate the number of rows.
$count = 0;
foreach ($listing as $entity) {
$count++;
// Validate the aggregated count in the first row.
$this->assertEquals(1, $entity->enrolments);
}
unset($listing);
$this->assertEquals(1, $count);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:23,代码来源:trackassignmentgetlisting_test.php
示例16: test_make_from_moodle_field
/**
* Test make_from_moodle_field function.
*
* @dataProvider dataprovider_make_from_moodle_field
* @param object $mfielddata Data to create the initial moodle profile with.
* @param array $expectedfielddata Expected data created for the field.
* @param array $expectedmanualownerdata Expected field_owner data created.
*/
public function test_make_from_moodle_field($mfielddata, $expectedfielddata, $expectedmanualownerdata)
{
require_once elis::file('eliscore/lib/data/customfield.class.php');
require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php');
global $DB;
$mfieldid = $DB->insert_record('user_info_field', $mfielddata);
$fieldcat = new field_category();
$fieldcat->name = 'Moodle Fields';
$fieldcat->save();
$efield = field::make_from_moodle_field($mfieldid, $fieldcat, pm_moodle_profile::sync_from_moodle);
$efieldrec = $DB->get_record(field::TABLE, array('shortname' => $efield->shortname));
unset($efieldrec->id);
unset($efieldrec->sortorder);
$expectedfielddata['categoryid'] = (string) $fieldcat->id;
$this->assertEquals($expectedfielddata, (array) $efieldrec);
$manualowner = $DB->get_record(field_owner::TABLE, array('fieldid' => $efield->id, 'plugin' => 'manual'));
ksort($expectedmanualownerdata);
$actualparams = unserialize($manualowner->params);
ksort($actualparams);
$this->assertEquals($expectedmanualownerdata, $actualparams);
$this->assertTrue(moodle_profile_can_sync($efield->shortname));
if ($mfielddata['defaultdata'] != '') {
switch ($efield->datatype) {
case 'bool':
$fielddatatype = 'int';
break;
case 'datetime':
$fielddatatype = 'int';
break;
case 'char':
$fielddatatype = 'char';
break;
default:
$fielddatatype = 'text';
}
$fielddataclass = 'field_data_' . $fielddatatype;
$defaultdata = $DB->get_record($fielddataclass::TABLE, array('fieldid' => $efield->id));
$this->assertNotEmpty($defaultdata);
$this->assertEquals($mfielddata['defaultdata'], $defaultdata->data);
}
}
开发者ID:jamesmcq,项目名称:elis,代码行数:49,代码来源:custom_field_makefrommoodlefield_test.php
示例17: 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
示例18: dirname
*
* 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 local_elisprogram
* @author Remote-Learner.net Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2008-2013 Remote Learner.net Inc http://www.remote-learner.net
*
*/
require_once dirname(__FILE__) . '/../../eliscore/test_config.php';
global $CFG;
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
// ELIS libs.
require_once elis::lib('data/customfield.class.php');
require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php');
require_once elispm::lib('deprecatedlib.php');
require_once elispm::lib('data/user.class.php');
require_once elispm::lib('data/usermoodle.class.php');
require_once $CFG->dirroot . '/user/profile/lib.php';
/**
* Test user custom fields.
* @group local_elisprogram
*/
class usercustomfields_testcase extends elis_database_test
{
/**
* Load initial data from CSVs.
*/
protected function load_csv_data()
{
开发者ID:jamesmcq,项目名称:elis,代码行数:31,代码来源:customuserfields_test.php
示例19: create_test_field
/**
* Create the test custom profile field and owner
*
* @param string $contextlevelname The name of the custom context level to create the field at
* @param string $name PM custom field shortname
* @param string $datatype The string identifier of the data type to use
* @param string $uitype The string identifier of the UI / control type to use
* @param int $categoryid PM custom field category id
* @param string $options Extra parameter, used for select options
* @param string $defaultdata Default value.
*
* @return int The id of the created field
*/
private function create_test_field($contextlevelname = 'user', $name = 'testfieldname', $datatype, $uitype, $categoryid, $options = null, $defaultdata = null)
{
global $CFG;
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once elis::lib('data/customfield.class.php');
// Category contextlevel.
$contextlevel = \local_eliscore\context\helper::get_level_from_name($contextlevelname);
$fieldcategorycontextlevel = new field_category_contextlevel(array('categoryid' => $categoryid, 'contextlevel' => $contextlevel));
$fieldcategorycontextlevel->save();
// Field.
$field = new field(array('shortname' => 'testfieldshortname', 'name' => $name, 'categoryid' => $categoryid, 'datatype' => $datatype));
$field->save();
// Field_data if a default value needs to be set.
if ($defaultdata !== null) {
$classname = 'field_data_' . $datatype;
$fielddata = new $classname(array('fieldid' => $field->id, 'data' => $defaultdata));
$fielddata->save();
}
// Field contextlevel.
$fieldcontextlevel = new field_contextlevel(array('fieldid' => $field->id, 'contextlevel' => $contextlevel));
$fieldcontextlevel->save();
// Field owner.
$ownerdata = array('control' => $uitype);
if ($options !== null) {
// Set options.
$options = is_array($options) ? implode("\n", $options) : $options;
$ownerdata['options'] = $options;
}
field_owner::ensure_field_owner_exists($field, 'manual', $ownerdata);
return $field;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:44,代码来源:version1elis_manual_incremental_export_test.php
示例20: defined
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2008-2013 Remote-Learner.net Inc (http://www.remote-learner.net)
*
*/
defined('MOODLE_INTERNAL') or die;
require_once elispm::lib('lib.php');
require_once elispm::lib('deepsightpage.class.php');
require_once elispm::lib('associationpage.class.php');
require_once elispm::lib('data/user.class.php');
require_once elispm::lib('data/userset.class.php');
require_once elispm::lib('data/clusterassignment.class.php');
require_once elispm::file('userpage.class.php');
require_once elispm::file('usersetpage.class.php');
require_once elis::plugin_file('usetenrol_manual', 'lib.php');
require_once elis::plugin_file('usetenrol_manual', 'usersetassignment_form.php');
require_once elis::plugin_file('usetenrol_manual', 'selectpage.class.php');
/**
* A base user-userset association implementation for code shared between userclusterpage and clusteruserpage.
*/
abstract class userclusterbase extends deepsightpage
{
public $section = 'users';
public $data_class = 'clusterassignment';
public $parent_page;
/**
* Determine whether the current can manage the association between a given user and userset.
* @param int $userid The ID of a user.
* @param int $clustid The ID of a userset.
* @return bool Success status.
*/
public static function can_manage_assoc($userid, $usersetid)
开发者ID:jamesmcq,项目名称:elis,代码行数:31,代码来源:usersetassignmentpage.class.php
注:本文中的elis类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论