本文整理汇总了PHP中elis::lib方法的典型用法代码示例。如果您正苦于以下问题:PHP elis::lib方法的具体用法?PHP elis::lib怎么用?PHP elis::lib使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elis
的用法示例。
在下文中一共展示了elis::lib方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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');
}
示例4: 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;
}
}
示例5: 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();
}
}
示例6: 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();
}
示例7: 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();
}
}
示例8: 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;
}
示例9: defined
* 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 programmanagement
* @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
*
*/
defined('MOODLE_INTERNAL') || die;
require_once elis::lib('data/data_filter.class.php');
function get_contexts_by_capability_for_user($contextlevel, $capability, $userid, $doanything = true)
{
return pm_context_set::for_user_with_capability($contextlevel, $capability, $userid, $doanything);
}
class pm_context_set
{
/**
* An array of the contexts (both at the requested context level, and in
* parent context levels) where the user is assigned the given
* capabilities. Clusters are considered a parent context of users. The
* return type is an array. The array has keys set to the name of the
* context level, and the value is an array of instance IDs where the user
* has the given capability.
*/
var $contexts;
示例10: defined
* values are arrays to pass to setHelpButton($helpbuttonargs)
* --- not implemented in all sub-filters!
*
* @package local_eliscore
* @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)
*
*/
defined('MOODLE_INTERNAL') || die;
require_once $CFG->dirroot . '/local/eliscore/lib/filtering/lib.php';
// Include the simple filter types that will be returned by an object of this type.
require_once elis::lib('filtering/simpleselect.php');
require_once elis::lib('filtering/text.php');
require_once elis::lib('filtering/date.php');
require_once elis::lib('filtering/userprofiledatetime.php');
/**
* Base class for multi-filter filters.
*
* A multi-filter is any filter which returns a group of related filter objects. The primary
* example of this filter who be a user profile filter which displays all of the profile fields
* as individual filter elements. In fact, this base class is derived from just such a filter.
*/
// BJB110330: php_report block upgrade increased size from 50 to 255
define('MAX_FILTER_SUFFIX_LEN', 30);
// was 6 before DB upgrade
/**
* Generic multifilter class - standalone, no parent!
*/
class generalized_filter_multifilter
{
示例11: defined
*
* 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-2014 Remote-Learner.net Inc (http://www.remote-learner.net)
*
*/
defined('MOODLE_INTERNAL') || die;
require_once dirname(__FILE__) . '/../../../../config.php';
global $CFG;
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once elis::lib('data/data_object.class.php');
require_once elis::lib('table.class.php');
require_once elispm::lib('lib.php');
require_once elispm::lib('deprecatedlib.php');
require_once elispm::lib('data/classmoodlecourse.class.php');
require_once elispm::lib('data/course.class.php');
require_once elispm::lib('data/curriculumcourse.class.php');
require_once elispm::lib('data/instructor.class.php');
require_once elispm::lib('data/pmclass.class.php');
require_once elispm::lib('data/user.class.php');
require_once elispm::lib('data/waitlist.class.php');
define('STUTABLE', 'local_elisprogram_cls_enrol');
define('GRDTABLE', 'local_elisprogram_cls_graded');
define('STUSTATUS_NOTCOMPLETE', 0);
define('STUSTATUS_FAILED', 1);
define('STUSTATUS_PASSED', 2);
class student extends elis_data_object
示例12: dirname
* 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 local_datahub
* @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__) . '/../../../../local/eliscore/lib/setup.php';
require_once elis::lib('testlib.php');
/**
* This class is handling log maintenance
*/
abstract class rlip_test extends elis_database_test
{
static $existing_csvfiles = array();
static $existing_logfiles = array();
static $existing_zipfiles = array();
/**
* Do setup before tests.
*/
protected function setUp()
{
global $CFG;
$ob = ob_get_level();
示例13: 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;
}
示例14: defined
* 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 local_eliscore
* @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)
*
*/
defined('MOODLE_INTERNAL') || die;
require_once $CFG->dirroot . '/backup/util/includes/backup_includes.php';
require_once elis::lib('rollover/backup/rollover_backup_factory.class.php');
/**
* Class representing the plan used during the backup portion of the rollover
*/
class rollover_backup_plan extends backup_plan
{
/**
* Entry point for building the backup plan
*/
public function build()
{
rollover_backup_factory::build_plan($this->controller);
// Dispatch to correct format
$this->built = true;
}
/**
示例15: test_delete_elis_userset_deletes_associations
/**
* Validate that deleting a userset deletes all appropriate associations
*/
public function test_delete_elis_userset_deletes_associations()
{
global $CFG, $DB;
// Entities.
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once elispm::lib('data/userset.class.php');
require_once elispm::lib('data/user.class.php');
require_once elispm::lib('data/curriculum.class.php');
require_once elispm::lib('data/track.class.php');
require_once elis::lib('data/customfield.class.php');
// Associations.
require_once elispm::lib('data/clusterassignment.class.php');
require_once elispm::lib('data/clustercurriculum.class.php');
require_once elispm::lib('data/clustertrack.class.php');
require_once elispm::file('enrol/userset/moodleprofile/userset_profile.class.php');
// For context level access.
require_once elispm::file('accesslib.php');
$origfieldcount = $DB->count_records(field::TABLE);
// Set up user set.
$userset = new userset(array('name' => 'testusersetname'));
$userset->save();
// Set up other entities and associations.
// Cluster enrolment.
$user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => 'test@useremail.com', 'country' => 'CA'));
$user->save();
$clusterassignment = new clusterassignment(array('clusterid' => $userset->id, 'userid' => $user->id));
$clusterassignment->save();
// Cluster-curriculum assignment.
$curriculum = new curriculum(array('idnumber' => 'testcurriculumidnumber'));
$curriculum->save();
$clustercurriculum = new clustercurriculum(array('clusterid' => $userset->id, 'curriculumid' => $curriculum->id));
$clustercurriculum->save();
// Cluster-track assignment.
$track = new track(array('curid' => $curriculum->id, 'idnumber' => 'testtrackidnumber'));
$track->save();
$clustertrack = new clustertrack(array('clusterid' => $userset->id, 'trackid' => $track->id));
$clustertrack->save();
// Custom field.
$field = new field(array('name' => 'testfieldname', 'categoryid' => 9999));
$field->save();
$context = \local_elisprogram\context\userset::instance($userset->id);
$data = new field_data_int(array('contextid' => $context->id, 'fieldid' => $field->id, 'data' => 1));
$data->save();
// Cluster profile criteria.
$clusterprofile = new userset_profile(array('clusterid' => $userset->id, 'fieldid' => $field->id, 'value' => 0));
$clusterprofile->save();
// Validate setup.
$this->assertEquals(1, $DB->count_records(userset::TABLE));
$this->assertEquals(1, $DB->count_records(user::TABLE));
$this->assertEquals(1, $DB->count_records(clusterassignment::TABLE));
$this->assertEquals(1, $DB->count_records(curriculum::TABLE));
$this->assertEquals(1, $DB->count_records(clustercurriculum::TABLE));
$this->assertEquals(1, $DB->count_records(track::TABLE));
$this->assertEquals(1, $DB->count_records(clustertrack::TABLE));
$this->assertEquals(1 + $origfieldcount, $DB->count_records(field::TABLE));
$this->assertEquals(1, $DB->count_records(field_data_int::TABLE));
$this->assertEquals(1, $DB->count_records(userset_profile::TABLE));
// Run the import.
$data = array('action' => 'delete');
$this->run_core_userset_import($data, true);
// Validation.
$this->assertEquals(0, $DB->count_records(userset::TABLE));
$this->assertEquals(1, $DB->count_records(user::TABLE));
$this->assertEquals(0, $DB->count_records(clusterassignment::TABLE));
$this->assertEquals(1, $DB->count_records(curriculum::TABLE));
$this->assertEquals(0, $DB->count_records(clustercurriculum::TABLE));
$this->assertEquals(1, $DB->count_records(track::TABLE));
$this->assertEquals(0, $DB->count_records(clustertrack::TABLE));
$this->assertEquals(1 + $origfieldcount, $DB->count_records(field::TABLE));
$this->assertEquals(0, $DB->count_records(field_data_int::TABLE));
$this->assertEquals(0, $DB->count_records(userset_profile::TABLE));
}