• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_all_roles函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_all_roles函数的典型用法代码示例。如果您正苦于以下问题:PHP get_all_roles函数的具体用法?PHP get_all_roles怎么用?PHP get_all_roles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __construct

 /**
  * Constructor.
  * @throws Command_Exception.
  */
 public function __construct()
 {
     global $DB;
     // Getting command description.
     $cmd_name = vmoodle_get_string('cmdsynccapabilityname', 'vmoodleadminset_roles');
     $cmd_desc = vmoodle_get_string('cmdsynccapabilitydesc', 'vmoodleadminset_roles');
     // Creating platform parameter.
     $platform_param = new Command_Parameter('platform', 'enum', vmoodle_get_string('platformparamsyncdesc', 'vmoodleadminset_roles'), null, get_available_platforms());
     // Getting role parameter.
     $roles = role_fix_names(get_all_roles(), \context_system::instance(), ROLENAME_ORIGINAL);
     $rolemenu = array();
     foreach ($roles as $r) {
         $rolemenu[$r->shortname] = $r->name;
     }
     $role_param = new Command_Parameter('role', 'enum', vmoodle_get_string('roleparamsyncdesc', 'vmoodleadminset_roles'), null, $rolemenu);
     // Creating capability parameter.
     $records = $DB->get_records('capabilities', null, 'name', 'name');
     $capabilities = array();
     foreach ($records as $record) {
         $capabilities[$record->name] = get_capability_string($record->name);
     }
     asort($capabilities);
     $capability_param = new Command_Parameter('capability', 'enum', vmoodle_get_string('capabilityparamsyncdesc', 'vmoodleadminset_roles'), null, $capabilities);
     // Creating command.
     parent::__construct($cmd_name, $cmd_desc, array($platform_param, $role_param, $capability_param));
 }
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:30,代码来源:Command_Role_Capability_Sync.php


示例2: definition

    function definition() {
        $mform =& $this->_form;
        $contextid = $this->_customdata['contextid'];

        $export = $mform->addElement('hidden', 'export', ''); // Will be overwritten below

        $table = new html_table();
        /* Styling done using HTML table and CSS */
        $table->attributes['class'] = 'export_form_table';
        $table->align = array('left', 'left', 'left', 'center');
        $table->wrap = array('nowrap', '', 'nowrap', 'nowrap');
        $table->data = array();

        $table->head = array(get_string('name'),
                            get_string('description'),
                            get_string('shortname'),
                            get_string('export', 'report_rolesmigration'));

        $roles = get_all_roles();
        foreach ($roles as $role) {
            $row = array();
            $roleurl = new moodle_url('/admin/roles/define.php', array('roleid' => $role->id, 'action' => 'view'));
            $row[0] = '<a href="'.$roleurl.'">'.format_string($role->name).'</a>';
            $row[1] = format_text($role->description, FORMAT_HTML);
            $row[2] = ($role->shortname);
            /* Export values are added from role checkboxes */
            $row[3] = '<input type="checkbox" name="export[]" value="'.$role->shortname.'" />';

            $table->data[] = $row;
        }

        $mform->addElement('html', html_writer::table($table));
        $mform->addElement('hidden', 'contextid', $contextid);
        $this->add_action_buttons(false, get_string('submitexport', 'report_rolesmigration'));
    }
开发者ID:ncsu-delta,项目名称:moodle-report_rolesmigration,代码行数:35,代码来源:exportroles_form.php


