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


PHP GroupManager::userHasAccessToBrowse方法代码示例

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


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

示例1: api_get_path

/*	Libraries & config files */
require_once api_get_path(SYS_CODE_PATH) . 'forum/forumfunction.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'forum/forumconfig.inc.php';
/*	MAIN CODE */
$group_id = api_get_group_id();
$user_id = api_get_user_id();
$current_group = GroupManager::get_group_properties($group_id);
if (empty($current_group)) {
    api_not_allowed(true);
}
$this_section = SECTION_COURSES;
$nameTools = get_lang('GroupSpace');
$interbreadcrumb[] = array('url' => 'group.php?' . api_get_cidReq(), 'name' => get_lang('Groups'));
/*	Ensure all private groups // Juan Carlos Raña Trabado */
$forums_of_groups = get_forums_of_group($current_group['id']);
if (!GroupManager::userHasAccessToBrowse($user_id, $current_group, api_get_session_id())) {
    api_not_allowed(true);
}
Display::display_header($nameTools . ' ' . Security::remove_XSS($current_group['name']), 'Group');
/*	Introduction section (editable by course admin) */
Display::display_introduction_section(TOOL_GROUP);
/*	Actions and Action links */
/*
 * User wants to register in this group
 */
if (!empty($_GET['selfReg']) && GroupManager::is_self_registration_allowed($user_id, $current_group['id'])) {
    GroupManager::subscribe_users($user_id, $current_group['id']);
    Display::display_normal_message(get_lang('GroupNowMember'));
}
/*
 * User wants to unregister from this group
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:group_space.php

示例2: process_groups

 /**
  * @param array $group_list
  * @param int $category_id
  *
  * @return string
  */
 public static function process_groups($group_list, $category_id = null)
 {
     global $origin, $charset;
     $category_id = intval($category_id);
     $totalRegistered = 0;
     $group_data = array();
     $user_info = api_get_user_info();
     $session_id = api_get_session_id();
     $user_id = $user_info['user_id'];
     $orig = isset($origin) ? $origin : null;
     $hideGroup = api_get_setting('group.hide_course_group_if_no_tools_available');
     foreach ($group_list as $this_group) {
         // Validation when belongs to a session
         $session_img = api_get_session_image($this_group['session_id'], $user_info['status']);
         // All the tutors of this group
         $tutorsids_of_group = self::get_subscribed_tutors($this_group['id'], true);
         // Create a new table-row
         $row = array();
         // Checkbox
         if (api_is_allowed_to_edit(false, true) && count($group_list) > 1) {
             $row[] = $this_group['id'];
         }
         if (GroupManager::userHasAccessToBrowse($user_id, $this_group, $session_id)) {
             // Group name
             $groupNameClass = null;
             if ($this_group['status'] == 0) {
                 $groupNameClass = 'muted';
             }
             $group_name = '<a class="' . $groupNameClass . '" href="group_space.php?cidReq=' . api_get_course_id() . '&origin=' . $orig . '&gidReq=' . $this_group['id'] . '">' . Security::remove_XSS($this_group['name']) . '</a> ';
             if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) {
                 $group_name .= Display::label(get_lang('OneMyGroups'), 'success');
             } elseif ($this_group['is_member']) {
                 $group_name .= Display::label(get_lang('MyGroup'), 'success');
             }
             if (api_is_allowed_to_edit() && !empty($this_group['session_name'])) {
                 $group_name .= ' (' . $this_group['session_name'] . ')';
             }
             $group_name .= $session_img;
             $row[] = $group_name . '<br />' . stripslashes(trim($this_group['description']));
         } else {
             if ($hideGroup === 'true') {
                 continue;
             }
             $row[] = $this_group['name'] . '<br />' . stripslashes(trim($this_group['description']));
         }
         // Tutor name
         $tutor_info = null;
         if (count($tutorsids_of_group) > 0) {
             foreach ($tutorsids_of_group as $tutor_id) {
                 $tutor = api_get_user_info($tutor_id);
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $tutor['username']), ENT_QUOTES);
                 if (api_get_setting('display.show_email_addresses') == 'true') {
                     $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', ';
                 } else {
                     if (api_is_allowed_to_edit()) {
                         $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', ';
                     } else {
                         $tutor_info .= Display::tag('span', api_get_person_name($tutor['firstName'], $tutor['lastName']), array('title' => $username)) . ', ';
                     }
                 }
             }
         }
         $tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2);
         $row[] = $tutor_info;
         // Max number of members in group
         $max_members = $this_group['maximum_number_of_members'] == self::MEMBER_PER_GROUP_NO_LIMIT ? ' ' : ' / ' . $this_group['maximum_number_of_members'];
         // Number of members in group
         $row[] = $this_group['number_of_members'] . $max_members;
         // Self-registration / unregistration
         if (!api_is_allowed_to_edit(false, true)) {
             if (self::is_self_registration_allowed($user_id, $this_group['id'])) {
                 $row[] = '<a class = "btn btn-default" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&action=self_reg&group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfRegInf') . '</a>';
             } elseif (self::is_self_unregistration_allowed($user_id, $this_group['id'])) {
                 $row[] = '<a class = "btn btn-default" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&action=self_unreg&group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfUnRegInf') . '</a>';
             } else {
                 $row[] = '-';
             }
         }
         $url = api_get_path(WEB_CODE_PATH) . 'group/';
         // Edit-links
         if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) {
             $edit_actions = '<a href="' . $url . 'settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '"  title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             if ($this_group['status'] == 1) {
                 $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=set_invisible&id=' . $this_group['id'] . '" title="' . get_lang('Hide') . '">' . Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             } else {
                 $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=set_visible&id=' . $this_group['id'] . '" title="' . get_lang('Show') . '">' . Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             }
             $edit_actions .= '<a href="' . $url . 'member_settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '"  title="' . get_lang('GroupMembers') . '">' . Display::return_icon('user.png', get_lang('GroupMembers'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $edit_actions .= '<a href="' . $url . 'group_overview.php?action=export&type=xls&' . api_get_cidreq(true, false) . '&id=' . $this_group['id'] . '"  title="' . get_lang('ExportUsers') . '">' . Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             /*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=empty_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'.
               Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';*/
             $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=fill_one&id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('FillGroup') . '">' . Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=delete_one&id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('Delete') . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
             $row[] = $edit_actions;
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:groupmanager.lib.php

示例3: isGranted

 /**
  * @param string $attribute
  * @param CGroupInfo $group
  * @param User $user
  * @return bool
  */
 protected function isGranted($attribute, $group, $user = null)
 {
     // make sure there is a user object (i.e. that the user is logged in)
     if (!$user instanceof UserInterface) {
         return false;
     }
     if ($group == false) {
         return false;
     }
     $authChecker = $this->container->get('security.authorization_checker');
     // Admins have access to everything
     if ($authChecker->isGranted('ROLE_ADMIN')) {
         return true;
     }
     $groupInfo = ['id' => $group->getId(), 'session_id' => 0, 'status' => $group->getStatus()];
     // Legacy
     return \GroupManager::userHasAccessToBrowse($user->getId(), $groupInfo);
     switch ($attribute) {
         case self::VIEW:
             if (!$group->hasUserInCourse($user, $course)) {
                 $user->addRole('ROLE_CURRENT_SESSION_COURSE_STUDENT');
                 return true;
             }
             break;
         case self::EDIT:
         case self::DELETE:
             if (!$session->hasCoachInCourseWithStatus($user, $course)) {
                 $user->addRole('ROLE_CURRENT_SESSION_COURSE_TEACHER');
                 return true;
             }
             break;
     }
     dump("You don't have access to this group!!");
     return false;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:41,代码来源:GroupVoter.php


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