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


PHP JUserHelper::removeUserFromGroup方法代码示例

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


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

示例1: onGroupJoin

 function onGroupJoin(&$group, $memberid)
 {
     // Get sync mappings
     $mappings = self::getJomSocialGroupSyncMappings();
     if (empty($mappings)) {
         return;
     }
     // Instantiate JomSocial
     require_once JPATH_ROOT . '/' . 'administrator/components/com_community/defines.php';
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
     jimport('joomla.user.helper');
     $model = CFactory::getModel('Groups');
     foreach ($mappings as $mapping) {
         if ($model->isMember($member, $mapping['jsgroup_id'])) {
             // Add user to jgroup members table
             JUserHelper::addUserToGroup($userid, $mapping['jgroup_id']);
         } else {
             JUserHelper::removeUserFromGroup($userid, $mapping['jgroup_id']);
         }
     }
     return true;
 }
开发者ID:hellojoomla,项目名称:JomSocial-Group-Sync,代码行数:22,代码来源:jomsocialgroupsync.php

示例2: testRemoveUserFromGroup

 /**
  * Testing removeUserFromGroup().
  *
  * @param   string   $userId    User id
  * @param   integer  $groupId   Group to remove user from
  * @param   boolean  $expected  Expected params
  *
  * @dataProvider casesRemoveUserFromGroup
  * @covers  JUserHelper::removeUserFromGroup
  * @return  void
  */
 public function testRemoveUserFromGroup($userId, $groupId, $expected)
 {
     $this->markTestSkipped('Unexpected test failure in CMS environment');
     $this->assertThat(JUserHelper::removeUserFromGroup($userId, $groupId), $this->equalTo($expected));
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:16,代码来源:JUserHelperTest.php

示例3: testRemoveUserFromGroup

	/**
	 * Testing removeUserFromGroup().
	 *
	 * @param   string   $userId    User id
	 * @param   integer  $groupId   Group to remove user from
	 * @param   boolean  $expected  Expected params
	 *
	 * @dataProvider casesRemoveUserFromGroup
	 * @covers  JUserHelper::removeUserFromGroup
	 * @return  void
	 */
	public function testRemoveUserFromGroup($userId, $groupId, $expected)
	{
		$this->assertThat(
			JUserHelper::removeUserFromGroup($userId, $groupId),
			$this->equalTo($expected)
		);
	}
开发者ID:realityking,项目名称:joomla-platform,代码行数:18,代码来源:JUserHelperTest.php

示例4: removeUserFromGroup

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

示例5: testRemoveUserFromGroup

 /**
  * Testing removeUserFromGroup().
  *
  * @param   string   $userId    User id
  * @param   integer  $groupId   Group to remove user from
  * @param   boolean  $expected  Expected params
  *
  * @dataProvider casesRemoveUserFromGroup
  * @covers  JUserHelper::removeUserFromGroup
  * @return  void
  */
 public function testRemoveUserFromGroup($userId, $groupId, $expected)
 {
     $this->assertEquals($expected, JUserHelper::removeUserFromGroup($userId, $groupId));
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:15,代码来源:JUserHelperTest.php

示例6: save

 public function save($data)
 {
     $pk = !empty($data['user_id']) ? $data['user_id'] : 0;
     $user = JUser::getInstance($pk);
     $my = JFactory::getUser();
     $db = $this->getDbo();
     $params = JComponentHelper::getParams('com_bt_socialconnect');
     //load plugin assigment
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('btsocialconnect');
     if ($params->get('remove_user') && $user->id == 0) {
         $data['username'] = $data['email'];
     }
     //If "name" was removed
     if (!isset($data["name"])) {
         $data['name'] = $data['user_fields']['first_name'] . ' ' . $data['user_fields']['last_name'];
     }
     //Check groups of user when save
     if (!empty($data['groups'])) {
         $iAmSuperAdmin = $my->authorise('core.admin');
         if ($iAmSuperAdmin && $my->get('id') == $pk) {
             $stillSuperAdmin = false;
             $myNewGroups = $data['groups'];
             foreach ($myNewGroups as $group) {
                 $stillSuperAdmin = $stillSuperAdmin ? $stillSuperAdmin : JAccess::checkGroup($group, 'core.admin');
             }
             if (!$stillSuperAdmin) {
                 $this->setError(JText::_('COM_BT_SOCIALCONNECT_ERROR_CANNOT_DEMOTE_SELF'));
                 return false;
             }
         }
     }
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError($user->getError());
         return false;
     }
     //Get value user field
     $user_fields = $data['user_fields'];
     if ($user->save()) {
         // Add group for user from usergroup field
         $group = $this->getUserGroupField();
         if ($group) {
             // removed all group defined in usergroup field
             $newGroup = $data['user_fields'][$group->alias];
             if (in_array($newGroup, $group->default_values['group'])) {
                 $oldGroup = array_diff($group->default_values['group'], array($newGroup));
                 // add group which user has selected
                 JUserHelper::addUserToGroup($user->id, $newGroup);
                 foreach ($oldGroup as $gr) {
                     JUserHelper::removeUserFromGroup($user->id, $gr);
                 }
             }
         }
         $this->setState('socialconnect.id', $user->id);
         $this->prepareFolders($this->saveDir);
         $this->prepareFolders($this->images_path);
         $path_image_avartar = $this->images_path;
         $data['user_id'] = $user->id;
         $data['params'] = $user->params;
         $IdUserOld = self::GetUserids();
         $IdOld = self::findIdOld($data['user_id'], $IdUserOld);
         $Oldata = self::getOldata($user->id);
         //Upload image
         if (isset($_FILES["user_fields"]["tmp_name"]) && !empty($_FILES["user_fields"]["tmp_name"])) {
             $source = $_FILES["user_fields"]["tmp_name"];
             foreach ($source as $key => $imgSource) {
                 if (!empty($imgSource)) {
                     $info = getimagesize($imgSource);
                     $imageExt = str_replace('image/', '', $info['mime']);
                     $imageName = md5($data['user_id'] . strtotime("now")) . '_(' . $data['username'] . '_' . $key . ')_' . '.' . $imageExt;
                     if (!empty($imgSource)) {
                         if (JFile::copy($imgSource, $path_image_avartar . $imageName)) {
                             foreach ($Oldata as $img) {
                                 @unlink(JPATH_SITE . '/images/bt_socialconnect/avatar/' . $img->{$key});
                             }
                             $user_fields[$key] = $imageName;
                         } else {
                             return false;
                         }
                     }
                 }
             }
         }
         //Conver string to save
         $keys = array_keys($user_fields);
         $values = array_values($user_fields);
         $value = array();
         foreach ($values as $key => $field) {
             if (is_array($field)) {
                 $field = implode(',', $field);
             }
             if (empty($field)) {
                 $field = '';
             }
             $value[] = '\'' . $db->escape($field) . '\'';
         }
         // End
         //Check user is new or no
         if ($IdOld >= 0) {
//.........这里部分代码省略.........
开发者ID:juanferden,项目名称:adoperp,代码行数:101,代码来源:socialconnect.php

示例7: processTransaction

 public function processTransaction($data)
 {
     if (!$this->loginUser()) {
         throw new Exception("Cannot login admin");
     }
     $userObj = UserService::getUserByEmail($data->reservationData->userData->email);
     if (isset($userObj->id)) {
         JUserHelper::addUserToGroup($userObj->id, 8);
     } else {
         throw new Exception("Cannot find client account " . $data->reservationData->userData->email);
     }
     if (!$this->loginClient($data->reservationData->userData->email, $data->userData->password)) {
         throw new Exception("Cannot login");
     }
     //error_reporting(E_ALL);
     //ini_set('display_errors','On');
     // create reservation product
     $vmProduct = JModel::getInstance("Product", "VirtueMartModel");
     $product = array();
     $product['product_name'] = $data->reservationData->hotel->hotel_name . " Reservation(" . $data->confirmation_id . ") from " . $data->reservationData->userData->start_date . ' to ' . $data->reservationData->userData->end_date;
     $product['slug'] = "hotel_reservation";
     $product['notification_template'] = 1;
     $product['product_unit'] = 'KG';
     $product['product_available_date'] = date("Y-m-d");
     $product['mprices'] = array('product_price' => array($data->cost > 0 ? $data->cost : $data->total));
     $product['mprices']['basePrice'] = array(0);
     //$product['mprices']['product_currency']=array(191);
     $product['mprices']['product_tax_id'] = array(0);
     $product['mprices']['salesPrice'] = array('');
     $product['mprices']['price_quantity_start'] = array('');
     $product['mprices']['price_quantity_end'] = array('');
     $product['mprices']['product_override_price'] = array('');
     $product['mprices']['virtuemart_product_price_id'] = array('');
     $product['mprices']['product_override_price'] = array('');
     $product['mprices']['virtuemart_shoppergroup_id'] = array('');
     $product['mprices']['product_discount_id'] = array(0);
     $product['mprices']['product_price_publish_up'] = array('');
     $product['mprices']['product_price_publish_down'] = array('');
     $product['mprices']['override'] = array('');
     $vmProduct->store($product);
     //add product to cart
     $cart = VirtueMartCart::getCart();
     $_POST['virtuemart_product_id'] = $vmProduct->_id;
     JRequest::setVar('virtuemart_product_id', $vmProduct->_id);
     JRequest::setVar('quantity', array(1));
     $cart->add();
     //update Bill TO info virtuemart
     $lastName = $data->reservationData->userData->last_name;
     $name = $data->reservationData->userData->first_name . " " . $data->reservationData->userData->last_name;
     $db = JFactory::getDBO();
     $country = $data->reservationData->userData->country;
     $query = "select * from #__virtuemart_countries where lower(country_name) like lower('%{$country}%') limit 0,1";
     $db->setQuery($query);
     $countryData = $db->loadObject();
     $vmCountryId = 0;
     if (count($countryData) > 0) {
         $vmCountryId = $countryData->virtuemart_country_id;
     }
     $query = "insert into #__virtuemart_userinfos(`virtuemart_user_id`,`address_type`,`name`,`first_name`,`last_name`,`phone_1`,`address_1`,`city`,`virtuemart_country_id`,`zip`,`created_by`) values( '" . JFactory::getUser()->id . "','BT','" . $name . "','" . $data->reservationData->userData->first_name . "','" . $lastName . "','" . $data->reservationData->userData->phone . "', '" . $data->reservationData->userData->address . "','" . $data->reservationData->userData->city . "',{$vmCountryId} ,'" . $data->reservationData->userData->postal_code . "','" . $data->confirmation_id . "')";
     $db->setQuery($query);
     if (!$db->query()) {
         throw new Exception("Cannot update billing info");
     }
     JUserHelper::removeUserFromGroup(JFactory::getUser()->id, 8);
     $result = new stdClass();
     $result->transaction_id = 0;
     $result->amount = $data->cost > 0 ? $data->cost : $data->total;
     $result->payment_date = date("Y-m-d");
     $result->response_code = 0;
     $result->confirmation_id = $data->confirmation_id;
     $result->currency = $data->reservationData->hotel->hotel_currency;
     $result->processor_type = $this->type;
     $result->status = PAYMENT_REDIRECT;
     $result->payment_status = PAYMENT_STATUS_PENDING;
     return $result;
 }
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:76,代码来源:virtuemart.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


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