本文整理汇总了PHP中CUser::SetUserGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP CUser::SetUserGroup方法的具体用法?PHP CUser::SetUserGroup怎么用?PHP CUser::SetUserGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUser
的用法示例。
在下文中一共展示了CUser::SetUserGroup方法的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: 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;
}
示例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: 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);
}
示例5: 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;
}
示例6: OnPostForm
//.........这里部分代码省略.........
}
}
function LocalGetPSActionParams($fileName)
{
$arPSCorrespondence = array();
if (file_exists($fileName) && is_file($fileName)) {
include $fileName;
}
return $arPSCorrespondence;
}
foreach ($paySystem as $pID => $value) {
foreach ($value as $personID) {
$arFields = array();
$arPaySysAction = "";
$dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $pID, "PERSON_TYPE_ID" => $personID));
if ($arPaySysAction = $dbPaySysAction->Fetch()) {
$pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysAction["ACTION_FILE"];
} else {
$dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $pID));
if ($arPaySysActionTmp = $dbPaySysAction->Fetch()) {
$pathToAction = $_SERVER["DOCUMENT_ROOT"] . $arPaySysActionTmp["ACTION_FILE"];
}
}
if (strlen($pathToAction) > 0) {
$arPSCorrespondence = LocalGetPSActionParams($pathToAction . "/.description.php");
$arParams = array();
foreach ($arPSCorrespondence as $k => $v) {
$typeTmp = $arResult[$pID . "_" . $k . "_" . $personID];
$valueTmp = $arResult["VALUE1_" . $pID . "_" . $k . "_" . $personID];
if (strlen($valueTmp) <= 0) {
$valueTmp = $arResult["VALUE2_" . $pID . "_" . $k . "_" . $personID];
}
$arParams[$k] = array("TYPE" => $typeTmp, "VALUE" => $valueTmp);
}
$arFields = array("NEW_WINDOW" => $arResult["paySystemPopup"][$pID][$personID], "PARAMS" => CSalePaySystemAction::SerializeParams($arParams));
if (IntVal($arPaySysAction["ID"]) > 0) {
CSalePaySystemAction::Update($arPaySysAction["ID"], $arFields);
} else {
$arFields["PAY_SYSTEM_ID"] = $pID;
$arFields["PERSON_TYPE_ID"] = $personID;
$arFields["NAME"] = $arPaySysActionTmp["NAME"];
$arFields["ACTION_FILE"] = $arPaySysActionTmp["ACTION_FILE"];
$arFields["HAVE_PREPAY"] = "N";
$arFields["HAVE_RESULT"] = "N";
$arFields["HAVE_ACTION"] = "N";
$arFields["HAVE_PAYMENT"] = "N";
$arFields["HAVE_RESULT_RECEIVE"] = "N";
if (file_exists($pathToAction)) {
if (is_dir($pathToAction)) {
if (file_exists($pathToAction . "/pre_payment.php")) {
$arFields["HAVE_PREPAY"] = "Y";
}
if (file_exists($pathToAction . "/result.php")) {
$arFields["HAVE_RESULT"] = "Y";
}
if (file_exists($pathToAction . "/action.php")) {
$arFields["HAVE_ACTION"] = "Y";
}
if (file_exists($pathToAction . "/payment.php")) {
$arFields["HAVE_PAYMENT"] = "Y";
}
if (file_exists($pathToAction . "/result_rec.php")) {
$arFields["HAVE_RESULT_RECEIVE"] = "Y";
}
} else {
$arFields["HAVE_PAYMENT"] = "Y";
}
}
CSalePaySystemAction::Add($arFields);
}
}
}
}
COption::SetOptionInt("sale", "location", $arResult["location"], false, $arResult["siteID"]);
if (empty($arResult["delivery"])) {
$arResult["delivery"] = array();
}
$dbDelivery = CSaleDeliveryHandler::GetList(array("SORT" => "ASC"), array("SITE_ID" => $arResult["siteID"], "ACTIVE" => "Y"));
while ($arDelivery = $dbDelivery->Fetch()) {
if (!in_array($arDelivery["SID"] . "_new", $arResult["delivery"])) {
CSaleDeliveryHandler::Set($arDelivery["SID"], array("ACTIVE" => "N"));
}
}
$dbDelivery = CSaleDelivery::GetList(array("SORT" => "ASC"), array("LID" => $arResult["siteID"], "ACTIVE" => "Y"));
while ($arDelivery = $dbDelivery->Fetch()) {
if (!in_array($arDelivery["ID"], $arResult["delivery"])) {
CSaleDelivery::Update($arDelivery["ID"], array("ACTIVE" => "N"));
}
}
if (strlen($arResult["login"]) > 0) {
$arFields = array("LOGIN" => $arResult["login"], "PASSWORD" => $arResult["password"], "CONFIRM_PASSWORD" => $arResult["password_rep"], "EMAIL" => $arResult["email"]);
$user = new CUser();
$ID = $user->Add($arFields);
if (IntVal($ID) > 0) {
$sGroups = COption::GetOptionString("main", "new_user_registration_def_group", "");
CUser::SetUserGroup($ID, array_merge(explode(",", $sGroups), $arResult["1C_GROUP_PERMISSIONS"]));
}
}
}
}
示例7: OnAfterUserRegister
public static function OnAfterUserRegister($arFields)
{
global $DB;
$err_mess = CRatings::err_mess() . "<br>Function: OnAfterUserRegister<br>Line: ";
$userId = isset($arFields["USER_ID"]) ? intval($arFields["USER_ID"]) : (isset($arFields["ID"]) ? intval($arFields["ID"]) : 0);
if ($userId > 0) {
$authorityRatingId = CRatings::GetAuthorityRating();
$ratingStartValue = COption::GetOptionString("main", "rating_start_authority", 3);
$ratingCountVote = COption::GetOptionString("main", "rating_count_vote", 10);
$arParam = array('RATING_ID' => $authorityRatingId, 'ENTITY_ID' => $userId, 'BONUS' => intval($ratingStartValue), 'VOTE_WEIGHT' => intval($ratingStartValue) * COption::GetOptionString("main", "rating_vote_weight", 1), 'VOTE_COUNT' => intval($ratingCountVote) + intval($ratingStartValue));
CRatings::UpdateRatingUserBonus($arParam);
if (IsModuleInstalled("intranet")) {
$strSql = "INSERT INTO b_rating_subordinate (RATING_ID, ENTITY_ID, VOTES) VALUES ('" . $authorityRatingId . "', '" . $userId . "', '" . (intval($ratingCountVote) + intval($ratingStartValue)) . "')";
$DB->Query($strSql, false, $err_mess . __LINE__);
}
$sRatingAssignType = COption::GetOptionString("main", "rating_assign_type", 'manual');
if ($sRatingAssignType == 'auto') {
$assignRatingGroup = COption::GetOptionString("main", "rating_assign_rating_group", 0);
$assignAuthorityGroup = COption::GetOptionString("main", "rating_assign_authority_group", 0);
if ($assignRatingGroup == 0 && $assignAuthorityGroup == 0) {
return false;
}
$arGroups = array();
$res = CUser::GetUserGroupList($userId);
while ($res_arr = $res->Fetch()) {
$arGroups[] = array("GROUP_ID" => $res_arr["GROUP_ID"], "DATE_ACTIVE_FROM" => $res_arr["DATE_ACTIVE_FROM"], "DATE_ACTIVE_TO" => $res_arr["DATE_ACTIVE_TO"]);
}
if ($assignRatingGroup > 0) {
$arGroups[] = array("GROUP_ID" => intval($assignRatingGroup));
}
if ($assignAuthorityGroup > 0 && $assignRatingGroup != $assignAuthorityGroup) {
$arGroups[] = array("GROUP_ID" => intval($assignAuthorityGroup));
}
CUser::SetUserGroup($userId, $arGroups);
}
if (CACHED_b_rating_vote !== false) {
global $CACHE_MANAGER;
$bucket_size = intval(CACHED_b_rating_bucket_size);
if ($bucket_size <= 0) {
$bucket_size = 100;
}
$bucket = intval($userId / $bucket_size);
$CACHE_MANAGER->Clean("b_rvu_" . $authorityRatingId . $bucket, "b_rating_user");
}
}
}
示例8: CatalogPayOrderCallback
function CatalogPayOrderCallback($productID, $userID, $bPaid, $orderID)
{
global $DB;
global $USER;
$productID = intval($productID);
$userID = intval($userID);
$bPaid = $bPaid ? true : false;
$orderID = intval($orderID);
if ($userID <= 0) {
return false;
}
$dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "N"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
if ($arIBlockElement = $dbIBlockElement->GetNext()) {
$arCatalog = CCatalog::GetByID($arIBlockElement["IBLOCK_ID"]);
if ($arCatalog["SUBSCRIPTION"] == "Y") {
$arProduct = CCatalogProduct::GetByID($productID);
if ($bPaid) {
if ('E' == CIBlock::GetArrayByID($arIBlockElement['IBLOCK_ID'], "RIGHTS_MODE")) {
$arUserRights = CIBlockElementRights::GetUserOperations($productID, $userID);
if (empty($arUserRights)) {
return false;
} elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
return false;
}
} else {
if ('R' > CIBlock::GetPermission($arIBlockElement['IBLOCK_ID'], $userID)) {
return false;
}
}
$arUserGroups = array();
$arTmp = array();
$ind = -1;
$curTime = time();
$dbProductGroups = CCatalogProductGroups::GetList(array(), array("PRODUCT_ID" => $productID), false, false, array("GROUP_ID", "ACCESS_LENGTH", "ACCESS_LENGTH_TYPE"));
while ($arProductGroups = $dbProductGroups->Fetch()) {
$ind++;
$arProductGroups['GROUP_ID'] = intval($arProductGroups['GROUP_ID']);
$accessType = $arProductGroups["ACCESS_LENGTH_TYPE"];
$accessLength = intval($arProductGroups["ACCESS_LENGTH"]);
$accessVal = 0;
if (0 < $accessLength) {
if ($accessType == CCatalogProduct::TIME_PERIOD_HOUR) {
$accessVal = mktime(date("H") + $accessLength, date("i"), date("s"), date("m"), date("d"), date("Y"));
} elseif ($accessType == CCatalogProduct::TIME_PERIOD_DAY) {
$accessVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + $accessLength, date("Y"));
} elseif ($accessType == CCatalogProduct::TIME_PERIOD_WEEK) {
$accessVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 7 * $accessLength, date("Y"));
} elseif ($accessType == CCatalogProduct::TIME_PERIOD_MONTH) {
$accessVal = mktime(date("H"), date("i"), date("s"), date("m") + $accessLength, date("d"), date("Y"));
} elseif ($accessType == CCatalogProduct::TIME_PERIOD_QUART) {
$accessVal = mktime(date("H"), date("i"), date("s"), date("m") + 3 * $accessLength, date("d"), date("Y"));
} elseif ($accessType == CCatalogProduct::TIME_PERIOD_SEMIYEAR) {
$accessVal = mktime(date("H"), date("i"), date("s"), date("m") + 6 * $accessLength, date("d"), date("Y"));
} elseif ($accessType == CCatalogProduct::TIME_PERIOD_YEAR) {
$accessVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") + $accessLength);
} elseif ($accessType == CCatalogProduct::TIME_PERIOD_DOUBLE_YEAR) {
$accessVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") + 2 * $accessLength);
}
}
$arUserGroups[$ind] = array("GROUP_ID" => $arProductGroups["GROUP_ID"], "DATE_ACTIVE_FROM" => date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID)), $curTime), "DATE_ACTIVE_TO" => 0 < $accessLength ? date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID)), $accessVal) : false);
$arTmp[$arProductGroups["GROUP_ID"]] = $ind;
}
if (!empty($arUserGroups)) {
$dbOldGroups = CUser::GetUserGroupEx($userID);
while ($arOldGroups = $dbOldGroups->Fetch()) {
$arOldGroups["GROUP_ID"] = intval($arOldGroups["GROUP_ID"]);
if (array_key_exists($arOldGroups["GROUP_ID"], $arTmp)) {
if (strlen($arOldGroups["DATE_ACTIVE_FROM"]) <= 0) {
$arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_FROM"] = false;
} else {
$oldDate = CDatabase::FormatDate($arOldGroups["DATE_ACTIVE_FROM"], CSite::GetDateFormat("SHORT", SITE_ID), "YYYYMMDDHHMISS");
$newDate = CDatabase::FormatDate($arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_FROM"], CSite::GetDateFormat("SHORT", SITE_ID), "YYYYMMDDHHMISS");
if ($oldDate > $newDate) {
$arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_FROM"] = $arOldGroups["DATE_ACTIVE_FROM"];
}
}
if (strlen($arOldGroups["DATE_ACTIVE_TO"]) <= 0) {
$arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_TO"] = false;
} elseif (false !== $arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_TO"]) {
$oldDate = CDatabase::FormatDate($arOldGroups["DATE_ACTIVE_TO"], CSite::GetDateFormat("SHORT", SITE_ID), "YYYYMMDDHHMISS");
$newDate = CDatabase::FormatDate($arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_TO"], CSite::GetDateFormat("SHORT", SITE_ID), "YYYYMMDDHHMISS");
if ($oldDate > $newDate) {
$arUserGroups[$arTmp[$arOldGroups["GROUP_ID"]]]["DATE_ACTIVE_TO"] = $arOldGroups["DATE_ACTIVE_TO"];
}
}
} else {
$ind++;
$arUserGroups[$ind] = array("GROUP_ID" => $arOldGroups["GROUP_ID"], "DATE_ACTIVE_FROM" => $arOldGroups["DATE_ACTIVE_FROM"], "DATE_ACTIVE_TO" => $arOldGroups["DATE_ACTIVE_TO"]);
}
}
CUser::SetUserGroup($userID, $arUserGroups);
if (CCatalog::IsUserExists()) {
if (intval($USER->GetID()) == $userID) {
$arUserGroupsTmp = array();
foreach ($arUserGroups as &$arOneGroup) {
$arUserGroupsTmp[] = $arOneGroup["GROUP_ID"];
}
if (isset($arOneGroup)) {
unset($arOneGroup);
}
//.........这里部分代码省略.........
示例9: SetUser
function SetUser($arLdapUser, $bAddNew = true)
{
global $USER;
$isHead = false;
$bUSERGen = false;
if (!is_object($USER)) {
$USER = new CUser();
$bUSERGen = true;
}
// process previously saved department data
if (IsModuleInstalled('intranet') && is_array($arLdapUser['UF_DEPARTMENT'])) {
$isHead = $arLdapUser['UF_DEPARTMENT']['IS_HEAD'];
// replace temporary value with a real one
$arLdapUser['UF_DEPARTMENT'] = array($arLdapUser['UF_DEPARTMENT']['ID']);
}
if (isset($arLdapUser["ID"])) {
$ID = intval($arLdapUser["ID"]);
self::PrepareUserPhoto($ID, $arLdapUser);
$USER->Update($ID, $arLdapUser);
} else {
$ldapUserID = 0;
if (isset($_REQUEST["ldap_user_id"]) && strlen($_REQUEST["ldap_user_id"]) == 32) {
$dbUser = CUser::GetList($O = "", $B = "", array("XML_ID" => $_REQUEST["ldap_user_id"], 'EXTERNAL_AUTH_ID' => $arLdapUser['EXTERNAL_AUTH_ID']));
if ($arUser = $dbUser->Fetch()) {
if ($arUser["XML_ID"]) {
$ldapUserID = $arUser["ID"];
}
}
}
$res = CUser::GetList($O = "", $B = "", array('LOGIN_EQUAL_EXACT' => $arLdapUser['LOGIN'], 'EXTERNAL_AUTH_ID' => $arLdapUser['EXTERNAL_AUTH_ID']));
$arLdapUser['PASSWORD'] = uniqid(rand(), true);
if (!($ar_res = $res->Fetch()) && $ldapUserID < 1) {
if ($bAddNew) {
if (strlen($arLdapUser["EMAIL"]) <= 0) {
$arLdapUser["EMAIL"] = COption::GetOptionString("ldap", "default_email", 'no@email');
}
$ID = $USER->Add($arLdapUser);
} else {
$ID = 0;
}
} else {
$ID = $ldapUserID > 1 ? $ldapUserID : $ar_res['ID'];
self::PrepareUserPhoto($ID, $arLdapUser);
$USER->Update($ID, $arLdapUser);
}
$ID = intval($ID);
}
// - add this user to groups
if ($ID > 0) {
// - set as head of department
if (IsModuleInstalled('intranet') && $isHead) {
CLdapUtil::SetDepartmentHead($ID, $arLdapUser['UF_DEPARTMENT'][0]);
}
// For each group finding all superior ones
$arUserLdapGroups = array();
$arLdapGroups = $this->GetGroupListArray();
$this->GetAllMemberOf($arLdapUser['LDAP_GROUPS'], $arUserLdapGroups, $arLdapGroups);
$arGroupMaps = $this->GetGroupMaps();
$arUserBitrixGroups = $USER->GetUserGroup($ID);
$arUserBitrixGroupsNew = array();
$prevGroups = $arUserBitrixGroups;
sort($prevGroups);
foreach ($arGroupMaps as $fromLdapGroup => $arToUserGroups) {
foreach ($arToUserGroups as $toUserGroup) {
if (($k = array_search($toUserGroup, $arUserBitrixGroups)) !== false) {
unset($arUserBitrixGroups[$k]);
}
// If there is such a group among user's
if (in_array($fromLdapGroup, $arUserLdapGroups)) {
$arUserBitrixGroupsNew[] = $toUserGroup;
}
}
}
$arUserBitrixGroups = array_merge($arUserBitrixGroups, array_unique($arUserBitrixGroupsNew));
sort($arUserBitrixGroups);
if ($arUserBitrixGroups != $prevGroups) {
$USER->SetUserGroup($ID, $arUserBitrixGroups);
}
}
if ($bUSERGen) {
unset($USER);
}
return $ID;
}
示例10: array
} else {
$UserId = CustomUser::NewUser($Fields);
}
if ($UserId > 0) {
/*
if($Fields["UF_YOU_HAVE_18"] == 1){
CustomUser::AddUserGroupClosedCommunity(array("USER_ID"=> $UserId,"UF_YOU_HAVE_18" => 1));
}
*/
$USER->Authorize($UserId);
$Fields["UF_FB_PROFILE"] = array($UserDate->id);
CustomUser::UserUpdate($Fields);
if ($ambassador) {
$arGroups = CUser::GetUserGroup($UserId);
$arGroups[] = 13;
CUser::SetUserGroup($UserId, $arGroups);
}
}
}
}
}
if (strripos($_SERVER['HTTP_USER_AGENT'], "iphone") || strripos($_SERVER['HTTP_USER_AGENT'], "android") || strripos($_SERVER['HTTP_USER_AGENT'], "ipod") || strripos($_SERVER['HTTP_USER_AGENT'], "windows phone")) {
$backurl = $APPLICATION->get_cookie("MQ_BACKURL");
if ($backurl) {
$APPLICATION->set_cookie("MQ_BACKURL", "", time(), "/");
}
LocalRedirect('http://' . $_SERVER['SERVER_NAME'] . "/?backurl=" . $backurl);
} else {
echo "<script type=\"text/javascript\">window.close();</script>";
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/epilog_after.php";
示例11: array_diff
$lAdmin->AddGroupError(GetMessage("MAIN_EDIT_ERROR").$ob->LAST_ERROR, $ID);
break;
case "add_group":
case "remove_group":
if($gr_id <= 0)
continue;
if($gr_id == 1 && !$USER->CanDoOperation('edit_php')) // not admin can't edit admins
continue;
if ($USER->CanDoOperation('edit_subordinate_users') && !$USER->CanDoOperation('edit_all_users') && !in_array($gr_id, $arUserSubordinateGroups))
continue;
$newGroups = array_diff($UGroups, array(2));
if($_REQUEST['action']=="add_group")
$newGroups[] = $gr_id;
else
$newGroups = array_diff($newGroups, array($gr_id));
CUser::SetUserGroup($ID, $newGroups);
break;
case "add_structure":
case "remove_structure":
if($struct_id <= 0)
continue;
$dbUser = CUser::GetByID($ID);
$arUser = $dbUser->Fetch();
$arDep = $arUser['UF_DEPARTMENT'];
if(!is_array($arDep))
$arDep = array();
if($_REQUEST['action']=="add_structure")
$arDep[] = $struct_id;
else
示例12: array
if ($arIBlock = $rsIBlock->Fetch()) {
$iblockID = $arIBlock["ID"];
$arFilter["ID"] = WIZARD_SITE_DEPARTAMENT;
$rsSections = CIBlockSection::GetList(array(), $arFilter);
$arSection = $rsSections->GetNext();
$arFilter = array("LEFT_MARGIN" => $arSection["LEFT_MARGIN"], "RIGHT_MARGIN" => $arSection["RIGHT_MARGIN"], "BLOCK_ID" => $iblockID, 'ACTIVE' => 'Y', 'GLOBAL_ACTIVE' => 'Y');
$rsSections = CIBlockSection::GetList(array("left_margin" => "asc"), $arFilter);
$arSectionUsers = array();
while ($arSection = $rsSections->GetNext()) {
$arSectionUsers[] = $arSection['ID'];
}
$rsUsers = CUser::GetList($by = "id", $order = "asc", array("UF_DEPARTMENT" => $arSectionUsers));
while ($arUsers = $rsUsers->Fetch()) {
$arGroups = CUser::GetUserGroup($arUsers["ID"]);
$arGroups[] = $groupID;
CUser::SetUserGroup($arUsers["ID"], $arGroups);
}
}
$dbResult = CGroup::GetList($by, $order, array("STRING_ID" => "PERSONNEL_DEPARTMENT", "STRING_ID_EXACT_MATCH" => "Y"));
if ($arExistsGroup = $dbResult->Fetch()) {
$groupID = $arExistsGroup["ID"];
$arSubordinateGroups = CGroup::GetSubordinateGroups($groupID);
$arSubordinateGroups[] = $SiteGroups["EMPLOYEES_" . WIZARD_SITE_ID];
$arSubordinateGroups[] = $SiteGroups["RATING_VOTE"];
$arSubordinateGroups[] = $SiteGroups["RATING_VOTE_AUTHORITY"];
CGroup::SetSubordinateGroups($groupID, $arSubordinateGroups);
}
CGroup::SetSubordinateGroups($SiteGroups["PORTAL_ADMINISTRATION_" . WIZARD_SITE_ID], array($SiteGroups["EMPLOYEES_" . WIZARD_SITE_ID]));
}
/*$allowGuests = COption::GetOptionString("main", "wizard_allow_group", "N", WIZARD_SITE_ID);
if($allowGuests == "Y")
示例13: foreach
foreach ($arGroup["TASKS_FILE"] as $arFile) {
$taskName = $arFile[0];
$filePath = $arFile[1];
$dbResult = CTask::GetList(array(), array("NAME" => $taskName));
if ($arTask = $dbResult->Fetch()) {
CExtranetWizardServices::SetFilePermission(array(WIZARD_SITE_ID, $filePath), array($groupID => "T_" . $arTask["ID"]));
}
}
}
// set view perms for employee groups
$rsGroupEmployees = CGroup::GetList($by = "c_sort", $order = "asc", array("STRING_ID" => "EMPLOYEES%"));
while ($arGroupEmployees = $rsGroupEmployees->Fetch()) {
$dbResult = CTask::GetList(array(), array("NAME" => "fm_folder_access_read"));
if ($arTask = $dbResult->Fetch()) {
CExtranetWizardServices::SetFilePermission(array(WIZARD_SITE_ID, WIZARD_SITE_DIR), array($arGroupEmployees["ID"] => "T_" . $arTask["ID"]));
}
}
$APPLICATION->SetGroupRight("fileman", WIZARD_EXTRANET_ADMIN_GROUP, "F");
$task_id = CTask::GetIdByLetter("F", "fileman");
if (intval($task_id) > 0) {
CGroup::SetTasksForModule("fileman", array(WIZARD_EXTRANET_ADMIN_GROUP => array("ID" => $task_id)));
}
CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/.top.menu.php", array("EXTRANET_ADMIN_GROUP_ID" => $ExtranetAdminGroupID));
$rsUser = CUser::GetList($by = "ID", $order = "desc", array("GROUPS_ID" => array(1)));
while ($arAdminUser = $rsUser->Fetch()) {
$arUserGroups = CUser::GetUserGroup($arAdminUser["ID"]);
if (is_array($arUserGroups) && !in_array(WIZARD_EXTRANET_GROUP, $arUserGroups)) {
$arUserGroups[] = WIZARD_EXTRANET_GROUP;
CUser::SetUserGroup($arAdminUser["ID"], $arUserGroups);
}
}
示例14: LoadUser
//.........这里部分代码省略.........
$arFields['LOGIN'] = 'user_' . $USER_COUNTER;
}
if (!$arFields['EXTERNAL_AUTH_ID']) {
if ($this->arParams['PASSWORD_PROPERTY_XML_ID']) {
$arFields['PASSWORD'] = $arFields['CONFIRM_PASSWORD'] = $arFields[$this->CalcPropertyFieldName($this->arParams['PASSWORD_PROPERTY_XML_ID'])];
}
if (!$arFields['PASSWORD']) {
$arFields['PASSWORD'] = $arFields['CONFIRM_PASSWORD'] = RandString($this->arParams['PASSWORD_LENGTH'] ? $this->arParams['PASSWORD_LENGTH'] : 7);
}
}
// set user groups list to default from main module setting
if (is_array($this->arUserGroups)) {
$arFields['GROUP_ID'] = $this->arUserGroups;
}
} else {
// for an existing user
if ($this->arParams['UPDATE_LOGIN']) {
$arFields['LOGIN'] = $arFields[$this->CalcPropertyFieldName($this->arParams['LOGIN_PROPERTY_XML_ID'])];
if (strlen($arFields['LOGIN']) <= 0) {
unset($arFields['LOGIN']);
}
}
if ($this->arParams['UPDATE_PASSWORD']) {
$arFields['PASSWORD'] = $arFields['CONFIRM_PASSWORD'] = $arFields[$this->CalcPropertyFieldName($this->arParams['PASSWORD_PROPERTY_XML_ID'])];
if (strlen($arFields['PASSWORD']) <= 0) {
unset($arFields['PASSWORD']);
unset($arFields['CONFIRM_PASSWORD']);
}
}
if (!$this->arParams['UPDATE_EMAIL'] || strlen($arFields['EMAIL']) <= 0) {
unset($arFields['EMAIL']);
}
}
$bNew = $CURRENT_USER <= 0;
if (!$bNew) {
foreach ($arFields as $key => $value) {
if ($key !== 'ACTIVE' && !in_array($key, $this->arParams['UPDATE_PROPERTIES'])) {
unset($arFields[$key]);
}
}
// update existing user
if ($res = $obUser->Update($CURRENT_USER, $arFields)) {
$counter[$arFields['ACTIVE'] == 'Y' ? 'UPD' : 'DEA']++;
}
} else {
$group_id = $arFields['GROUP_ID'];
unset($arFields['GROUP_ID']);
// create new user
if ($CURRENT_USER = $obUser->Add($arFields)) {
$counter['ADD']++;
CUser::SetUserGroup($CURRENT_USER, $group_id);
if (isset($this->next_step['_TEMPORARY']['DEPARTMENT_HEADS'][$arFields['XML_ID']])) {
$obSection = new CIBlockSection();
foreach ($this->next_step['_TEMPORARY']['DEPARTMENT_HEADS'][$arFields['XML_ID']] as $dpt) {
$obSection->Update($dpt, array('UF_HEAD' => $CURRENT_USER), false, false);
}
}
if ($this->arParams['EMAIL_NOTIFY'] == 'Y' || $this->arParams['EMAIL_NOTIFY'] == 'E' && $bEmailExists) {
$arFields['ID'] = $CURRENT_USER;
//$this->__event->Send("USER_INFO", SITE_ID, $arFields);
//echo CEvent::Send("USER_INFO", 's1', $arFields);
$this->__user->SendUserInfo($CURRENT_USER, $this->arParams['SITE_ID'], '', $this->arParams['EMAIL_NOTIFY_IMMEDIATELY'] == 'Y');
}
}
if (!($res = $CURRENT_USER > 0)) {
$USER_COUNTER--;
}
}
if (!$res) {
$counter['ERR']++;
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intranet/cml2-import-user.log', 'a');
fwrite($fp, "==============================================================\r\n");
fwrite($fp, $obUser->LAST_ERROR . "\r\n");
fwrite($fp, print_r($arFields, true));
fwrite($fp, "==============================================================\r\n");
fclose($fp);
} elseif (is_array($arStateHistory) && count($arStateHistory) > 0) {
if (null == $this->__ib) {
$this->__ib = new CIBlockElement();
}
if (!$bNew) {
$dbRes = $this->__ib->GetList(array(), array('PROPERTY_USER' => $CURRENT_USER, 'IBLOCK_ID' => $this->STATE_HISTORY_IBLOCK_ID), false, false, array('ID', 'IBLOCK_ID'));
while ($arRes = $dbRes->Fetch()) {
$this->__ib->Delete($arRes['ID']);
}
}
foreach ($arStateHistory as $date => $arState) {
$arStateFields = array('IBLOCK_SECTION' => false, 'IBLOCK_ID' => $this->STATE_HISTORY_IBLOCK_ID, 'DATE_ACTIVE_FROM' => ConvertTimeStamp($date, 'SHORT'), 'ACTIVE' => 'Y', 'NAME' => $arState['STATE'] . ' - ' . $arFields['LAST_NAME'] . ' ' . $arFields['NAME'], 'PREVIEW_TEXT' => $arState['STATE'], 'PROPERTY_VALUES' => array('POST' => $arState['POST'], 'USER' => $CURRENT_USER, 'DEPARTMENT' => $arState['DEPARTMENT'], 'STATE' => array("VALUE" => $property_state_final[ToLower($arState['STATE'])])));
if (!$this->__ib->Add($arStateFields, false, false)) {
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intranet/cml2-import-state.log', 'a');
fwrite($fp, "==============================================================\r\n");
fwrite($fp, $this->__ib->LAST_ERROR . "\r\n");
fwrite($fp, print_r($arStateFields, true));
fwrite($fp, "==============================================================\r\n");
fclose($fp);
}
}
}
return $CURRENT_USER;
}
示例15: array_merge
// Тут что-то обновляется неведомое от старого сайта
/*
if ($APPLICATION->get_cookie("MQ_REGISTRATION_TOKEN")) {
$fields = array_merge($fields, array(
'UF_INVITE_STATUS' => 1,
'UF_STATUS' => 31
));
}
*/
if (!$APPLICATION->get_cookie("MQ_AUTH_TOKEN")) {
$APPLICATION->set_cookie("MQ_AUTH_TOKEN", $token, time() + 60 * 60 * 24 * 30 * 12 * 4, "/");
$fields = array_merge($fields, array('UF_AUTH_TOKEN' => $token));
}
if ($APPLICATION->get_cookie("MQ_AMBASSADOR")) {
$APPLICATION->set_cookie("MQ_AMBASSADOR", 0, time() - 60, "/");
CUser::SetUserGroup($ID, array_merge(array(13), CUser::GetUserGroup($ID)));
}
}
} else {
$result['url'] = '/signup/lock/';
}
$user = new CUser();
$user->Update($ID, $fields);
}
}
} else {
$result['url'] = '/';
}
?>
<script type="text/javascript">
if(window.opener) {