当前位置: 首页>>代码示例>>PHP>>正文


PHP user::get_moodleuser方法代码示例

本文整理汇总了PHP中user::get_moodleuser方法的典型用法代码示例。如果您正苦于以下问题:PHP user::get_moodleuser方法的具体用法?PHP user::get_moodleuser怎么用?PHP user::get_moodleuser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user的用法示例。


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

示例1: test_customusersetthemectx

 /**
  * Test custom userset theme assignment.
  */
 public function test_customusersetthemectx()
 {
     $this->load_csv_data();
     // ELIS user with the associated moodle user.
     $user = new user(103);
     $muser = $user->get_moodleuser();
     // Userset with a custom theme.
     $userset = new userset(1);
     $userset->field__elis_userset_theme = 'formal_white';
     $userset->field__elis_userset_themepriority = 1;
     $userset->save();
     // Assign the user to the user set.
     $usersetassign = new clusterassignment();
     $usersetassign->userid = $user->id;
     $usersetassign->clusterid = $userset->id;
     $usersetassign->save();
     // Pretend to be that user.
     $this->setUser($muser->id);
     // Initialize page.
     $page = new moodle_page();
     $page->initialise_theme_and_output();
     // Assert we have our theme.
     $this->assertEquals('formal_white', $page->theme->name);
     $this->setUser(null);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:28,代码来源:customusersettheme_test.php

示例2: test_block_elisadmin_load_menu_children_course

 /**
  * Test block_elisadmin_load_menu_children_course function.
  */
 public function test_block_elisadmin_load_menu_children_course()
 {
     global $DB, $USER;
     accesslib_clear_all_caches(true);
     // Create test user - ensure the returned user is NOT a site admin. if they are, our capability restrictions won't work.
     $testuser = new user();
     $testuser->username = 'testELIS4093';
     $testuser->idnumber = 'testELIS4093';
     $testuser->firstname = 'testELIS4093';
     $testuser->lastname = 'testELIS4093';
     $testuser->email = 'testELIS4093@example.com';
     $testuser->country = 'CA';
     $testuser->save();
     $testmuser = $testuser->get_moodleuser();
     // Create role with cap: 'local/elisprogram:class_view'.
     $testrole = new stdClass();
     $testrole->name = 'ELIS Class View';
     $testrole->shortname = '_test_ELIS_4093';
     $testrole->description = 'ELIS Class View';
     $testrole->archetype = '';
     $testrole->id = create_role($testrole->name, $testrole->shortname, $testrole->description, $testrole->archetype);
     // Ensure our new role is assignable to ELIS class contexts.
     set_role_contextlevels($testrole->id, array(CONTEXT_ELIS_CLASS));
     // Ensure the role has our required capability assigned.
     $sitecontext = context_system::instance();
     assign_capability('local/elisprogram:class_view', CAP_ALLOW, $testrole->id, $sitecontext->id, true);
     $sitecontext->mark_dirty();
     // Create ELIS Course Description.
     $testcrs = new course(array('name' => 'CD-ELIS-4093', 'idnumber' => 'CDELIS4093', 'syllabus' => ''));
     $testcrs->save();
     $testcrs->load();
     // Create three(3) Class Instances for Course Descrption.
     $testcls1 = new pmclass(array('courseid' => $testcrs->id, 'idnumber' => 'CI_ELIS_4093.1'));
     $testcls1->save();
     $testcls1->load();
     $testcls2 = new pmclass(array('courseid' => $testcrs->id, 'idnumber' => 'CI_ELIS_4093.2'));
     $testcls2->save();
     $testcls2->load();
     $testcls3 = new pmclass(array('courseid' => $testcrs->id, 'idnumber' => 'CI_ELIS_4093.3'));
     $testcls3->save();
     $testcls3->load();
     // Assign testuser new role in one Class Instance.
     $context = \local_elisprogram\context\pmclass::instance($testcls2->id);
     role_assign($testrole->id, $testmuser->id, $context->id);
     // Switch to testuser.
     $USER = $testmuser;
     $this->setUser($testmuser);
     $items = block_elisadmin_load_menu_children_course($testcrs->id, 0, 0, 5, '');
     $this->assertEquals(1, count($items));
     $this->assertTrue($items[0]->name == 'pmclass_2');
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:54,代码来源:block_elisadmin_test.php

示例3: test_mapping_applied_during_user_enrolment_delete

 /**
  * Validate that mappings are applied during the user enrolment (role assignment) delete action
  */
 public function test_mapping_applied_during_user_enrolment_delete()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/accesslib.php';
     $this->init_mapping();
     $userid = $this->create_test_user();
     $user = new user($userid);
     $user->load();
     $muser = $user->get_moodleuser();
     $roleid = create_role('testrolename', 'testroleshortname', 'testroledescription');
     $instance = context_user::instance($muser->id);
     role_assign($roleid, $muser->id, $instance->id);
     // Run the user enrolment delete actions.
     $record = new stdClass();
     $record->customaction = 'delete';
     $record->customcontext = 'user_testuseridnumber';
     $record->customuser_username = 'testuserusername';
     $record->customuser_email = 'test@useremail.com';
     $record->customuser_idnumber = 'testuseridnumber';
     $record->customrole = 'testroleshortname';
     $this->run_enrolment_import((array) $record);
     // Validation.
     $this->assertEquals(0, $DB->count_records('role_assignments'));
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:27,代码来源:elis_enrolment_field_mappings_test.php

示例4: test_assignuserforusersetctx

 /**
  * ELIS-4749: Test for assigning a user a role on a user context
  */
 public function test_assignuserforusersetctx()
 {
     global $DB;
     // Get role to assign (we'll just take the first one returned).
     $rolesctx = $DB->get_records('role_context_levels', array('contextlevel' => CONTEXT_ELIS_USERSET));
     foreach ($rolesctx as $rolectx) {
         $roleid = $rolectx->roleid;
         break;
     }
     // Get user to assign role.
     $user = new user(103);
     $muser = $user->get_moodleuser();
     // Get specific context.
     $usrset = new userset(1);
     $context = \local_elisprogram\context\userset::instance($usrset->id);
     // Assign role.
     $this->assertGreaterThan(0, role_assign($roleid, $muser->id, $context->id));
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:21,代码来源:roleassignments_test.php

示例5: view_form_html


//.........这里部分代码省略.........
                 }
                 if (isset($selection->unenrol) && $selection->unenrol === true) {
                     $unenrol = $selection->unenrol;
                 }
                 if (isset($selection->locked) && $selection->locked === true) {
                     $locked = $selection->locked;
                 }
                 if (isset($selection->credits)) {
                     $credits = $selection->credits;
                 }
                 if (isset($selection->grade)) {
                     $grade = $selection->grade;
                 }
                 if (isset($selection->status)) {
                     $status = $selection->status;
                 }
                 if (isset($selection->enrolment_date)) {
                     $enrolmenttime = pm_timestamp(0, 0, 0, $selection->enrolment_date->month, $selection->enrolment_date->day, $selection->enrolment_date->year);
                 }
                 if (isset($selection->completion_date)) {
                     $completetime = pm_timestamp(0, 0, 0, $selection->completion_date->month, $selection->completion_date->day, $selection->completion_date->year);
                 }
                 $changed = true;
             }
             $tabobj = new stdClass();
             foreach ($columns as $column => $cdesc) {
                 switch ($column) {
                     case 'select':
                         $tabobj->{$column} = '<input type="checkbox" onclick="select_item(' . $user->id . ')" name="users[' . $user->id . '][selected]" ' . 'value="1" id="selected' . $user->id . '" ' . ($selected ? 'checked="checked" ' : ' ') . 'onchange="proxy_select(' . $user->id . ')"/>';
                         break;
                     case 'unenrol':
                         if (!empty($mcourse)) {
                             $userobj = new user($user);
                             $muser = $userobj->get_moodleuser();
                             if (!empty($muser)) {
                                 $role_assignment_exists = $this->_db->record_exists_select('role_assignments', "userid = ? AND contextid = ? AND component != 'enrol_elis'", array($muser->id, $ctx->id));
                                 if ($role_assignment_exists) {
                                     // user is assigned a role other than via the elis
                                     // enrolment plugin
                                     $tabobj->{$column} = '';
                                     break;
                                 }
                             }
                         }
                         $tabobj->{$column} = '<input type="checkbox" id="unenrol' . $user->id . '" name="users[' . $user->id . '][unenrol]" ' . 'value="1" onchange="proxy_select(' . $user->id . ')" ' . ($unenrol ? 'checked="checked" ' : ' ') . '/>';
                         break;
                     case 'name':
                     case 'idnumber':
                     case 'description':
                         $tabobj->{$column} = $user->{$column};
                         break;
                     case 'enrolmenttime':
                         $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][startday]', 'users[' . $user->id . '][startmonth]', 'users[' . $user->id . '][startyear]', $enrolmenttime, true, 'proxy_select(' . $user->id . ')');
                         break;
                     case 'completetime':
                         $tabobj->{$column} = cm_print_date_selector('users[' . $user->id . '][endday]', 'users[' . $user->id . '][endmonth]', 'users[' . $user->id . '][endyear]', $completetime, true, 'proxy_select(' . $user->id . ')');
                         break;
                     case 'completestatusid':
                         $choices = array();
                         foreach (student::$completestatusid_values as $key => $csidv) {
                             $choices[$key] = get_string($csidv, self::LANG_FILE);
                         }
                         $tabobj->{$column} = cm_choose_from_menu($choices, 'users[' . $user->id . '][completestatusid]', $status, '', 'proxy_select(' . $user->id . ')', '', true);
                         break;
                     case 'grade':
                         $tabobj->{$column} = '<input type="text" id="grade' . $user->id . '" id="locked' . $user->id . '" ' . 'name="users[' . $user->id . '][grade]" value="' . $grade . '" ' . 'size="5" onchange="proxy_select(' . $user->id . ')" />';
开发者ID:jamesmcq,项目名称:elis,代码行数:67,代码来源:student.class.php

示例6: test_version1importnewenrolmentemail

 /**
  * Test main newenrolmentemail() function.
  */
 public function test_version1importnewenrolmentemail()
 {
     global $CFG, $DB;
     // This is needed by the required files.
     require_once dirname(__FILE__) . '/other/rlip_importplugin_version1elis_fakeemail.php';
     $importplugin = new rlip_importplugin_version1elis_fakeemail();
     // Create Moodle course.
     $course = $this->getDataGenerator()->create_course();
     // Enrol some students into Moodle course.
     $user2 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user2->id, $course->id);
     $user3 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user3->id, $course->id);
     // Enrol teachers into Moodle course.
     $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher'));
     $teacher = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
     $teacher2 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($teacher2->id, $course->id, $teacherrole->id);
     // Create ELIS class and ELIS user.
     $ecourse = new course(array('name' => 'Test Course', 'idnumber' => 'CRS100', 'syllabus' => ''));
     $ecourse->save();
     $eclass = new pmclass(array('idnumber' => 'CLS100', 'courseid' => $ecourse->id));
     $eclass->save();
     $euser = new user(array('username' => 'testuser', 'idnumber' => 'testuser', 'firstname' => 'Test', 'lastname' => 'User', 'email' => 'testuser@example.com', 'city' => 'Waterloo', 'country' => 'CA'));
     $euser->save();
     $muser = $euser->get_moodleuser();
     // Create student object for elis user/elis class.
     $student = new student(array('userid' => $euser->id, 'classid' => $eclass->id));
     // Test false return when student "no_moodle_enrol" is set.
     $student->no_moodle_enrol = true;
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     $student->no_moodle_enrol = false;
     // Test false return when ELIS class is not linked to Moodle course.
     $DB->delete_records(classmoodlecourse::TABLE, array('classid' => $eclass->id, 'moodlecourseid' => $course->id));
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     // Test false return when ELIS class is linked to a Moodle course, but Moodle course does not exist.
     $cmcid = $DB->insert_record(classmoodlecourse::TABLE, array('classid' => $eclass->id, 'moodlecourseid' => 999999999));
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     $DB->update_record(classmoodlecourse::TABLE, array('id' => $cmcid, 'moodlecourseid' => $course->id));
     // Test false return when ELIS user is not linked to Moodle user.
     $DB->delete_records(usermoodle::TABLE, array('cuserid' => $euser->id, 'muserid' => $muser->id));
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     // Test false return when ELIS user is linked to Moodle user, but Moodle user does not exist.
     $usermoodleid = $DB->insert_record(usermoodle::TABLE, array('cuserid' => $euser->id, 'muserid' => 99999999));
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     $DB->update_record(usermoodle::TABLE, array('id' => $usermoodleid, 'muserid' => $muser->id));
     // Test false return when not enabled.
     set_config('newenrolmentemailenabled', '0', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', 'Test Subject', 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', 'Test Body', 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'teacher', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     // Test false return when enabled but empty template.
     set_config('newenrolmentemailenabled', '1', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', 'Test Subject', 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', '', 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'teacher', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     // Test success when enabled, has template text, and user has email.
     $testsubject = 'Test Subject';
     $testbody = 'Test Body';
     set_config('newenrolmentemailenabled', '1', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', $testsubject, 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', $testbody, 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'admin', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertNotEmpty($result);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('user', $result);
     $this->assertEquals($muser, $result['user']);
     $this->assertArrayHasKey('from', $result);
     $this->assertEquals(get_admin(), $result['from']);
     $this->assertArrayHasKey('subject', $result);
     $this->assertEquals($testsubject, $result['subject']);
     $this->assertArrayHasKey('body', $result);
     $this->assertEquals($testbody, $result['body']);
     // Test success and from is set to teacher when selected.
     $testsubject = 'Test Subject';
     $testbody = 'Test Body';
     set_config('newenrolmentemailenabled', '1', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', $testsubject, 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', $testbody, 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'teacher', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertNotEmpty($result);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('user', $result);
     $this->assertEquals($muser, $result['user']);
     $this->assertArrayHasKey('from', $result);
//.........这里部分代码省略.........
开发者ID:jamesmcq,项目名称:elis,代码行数:101,代码来源:elis_notifications_test.php

示例7: test_notifications

 /**
  * Test contexts in notifications.
  *
  * Covers:
  * local/elisprogram/lib/notifications.php:616
  * local/elisprogram/lib/notifications.php:617
  */
 public function test_notifications()
 {
     global $DB;
     $this->setup_users();
     context_helper::reset_caches();
     elis::$config->local_elisprogram->notify_classenrol_user = true;
     $rolesctx = $DB->get_records('role_context_levels', array('contextlevel' => CONTEXT_ELIS_PROGRAM));
     foreach ($rolesctx as $rolectx) {
         $roleid = $rolectx->roleid;
         break;
     }
     // Get user to assign role.
     $user = new user(103);
     $muser = $user->get_moodleuser();
     // Get specific context.
     $cur = $this->create_curriculum();
     $context = \local_elisprogram\context\program::instance($cur->id);
     // Assign role.
     $raid = role_assign($roleid, $muser->id, $context);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:27,代码来源:miscellaneouscontexts_test.php

示例8: pm_notify_instructor_unassigned_handler

/**
 *
 * Takes an instructor unassignment and deletes the appropriate
 * Moodle course role assignments
 *
 * @param  stdClass  $eventdata  The appropriate local_elisprogram_cls_nstrct record
 * @return bool always returns true
 */
function pm_notify_instructor_unassigned_handler($eventdata)
{
    global $CFG, $DB;
    require_once elispm::lib('data/user.class.php');
    // make sure users in some roles are identified as course managers
    if (empty($CFG->coursecontact)) {
        return true;
    }
    // create the curriculum administration class
    try {
        if (!($pmclass = new pmclass($eventdata->classid))) {
            return true;
        }
    } catch (dml_missing_record_exception $e) {
        // record does not exists, so no need to sync
        return true;
    }
    // ensure that the class is tied to a Moodle course
    $moodlecourseid = $pmclass->get_moodle_course_id();
    if (empty($moodlecourseid)) {
        return true;
    }
    // retrieve the context for the Moodle course
    $coursecontext = context_course::instance($moodlecourseid);
    if (!$coursecontext) {
        return true;
    }
    // make sure the Moodle course is not tied to other curriculum administration classes
    if ($DB->count_records(classmoodlecourse::TABLE, array('moodlecourseid' => $moodlecourseid)) != 1) {
        return true;
    }
    // Retrieve the Moodle user
    $cmuser = new user();
    $cmuser->id = $eventdata->userid;
    $instructor = $cmuser->get_moodleuser();
    if (!$instructor) {
        return true;
    }
    // Go through all applicable roles to see if we can remove them from the Moodle side of things
    $roleids = explode(',', $CFG->coursecontact);
    $course = new stdClass();
    $course->id = $coursecontext->instanceid;
    // Loop through each of the course contact roles, check if they have the role assignment, unenroll them and remove it
    foreach ($roleids as $roleid) {
        $hasroleassignment = user_has_role_assignment($instructor->id, $roleid, $coursecontext->id);
        if ($hasroleassignment) {
            // This method  unenrolls and removes all of the user's roles from the course @see role_unassign_all()
            $plugin = enrol_get_plugin('elis');
            $enrolinstance = $plugin->get_or_create_instance($course);
            $plugin->unenrol_user($enrolinstance, $instructor->id);
        }
    }
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:62,代码来源:notifications.php

示例9: newenrolmentemail

 /**
  * Send an email to the user when they are enroled.
  *
  * @param student $student The student object of for the enrolment.
  * @return bool Success/Failure.
  */
 public function newenrolmentemail(student $student)
 {
     global $DB;
     if (!empty($student->no_moodle_enrol)) {
         return false;
     }
     // Look for attached Moodle course, and get the course info.
     $moodlecourseid = moodle_get_course($student->classid);
     if (empty($moodlecourseid)) {
         return false;
     }
     $course = $DB->get_record('course', array('id' => $moodlecourseid));
     if (empty($course)) {
         return false;
     }
     // Get the elis user and the moodle user.
     $user = new user($student->userid);
     $muser = $user->get_moodleuser();
     if (empty($muser)) {
         return false;
     }
     // Check whether emails are enabled.
     $enabled = get_config('dhimport_version1elis', 'newenrolmentemailenabled');
     if (empty($enabled)) {
         return false;
     }
     // Check whether email text has been set.
     $template = get_config('dhimport_version1elis', 'newenrolmentemailtemplate');
     if (empty($template)) {
         return false;
     }
     // Ensure Moodle user has an email address.
     if (empty($muser->email)) {
         return false;
     }
     // Get the email subject line, set an empty string if necessary.
     $subject = get_config('dhimport_version1elis', 'newenrolmentemailsubject');
     if (empty($subject) || !is_string($subject)) {
         $subject = '';
     }
     // Get the user the email will be from.
     $from = get_config('dhimport_version1elis', 'newenrolmentemailfrom');
     if ($from === 'teacher') {
         $context = context_course::instance($course->id);
         $cap = 'moodle/course:update';
         if ($users = get_users_by_capability($context, $cap, 'u.*', 'u.id ASC', '', '', '', '', false, true)) {
             $users = sort_by_roleassignment_authority($users, $context);
             $from = current($users);
         } else {
             $from = get_admin();
         }
     } else {
         $from = get_admin();
     }
     // Generate email.
     $body = $this->newenrolmentemail_generate($template, $muser, $course);
     // Send!
     return $this->sendemail($muser, $from, $subject, $body);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:65,代码来源:version1elis.class.php

示例10: elis_files_userset_deassigned

/**
 * Handle the event when a user is unassigned from a user set.
 *
 * @uses $DB
 * @param object $usersetinfo The ELIS crlm_cluster_assignments record object.
 * @return bool True on success or failure (event handlers must always return true).
 */
function elis_files_userset_deassigned($usersetinfo) {
    global $DB;

    // Only proceed here if we have valid userid,clusterid & the Alfresco plug-in is actually enabled.
    if (empty($usersetinfo->userid) || empty($usersetinfo->clusterid) ||
        !($repo = repository_factory::factory('elisfiles'))) {
        return true;
    }

    $user = new user($usersetinfo->userid);

    // Get the Moodle user info from the CM user record.
    if (!$muser = $user->get_moodleuser()) {
        return true;
    }

    if (!($userset = $DB->get_record(userset::TABLE, array('id' => $usersetinfo->clusterid)))) {
        return true;
    }

    if (!file_exists(elispm::file('plugins/usetclassify/usersetclassification.class.php'))) {
        return true;
    }

    require_once(elispm::file('plugins/usetclassify/usersetclassification.class.php'));

    // Get the extra user set data and ensure it is present before proceeding.
    $usersetdata = usersetclassification::get_for_cluster($userset);

    if (empty($usersetdata->params)) {
        return true;
    }

    $usersetparams = unserialize($usersetdata->params);

    // Make sure this user set has the Alfresco shared folder property defined
    if (empty($usersetparams['elis_files_shared_folder'])) {
        return true;
    }

    // Does this organization have an Alfresco storage space?
    if (!$uuid = $repo->get_userset_store($userset->id, false)) {
        return true;
    }

    $context = \local_elisprogram\context\userset::instance($userset->id);

    $sql = 'SELECT rc.*
            FROM {role_assignments} ra
            INNER JOIN {role} r ON ra.roleid = r.id
            INNER JOIN {role_capabilities} rc ON r.id = rc.roleid
            WHERE ra.contextid = :contextid
            AND ra.userid = :userid
            AND rc.capability IN (:cap1, :cap2)
            AND rc.permission = '.CAP_ALLOW;

    $params = array(
        'contextid' => $context->id,
        'userid'    => $muser->id,
        'cap1'      => 'repository/elisfiles:createusersetcontent',
        'cap2'      => 'local/elisprogram:userset_enrol'
    );

    // Check if the user has a specific role assignment on the user set context with the editing capability
    if ($DB->record_exists_sql($sql, $params)) {
        // Remove all non-editing permissions for this user on the organization shared space.
        if ($permissions = elis_files_get_permissions($uuid, $muser->username)) {
            foreach ($permissions as $permission) {
                // Do not remove editing permissions if this user still actually has a user set membership.
                if ($permission == ELIS_FILES_ROLE_COLLABORATOR) {
                    continue;
                }

                elis_files_set_permission($muser->username, $uuid, $permission, ELIS_FILES_CAPABILITY_DENIED);
            }
        }

    // Remove all permissions for this user on the organization shared space.
    } else if ($permissions = elis_files_get_permissions($uuid, $muser->username)) {
        require_once(elispm::lib('data/clusterassignment.class.php'));
        foreach ($permissions as $permission) {
            // Do not remove view permissions if this user still actually has a user set membership.
            $params = array(
                'userid'    => $usersetinfo->userid,
                'clusterid' => $userset->id
            );

            if ($permission == ELIS_FILES_ROLE_CONSUMER && $DB->record_exists(clusterassignment::TABLE, $params)) {
                continue;
            }

            elis_files_set_permission($muser->username, $uuid, $permission, ELIS_FILES_CAPABILITY_DENIED);
        }
//.........这里部分代码省略.........
开发者ID:jamesmcq,项目名称:elis,代码行数:101,代码来源:eventlib.php

示例11: user

 function can_do_delete()
 {
     global $USER;
     // make sure we don't delete the admin user, or ourselves
     $cuser = new user($this->required_param('id', PARAM_INT));
     $muser = $cuser->get_moodleuser();
     if (!isset($muser->id)) {
         //no corresponding Moodle user, so just check the capability
         return $this->_has_capability('local/elisprogram:user_delete');
     }
     return !is_primary_admin($muser->id) && $muser->id != $USER->id && $this->_has_capability('local/elisprogram:user_delete');
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:12,代码来源:userpage.class.php


注:本文中的user::get_moodleuser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。