- PHP models UserGroup примеры использования
- PHP UserGroup, Examples
- Saved searches
- Use saved searches to filter your results more quickly
- License
- vakata/user
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
PHP models UserGroup примеры использования
PHP models UserGroup — 11 примеров найдено. Это лучшие примеры PHP кода для models\UserGroup, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
public function __construct() < parent::__construct(); $this->user_model = \models\User::getInstance(); $groups = \models\UserGroup::getInstance()->getAllGroups(); foreach ($groups as $g) < $this->groups[$g->id] = $g; > >
public function beforeroute() < $this->model = \models\UserGroup::getInstance(); parent::beforeroute(); $this->table = 'groups'; $this->fw->mset(['ctrl_base' => $this->fw->get('backend_base.group'), 'core_ctrl_base' => $this->fw->get('backend_base.group_core')]); $default_group = $this->model->getDefaultGroup(); $this->fw->set('default_group', $default_group); $this->fw->set('no_bulk', 'true'); >
public function addUsersFromArray($users = array()) < foreach ($users as $user) < $u = UserQuery::create()->findOneByUsername($user["username"]); if ($u) < if ($u == $this->data["loggedUser"]) < $response["messages"][] = "You can not add yourself to group."; continue; >$userGroup = UserGroupQuery::create()->filterByUser($u)->filterByGroup($this->data["group"])->findOne(); if ($userGroup) < $response["messages"][] = "User " . $user["username"] . " is already in this group."; continue; >$userGroup = new UserGroup(); $userGroup->setUser($u); $userGroup->setGroup($this->data["group"]); $userGroup->save(); > else < $response["messages"][] = "User " . $user["username"] . " does not exist."; >> >
/** * Remove user of this object * through the user_group cross reference table. * * @param ChildUser $user * @return ChildGroup The current object (for fluent API support) */ public function removeUser(ChildUser $user) < if ($this->getUsers()->contains($user)) < $userGroup = new ChildUserGroup(); $userGroup->setUser($user); if ($user->isGroupsLoaded()) < //remove the back reference if available $user->getGroups()->removeObject($this); > $userGroup->setGroup($this); $this->removeUserGroup(clone $userGroup); $userGroup->clear(); $this->collUsers->remove($this->collUsers->search($user)); if (null === $this->usersScheduledForDeletion) < $this->usersScheduledForDeletion = clone $this->collUsers; $this->usersScheduledForDeletion->clear(); > $this->usersScheduledForDeletion->push($user); > return $this; >
/** * Filter the query by a related \Models\UserGroup object * * @param \Models\UserGroup|ObjectCollection $userGroup the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildUserQuery The current query, for fluid interface */ public function filterByUserGroup($userGroup, $comparison = null) < if ($userGroup instanceof \Models\UserGroup) < return $this->addUsingAlias(UserTableMap::COL_ID, $userGroup->getUserId(), $comparison); > elseif ($userGroup instanceof ObjectCollection) < return $this->useUserGroupQuery()->filterByPrimaryKeys($userGroup->getPrimaryKeys())->endUse(); > else < throw new PropelException('filterByUserGroup() only accepts arguments of type \\Models\\UserGroup or Collection'); >>
/** * Exclude object from result * * @param ChildUserGroup $userGroup Object to remove from the list of results * * @return $this|ChildUserGroupQuery The current query, for fluid interface */ public function prune($userGroup = null) < if ($userGroup) < $this->addCond('pruneCond0', $this->getAliasedColName(UserGroupTableMap::COL_USER_ID), $userGroup->getUserId(), Criteria::NOT_EQUAL); $this->addCond('pruneCond1', $this->getAliasedColName(UserGroupTableMap::COL_GROUP_ID), $userGroup->getGroupId(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); > return $this; >
/** * Проверяет данные перед добавлением на корректность * Полe 'actions' могут быть заданы как массивами, так и строками, в которых действия/связи разделены запятыми */ private function isValid($post) < if (is_array($post) && count($post) >0) < $isValid = true; /* Действия */ if (isset($post['actions'])) < $actions = $post['actions']; if (!is_array($actions)) < $actions = explode(',', $actions); >foreach ($actions as $a) < if (!in_array(trim($a), self::$actions)) < \helpers\Msg::error('acl.action_incorrect'); $isValid = false; >> if ($isValid) < $post['actions'] = implode($actions, ','); >> /* Группы */ if (isset($post['group_id'])) < $group = \models\UserGroup::getInstance()->get($post['group_id']); if (!$group) < \helpers\Msg::error('acl.group_incorrect'); $isValid = false; >> /* Связи */ if (isset($post['relation'])) < $relation = $post['relation']; if (!in_array(trim($relation), self::$relations)) < \helpers\Msg::error('acl.relation_incorrect'); $isValid = false; >else < /* $relation = self::$relations[trim($relation)]; >if ($isValid) > /* Объекты */ if (isset($post['object'])) < $objects = $this->getObjectNamesList(); if (!in_array(trim($post['object']), $objects)) < \helpers\Msg::error('acl.object_incorrect'); $isValid = false; >if ($isValid) < $post['object'] = trim($post['object']); >> > return $isValid ? $post : false; >
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by find*() * and findPk*() calls. * * @param \Models\UserGroup $obj A \Models\UserGroup object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) < if (Propel::isInstancePoolingEnabled()) < if (null === $key) < $key = serialize(array((string) $obj->getUserId(), (string) $obj->getGroupId())); > // if key === null self::$instances[$key] = $obj; > >
private function clearGroupId($post, $f3) < $group_id = false; if (!isset($post['group_id'])) < if ($f3->exists('account.default_group_id')) < $group_id = $f3->get('account.default_group_id'); > else < $group_id = 0; >> else < $group_id = $post['group_id']; >$group = \models\UserGroup::getInstance()->get($group_id); if (!$group) < \helpers\Msg::error('acl.group_incorrect'); $isValid = false; >return $group_id; >
/** * Устанавливает массив с данными для генерации AJAX-полей * @param type $this->fw */ private function setAJAXFields() < $object_options = $this->model->getObjectSelectOptions(); $this->fw->set('ajax_fields', [['name' => 'group_id', 'options' => \models\UserGroup::getInstance()->getSelectOptions(), 'type' => 'select_list', 'multiselect' => false, 'selected_id' => $this->fw->get('account.default_group_id') * 1, 'placeHolder' => $this->fw->get('i18n.acl.group.placeholder'), 'label' => $this->fw->get('i18n.acl.group.label')], ['name' => 'object', 'options' => $object_options, 'type' => 'select_list', 'multiselect' => false, 'selected_id' => $object_options[0], 'placeHolder' => $this->fw->get('i18n.acl.object.placeholder'), 'label' => $this->fw->get('i18n.acl.object.label')], ['name' => 'relation', 'options' => $this->model->getRelationSelectOptions(), 'type' => 'select_list', 'multiselect' => false, 'selected_id' => $this->model->RELATION_NO, 'placeHolder' => $this->fw->get('i18n.acl.relation.placeholder'), 'label' => $this->fw->get('i18n.acl.relation.label')], ['name' => 'actions', 'options' => $this->model->getActionsSelectOptions(), 'type' => 'select_list', 'multiselect' => true, 'selected_id' => ['create', 'read', 'update', 'delete'], 'placeHolder' => $this->fw->get('i18n.acl.action.placeholder'), 'label' => $this->fw->get('i18n.acl.action.label')]]); $this->setAjaxFieldsPost(); >
PHP UserGroup, Examples
PHP UserGroup — 30 examples found. These are the top rated real world PHP examples of UserGroup extracted from open source projects. You can rate examples to help us improve the quality of examples.
/** * 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; >
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 = "nickname> :: Groups"; $this->render("user/groups.tpl"); >
/** * 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'); > > > >
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 = 'Manage Custom Ranks'; > 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; > >
function update_display_group($uid, $gid) < global $mybb, $db, $cache; $usergroup = new UserGroup($mybb, $db, $cache); if ($usergroup->initialize($gid)) < $usergroup->add_member($uid); > >
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
License
vakata/user
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
$ composer require vakata/user
use \vakata\database\DB; use \vakata\user\UserManagementDatabase; use \vakata\user\Group; use \vakata\user\User; $db = new DB('mysql://root@127.0.0.1/dbname'); $usrm = new UserManagementDatabase($db, [ 'tableUsers' => 'users', 'tableProviders' => 'user_providers', 'tableGroups' => 'groups', 'tablePermissions' => 'permissions', 'tableGroupsPermissions' => 'group_permissions', 'tableUserGroups' => 'user_groups' ]); // get a user by ID $user = $usrm->getUser(1); // or by a provider $user = $usrm->getUserByProviderID($provider, $providerID); // add a group $group = new Group(1, "Name", ["some", "permissions"]); $usrm->saveGroup($group); // add the new group to a user $user->addGroup($group); $usrm->saveUser($user);
If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.