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


PHP JUserHelper::setUserGroups方法代码示例

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


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

示例1: save

 public function save()
 {
     $this->_user->save();
     JUserHelper::setUserGroups($this->_user->id, $this->_userGroups);
     parent::save();
     $uid = $this->params->get('user');
     if (!$uid || $uid != $this->_user->id) {
         $this->params->set('user', $this->_user->id);
         $this->mapUser();
     }
     return $this;
 }
开发者ID:camigreen,项目名称:ttop,代码行数:12,代码来源:user.php

示例2: save

 public function save()
 {
     $profile = new JRegistry();
     foreach ($this->params as $key => $value) {
         $profile->set('params.' . $key, $value);
     }
     foreach ($this->elements as $key => $value) {
         $profile->set('elements.' . $key, $value);
     }
     var_dump($profile);
     $this->_user->profile = $profile;
     $this->_user->save();
     $this->mapAccount($this->_account);
     JUserHelper::setUserGroups($this->_user->id, $this->_permissions);
     return true;
 }
开发者ID:camigreen,项目名称:ttop,代码行数:16,代码来源:storeuser.php

示例3: createUser

 public function createUser()
 {
     $name = $this->state->get('f_name') . ' ' . $this->state->get('l_name');
     $username = $this->state->get('email');
     $password1 = $this->state->get('password1');
     $password2 = $this->state->Get('password2');
     $email = $this->state->get('email');
     $data = array("name" => $name, "username" => $username, "password" => $password1, "password2" => $password2, "email" => $email, "groups" => [2]);
     $this->juser = $user = clone JFactory::getUser();
     //Write to database
     if (!($user->bind($data) && $user->save())) {
         $this->error = $user->getError();
     } else {
         JUserHelper::setUserGroups($user->id, [2]);
     }
     //todo test result and set error on fail.
 }
开发者ID:RustyIngles,项目名称:sp4k_php,代码行数:17,代码来源:account.php