示例3: definition

 function definition()
 {
     $mform =& $this->_form;
     $mform->addElement('header', 'general', get_string('message', 'message'));
     //$mform->addElement('htmleditor', 'messagebody', get_string('messagebody'), array('rows'=>15, 'cols'=>60));
     //$mform->addRule('messagebody', '', 'required', null, 'client');
     //$mform->setHelpButton('messagebody', array('writing', 'reading', 'questions', 'richtext'), false, 'editorhelpbutton');
     //$mform->addElement('format', 'format', get_string('format'));
     $courses = get_courses();
     foreach ($courses as $course) {
         //$mform->addElement('checkbox','courseid',get_string('course')." ".$course->shortname);
         $courselist[$course->id] = $course->shortname;
     }
     //$select = &$mform->addElement('select', 'colors', get_string('colors'), array('red', 'blue', 'green'), $attributes);
     //$select->setMultiple(true);
     $select =& $mform->addElement('select', 'courses', get_string('courses'), $courselist, 'size="15"');
     $select->setMultiple(true);
     //$mform->addElement('group', 'coursesgrp', get_string('courses'), $select , ' ', false);
     $allroles = array();
     if ($roles = get_all_roles()) {
         foreach ($roles as $role) {
             $rolename = strip_tags(format_string($role->name, true));
             $allroles[$role->id] = $rolename;
         }
     }
     $mform->addElement('select', 'role', get_string('roles'), $allroles);
     $mform->setDefault('role', 'Student');
     $this->add_action_buttons();
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:29,代码来源:user_courselist_form.php


示例4: get_moodle_roles

function get_moodle_roles()
{
    $moodle_roles = array();
    foreach (get_all_roles() as $role) {
        $moodle_roles[] = $role->shortname;
    }
    return $moodle_roles;
}
开发者ID:blionut,项目名称:elearning,代码行数:8,代码来源:roles.php


示例5: xmldb_enrol_flatfile_install

function xmldb_enrol_flatfile_install()
{
    global $CFG, $DB;
    // Flatfile role mappings are empty by default now.
    $roles = get_all_roles();
    foreach ($roles as $role) {
        set_config('map_' . $role->id, $role->shortname, 'enrol_flatfile');
    }
}
开发者ID:evltuma,项目名称:moodle,代码行数:9,代码来源:install.php


示例6: __construct

 /**
  * Constructor.
  * @param context $context the context this table relates to.
  * @param string $contextname $context->get_context_name() - to save recomputing.
  * @param array $allowoverrides
  * @param array $allowsafeoverrides
  * @param array $overridableroles
  */
 public function __construct($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles)
 {
     parent::__construct($context, 'permissions');
     $this->contextname = $contextname;
     $this->allowoverrides = $allowoverrides;
     $this->allowsafeoverrides = $allowsafeoverrides;
     $this->overridableroles = $overridableroles;
     $roles = get_all_roles($context);
     $this->roles = role_fix_names(array_reverse($roles, true), $context, ROLENAME_ALIAS, true);
 }
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:18,代码来源:permissions_table.php


示例7: __construct

 /**
  * Constructor.
  * @throws Command_Exception.
  */
 public function __construct()
 {
     global $DB;
     // Getting command description
     $cmd_name = vmoodle_get_string('cmdcomparename', 'vmoodleadminset_roles');
     $cmd_desc = vmoodle_get_string('cmdcomparedesc', 'vmoodleadminset_roles');
     // Getting role parameter
     $roles = role_fix_names(get_all_roles(), \context_system::instance(), ROLENAME_ORIGINAL);
     $rolemenu = array();
     foreach ($roles as $r) {
         $rolemenu[$r->shortname] = $r->localname;
     }
     $role_param = new Command_Parameter('role', 'enum', vmoodle_get_string('roleparamcomparedesc', 'vmoodleadminset_roles'), null, $rolemenu);
     // Creating command.
     parent::__construct($cmd_name, $cmd_desc, $role_param);
 }
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:20,代码来源:Command_Role_Compare.php


示例8: definition

 public function definition()
 {
     $mform =& $this->_form;
     $category = $this->_customdata['category'];
     $mform->addElement('header', 'rolerenaming', get_string('rolerenaming'));
     $mform->addHelpButton('rolerenaming', 'rolerenaming');
     if ($roles = get_all_roles()) {
         $roles = role_fix_names($roles, null, ROLENAME_ORIGINAL);
         $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSECAT);
         foreach ($roles as $role) {
             $mform->addElement('text', 'role_' . $role->id, get_string('yourwordforx', '', $role->localname));
             $mform->setType('role_' . $role->id, PARAM_TEXT);
             if (!in_array($role->id, $assignableroles)) {
                 $mform->setAdvanced('role_' . $role->id);
             }
         }
     }
     $mform->addElement('hidden', 'id', $category->id);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('html', get_string('roleedit_notice', 'local_contextadmin'));
     $this->add_action_buttons(true, get_string('savechanges'));
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:22,代码来源:categoryroles_form.php


示例9: set_parameters

 /**
  * Sets the parameters property of the extended class
  *
  * @param    USER  global object
  * @param    CFG   global object
  */
 function set_parameters()
 {
     global $USER, $CFG;
     $site = get_site();
     $littlecfg = new object();
     // to avoid some notices later
     $littlecfg->wwwroot = $CFG->wwwroot;
     $courseparameters = array('label3' => array('langstr' => get_string('course'), 'value' => 'optgroup'), 'courseid' => array('langstr' => 'id', 'value' => $this->course->id), 'coursefullname' => array('langstr' => get_string('fullnamecourse'), 'value' => $this->course->fullname), 'courseshortname' => array('langstr' => get_string('shortnamecourse'), 'value' => $this->course->shortname), 'courseidnumber' => array('langstr' => get_string('idnumbercourse'), 'value' => $this->course->idnumber), 'coursesummary' => array('langstr' => get_string('summary'), 'value' => $this->course->summary), 'courseformat' => array('langstr' => get_string('format'), 'value' => $this->course->format));
     $roles = get_all_roles();
     $coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id);
     $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS);
     foreach ($roles as $role) {
         $courseparameters['course' . $role->shortname] = array('langstr' => get_string('yourwordforx', '', $role->name), 'value' => $role->localname);
     }
     $courseparameters['label4'] = array('langstr' => '', 'value' => '/optgroup');
     $miscparameters = array('label5' => array('langstr' => get_string('miscellaneous'), 'value' => 'optgroup'), 'lang' => array('langstr' => get_string('preferredlanguage'), 'value' => current_language()), 'sitename' => array('langstr' => get_string('fullsitename'), 'value' => format_string($site->fullname)), 'serverurl' => array('langstr' => get_string('serverurl', 'resource', $littlecfg), 'value' => $littlecfg->wwwroot), 'currenttime' => array('langstr' => get_string('time'), 'value' => time()), 'encryptedcode' => array('langstr' => get_string('encryptedcode'), 'value' => $this->set_encrypted_parameter()), 'label6' => array('langstr' => "", 'value' => '/optgroup'));
     $userparameters = array();
     if (!empty($USER->id)) {
         $userparameters = array('label1' => array('langstr' => get_string('user'), 'value' => 'optgroup'), 'userid' => array('langstr' => 'id', 'value' => $USER->id), 'userusername' => array('langstr' => get_string('username'), 'value' => $USER->username), 'useridnumber' => array('langstr' => get_string('idnumber'), 'value' => $USER->idnumber), 'userfirstname' => array('langstr' => get_string('firstname'), 'value' => $USER->firstname), 'userlastname' => array('langstr' => get_string('lastname'), 'value' => $USER->lastname), 'userfullname' => array('langstr' => get_string('fullnameuser'), 'value' => fullname($USER)), 'useremail' => array('langstr' => get_string('email'), 'value' => $USER->email), 'usericq' => array('langstr' => get_string('icqnumber'), 'value' => $USER->icq), 'userphone1' => array('langstr' => get_string('phone') . ' 1', 'value' => $USER->phone1), 'userphone2' => array('langstr' => get_string('phone2') . ' 2', 'value' => $USER->phone2), 'userinstitution' => array('langstr' => get_string('institution'), 'value' => $USER->institution), 'userdepartment' => array('langstr' => get_string('department'), 'value' => $USER->department), 'useraddress' => array('langstr' => get_string('address'), 'value' => $USER->address), 'usercity' => array('langstr' => get_string('city'), 'value' => $USER->city), 'usertimezone' => array('langstr' => get_string('timezone'), 'value' => get_user_timezone_offset()), 'userurl' => array('langstr' => get_string('webpage'), 'value' => $USER->url), 'label2' => array('langstr' => "", 'value' => '/optgroup'));
     }
     $this->parameters = array_merge($userparameters, $courseparameters, $miscparameters);
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:28,代码来源:resource.class.php


