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


PHP Institution::removeMembers方法代码示例

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


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

示例1: clean_institution

 /**
  * reset a test institution
  */
 protected function clean_institution()
 {
     // clean down the institution
     $dbinstitution = get_record("institution", 'name', $this->testinstitution);
     if (!empty($dbinstitution)) {
         db_begin();
         $institution = new Institution($this->testinstitution);
         $dbinvites = get_records_array('usr_institution_request', 'institution', $this->testinstitution);
         if (!empty($dbinvites)) {
             $userids = array();
             foreach ($dbinvites as $dbinvite) {
                 $userids[] = $dbinvite->usr;
             }
             $institution->decline_requests($userids);
         }
         $dbmembers = get_records_array('usr_institution', 'institution', $this->testinstitution);
         if (!empty($dbmembers)) {
             $userids = array();
             foreach ($dbmembers as $dbmember) {
                 $userids[] = $dbmember->usr;
             }
             $institution->removeMembers($userids);
         }
         db_commit();
     }
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:29,代码来源:WebServiceTestBase.class.php

示例2: institutionusers_submit

function institutionusers_submit(Pieform $form, $values)
{
    global $SESSION, $USER;
    $inst = $values['institution'];
    $url = '/admin/users/institutionusers.php?usertype=' . $values['usertype'] . (isset($values['lastinstitution']) ? '&lastinstitution=' . $values['lastinstitution'] : '') . '&institution=' . $inst;
    if (empty($inst) || !$USER->can_edit_institution($inst)) {
        $SESSION->add_error_msg(get_string('notadminforinstitution', 'admin'));
        redirect($url);
    }
    $dataerror = false;
    if (!in_array($values['usertype'], array('requesters', 'members', 'lastinstitution', 'nonmembers', 'invited')) || !is_array($values['users'])) {
        $dataerror = true;
    } else {
        foreach ($values['users'] as $id) {
            if (!is_numeric($id)) {
                $dataerror = true;
                break;
            }
        }
    }
    if ($dataerror) {
        $SESSION->add_error_msg(get_string('errorupdatinginstitutionusers', 'admin'));
        redirect($url);
    } else {
        if (empty($values['users'])) {
            $SESSION->add_ok_msg(get_string('nousersupdated', 'admin'));
            redirect($url);
        }
    }
    if ($values['usertype'] == 'members') {
        $action = 'removeMembers';
    } else {
        if ($values['usertype'] == 'requesters') {
            $action = !empty($values['reject']) ? 'declineRequestFromUser' : 'addUserAsMember';
        } else {
            if ($values['usertype'] == 'nonmembers') {
                $action = !empty($values['add']) && $USER->get('admin') ? 'addUserAsMember' : 'inviteUser';
            } else {
                if ($values['usertype'] == 'lastinstitution') {
                    $action = !empty($values['add']) && $USER->get('admin') ? 'addUserAsMember' : 'inviteUser';
                } else {
                    $action = 'uninvite_users';
                }
            }
        }
    }
    $institution = new Institution($values['institution']);
    $maxusers = $institution->maxuseraccounts;
    if (!empty($maxusers)) {
        $members = $institution->countMembers();
        if ($action == 'addUserAsMember' && $members + count($values['users']) > $maxusers) {
            $SESSION->add_error_msg(get_string('institutionuserserrortoomanyusers', 'admin'));
            redirect($url);
        }
        if ($action == 'inviteUser' && $members + $institution->countInvites() + count($values['users']) > $maxusers) {
            $SESSION->add_error_msg(get_string('institutionuserserrortoomanyinvites', 'admin'));
            redirect($url);
        }
    }
    if ($action == 'removeMembers') {
        $institution->removeMembers($values['users']);
    } else {
        if ($action == 'addUserAsMember') {
            $institution->add_members($values['users']);
        } else {
            if ($action == 'inviteUser') {
                $institution->invite_users($values['users']);
            } else {
                if ($action == 'declineRequestFromUser') {
                    $institution->decline_requests($values['users']);
                } else {
                    if ($action == 'uninvite_users') {
                        $institution->uninvite_users($values['users']);
                    }
                }
            }
        }
    }
    $SESSION->add_ok_msg(get_string('institutionusersupdated_' . $action, 'admin'));
    if (!$USER->get('admin') && !$USER->is_institutional_admin()) {
        redirect(get_config('wwwroot'));
    }
    redirect($url);
}
开发者ID:rboyatt,项目名称:mahara,代码行数:84,代码来源:institutionusers.php

示例3: remove_members

 /**
  * remove one or more users from an institution
  *
  * @param string $institution
  * @param array $users
  */
 public static function remove_members($institution, $users)
 {
     global $USER, $WEBSERVICE_INSTITUTION;
     self::check_oauth();
     $params = array('institution' => $institution, 'users' => $users);
     $params = self::validate_parameters(self::remove_members_parameters(), $params);
     if (!$USER->get('admin') && !$USER->is_institutional_admin()) {
         throw new AccessDeniedException("Institution::remove_members | " . get_string('accessdenied', 'auth.webservice'));
     }
     // check the institution is allowed
     if (!$USER->can_edit_institution($params['institution'])) {
         throw new WebserviceInvalidParameterException('remove_members | ' . get_string('accessdeniedforinst', 'auth.webservice', $params['institution']));
     }
     db_begin();
     $userids = array();
     foreach ($params['users'] as $user) {
         $dbuser = self::checkuser($user);
         // Make sure auth is valid
         if (!($authinstance = get_record('auth_instance', 'id', $dbuser->authinstance))) {
             throw new WebserviceInvalidParameterException('remove_members | ' . get_string('invalidauthtype', 'auth.webservice', $dbuser->authinstance));
         }
         // check the institution is allowed
         // basic check authorisation to edit for the current institution
         if (!$USER->can_edit_institution($authinstance->institution)) {
             throw new WebserviceInvalidParameterException('remove_members | ' . get_string('accessdeniedforinstuser', 'auth.webservice', $authinstance->institution, $dbuser->id));
         }
         $userids[] = $dbuser->id;
     }
     $institution = new Institution($params['institution']);
     $institution->removeMembers($userids);
     db_commit();
     return null;
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:39,代码来源:mahara_institution_external.php


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