本文整理汇总了PHP中elis类的典型用法代码示例。如果您正苦于以下问题:PHP elis类的具体用法?PHP elis怎么用?PHP elis使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了elis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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;
}
示例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;
}
示例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";']);
}
示例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);
}
示例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');
}
示例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);
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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);
}
}
}
示例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();
}
示例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();
}
}
示例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);
}
示例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);
}