示例10: __construct

 /**
  * Constructor.
  * @throws Command_Exception.
  */
 function __construct()
 {
     global $DB;
     // Getting command description.
     $cmd_name = vmoodle_get_string('cmdallowsyncname', 'vmoodleadminset_roles');
     $cmd_desc = vmoodle_get_string('cmdallowsyncdesc', 'vmoodleadminset_roles');
     // Creating platform parameter
     $platform_param = new Command_Parameter('platform', 'enum', vmoodle_get_string('platformparamsyncdesc', 'vmoodleadminset_roles'), null, get_available_platforms());
     // Creating table parameter
     $tables['assign'] = vmoodle_get_string('assigntable', 'vmoodleadminset_roles');
     $tables['override'] = vmoodle_get_string('overridetable', 'vmoodleadminset_roles');
     $tables['switch'] = vmoodle_get_string('switchtable', 'vmoodleadminset_roles');
     $table_param = new Command_Parameter('table', 'enum', vmoodle_get_string('tableparamdesc', 'vmoodleadminset_roles'), null, $tables);
     // Creating role parameter
     $roles = role_fix_names(get_all_roles(), \context_system::instance(), ROLENAME_ORIGINAL);
     $rolemenu = array();
     foreach ($roles as $r) {
         $rolemenu[$r->shortname] = $r->localname;
     }
     $role_param = new Command_Parameter('role', 'enum', vmoodle_get_string('roleparamsyncdesc', 'vmoodleadminset_roles'), null, $rolemenu);
     // Creating command
     parent::__construct($cmd_name, $cmd_desc, array($platform_param, $table_param, $role_param));
 }
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:27,代码来源:Command_Role_Allow_Sync.php


