本文整理汇总了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;
}
示例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");
}
示例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');
}
}
}
}
示例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§ion=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 .= "§ion=" . $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;
}
}
示例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);
}
}
示例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();
}
示例7: GetPermissions
public function GetPermissions($objectId)
{
$userGroup = new UserGroup();
if (!($result = $userGroup->GetPermissionsForObject('lkcampaigngroup', 'CampaignID', $objectId))) {
return $this->SetError($userGroup->GetErrorMessage());
}
return $result;
}
示例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);
}
}
示例9: createFromArray
public function createFromArray($data)
{
$data = (object) $data;
$instance = new UserGroup();
$instance->setId($data->id);
$instance->setName($data->name);
return $instance;
}
示例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');
}
示例11: addUser
public function addUser($oUser)
{
if ($this->containsUser($oUser)) {
return;
}
$oUserGroup = new UserGroup();
$oUserGroup->setUser($oUser);
$this->addUserGroup($oUserGroup);
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
}