本文整理汇总了PHP中CUser::GetUserGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP CUser::GetUserGroup方法的具体用法?PHP CUser::GetUserGroup怎么用?PHP CUser::GetUserGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUser
的用法示例。
在下文中一共展示了CUser::GetUserGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
/**
* Delete
* @param $CODE
* @return array
* @throws \Exception
*/
public static function Delete($CODE)
{
$group = new \CGroup();
$user = new \CUser();
if (!empty($CODE)) {
$by = "ID";
$order = "asc";
$dbGroup = $group->GetList($by, $order, array('STRING_ID' => $CODE));
if ($arGroup = $dbGroup->Fetch()) {
$arReturn = $arGroup;
}
} else {
throw new BimException('Empty group code');
}
if (intval($arReturn['ID']) > 0) {
$arUsers = $group->GetGroupUser($arReturn['ID']);
foreach ($arUsers as $UserID) {
$arGroup = $user->GetUserGroup($UserID);
$arGroup[] = "3";
$user->SetUserGroup($UserID, $arGroup);
}
$res = $group->Delete($arReturn['ID']);
if (is_object($res)) {
return $arReturn['ID'];
} else {
throw new BimException($group->LAST_ERROR);
}
} else {
throw new BimException('Group not found');
}
}
示例2: HaveRole
function HaveRole($role, $userID = false)
{
global $DB, $USER, $APPLICATION, $SUPPORT_CACHE_USER_ROLES;
if (!is_object($USER)) {
$USER = new CUser();
}
if ($userID === false && is_object($USER)) {
$uid = $USER->GetID();
} else {
$uid = $userID;
}
$arRoles = array();
if (array_key_exists($uid, $SUPPORT_CACHE_USER_ROLES) && is_array($SUPPORT_CACHE_USER_ROLES[$uid])) {
$arRoles = $SUPPORT_CACHE_USER_ROLES[$uid];
} else {
$arrGroups = array();
if ($userID === false && is_object($USER)) {
$arrGroups = $USER->GetUserGroupArray();
} else {
$arrGroups = CUser::GetUserGroup($userID);
}
sort($arrGroups);
$arRoles = $APPLICATION->GetUserRoles("support", $arrGroups);
$SUPPORT_CACHE_USER_ROLES[$uid] = $arRoles;
}
if (in_array($role, $arRoles)) {
return true;
}
return false;
}
示例3: SetDiscount
private static function SetDiscount($USER_ID, $iSumm, $arDiscount)
{
$GROUP_ID = 0;
$arGroups = array();
foreach($arDiscount as $ar)
{
if($iSumm >= $ar["PROPERTY_" . self::$PROPERTY_SUMM . "_VALUE"])
$GROUP_ID = $ar["PROPERTY_" . self::$PROPERTY_GROUP . "_VALUE"];
$arGroups[$ar["PROPERTY_" . self::$PROPERTY_GROUP . "_VALUE"]] = $ar["PROPERTY_" . self::$PROPERTY_GROUP . "_VALUE"];
}
$arUserGroups = CUser::GetUserGroup($USER_ID);
foreach($arUserGroups as $k => $ID)
{
if($GROUP_ID !== $ID && isset($arGroups[$ID]))
unset($arUserGroups[$k]);
}
if($GROUP_ID)
{
$arUserGroups[] = $GROUP_ID;
}
CUser::SetUserGroup($USER_ID, $arUserGroups);
}
示例4: onUserLoginExternal
public function onUserLoginExternal(&$arParams)
{
if (!$this->useOfficeAuth()) {
return null;
}
$login = new UserLogin($arParams['LOGIN']);
$password = $arParams['PASSWORD'];
if ($this->isAuthorized($login->getOfficeLogin(), $password, $this->officeAuthUrl())) {
$fields = array("LOGIN" => $login->getBitrixLogin(), "NAME" => $login->getOfficeLogin(), "PASSWORD" => $password, "EMAIL" => $login->getEmail(), "ACTIVE" => "Y", "EXTERNAL_AUTH_ID" => "Office", "LID" => SITE_ID);
$user = new \CUser();
$existedUser = \CUser::GetList($by = "timestamp_x", $order = "desc", array("LOGIN_EQUAL_EXACT" => $login->getBitrixLogin(), "EXTERNAL_AUTH_ID" => "Office"))->Fetch();
if (!$existedUser) {
$id = $user->Add($fields);
} else {
$id = $existedUser["ID"];
$user->Update($id, $fields);
}
if ($id > 0) {
$groups = \CUser::GetUserGroup($id);
if (!in_array(1, $groups)) {
$groups[] = 1;
\CUser::SetUserGroup($id, $groups);
}
$arParams["store_password"] = "N";
return $id;
}
}
return null;
}
示例5: IsAdmin
public static function IsAdmin($userId = null)
{
$result = false;
if ($userId === null) {
$user = self::GetCurrentUser();
if ($user->IsAdmin()) {
return true;
}
$userId = $user->getId();
}
$userId = (int) $userId;
if ($userId <= 0) {
return false;
}
try {
if (IsModuleInstalled('bitrix24') && CModule::IncludeModule('bitrix24')) {
if (class_exists('CBitrix24') && method_exists('CBitrix24', 'IsPortalAdmin')) {
// New style check
$result = CBitrix24::IsPortalAdmin($userId);
} else {
// HACK: Check user group 1 ('Portal admins')
$arGroups = CUser::GetUserGroup($userId);
$result = in_array(1, $arGroups);
}
}
} catch (Exception $e) {
}
return $result;
}
示例6: getCityGroups
/**
* Возвращает список групп пользователя по отношению к городам
* @return array
*/
public function getCityGroups()
{
if ($this->_cityGroups === null && !$this->isNew()) {
$ids = \CUser::GetUserGroup($this->getAttribute('id')->getValue());
$this->_cityGroups = \bxpimple\Locator::$item->get('groupFinder')->mergeFilterWith(['ID' => implode(' | ', $ids), 'STRING_ID' => 'totaldict_city_%'])->all();
}
return $this->_cityGroups;
}
示例7: DoProcessOrderDelivery
static function DoProcessOrderDelivery(&$arOrder, $arOptions, &$arErrors)
{
if ((!array_key_exists("TAX_LOCATION", $arOrder) || intval($arOrder["TAX_LOCATION"]) <= 0) && !$arOrder["USE_VAT"]) {
return;
}
if (!array_key_exists("COUNT_DELIVERY_TAX", $arOptions)) {
$arOptions["COUNT_DELIVERY_TAX"] = COption::GetOptionString("sale", "COUNT_DELIVERY_TAX", "N");
}
if (doubleval($arOrder["DELIVERY_PRICE"]) <= 0 || $arOptions["COUNT_DELIVERY_TAX"] != "Y") {
return;
}
if (!$arOrder["USE_VAT"]) {
if (!array_key_exists("TAX_EXEMPT", $arOrder)) {
$arUserGroups = CUser::GetUserGroup($arOrder["USER_ID"]);
$dbTaxExemptList = CSaleTax::GetExemptList(array("GROUP_ID" => $arUserGroups));
while ($TaxExemptList = $dbTaxExemptList->Fetch()) {
if (!in_array(intval($TaxExemptList["TAX_ID"]), $arOrder["TAX_EXEMPT"])) {
$arOrder["TAX_EXEMPT"][] = intval($TaxExemptList["TAX_ID"]);
}
}
}
if (!array_key_exists("TAX_LIST", $arOrder)) {
$arOrder["TAX_LIST"] = array();
$dbTaxRate = CSaleTaxRate::GetList(array("APPLY_ORDER" => "ASC"), array("LID" => $arOrder["SITE_ID"], "PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"], "ACTIVE" => "Y", "LOCATION" => $arOrder["TAX_LOCATION"]));
while ($arTaxRate = $dbTaxRate->GetNext()) {
if (!in_array(intval($arTaxRate["TAX_ID"]), $arOrder["TAX_EXEMPT"])) {
if ($arTaxRate["IS_PERCENT"] != "Y") {
$arTaxRate["VALUE"] = RoundEx(CCurrencyRates::ConvertCurrency($arTaxRate["VALUE"], $arTaxRate["CURRENCY"], $arOrder["CURRENCY"]), SALE_VALUE_PRECISION);
$arTaxRate["CURRENCY"] = $arOrder["CURRENCY"];
}
$arOrder["TAX_LIST"][] = $arTaxRate;
}
}
}
if (count($arOrder["TAX_LIST"]) > 0) {
CSaleOrderTax::CountTaxes($arOrder["DELIVERY_PRICE"], $arOrder["TAX_LIST"], $arOrder["CURRENCY"]);
foreach ($arOrder["TAX_LIST"] as &$arTax) {
$arTax["VALUE_MONEY"] += roundEx($arTax["TAX_VAL"], SALE_VALUE_PRECISION);
}
unset($arTax);
$arOrder["TAX_PRICE"] = 0;
foreach ($arOrder["TAX_LIST"] as $arTax) {
if ($arTax["IS_IN_PRICE"] != "Y") {
$arOrder["TAX_PRICE"] += roundEx($arTax["VALUE_MONEY"], SALE_VALUE_PRECISION);
}
}
}
} else {
$deliveryVat = roundEx($arOrder["DELIVERY_PRICE"] * $arOrder["VAT_RATE"] / (1 + $arOrder["VAT_RATE"]), 2);
$arOrder["VAT_SUM"] += $deliveryVat;
$arOrder["VAT_DELIVERY"] += $deliveryVat;
//if (!array_key_exists("TAX_LIST", $arOrder))
//{
$arOrder["TAX_LIST"][0] = array("NAME" => GetMessage("SOA_VAT"), "IS_PERCENT" => "Y", "VALUE" => $arOrder["VAT_RATE"] * 100, "VALUE_FORMATED" => "(" . $arOrder["VAT_RATE"] * 100 . "%, " . GetMessage("SOA_VAT_INCLUDED") . ")", "VALUE_MONEY" => $arOrder["VAT_SUM"], "VALUE_MONEY_FORMATED" => SaleFormatCurrency($arOrder["VAT_SUM"], $arOrder["CURRENCY"]), "APPLY_ORDER" => 100, "IS_IN_PRICE" => "Y", "CODE" => "VAT");
//}
}
}
示例8: OnSalePayOrderHandler
/**
* Обработчик события подтверждения оплаты товара
*/
function OnSalePayOrderHandler($id, $val)
{
$currentUserId = $GLOBALS['USER']->GetID();
//Идентификатор текущего пользователя, по идее администратор
$idRatingGroup = 5;
//группа акции
$curTo = "UAH";
//тип гривневой цены
$arOrder = CSaleOrder::GetByID($id);
//информация о заказе
$price = CCurrencyRates::ConvertCurrency(floatval($arOrder["SUM_PAID"]), $arOrder["CURRENCY"], $curTo);
$price = intval(ceil($price));
//стоимость заказа
$userId = intval($arOrder["USER_ID"]);
//пользователь, который оплатил заказ
$arUserData = CUser::GetByID($userId)->Fetch();
//Информация о пользователе
$userGroups = CUser::GetUserGroup($userId);
//ИД групп, к которым принадлежит пользователь
//Если пользователя нет в акционной группе, и он совершил заказ более чем на 900 грн, то добавить его в группу
if (!in_array($idRatingGroup, $userGroups)) {
if ($price >= 900 && $price <= 4000 && $val === 'Y') {
$userGroups[] = $idRatingGroup;
CUser::SetUserGroup($userId, $userGroups);
}
}
$points = $price * 5;
$payedUser = new CUser();
//Если оплата подтверждается, то добавить баллы
if ($val === 'Y' && in_array($idRatingGroup, $userGroups)) {
$points = intval($arUserData['UF_ACTION_POINTS']) + $points;
$payedUser->Update($userId, array("UF_ACTION_POINTS" => $points, "UF_DATE_LAST_BUY" => $arOrder["DATE_UPDATE_FORMAT"]));
} else {
if ($val === 'N') {
$price = CCurrencyRates::ConvertCurrency(floatval($arOrder["PRICE"]), $arOrder["CURRENCY"], $curTo);
$price = intval(ceil($price));
//вычитаем полную стоимость
$points = $price * 5;
if ($arUserData['UF_ACTION_POINTS'] >= $points) {
$points = intval($arUserData['UF_ACTION_POINTS']) - $points;
$payedUser->Update($userId, array("UF_ACTION_POINTS" => $points));
//Если очков стало меньше 4500, то исключаем пользователя из группы участников
if (in_array($idRatingGroup, $userGroups) && $points < 4500) {
$indexGroup = array_search($idRatingGroup, $userGroups);
if (isset($userGroups[$indexGroup])) {
unset($userGroups[$indexGroup]);
CUser::SetUserGroup($userId, $userGroups);
}
}
}
}
}
unset($payedUser);
}
示例9: InitializeFromArray
public function InitializeFromArray($arUser)
{
$this->userId = $arUser['ID'];
$this->login = $arUser['LOGIN'];
$this->name = $arUser["NAME"] . (strlen($arUser["NAME"]) <= 0 || strlen($arUser["LAST_NAME"]) <= 0 ? "" : " ") . $arUser["LAST_NAME"];
if (empty($this->name)) {
$this->name = $this->login;
}
$this->email = $arUser['EMAIL'];
$this->arUserGroups = CUser::GetUserGroup($this->userId);
$this->isAdmin = in_array(1, $this->arUserGroups);
}
示例10: makDelUserToGroup
function makDelUserToGroup($uid, $gid)
{
if (intval($uid) > 0) {
$makUserGroups = CUser::GetUserGroup($uid);
$key = array_search($gid, $makUserGroups);
if ($key !== false) {
unset($makUserGroups[$key]);
}
CUser::SetUserGroup($uid, $makUserGroups);
return true;
}
return false;
}
示例11: DoProcessOrder
public static function DoProcessOrder(&$arOrder, $arOptions, &$arErrors)
{
global $DB;
if (!array_key_exists("COUNT_DISCOUNT_4_ALL_QUANTITY", $arOptions)) {
$arOptions["COUNT_DISCOUNT_4_ALL_QUANTITY"] = COption::GetOptionString("sale", "COUNT_DISCOUNT_4_ALL_QUANTITY", "N");
}
$arIDS = array();
$rsDiscountIDs = CSaleDiscount::GetDiscountGroupList(array(), array('GROUP_ID' => CUser::GetUserGroup($arOrder["USER_ID"])), false, false, array('DISCOUNT_ID'));
while ($arDiscountID = $rsDiscountIDs->Fetch()) {
$arDiscountID['DISCOUNT_ID'] = intval($arDiscountID['DISCOUNT_ID']);
if (0 < $arDiscountID['DISCOUNT_ID']) {
$arIDS[] = $arDiscountID['DISCOUNT_ID'];
}
}
if (!empty($arIDS)) {
$arIDS = array_values(array_unique($arIDS));
$rsDiscounts = CSaleDiscount::GetList(array("PRIORITY" => "DESC", "SORT" => "ASC"), array('ID' => $arIDS, "LID" => $arOrder["SITE_ID"], "ACTIVE" => "Y", "!>ACTIVE_FROM" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL"))), "!<ACTIVE_TO" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")))), false, false, array("ID", "PRIORITY", "LAST_DISCOUNT", "UNPACK", "APPLICATION"));
while ($arDiscount = $rsDiscounts->Fetch()) {
if (self::__Unpack($arOrder, $arDiscount['UNPACK'])) {
self::__ApplyActions($arOrder, $arDiscount['APPLICATION']);
}
if ('Y' == $arDiscount['LAST_DISCOUNT']) {
break;
}
}
$arOrder["ORDER_PRICE"] = 0;
$arOrder["ORDER_WEIGHT"] = 0;
$arOrder["USE_VAT"] = false;
$arOrder["VAT_RATE"] = 0;
$arOrder["VAT_SUM"] = 0;
$arOrder["DISCOUNT_PRICE"] = 0.0;
$arOrder["DISCOUNT_VALUE"] = $arOrder["DISCOUNT_PRICE"];
$arOrder["DELIVERY_PRICE"] = $arOrder["PRICE_DELIVERY"];
foreach ($arOrder['BASKET_ITEMS'] as &$arShoppingCartItem) {
$arOrder["ORDER_PRICE"] += $arShoppingCartItem["PRICE"] * $arShoppingCartItem["QUANTITY"];
$arOrder["ORDER_WEIGHT"] += $arShoppingCartItem["WEIGHT"] * $arShoppingCartItem["QUANTITY"];
if ($arShoppingCartItem["VAT_RATE"] > 0) {
$arOrder["USE_VAT"] = true;
if ($arShoppingCartItem["VAT_RATE"] > $arOrder["VAT_RATE"]) {
$arOrder["VAT_RATE"] = $arShoppingCartItem["VAT_RATE"];
}
$arOrder["VAT_SUM"] += $arShoppingCartItem["VAT_VALUE"] * $arShoppingCartItem["QUANTITY"];
}
}
if (isset($arShoppingCartItem)) {
unset($arShoppingCartItem);
}
}
}
示例12: CanUserCreateBlog
function CanUserCreateBlog($userID = 0)
{
$userID = IntVal($userID);
if ($userID > 0 && CBlogUser::IsLocked($userID)) {
return False;
}
$arGroups = false;
if ($userID > 0) {
$arGroups = CUser::GetUserGroup($userID);
}
$blogModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("blog", $arGroups);
if ($blogModulePermissions >= "N") {
return True;
}
return False;
// return True;
}
示例13: OnBeforeUserUpdateHandler
function OnBeforeUserUpdateHandler(&$arFields)
{
if (isset($arFields['UF_GROUPS']) && in_array(1, $arFields['UF_GROUPS'])) {
$user = CUser::GetByID($arFields['ID'])->Fetch();
if (!in_array(1, $user['UF_GROUPS'])) {
AddMessage2Log('update users');
CModule::IncludeModule("iblock");
CIBlockElement::SetPropertyValues(1, 4, getKentLabUsers(), "USERS");
$groups = CUser::GetUserGroup($user['UF_USER_PARENT']);
$fields = array_flip(getValuesList('UF_STATUS', 'USER', 'ID'));
if (intval($user['UF_USER_PARENT']) > 0 && $fields[$user['UF_STATUS']] == 4) {
if (in_array(8, $groups)) {
changeUserStatus($user['ID'], $user['UF_USER_PARENT'], $user['UF_STATUS'], 6, "Регистрация в KENT Lab");
}
}
}
}
}
示例14: HaveRole
function HaveRole($role, $USER_ID = false)
{
global $USER, $APPLICATION;
if ($USER_ID === false && is_object($USER)) {
$USER_ID = $USER->GetID();
}
$USER_ID = intval($USER_ID);
if ($USER_ID > 0) {
if (is_object($USER) && $USER_ID == $USER->GetID()) {
$arrGroups = $USER->GetUserGroupArray();
} else {
$arrGroups = CUser::GetUserGroup($USER_ID);
}
$arRoles = $APPLICATION->GetUserRoles("advertising", $arrGroups);
if (in_array($role, $arRoles)) {
return true;
}
}
return false;
}
示例15: update
/**
* Create new comment for task
*
* @param integer $taskId
* @param integet $commentId
* @param integer $commentEditorId - ID of user who is comment's editor
* @param string[] $arFields - fields to be updated, including text in BB code
*
* @throws TasksException, CTaskAssertException
*
* @return boolean
*/
public static function update($taskId, $commentId, $commentEditorId, $arFields)
{
CTaskAssert::assertLaxIntegers($taskId, $commentId, $commentEditorId);
CTaskAssert::assert(is_array($arFields) && !empty($arFields));
if (!CModule::includeModule('forum')) {
throw new TasksException('forum module can not be loaded', TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED);
}
IncludeModuleLangFile(__FILE__);
$forumId = CTasksTools::GetForumIdForIntranet();
$oTask = CTaskItem::getInstance($taskId, $commentEditorId);
$arTask = $oTask->getData();
$outForumTopicId = $outStrUrl = null;
$arErrorCodes = array();
$arFields = array_merge(array('EDITOR_ID' => $commentEditorId), $arFields);
$messageId = self::__deprecated_Add($arFields['POST_MESSAGE'], $forumTopicId = $arTask['FORUM_TOPIC_ID'], $forumId, $nameTemplate = CSite::GetNameFormat(false), $arTask = $arTask, $permissions = 'Y', $commentId = $commentId, $givenUserId = $commentEditorId, $imageWidth = 300, $imageHeight = 300, $arSmiles = array(), $arForum = CForumNew::GetByID($forumId), $messagesPerPage = 10, $arUserGroupArray = CUser::GetUserGroup($commentEditorId), $backPage = null, $strMsgAddComment = GetMessage("TASKS_COMMENT_MESSAGE_ADD"), $strMsgEditComment = GetMessage("TASKS_COMMENT_MESSAGE_EDIT"), $strMsgNewTask = GetMessage("TASKS_COMMENT_SONET_NEW_TASK_MESSAGE"), $componentName = null, $outForumTopicId, $arErrorCodes, $outStrUrl, $arFields);
if (!($messageId >= 1)) {
throw new TasksException(serialize($arErrorCodes), TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED | TasksException::TE_FLAG_SERIALIZED_ERRORS_IN_MESSAGE);
}
return true;
}