示例11: admin_externalpage

 $ADMIN->add('accounts', new admin_externalpage('profilefields', get_string('profilefields', 'admin'), "{$CFG->wwwroot}/user/profile/index.php", 'moodle/site:config'));
 $ADMIN->add('accounts', new admin_externalpage('cohorts', get_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
 // stuff under the "roles" subcategory
 // "userpolicies" settingpage
 $temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
 if ($ADMIN->fulltree) {
     if (!during_initial_install()) {
         $context = get_context_instance(CONTEXT_SYSTEM);
         $otherroles = array();
         $guestroles = array();
         $userroles = array();
         $creatornewroles = array();
         $defaultteacherid = null;
         $defaultuserid = null;
         $defaultguestid = null;
         foreach (get_all_roles() as $role) {
             $rolename = strip_tags(format_string($role->name)) . ' (' . $role->shortname . ')';
             switch ($role->archetype) {
                 case 'manager':
                     $creatornewroles[$role->id] = $rolename;
                     break;
                 case 'coursecreator':
                     break;
                 case 'editingteacher':
                     $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
                     $creatornewroles[$role->id] = $rolename;
                     break;
                 case 'teacher':
                     $creatornewroles[$role->id] = $rolename;
                     break;
                 case 'student':
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:users.php


示例12: test_data_saved

 public function test_data_saved()
 {
     global $DB;
     $this->resetAfterTest(true);
     // Create.
     $mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
     $updatemode = tool_uploadcourse_processor::UPDATE_NOTHING;
     $data = array('shortname' => 'c1', 'fullname' => 'Fullname', 'category' => '1', 'visible' => '0', 'startdate' => '8 June 1990', 'idnumber' => '123abc', 'summary' => 'Summary', 'format' => 'weeks', 'theme' => 'afterburner', 'lang' => 'en', 'newsitems' => '7', 'showgrades' => '0', 'showreports' => '1', 'legacyfiles' => '1', 'maxbytes' => '1234', 'groupmode' => '2', 'groupmodeforce' => '1', 'enablecompletion' => '1', 'tags' => 'Cat, Dog', 'role_teacher' => 'Knight', 'role_manager' => 'Jedi', 'enrolment_1' => 'guest', 'enrolment_2' => 'self', 'enrolment_2_roleid' => '1', 'enrolment_3' => 'manual', 'enrolment_3_disable' => '1');
     $this->assertFalse($DB->record_exists('course', array('shortname' => 'c1')));
     $co = new tool_uploadcourse_course($mode, $updatemode, $data);
     $this->assertTrue($co->prepare());
     $co->proceed();
     $this->assertTrue($DB->record_exists('course', array('shortname' => 'c1')));
     $course = $DB->get_record('course', array('shortname' => 'c1'));
     $ctx = context_course::instance($course->id);
     $this->assertEquals($data['fullname'], $course->fullname);
     $this->assertEquals($data['category'], $course->category);
     $this->assertEquals($data['visible'], $course->visible);
     $this->assertEquals(mktime(0, 0, 0, 6, 8, 1990), $course->startdate);
     $this->assertEquals($data['idnumber'], $course->idnumber);
     $this->assertEquals($data['summary'], $course->summary);
     $this->assertEquals($data['format'], $course->format);
     $this->assertEquals($data['theme'], $course->theme);
     $this->assertEquals($data['lang'], $course->lang);
     $this->assertEquals($data['newsitems'], $course->newsitems);
     $this->assertEquals($data['showgrades'], $course->showgrades);
     $this->assertEquals($data['showreports'], $course->showreports);
     $this->assertEquals($data['legacyfiles'], $course->legacyfiles);
     $this->assertEquals($data['maxbytes'], $course->maxbytes);
     $this->assertEquals($data['groupmode'], $course->groupmode);
     $this->assertEquals($data['groupmodeforce'], $course->groupmodeforce);
     $this->assertEquals($data['enablecompletion'], $course->enablecompletion);
     $this->assertEquals($data['tags'], join(', ', core_tag_tag::get_item_tags_array('core', 'course', $course->id)));
     // Roles.
     $roleids = array();
     $roles = get_all_roles();
     foreach ($roles as $role) {
         $roleids[$role->shortname] = $role->id;
     }
     $this->assertEquals('Knight', $DB->get_field_select('role_names', 'name', 'roleid = :roleid AND contextid = :ctxid', array('ctxid' => $ctx->id, 'roleid' => $roleids['teacher'])));
     $this->assertEquals('Jedi', $DB->get_field_select('role_names', 'name', 'roleid = :roleid AND contextid = :ctxid', array('ctxid' => $ctx->id, 'roleid' => $roleids['manager'])));
     // Enrolment methods.
     $enroldata = array();
     $instances = enrol_get_instances($course->id, false);
     $this->assertCount(3, $instances);
     foreach ($instances as $instance) {
         $enroldata[$instance->enrol] = $instance;
     }
     $this->assertNotEmpty($enroldata['guest']);
     $this->assertEquals(ENROL_INSTANCE_ENABLED, $enroldata['guest']->status);
     $this->assertNotEmpty($enroldata['self']);
     $this->assertEquals($data['enrolment_2_roleid'], $enroldata['self']->roleid);
     $this->assertEquals(ENROL_INSTANCE_ENABLED, $enroldata['self']->status);
     $this->assertNotEmpty($enroldata['manual']);
     $this->assertEquals(ENROL_INSTANCE_DISABLED, $enroldata['manual']->status);
     // Update existing course.
     $cat = $this->getDataGenerator()->create_category();
     $mode = tool_uploadcourse_processor::MODE_UPDATE_ONLY;
     $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
     $data = array('shortname' => 'c1', 'fullname' => 'Fullname 2', 'category' => $cat->id, 'visible' => '1', 'startdate' => '11 June 1984', 'idnumber' => 'changeidn', 'summary' => 'Summary 2', 'format' => 'topics', 'theme' => 'clean', 'lang' => '', 'newsitems' => '2', 'showgrades' => '1', 'showreports' => '0', 'legacyfiles' => '0', 'maxbytes' => '4321', 'groupmode' => '1', 'groupmodeforce' => '0', 'enablecompletion' => '0', 'role_teacher' => 'Teacher', 'role_manager' => 'Manager', 'enrolment_1' => 'guest', 'enrolment_1_disable' => '1', 'enrolment_2' => 'self', 'enrolment_2_roleid' => '2', 'enrolment_3' => 'manual', 'enrolment_3_delete' => '1');
     $this->assertTrue($DB->record_exists('course', array('shortname' => 'c1')));
     $co = new tool_uploadcourse_course($mode, $updatemode, $data);
     $this->assertTrue($co->prepare());
     $co->proceed();
     $course = $DB->get_record('course', array('shortname' => 'c1'));
     $ctx = context_course::instance($course->id);
     $this->assertEquals($data['fullname'], $course->fullname);
     $this->assertEquals($data['category'], $course->category);
     $this->assertEquals($data['visible'], $course->visible);
     $this->assertEquals(mktime(0, 0, 0, 6, 11, 1984), $course->startdate);
     $this->assertEquals($data['idnumber'], $course->idnumber);
     $this->assertEquals($data['summary'], $course->summary);
     $this->assertEquals($data['format'], $course->format);
     $this->assertEquals($data['theme'], $course->theme);
     $this->assertEquals($data['lang'], $course->lang);
     $this->assertEquals($data['newsitems'], $course->newsitems);
     $this->assertEquals($data['showgrades'], $course->showgrades);
     $this->assertEquals($data['showreports'], $course->showreports);
     $this->assertEquals($data['legacyfiles'], $course->legacyfiles);
     $this->assertEquals($data['maxbytes'], $course->maxbytes);
     $this->assertEquals($data['groupmode'], $course->groupmode);
     $this->assertEquals($data['groupmodeforce'], $course->groupmodeforce);
     $this->assertEquals($data['enablecompletion'], $course->enablecompletion);
     // Roles.
     $roleids = array();
     $roles = get_all_roles();
     foreach ($roles as $role) {
         $roleids[$role->shortname] = $role->id;
     }
     $this->assertEquals('Teacher', $DB->get_field_select('role_names', 'name', 'roleid = :roleid AND contextid = :ctxid', array('ctxid' => $ctx->id, 'roleid' => $roleids['teacher'])));
     $this->assertEquals('Manager', $DB->get_field_select('role_names', 'name', 'roleid = :roleid AND contextid = :ctxid', array('ctxid' => $ctx->id, 'roleid' => $roleids['manager'])));
     // Enrolment methods.
     $enroldata = array();
     $instances = enrol_get_instances($course->id, false);
     $this->assertCount(2, $instances);
     foreach ($instances as $instance) {
         $enroldata[$instance->enrol] = $instance;
     }
     $this->assertNotEmpty($enroldata['guest']);
     $this->assertEquals(ENROL_INSTANCE_DISABLED, $enroldata['guest']->status);
//.........这里部分代码省略.........
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:course_test.php


示例13: get_setting

 /**
  * Returns the current setting if it is set
  *
  * @return mixed null if null, else an array
  */
 public function get_setting()
 {
     $roles = role_fix_names(get_all_roles());
     $result = array();
     foreach ($roles as $role) {
         $contexts = $this->config_read('contexts_role' . $role->id);
         $memberattribute = $this->config_read('memberattribute_role' . $role->id);
         $result[] = array('id' => $role->id, 'name' => $role->localname, 'contexts' => $contexts, 'memberattribute' => $memberattribute);
     }
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:16,代码来源:settingslib.php


示例14: admin_externalpage

     $ADMIN->add('accounts', new admin_externalpage('cohorts', new lang_string('cohorts', 'cohort'), $CFG->wwwroot . '/cohort/index.php', array('moodle/cohort:manage', 'moodle/cohort:view')));
 }
 // stuff under the "roles" subcategory
 // "userpolicies" settingpage
 $temp = new admin_settingpage('userpolicies', new lang_string('userpolicies', 'admin'));
 if ($ADMIN->fulltree) {
     if (!during_initial_install()) {
         $context = context_system::instance();
         $otherroles = array();
         $guestroles = array();
         $userroles = array();
         $creatornewroles = array();
         $defaultteacherid = null;
         $defaultuserid = null;
         $defaultguestid = null;
         $roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT);
         foreach ($roles as $role) {
             $rolename = $role->localname;
             switch ($role->archetype) {
                 case 'manager':
                     $creatornewroles[$role->id] = $rolename;
                     break;
                 case 'coursecreator':
                     break;
                 case 'editingteacher':
                     $defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
                     $creatornewroles[$role->id] = $rolename;
                     break;
                 case 'teacher':
                     $creatornewroles[$role->id] = $rolename;
                     break;
开发者ID:vinoth4891,项目名称:clinique,代码行数:31,代码来源:users.php


示例15: set_config

             set_config('creatornewroleid', 0);
         }
     }
     if (!($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW))) {
         $guestroles = array();
         $defaultguestid = null;
     } else {
         $defaultguestid = reset($guestroles);
         $defaultguestid = $defaultguestid->id;
     }
     // we must not use assignable roles here:
     //   1/ unsetting roles as assignable for admin might bork the settings!
     //   2/ default user role should not be assignable anyway
     $allroles = array();
     $nonguestroles = array();
     if ($roles = get_all_roles()) {
         foreach ($roles as $role) {
             $rolename = strip_tags(format_string($role->name, true));
             $allroles[$role->id] = $rolename;
             if (!isset($guestroles[$role->id])) {
                 $nonguestroles[$role->id] = $rolename;
             }
         }
     }
     $temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'), get_string('confignotloggedinroleid', 'admin'), $defaultguestid, $allroles));
     $temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'), get_string('configguestroleid', 'admin'), $defaultguestid, $allroles));
     $temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'), get_string('configdefaultuserroleid', 'admin'), $userrole->id, $nonguestroles));
     // guest role here breaks a lot of stuff
 }
 // enable auto assign role LPC #2 in "Yesumy lemida" category #7 (nadavkav)
 $temp->add(new admin_setting_configcheckbox('autoassignlpctocategory', get_string('autoassignlpctocategory', 'admin'), get_string('configautoassignlpctocategory', 'admin'), 1));
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:users.php


示例16: load_choices

 /**
  * Load roles as choices
  *
  * @return bool true=>success, false=>error
  */
 public function load_choices()
 {
     global $CFG, $DB;
     if (during_initial_install()) {
         return false;
     }
     if (is_array($this->choices)) {
         return true;
     }
     if ($roles = get_all_roles()) {
         $this->choices = role_fix_names($roles, null, ROLENAME_ORIGINAL, true);
         return true;
     } else {
         return false;
     }
 }
开发者ID:Alexbado,项目名称:moodle2,代码行数:21,代码来源:adminlib.php


示例17: url_get_variable_values

/**
 * Get the parameter values that may be appended to URL
 * @param object $url module instance
 * @param object $cm
 * @param object $course
 * @param object $config module config options
 * @return array of parameter values
 */
function url_get_variable_values($url, $cm, $course, $config)
{
    global $USER, $CFG;
    $site = get_site();
    $coursecontext = context_course::instance($course->id);
    $values = array('courseid' => $course->id, 'coursefullname' => format_string($course->fullname), 'courseshortname' => format_string($course->shortname, true, array('context' => $coursecontext)), 'courseidnumber' => $course->idnumber, 'coursesummary' => $course->summary, 'courseformat' => $course->format, 'lang' => current_language(), 'sitename' => format_string($site->fullname), 'serverurl' => $CFG->wwwroot, 'currenttime' => time(), 'urlinstance' => $url->id, 'urlcmid' => $cm->id, 'urlname' => format_string($url->name), 'urlidnumber' => $cm->idnumber);
    if (isloggedin()) {
        $values['userid'] = $USER->id;
        $values['userusername'] = $USER->username;
        $values['useridnumber'] = $USER->idnumber;
        $values['userfirstname'] = $USER->firstname;
        $values['userlastname'] = $USER->lastname;
        $values['userfullname'] = fullname($USER);
        $values['useremail'] = $USER->email;
        $values['usericq'] = $USER->icq;
        $values['userphone1'] = $USER->phone1;
        $values['userphone2'] = $USER->phone2;
        $values['userinstitution'] = $USER->institution;
        $values['userdepartment'] = $USER->department;
        $values['useraddress'] = $USER->address;
        $values['usercity'] = $USER->city;
        $now = new DateTime('now', core_date::get_user_timezone_object());
        $values['usertimezone'] = $now->getOffset() / 3600.0;
        // Value in hours for BC.
        $values['userurl'] = $USER->url;
    }
    // weak imitation of Single-Sign-On, for backwards compatibility only
    // NOTE: login hack is not included in 2.0 any more, new contrib auth plugin
    //       needs to be createed if somebody needs the old functionality!
    if (!empty($config->secretphrase)) {
        $values['encryptedcode'] = url_get_encrypted_parameter($url, $config);
    }
    //hmm, this is pretty fragile and slow, why do we need it here??
    if ($config->rolesinparams) {
        $coursecontext = context_course::instance($course->id);
        $roles = role_fix_names(get_all_roles($coursecontext), $coursecontext, ROLENAME_ALIAS);
        foreach ($roles as $role) {
            $values['course' . $role->shortname] = $role->localname;
        }
    }
    return $values;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:50,代码来源:locallib.php


示例18: test_enrol_ldap

 public function test_enrol_ldap()
 {
     global $CFG, $DB;
     if (!extension_loaded('ldap')) {
         $this->markTestSkipped('LDAP extension is not loaded.');
     }
     $this->resetAfterTest();
     require_once $CFG->dirroot . '/enrol/ldap/lib.php';
     require_once $CFG->libdir . '/ldaplib.php';
     if (!defined('TEST_ENROL_LDAP_HOST_URL') or !defined('TEST_ENROL_LDAP_BIND_DN') or !defined('TEST_ENROL_LDAP_BIND_PW') or !defined('TEST_ENROL_LDAP_DOMAIN')) {
         $this->markTestSkipped('External LDAP test server not configured.');
     }
     // Make sure we can connect the server.
     $debuginfo = '';
     if (!($connection = ldap_connect_moodle(TEST_ENROL_LDAP_HOST_URL, 3, 'rfc2307', TEST_ENROL_LDAP_BIND_DN, TEST_ENROL_LDAP_BIND_PW, LDAP_DEREF_NEVER, $debuginfo, false))) {
         $this->markTestSkipped('Can not connect to LDAP test server: ' . $debuginfo);
     }
     $this->enable_plugin();
     // Create new empty test container.
     $topdn = 'dc=moodletest,' . TEST_ENROL_LDAP_DOMAIN;
     $this->recursive_delete($connection, TEST_ENROL_LDAP_DOMAIN, 'dc=moodletest');
     $o = array();
     $o['objectClass'] = array('dcObject', 'organizationalUnit');
     $o['dc'] = 'moodletest';
     $o['ou'] = 'MOODLETEST';
     if (!ldap_add($connection, 'dc=moodletest,' . TEST_ENROL_LDAP_DOMAIN, $o)) {
         $this->markTestSkipped('Can not create test LDAP container.');
     }
     // Configure enrol plugin.
     /** @var enrol_ldap_plugin $enrol */
     $enrol = enrol_get_plugin('ldap');
     $enrol->set_config('host_url', TEST_ENROL_LDAP_HOST_URL);
     $enrol->set_config('start_tls', 0);
     $enrol->set_config('ldap_version', 3);
     $enrol->set_config('ldapencoding', 'utf-8');
     $enrol->set_config('page_size', '2');
     $enrol->set_config('bind_dn', TEST_ENROL_LDAP_BIND_DN);
     $enrol->set_config('bind_pw', TEST_ENROL_LDAP_BIND_PW);
     $enrol->set_config('course_search_sub', 0);
     $enrol->set_config('memberattribute_isdn', 0);
     $enrol->set_config('user_contexts', '');
     $enrol->set_config('user_search_sub', 0);
     $enrol->set_config('user_type', 'rfc2307');
     $enrol->set_config('opt_deref', LDAP_DEREF_NEVER);
     $enrol->set_config('objectclass', '(objectClass=posixGroup)');
     $enrol->set_config('course_idnumber', 'cn');
     $enrol->set_config('course_shortname', 'cn');
     $enrol->set_config('course_fullname', 'cn');
     $enrol->set_config('course_summary', '');
     $enrol->set_config('ignorehiddencourses', 0);
     $enrol->set_config('nested_groups', 0);
     $enrol->set_config('autocreate', 0);
     $enrol->set_config('unenrolaction', ENROL_EXT_REMOVED_KEEP);
     $roles = get_all_roles();
     foreach ($roles as $role) {
         $enrol->set_config('contexts_role' . $role->id, '');
         $enrol->set_config('memberattribute_role' . $role->id, '');
     }
     // Create group for teacher enrolments.
     $teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
     $this->assertNotEmpty($teacherrole);
     $o = array();
     $o['objectClass'] = array('organizationalUnit');
     $o['ou'] = 'teachers';
     ldap_add($connection, 'ou=teachers,' . $topdn, $o);
     $enrol->set_config('contexts_role' . $teacherrole->id, 'ou=teachers,' . $topdn);
     $enrol->set_config('memberattribute_role' . $teacherrole->id, 'memberuid');
     // Create group for student enrolments.
     $studentrole = $DB->get_record('role', array('shortname' => 'student'));
     $this->assertNotEmpty($studentrole);
     $o = array();
     $o['objectClass'] = array('organizationalUnit');
     $o['ou'] = 'students';
     ldap_add($connection, 'ou=students,' . $topdn, $o);
     $enrol->set_config('contexts_role' . $studentrole->id, 'ou=students,' . $topdn);
     $enrol->set_config('memberattribute_role' . $studentrole->id, 'memberuid');
     // Create some users and courses.
     $user1 = $this->getDataGenerator()->create_user(array('idnumber' => 'user1', 'username' => 'user1'));
     $user2 = $this->getDataGenerator()->create_user(array('idnumber' => 'user2', 'username' => 'user2'));
     $user3 = $this->getDataGenerator()->create_user(array('idnumber' => 'user3', 'username' => 'user3'));
     $user4 = $this->getDataGenerator()->create_user(array('idnumber' => 'user4', 'username' => 'user4'));
     $user5 = $this->getDataGenerator()->create_user(array('idnumber' => 'user5', 'username' => 'user5'));
     $user6 = $this->getDataGenerator()->create_user(array('idnumber' => 'user6', 'username' => 'user6'));
     $course1 = $this->getDataGenerator()->create_course(array('idnumber' => 'course1', 'shortname' => 'course1'));
     $course2 = $this->getDataGenerator()->create_course(array('idnumber' => 'course2', 'shortname' => 'course2'));
     $course3 = $this->getDataGenerator()->create_course(array('idnumber' => 'course3', 'shortname' => 'course3'));
     // Set up some ldap data.
     $o = array();
     $o['objectClass'] = array('posixGroup');
     $o['cn'] = 'course1';
     $o['gidNumber'] = '1';
     $o['memberUid'] = array('user1', 'user2', 'user3', 'userx');
     ldap_add($connection, 'cn=' . $o['cn'] . ',ou=students,' . $topdn, $o);
     $o = array();
     $o['objectClass'] = array('posixGroup');
     $o['cn'] = 'course1';
     $o['gidNumber'] = '2';
     $o['memberUid'] = array('user5');
     ldap_add($connection, 'cn=' . $o['cn'] . ',ou=teachers,' . $topdn, $o);
     $o = array();
//.........这里部分代码省略.........
开发者ID:pzhu2004,项目名称:moodle,代码行数:101,代码来源:ldap_test.php


示例19: sync_enrolments

 /**
  * Forces synchronisation of all enrolments with external database.
  *
  * @param bool $verbose
  * @param null|int $onecourse limit sync to one course only (used primarily in restore)
  * @return int 0 means success, 1 db connect failure, 2 db read failure
  */
 public function sync_enrolments($verbose = false, $onecourse = null)
 {
     global $CFG, $DB;
     // We do not create courses here intentionally because it requires full sync and is slow.
     if (!$this->get_config('dbtype') or !$this->get_config('dbhost') or !$this->get_config('remoteenroltable') or !$this->get_config('remotecoursefield') or !$this->get_config('remoteuserfield')) {
         if ($verbose) {
             mtrace('User enrolment synchronisation skipped.');
         }
         return 0;
     }
     if ($verbose) {
         mtrace('Starting user enrolment synchronisation...');
     }
     if (!($extdb = $this->db_init())) {
         mtrace('Error while communicating with external enrolment database');
         return 1;
     }
     // We may need a lot of memory here.
     @set_time_limit(0);
     raise_memory_limit(MEMORY_HUGE);
     $table = $this->get_config('remoteenroltable');
     $coursefield = trim($this->get_config('remotecoursefield'));
     $userfield = trim($this->get_config('remoteuserfield'));
     $rolefield = trim($this->get_config('remoterolefield'));
     // Lowercased versions - necessary because we normalise the resultset with array_change_key_case().
     $coursefield_l = strtolower($coursefield);
     $userfield_l = strtolower($userfield);
     $rolefield_l = strtolower($rolefield);
     $localrolefield = $this->get_config('localrolefield');
     $localuserfield = $this->get_config('localuserfield');
     $localcoursefield = $this->get_config('localcoursefield');
     $unenrolaction = $this->get_config('unenrolaction');
     $defaultrole = $this->get_config('defaultrole');
     // Create roles mapping.
     $allroles = get_all_roles();
     if (!isset($allroles[$defaultrole])) {
         $defaultrole = 0;
     }
     

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_all_sections函数代码示例发布时间:2022-05-15
下一篇:
PHP get_all_post_type_supports函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap