當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。