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


PHP UserGroup类代码示例

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


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

示例1: save_data

/**
 * Save imported class data to database
 *
 * @param $classes
 *
 * @return int
 */
function save_data($classes)
{
    $count = 0;
    $usergroup = new UserGroup();
    foreach ($classes as $index => $class) {
        $usersToAdd = isset($class['users']) ? $class['users'] : null;
        unset($class['users']);
        $id = $usergroup->save($class);
        if ($id) {
            if (!empty($usersToAdd)) {
                $usersToAddList = explode(',', $usersToAdd);
                $userIdList = array();
                foreach ($usersToAddList as $username) {
                    $userInfo = api_get_user_info_from_username($username);
                    $userIdList[] = $userInfo['user_id'];
                }
                if (!empty($userIdList)) {
                    $usergroup->subscribe_users_to_usergroup($id, $userIdList, false);
                }
            }
            $count++;
        }
    }
    return $count;
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:32,代码来源:usergroup_import.php

示例2: groups

 public function groups($nickname = null)
 {
     $user = $this->load_user($nickname);
     $this->assign("user", $user);
     if ($this->post && isset($_POST['group_id'])) {
         $group = Group::find_by_iD($_POST['group_id']);
         if ($group) {
             $userGroup = new UserGroup();
             $userGroup->group_id = $group->id;
             $userGroup->user_id = $user->id;
             if ($userGroup->save()) {
                 Site::Flash('notice', 'The user has been added to the group');
                 Redirect("admin/users/" . $user->permalink() . '/groups');
             }
         }
     }
     $userGroups = array();
     foreach ($user->groups() as $ug) {
         $userGroups[] = $ug->id;
     }
     $allGroups = Group::find_all();
     $groups = array();
     foreach ($allGroups as $group) {
         if (in_array($group->id, $userGroups)) {
             continue;
         }
         $groups[$group->id] = $group->name;
     }
     $this->assign('groups', $groups);
     $this->title = "{$user->nickname} :: Groups";
     $this->render("user/groups.tpl");
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:32,代码来源:user.controller.php

示例3: beforeFilter

 /**
  * Called before the controller action.  You can use this method to configure and customize components
  * or perform logic that needs to happen before each controller action.
  *
  * @param object $c current controller object
  * @return void
  */
 function beforeFilter(&$c)
 {
     $user = $this->__getActiveUser();
     UsermgmtInIt($this);
     $pageRedirect = $c->Session->read('permission_error_redirect');
     $c->Session->delete('permission_error_redirect');
     $controller = $c->params['controller'];
     $action = $c->params['action'];
     $actionUrl = $controller . '/' . $action;
     $requested = isset($controller->params['requested']) && $controller->params['requested'] == 1 ? true : false;
     $permissionFree = array('users/login', 'users/logout', 'users/register', 'users/userVerification', 'users/forgotPassword', 'users/activatePassword', 'pages/display', 'users/accessDenied', 'users/customer_register', 'users/customer_login');
     if ((empty($pageRedirect) || $actionUrl != 'users/login') && !$requested && !in_array($actionUrl, $permissionFree)) {
         App::import("Model", "Usermgmt.UserGroup");
         $userGroupModel = new UserGroup();
         if (!$this->isLogged()) {
             if (!$userGroupModel->isGuestAccess($controller, $action)) {
                 $c->log('permission: actionUrl-' . $actionUrl, LOG_DEBUG);
                 $c->Session->write('permission_error_redirect', '/users/login');
                 $c->Session->setFlash('You need to be signed in to view this page.');
                 $c->Session->write('Usermgmt.OriginAfterLogin', '/' . $c->params->url);
                 $c->redirect('/login');
             }
         } else {
             if (!$userGroupModel->isUserGroupAccess($controller, $action, $this->getGroupId())) {
                 $c->log('permission: actionUrl-' . $actionUrl, LOG_DEBUG);
                 $c->Session->write('permission_error_redirect', '/users/login');
                 $c->redirect('/accessDenied');
             }
         }
     }
 }
开发者ID:Numerico-Informatic-Systems-Pvt-Ltd,项目名称:asha,代码行数:38,代码来源:UserAuthComponent.php

示例4: load_groupcp

function load_groupcp()
{
    global $mybb, $db, $cache, $templates, $title, $header, $headerinclude, $footer, $theme, $group;
    if ($mybb->settings['rpgsuite_groupmanagecp'] && $mybb->input['action'] == "managegroup") {
        // Get group id
        if ($mybb->input['gid'] && $mybb->usergroup['issupermod']) {
            $gid = intval($mybb->input['gid']);
            $groupnav = '&gid=' . $gid;
        } else {
            $gid = $mybb->user['displaygroup'];
            $groupnav = '';
        }
        $cpcontent = "";
        if ($mybb->settings['rpgsuite_groupranks_custom']) {
            $customranklink = '<a href="modcp.php?action=managegroup&section=customranks' . $groupnav . '">Manage Custom Ranks</a>';
        } else {
            $customranklink = '';
        }
        $usergroup = new UserGroup($mybb, $db, $cache);
        if ($usergroup->initialize($gid)) {
            $group = $usergroup->get_info();
            if (handle_form($usergroup)) {
                $url = "modcp.php?action=managegroup&gid=" . $gid;
                if ($mybb->input['section']) {
                    $url .= "&section=" . $mybb->input['section'];
                }
                redirect($url, "Your pack settings were successfully updated.");
            }
            if ($mybb->input['section'] == 'groupoptions') {
                $title = 'Manage Options';
                add_breadcrumb('Manage Options');
                $cpcontent = load_groupmod_options($usergroup);
            } else {
                if ($mybb->input['section'] == 'groupmembers') {
                    $title = 'Manage Members';
                    add_breadcrumb('Manage Members');
                    $cpcontent = load_groupmod_members($usergroup);
                } else {
                    if ($mybb->input['section'] == 'customranks' && $mybb->settings['rpgsuite_groupranks_custom']) {
                        $ttile = 'Manage Custom Ranks';
                        add_breadcrumb('Manage Custom Ranks');
                        $cpcontent = load_groupmod_customranks($usergroup);
                    } else {
                        $title = 'Manage Ranks';
                        add_breadcrumb('Manage Ranks');
                        $cpcontent = load_groupmod_ranks($usergroup);
                    }
                }
            }
            // Add group styling
            eval("\$headerinclude .= \"" . $templates->get('rpgmisc_groupstyle') . "\";");
        } else {
            $cpcontent = "Invalid Group";
        }
        eval("\$groupmanagecp = \"" . $templates->get('rpggroupmanagecp_full') . "\";");
        output_page($groupmanagecp);
        exit;
    }
}
开发者ID:megan-starr9,项目名称:RPGSuite,代码行数:59,代码来源:groupmanagecp.php

示例5: update_display_group

function update_display_group($uid, $gid)
{
    global $mybb, $db, $cache;
    $usergroup = new UserGroup($mybb, $db, $cache);
    if ($usergroup->initialize($gid)) {
        $usergroup->add_member($uid);
    }
}
开发者ID:megan-starr9,项目名称:RPGSuite,代码行数:8,代码来源:displaygroupfix.php

示例6: setUp

 public function setUp()
 {
     parent::setUp();
     $this->role = Role::getNewInstance('__testrole__');
     $this->role->save();
     $this->userGroup = UserGroup::getNewInstance('Any random group name');
     $this->userGroup->save();
 }
开发者ID:saiber,项目名称:livecart,代码行数:8,代码来源:AccessControlAssociationTest.php

示例7: GetPermissions

 public function GetPermissions($objectId)
 {
     $userGroup = new UserGroup();
     if (!($result = $userGroup->GetPermissionsForObject('lkcampaigngroup', 'CampaignID', $objectId))) {
         return $this->SetError($userGroup->GetErrorMessage());
     }
     return $result;
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:8,代码来源:campaignsecurity.data.class.php

示例8: setGroup

 /**
  * Assign the user to a group
  *
  * @param	Entity\UserGroup	$group
  * @return	void
  */
 public function setGroup(UserGroup $group)
 {
     $this->group = $group;
     // The association must be defined in both directions
     if (!$group->getUsers()->contains($this)) {
         $group->addUser($this);
     }
 }
开发者ID:riteshsingh1,项目名称:cidoctrine,代码行数:14,代码来源:User.php

示例9: createFromArray

 public function createFromArray($data)
 {
     $data = (object) $data;
     $instance = new UserGroup();
     $instance->setId($data->id);
     $instance->setName($data->name);
     return $instance;
 }
开发者ID:rsicart,项目名称:smartadserver,代码行数:8,代码来源:UserGroup.php

示例10: addUserGroupSubmit

function addUserGroupSubmit($p)
{
    $grp = new UserGroup();
    $grp->setName($p['name']);
    $grp->setInfo($p['info']);
    $grp->setLevel($p['level']);
    $grp->save();
    redir('a/usergroups');
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:9,代码来源:usergroups.php

示例11: addUser

 public function addUser($oUser)
 {
     if ($this->containsUser($oUser)) {
         return;
     }
     $oUserGroup = new UserGroup();
     $oUserGroup->setUser($oUser);
     $this->addUserGroup($oUserGroup);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:9,代码来源:Group.php

示例12: saveUserGroupSubmit

function saveUserGroupSubmit($p)
{
    $grp = new UserGroup($p['g_id']);
    $grp->setName($p['name']);
    $grp->setInfo($p['info']);
    $grp->setLevel($p['level']);
    $grp->save();
    return true;
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:9,代码来源:usergroup.php

示例13: mockEffect

 /**
  * Callback method that will be called in place of the effect()
  * method of a mock policy.
  * @return integer AUTHORIZATION_PERMIT
  */
 public function mockEffect()
 {
     // Add a user group to the authorized context
     // of the authorization context manipulation policy.
     $policy = $this->getAuthorizationContextManipulationPolicy();
     $userGroup = new UserGroup();
     $userGroup->setRoleId(ROLE_ID_TEST);
     $policy->addAuthorizedContextObject(ASSOC_TYPE_USER_GROUP, $userGroup);
     return AUTHORIZATION_PERMIT;
 }
开发者ID:ramonsodoma,项目名称:pkp-lib,代码行数:15,代码来源:PolicyTestCase.inc.php

示例14: addToGroups

 /**
  * add user to groups
  *
  * @param array $group_name
  */
 public function addToGroups($group_name)
 {
     $group_ids = Group::findGroupIdByNames($group_name);
     foreach ($group_ids as $group_id) {
         $user_group = new UserGroup();
         $user_group->user_id = $this->getId();
         $user_group->group_id = $group_id;
         $user_group->save();
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:15,代码来源:User.class.php

示例15: checkIdeabox

function checkIdeabox($id = 0)
{
    global $db, $langs;
    if (isset($id) && $id > 0) {
        $usergroup = new UserGroup($db);
        return $usergroup->listGroupsForUser($id);
    } else {
        return false;
    }
}
开发者ID:atm-arnaud,项目名称:dolibarr_module_ideabox,代码行数:10,代码来源:ideabox.lib.php


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