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


PHP groups_remove_member_allowed函数代码示例

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


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

示例1: user_groups_and_actions

 /**
  * Generates the HTML to view the users groups and available group actions
  *
  * @param int $userid
  * @param array $groups
  * @param array $allgroups
  * @param bool $canmanagegroups
  * @param moodle_url $pageurl
  * @return string
  */
 public function user_groups_and_actions($userid, $groups, $allgroups, $canmanagegroups, $pageurl)
 {
     $iconenrolremove = $this->output->pix_url('t/delete');
     $groupicon = $this->output->pix_icon('i/group', get_string('addgroup', 'group'));
     $groupoutput = '';
     foreach ($groups as $groupid => $name) {
         if ($canmanagegroups and groups_remove_member_allowed($groupid, $userid)) {
             $icon = html_writer::empty_tag('img', array('alt' => get_string('removefromgroup', 'group', $name), 'src' => $iconenrolremove));
             $url = new moodle_url($pageurl, array('action' => 'removemember', 'group' => $groupid, 'user' => $userid));
             $groupoutput .= html_writer::tag('div', $name . html_writer::link($url, $icon), array('class' => 'group', 'rel' => $groupid));
         } else {
             $groupoutput .= html_writer::tag('div', $name, array('class' => 'group', 'rel' => $groupid));
         }
     }
     $output = '';
     if ($canmanagegroups && count($groups) < count($allgroups)) {
         $url = new moodle_url($pageurl, array('action' => 'addmember', 'user' => $userid));
         $output .= html_writer::tag('div', html_writer::link($url, $groupicon), array('class' => 'addgroup'));
     }
     $output = $output . html_writer::tag('div', $groupoutput, array('class' => 'groups'));
     return $output;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:32,代码来源:renderer.php

示例2: remove_user_from_group

 /**
  * Removes a user from a group
  *
  * @global moodle_database $DB
  * @param StdClass $user
  * @param int $groupid
  * @return bool
  */
 public function remove_user_from_group($user, $groupid)
 {
     global $DB;
     require_capability('moodle/course:managegroups', $this->context);
     $group = $this->get_group($groupid);
     if (!groups_remove_member_allowed($group, $user)) {
         return false;
     }
     if (!$group) {
         return false;
     }
     return groups_remove_member($group, $user);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:21,代码来源:locallib.php

示例3: delete_group_members

 /**
  * Delete group members
  *
  * @param array $members of arrays with keys userid, groupid
  * @since Moodle 2.2
  */
 public static function delete_group_members($members)
 {
     global $CFG, $DB;
     require_once "{$CFG->dirroot}/group/lib.php";
     $params = self::validate_parameters(self::delete_group_members_parameters(), array('members' => $members));
     $transaction = $DB->start_delegated_transaction();
     foreach ($params['members'] as $member) {
         // validate params
         $groupid = $member['groupid'];
         $userid = $member['userid'];
         $group = groups_get_group($groupid, 'id, courseid', MUST_EXIST);
         $user = $DB->get_record('user', array('id' => $userid, 'deleted' => 0, 'mnethostid' => $CFG->mnet_localhost_id), '*', MUST_EXIST);
         // now security checks
         $context = context_course::instance($group->courseid, IGNORE_MISSING);
         try {
             self::validate_context($context);
         } catch (Exception $e) {
             $exceptionparam = new stdClass();
             $exceptionparam->message = $e->getMessage();
             $exceptionparam->courseid = $group->courseid;
             throw new moodle_exception('errorcoursecontextnotvalid', 'webservice', '', $exceptionparam);
         }
         require_capability('moodle/course:managegroups', $context);
         if (!groups_remove_member_allowed($group, $user)) {
             throw new moodle_exception('errorremovenotpermitted', 'group', '', fullname($user));
         }
         groups_remove_member($group, $user);
     }
     $transaction->allow_commit();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:36,代码来源:externallib.php

示例4: foreach

    $userstoadd = $potentialmembersselector->get_selected_users();
    if (!empty($userstoadd)) {
        foreach ($userstoadd as $user) {
            if (!groups_add_member($groupid, $user->id)) {
                print_error('erroraddremoveuser', 'group', $returnurl);
            }
            $groupmembersselector->invalidate_selected_users();
            $potentialmembersselector->invalidate_selected_users();
        }
    }
}
if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
    $userstoremove = $groupmembersselector->get_selected_users();
    if (!empty($userstoremove)) {
        foreach ($userstoremove as $user) {
            if (!groups_remove_member_allowed($groupid, $user->id)) {
                print_error('errorremovenotpermitted', 'group', $returnurl, $user->fullname);
            }
            if (!groups_remove_member($groupid, $user->id)) {
                print_error('erroraddremoveuser', 'group', $returnurl);
            }
            $groupmembersselector->invalidate_selected_users();
            $potentialmembersselector->invalidate_selected_users();
        }
    }
}
// Print the page and form
$strgroups = get_string('groups');
$strparticipants = get_string('participants');
$stradduserstogroup = get_string('adduserstogroup', 'group');
$strusergroupmembership = get_string('usergroupmembership', 'group');
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:members.php


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