示例4: updateJoomlaUserType

 /**
  * Save user's joomla-user-type
  * @param $userid
  * @param $newUsertype
  * @return true/false
  */
 function updateJoomlaUserType($userid, $newUsertype = JOOMLA_USER_TYPE_NONE)
 {
     //do not change usertypes for admins
     if (XiptHelperUtils::isAdmin($userid) == true || 0 == $userid || $newUsertype === JOOMLA_USER_TYPE_NONE) {
         return false;
     }
     //self::reloadCUser($userid);
     $user = CFactory::getUser($userid);
     $authorize = JFactory::getACL();
     $user->set('usertype', $newUsertype);
     if (XIPT_JOOMLA_15) {
         $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
     } else {
         $group = CACL::getInstance();
         $groups[] = $group->getGroupID($newUsertype);
         JUserHelper::setUserGroups($userid, $groups);
     }
     $user->save();
     self::reloadCUser($userid);
     return true;
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:27,代码来源:jomsocial.php

示例5: postSaveHook

 /**
  * Function that allows child controller access to model data
  * after the data has been saved.
  *
  * @param   JModel  &$model     The data model object.
  * @param   array   $validData  The validated data.
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     if ($validData['id'] >= 0) {
         // get user object
         $user = JFactory::getUser();
         // if id is 0 get id
         if (0 >= (int) $validData['id']) {
             // Get the created by id
             $created_by = isset($validData['created_by']) && $validData['created_by'] > 0 ? $validData['created_by'] : $user->id;
             // Get a db connection.
             $db = JFactory::getDbo();
             // Create a new query object.
             $query = $db->getQuery(true);
             // Select id of this company
             $query->select($db->quoteName(array('id')));
             $query->from($db->quoteName('#__costbenefitprojection_company'));
             $query->where($db->quoteName('name') . ' = ' . $db->quote($validData['name']));
             $query->where($db->quoteName('email') . ' = ' . $db->quote($validData['email']));
             $query->where($db->quoteName('country') . ' = ' . (int) $validData['country']);
             $query->where($db->quoteName('service_provider') . ' = ' . (int) $validData['service_provider']);
             $query->where($db->quoteName('created_by') . ' = ' . (int) $created_by);
             if (isset($validData['created'])) {
                 $query->where($db->quoteName('created') . ' = ' . $db->quote($validData['created']));
             }
             $db->setQuery($query);
             $db->execute();
             if ($db->getNumRows()) {
                 $validData['id'] = $db->loadResult();
             } else {
                 return;
             }
         }
         // user setup if not set
         if (0 >= (int) $validData['user'] && (int) $validData['id'] > 0) {
             $userIs = CostbenefitprojectionHelper::userIs($user->id);
             if (1 == $userIs) {
                 // this is a company so just use its id
                 $userId = $user->id;
                 // add this user id to this company
                 $validData['user'] = $userId;
                 $model->save($validData);
             } else {
                 // setup config array
                 $newUser = array('name' => $validData['name'], 'email' => $validData['email']);
                 $userId = CostbenefitprojectionHelper::createUser($newUser);
                 if (!is_int($userId)) {
                     $this->setMessage($userId, 'error');
                 } else {
                     // add this user id to this company
                     $validData['user'] = $userId;
                     $model->save($validData);
                 }
             }
         }
         // only continue if we have a company id
         if ((int) $validData['id'] > 0) {
             // get params
             $params = JComponentHelper::getParams('com_costbenefitprojection');
             // get all this users companies
             $hisCompanies = CostbenefitprojectionHelper::hisCompanies($validData['user']);
             if (CostbenefitprojectionHelper::checkArray($hisCompanies)) {
                 // set the user group based on the overall status of its companies
                 $departments = CostbenefitprojectionHelper::getVars('company', $hisCompanies, 'id', 'department');
                 if (in_array(2, $departments)) {
                     $memberGroups = $params->get('advancedmembergroup');
                 } else {
                     $memberGroups = $params->get('memberbasicgroup');
                 }
             } else {
                 // first company so act simply on this company department status
                 if (2 == $validData['department']) {
                     $memberGroups = $params->get('advancedmembergroup');
                 } else {
                     $memberGroups = $params->get('memberbasicgroup');
                 }
             }
             // update the user groups
             JUserHelper::setUserGroups((int) $validData['user'], (array) $memberGroups);
             // Get a db connection.
             $db = JFactory::getDbo();
             // Create a new query object.
             $query = $db->getQuery(true);
             // Select all records in scaling factors the belong to this company
             $query->select($db->quoteName(array('id', 'causerisk', 'published')));
             $query->from($db->quoteName('#__costbenefitprojection_scaling_factor'));
             $query->where($db->quoteName('company') . ' = ' . (int) $validData['id']);
             $db->setQuery($query);
             $db->execute();
             if ($db->getNumRows()) {
//.........这里部分代码省略.........
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:101,代码来源:company.php

示例6: setUserGroups

 /**
  * Helper wrapper method for setUserGroups
  *
  * @param   integer  $userId  The id of the user.
  * @param   array    $groups  An array of group ids to put the user in.
  *
  * @return  boolean  True on success
  *
  * @see     JUserHelper::setUserGroups()
  * @since   3.4
  */
 public function setUserGroups($userId, $groups)
 {
     return JUserHelper::setUserGroups($userId, $groups);
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:15,代码来源:helper.php

示例7: save

 public function save()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $jinput = JFactory::getApplication()->input;
     $uri =& JFactory::getURI();
     $pageURL = $uri->toString();
     $task = $jinput->get('task');
     $selected_usersid = $jinput->get('selected_usersid', array(), 'ARRAY');
     $lesson_title = $jinput->get('lesson_title');
     $title = trim($jinput->get('lesson_title', '', 'RAW'));
     $parent_id = 1;
     $table = JTable::getInstance('usergroup');
     $table->parent_id = $parent_id;
     $table->title = $title;
     $table->check();
     $table->store();
     $insertedGroupId = $table->id;
     foreach ($selected_usersid as $userid) {
         $groups = array();
         $groups[] = $insertedGroupId;
         $user_Group = JAccess::getGroupsByUser($userid);
         foreach ($user_Group as $gId) {
             $groups[] = $gId;
         }
         JUserHelper::setUserGroups($userid, $groups);
     }
     $app->redirect($pageURL);
 }
开发者ID:jboydacs,项目名称:com_joombbb,代码行数:29,代码来源:bbbcreategroup.php

示例8: updateGid

 public static function updateGid($user_id, $gid, $unblock = false, $action = 'add')
 {
     try {
         jimport('joomla.user.helper');
         $user_id = (int) $user_id;
         if (!is_array($gid)) {
             $gid = explode(',', $gid);
         }
         JArrayHelper::toInteger($gid);
         // old version
         if (RSMembershipHelper::getConfig('replace_gid')) {
             JUserHelper::setUserGroups($user_id, $gid);
         } else {
             foreach ($gid as $group) {
                 if ($action == 'add') {
                     self::syslog('gid', "Adding user({$user_id}) to group({$group})");
                     JUserHelper::addUserToGroup($user_id, $group);
                 } elseif ($action == 'remove') {
                     self::syslog('gid', "Removing user({$user_id}) from group({$group})");
                     JUserHelper::removeUserFromGroup($user_id, $group);
                 }
             }
         }
         if ($unblock) {
             RSMembership::enableUser($user_id);
         }
     } catch (Exception $e) {
         self::syslog('gid', "Error on changing group for user({$user_id}). Message: " . $e->getMessage());
     }
 }
开发者ID:JozefAB,项目名称:qk,代码行数:30,代码来源:rsmembership.php

示例9: postSaveHook

 /**
  * Function that allows child controller access to model data
  * after the data has been saved.
  *
  * @param   JModel  &$model     The data model object.
  * @param   array   $validData  The validated data.
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     if ($validData['id'] >= 0) {
         // get user object
         $user = JFactory::getUser();
         // if id is 0 get id
         if (0 >= (int) $validData['id']) {
             // Get the created by id
             $created_by = isset($validData['created_by']) && $validData['created_by'] > 0 ? $validData['created_by'] : $user->id;
             // Get a db connection.
             $db = JFactory::getDbo();
             // Create a new query object.
             $query = $db->getQuery(true);
             // Select id of this service_provider
             $query->select($db->quoteName(array('id')));
             $query->from($db->quoteName('#__costbenefitprojection_service_provider'));
             $query->where($db->quoteName('publicemail') . ' = ' . $db->quote($validData['publicemail']));
             $query->where($db->quoteName('publicname') . ' = ' . $db->quote($validData['publicname']));
             $query->where($db->quoteName('country') . ' = ' . (int) $validData['country']);
             $query->where($db->quoteName('created_by') . ' = ' . (int) $created_by);
             if (isset($validData['created'])) {
                 $query->where($db->quoteName('created') . ' = ' . $db->quote($validData['created']));
             }
             $db->setQuery($query);
             $db->execute();
             if ($db->getNumRows()) {
                 $validData['id'] = $db->loadResult();
             } else {
                 return;
             }
         }
         // user setup if not set
         if (0 >= (int) $validData['user']) {
             // setup config array
             $newUser = array('name' => $validData['publicname'], 'email' => $validData['publicemail']);
             $userId = costbenefitprojectionHelper::createUser($newUser);
             if (!is_int($userId)) {
                 $this->setMessage($userId, 'error');
             } else {
                 // get params
                 $params = JComponentHelper::getParams('com_costbenefitprojection');
                 // get groups for members
                 $groups = (array) $params->get('serviceprovideruser');
                 // update the user groups
                 JUserHelper::setUserGroups($userId, $groups);
                 // add this user id to this serviceprovider
                 $validData['user'] = $userId;
                 $model->save($validData);
             }
         }
     }
     return;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:64,代码来源:service_provider.php

示例10: updateGid

 function updateGid($user_id, $gid, $unblock = false)
 {
     $db =& JFactory::getDBO();
     $user_id = (int) $user_id;
     if (RSMembershipHelper::isJ16()) {
         jimport('joomla.user.helper');
         if (!is_array($gid)) {
             $gid = explode(',', $gid);
         }
         JArrayHelper::toInteger($gid);
         JUserHelper::setUserGroups($user_id, $gid);
     } else {
         $gid = (int) $gid;
         // Update aro_id
         $db->setQuery("SELECT id FROM #__core_acl_aro WHERE `value`='" . $user_id . "' AND `section_value`='users'");
         $db->setQuery("UPDATE #__core_acl_groups_aro_map SET `group_id`='" . $gid . "' WHERE `aro_id`='" . $db->loadResult() . "'");
         $db->query();
         // Update gid
         $db->setQuery("SELECT `name` FROM #__core_acl_aro_groups WHERE `id`='" . $gid . "'");
         $db->setQuery("UPDATE #__users SET `gid`='" . $gid . "', `usertype`='" . $db->getEscaped($db->loadResult()) . "' WHERE `id`='" . $user_id . "'");
         $db->query();
     }
     if ($unblock) {
         RSMembership::enableUser($user_id);
     }
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:26,代码来源:rsmembership.php


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