本文整理汇总了PHP中elis::config方法的典型用法代码示例。如果您正苦于以下问题:PHP elis::config方法的具体用法?PHP elis::config怎么用?PHP elis::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elis
的用法示例。
在下文中一共展示了elis::config方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: test_availableusersrespectspaging
/**
* Validate that the listing respects paging
*/
public function test_availableusersrespectspaging()
{
$this->load_csv_data();
$this->assign_track_enrol_permissions();
set_config('siteguest', '');
set_config('siteadmins', '');
pm_set_config('legacy_show_inactive_users', 0);
elis::$config = new elis_config();
$usersrecset = usertrack::get_available_users(1, 'lastname', 'ASC', '', '', 0, 1);
$users = array();
foreach ($usersrecset as $key => $user) {
$users[$key] = $user;
}
unset($usersrecset);
// Validate that only one record is picked up when paging with page size 1.
$this->assertEquals(1, count($users));
}
示例4: test_autoassignidnumberdisabledwhensettingandparameterdisabledwhenuseridprovided
/**
* Validate that our method does not auto-assign idnumber for a particular user when the parameter and setting are disabled.
*
* @dataProvider dataprovider_autoassignidnumber
* @param array An array containing users with their required information
*/
public function test_autoassignidnumberdisabledwhensettingandparameterdisabledwhenuseridprovided($users)
{
global $DB;
// NOTE: this test does not specifically depend on the userid parameter but is a valuable sanity check.
// Make sure the config is not enabling the functionality.
set_config('auto_assign_user_idnumber', 0, 'local_elisprogram');
elis::$config = new elis_config();
foreach ($users as $i => $user) {
// Set up the provided users.
$users[$i]['id'] = $DB->insert_record('user', (object) $user);
}
// Call the migration method.
pm_migrate_moodle_users(false, 0, $users[0]['id']);
// Count the number of users.
$this->assertEquals(0, $DB->count_records_select('user', 'username = idnumber'));
}
示例5: test_myoodleredirectreturnstruewhensettingenabled
/**
* Validate that My Moodle redirection works when it's supposed to
*/
public function test_myoodleredirectreturnstruewhensettingenabled()
{
global $CFG, $USER, $DB;
require_once $CFG->dirroot . '/user/lib.php';
// Set up our test user.
$user = new stdClass();
$user->username = "testuser";
$userid = user_create_user($user);
$USER = $DB->get_record('user', array('id' => $userid));
// Enable functionality.
pm_set_config('mymoodle_redirect', 1);
elis::$config = new elis_config();
// Validation.
$result = pm_mymoodle_redirect();
$this->assertTrue($result);
}
示例6: test_track_enrolment_sends_class_enrolment_notification
/**
* Validating that enrolling a user in a track instance triggers the enrolment
* notification
*/
public function test_track_enrolment_sends_class_enrolment_notification()
{
global $CFG, $DB;
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once elispm::lib('data/curriculum.class.php');
require_once elispm::lib('data/track.class.php');
require_once elispm::lib('data/user.class.php');
// Configuration.
set_config('popup_provider_elis_program_notify_pm_permitted', 1, 'message');
set_config('email_provider_elis_program_notify_pm_permitted', 1, 'message');
set_config('notify_trackenrol_user', 1, 'local_elisprogram');
$message = '%%userenrolname%% has been enrolled in the track %%trackname%%.';
set_config('notify_trackenrol_message', $message, 'local_elisprogram');
// Force refreshing of configuration.
elis::$config = new elis_config();
$this->setAdminUser();
unset_config('noemailever');
// Setup.
$user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => 'test@user.com', 'country' => 'CA'));
$user->save();
$program = new curriculum(array('idnumber' => 'testprogramidnumber'));
$program->save();
$track = new track(array('curid' => $program->id, 'idnumber' => 'testtrackidnumber', 'name' => 'testtrackname'));
$track->save();
// Run the enrolment create action.
$record = new stdClass();
$record->context = 'track_testtrackidnumber';
$record->user_username = 'testuserusername';
$importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
$importplugin->fslogger = new silent_fslogger(null);
$sink = $this->redirectEmails();
$importplugin->track_enrolment_create($record, 'bogus', 'testtrackidnumber');
$this->assertEquals(1, count($sink->get_messages()));
$sink->close();
// Validation.
$mdluserid = $DB->get_field('user', 'id', array('username' => 'testuserusername'));
$expectedmessage = "{$user->firstname} {$user->lastname} has been enrolled in the track {$track->name}.";
$like = $DB->sql_like('fullmessagehtml', ':message');
$select = "useridto = :userid\n AND {$like}";
$this->assertTrue($DB->record_exists_select('message', $select, array('userid' => $mdluserid, 'message' => "{$expectedmessage}%")));
}
示例7: test_clusterrolepagecountroleusersrespectsusersetpermissions
/**
* Validate that counting the number of role assignments on a particular
* cluster for a particular role respects special userset permissions
*/
public function test_clusterrolepagecountroleusersrespectsusersetpermissions()
{
global $CFG, $USER, $DB;
require_once elispm::lib('data/clusterassignment.class.php');
require_once elispm::lib('data/user.class.php');
require_once elispm::lib('data/userset.class.php');
accesslib_clear_all_caches(true);
// Create a user record so that Moodle and PM ids don't match by fluke.
set_config('auto_assign_user_idnumber', 0, 'local_elisprogram');
elis::$config = new elis_config();
create_user_record('bogususer', 'Bogususer!0');
// Create our test userset.
$userset = new userset(array('name' => 'testuserset'));
$userset->save();
// The user who is assigned to the user set.
$assigneduser = new user(array('idnumber' => 'assigned', 'username' => 'assigned', 'firstname' => 'assigned', 'lastname' => 'assigned', 'email' => 'assigned@assigned.com', 'country' => 'CA'));
$assigneduser->save();
// Userset assignment.
$clusterassignment = new clusterassignment(array('clusterid' => $userset->id, 'userid' => $assigneduser->id));
$clusterassignment->save();
// User who is potentially assigning the userset member a new role within the userset.
$assigninguser = new user(array('idnumber' => 'assigning', 'username' => 'assigning', 'firstname' => 'assigning', 'lastname' => 'assigning', 'email' => 'assigning@assigning.com', 'country' => 'CA'));
$assigninguser->save();
// Need the system context for role assignments.
$systemcontext = context_system::instance();
// Set up the role that allows a user to assign roles but only to userset members.
$permissionsroleid = create_role('permissionsrole', 'permissionsrole', 'permissionsrole');
// Enable the appropriate capabilities.
assign_capability('moodle/role:assign', CAP_ALLOW, $permissionsroleid, $systemcontext->id);
assign_capability('local/elisprogram:userset_role_assign_userset_users', CAP_ALLOW, $permissionsroleid, $systemcontext->id);
// Perform the role assignment.
$moodleuserid = $DB->get_field('user', 'id', array('username' => 'assigning'));
role_assign($permissionsroleid, $moodleuserid, $systemcontext->id);
// Imitate the user assigned the role which allows for further role assignments only on userset members.
$USER = $DB->get_record('user', array('id' => $moodleuserid));
// Test role for potential assignment to userset members.
$roleid = create_role('targetrole', 'targetrole', 'targetrole');
// Assign the both users to the userset role.
$contextclass = \local_eliscore\context\helper::get_class_for_level(CONTEXT_ELIS_USERSET);
$usersetcontext = $contextclass::instance($userset->id);
role_assign($roleid, $moodleuserid, $usersetcontext->id);
$moodleuserid = $DB->get_field('user', 'id', array('username' => 'assigned'));
role_assign($roleid, $moodleuserid, $usersetcontext->id);
// Obtain the count of assigned users.
$page = new cluster_rolepage(array('id' => $userset->id));
$count = $page->count_role_users($roleid, $usersetcontext);
// List should only contain the userset member.
$this->assertEquals(1, $count);
}
示例8: stdClass
{
global $DB;
if (!isset($this->configs[$name])) {
$config = new stdClass();
// load the defaults
if (file_exists(elis::plugin_file($name, 'defaults.php'))) {
$defaults = array();
include elis::plugin_file($name, 'defaults.php');
foreach ($defaults as $key => $value) {
$config->{$key} = $value;
}
}
$configrecs = $DB->get_recordset('config_plugins', array('plugin' => $name));
foreach ($configrecs as $rec) {
$key = $rec->name;
$config->{$key} = $rec->value;
}
unset($configrecs);
$this->configs[$name] = $config;
}
return $this->configs[$name];
}
}
global $CFG;
elis::$basedir = "{$CFG->dirroot}/local";
elis::$libdir = elis::file('eliscore/lib');
elis::$config = new elis_config();
$plugin = new stdClass();
require elis::file('eliscore/version.php');
elis::$version = $plugin->version;
elis::$release = $plugin->release;
示例9: setUp
/**
* Load ELIS config data before every test.
* (otherwise config setting changes are lost when loading csv data during group testing)
*/
protected function setUp()
{
parent::setUp();
elis::$config = new elis_config();
}
示例10: test_version1importsetsdefaultsonusercreate
/**
* Validate that default values are correctly set on user creation
*/
public function test_version1importsetsdefaultsonusercreate()
{
global $CFG, $DB;
require_once $CFG->dirroot . '/local/eliscore/lib/setup.php';
set_config('forcetimezone', 99);
// Make sure we are not auto-assigning idnumbers.
set_config('auto_assign_user_idnumber', 0, 'local_elisprogram');
elis::$config = new elis_config();
$this->run_core_user_import(array());
$select = "username = :username AND\n mnethostid = :mnethostid AND\n auth = :auth AND\n maildigest = :maildigest AND\n autosubscribe = :autosubscribe AND\n trackforums = :trackforums AND\n timezone = :timezone AND\n theme = :theme AND\n lang = :lang AND\n {$DB->sql_compare_text('description')} = :description AND\n idnumber = :idnumber AND\n institution = :institution AND\n department = :department";
$params = array('username' => 'rlipusername', 'mnethostid' => $CFG->mnet_localhost_id, 'auth' => 'manual', 'maildigest' => 0, 'autosubscribe' => 1, 'trackforums' => 0, 'timezone' => 99, 'theme' => '', 'lang' => $CFG->lang, 'description' => '', 'idnumber' => '', 'institution' => '', 'department' => '');
$exists = $DB->record_exists_select('user', $select, $params);
$this->assertEquals($exists, true);
}