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


PHP CUser::Add方法代码示例

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


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

示例1: 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;
 }
开发者ID:techart,项目名称:bitrix.tao,代码行数:29,代码来源:auth.php

示例2: Add

 public function Add()
 {
     global $USER;
     if ($USER->isAuthorized()) {
         return \CUser::GetID();
     }
     $this->arFields = array_merge($this->getFields(), $this->defaultFields);
     if (!$this->arFields["EMAIL"]) {
         throw new CRUDException("Please, set email for new user");
     }
     $u = \CUser::GetList($by = "ID", $order = "DESC", array("EMAIL" => $this->arFields["EMAIL"]))->Fetch();
     if ($u) {
         return $u["ID"];
     }
     try {
         $this->generate('LOGIN')->generate('PASSWORD')->generate('GROUP_ID');
     } catch (CRUDGenerateException $e) {
         prentExpection($e->getMessage());
     }
     $objUser = new \CUser();
     $newUserID = $objUser->Add($this->arFields);
     if (!intval($newUserID)) {
         throw new CRUDException("An error was occured while adding new User in CRUD: " . $objUser->LAST_ERROR . ". Line: " . __LINE__);
     } else {
         return $newUserID;
     }
 }
开发者ID:ASDAFF,项目名称:bitrix_tehnomir,代码行数:27,代码来源:CRUD.php

示例3: UserCreate

    public static function UserCreate($name, $phone, $domen, $login, $group) //$name - string, $phone - string, $domen - string, $login - string, $group - array
    {

        if (CUser::IsAuthorized()) {
            $userId = CUser::GetID();
            return (int)$userId;
        } else {
            $usersCheck = CUser::GetByLogin($login);
            if ($arUser = $usersCheck->Fetch()) {
                return (int)$arUser["ID"];
            } else {
            	$stringPhone = preg_replace('~\D~','',$phone);
                $password = OrderClick::GeneratePassword(10);
                $user = new CUser;
                $arFields = Array(
                    "NAME" => $name,
                    "EMAIL" => $stringPhone . "@" . $domen,
                    "LOGIN" => $phone,
                    "ACTIVE" => "N", // Делаю пользователя не активным
                    "GROUP_ID" => $group,
                    "PASSWORD" => $password,
                    "CONFIRM_PASSWORD" => $password,
                    "PERSONAL_PHONE" => $stringPhone,
                );
                return $user->Add($arFields);
            }
        }

    }
开发者ID:ASDAFF,项目名称:order_click,代码行数:29,代码来源:class.php

示例4: registerUser

function registerUser($userInfo)
{
    $errors = array();
    $result = '';
    if (empty($userInfo['name'])) {
        $errors[] = 'Вы не ввели имя';
    }
    if (empty($userInfo['email'])) {
        $errors[] = 'Вы не ввели email';
    }
    if (empty($userInfo['phone'])) {
        $errors[] = 'Вы не ввели телефон';
    }
    if (empty($errors)) {
        $user = new CUser();
        $password = make_password(8);
        $arFields = array("NAME" => $userInfo['name'], "EMAIL" => $userInfo['email'], "LOGIN" => $userInfo['email'], "ACTIVE" => "Y", "GROUP_ID" => array(6), "PASSWORD" => $password, "CONFIRM_PASSWORD" => $password, "PERSONAL_PHONE" => $userInfo['phone']);
        $ID = $user->Add($arFields);
        if (intval($ID) > 0) {
            $result = "Вы успешно зарегистрированы.";
            $arEventField = array("NAME" => $userInfo['name'], "EMAIL" => $userInfo['email'], "PASSWORD" => $password);
            CEvent::SendImmediate("NEW_REG", "s1", $arEventField);
            unset($_POST['user']);
            global $USER;
            global $APPLICATION;
            $USER->Authorize($ID);
            LocalRedirect($APPLICATION->GetCurPageParam('', array('user[name]', 'user[email]', 'ELEMENT_CODE', 'code')));
        } else {
            $errors[] = $user->LAST_ERROR;
        }
    }
    return $errors;
}
开发者ID:ASDAFF,项目名称:mp,代码行数:33,代码来源:registration.php

示例5: createUloginAccount

 public static function createUloginAccount($profile, $id)
 {
     $user = new CUser();
     $ulogin_profile['EMAIL'] = $profile['EMAIL'];
     $ulogin_profile['LOGIN'] = $profile['LOGIN'];
     $ulogin_profile['PASSWORD'] = rand(1000000, 10000000);
     $ulogin_profile['CONFIRM_PASSWORD'] = $ulogin_profile['PASSWORD'];
     $ulogin_profile['ACTIVE'] = 'N';
     $ulogin_profile['ADMIN_NOTES'] = $profile['NETWORK'] . '=' . $id;
     $ulogin_profile['EXTERNAL_AUTH_ID'] = $profile['EXTERNAL_AUTH_ID'];
     return $user->Add($ulogin_profile);
 }
开发者ID:rasuldev,项目名称:torino,代码行数:12,代码来源:Ulogun.class.php

示例6: addUser

 function addUser($arUserFields = array(), $arDepartmens = array())
 {
     $arUserFields["GROUP_ID"] = array(5);
     $emails = array_unique(split(', ', $arUserFields["EMAIL"]));
     $arUserFields["EMAIL"] = trim($emails[0]);
     $arUserFields["COPY_EMAIL"] = implode(', ', $emails);
     $arUserFields["UID"] = $ID;
     $arUserFields["CONFIRM_PASSWORD"] = trim($arUserFields["CONFIRM_PASSWORD"]);
     $arUserFields["PASSWORD"] = trim($arUserFields["PASSWORD"]);
     $user = new CUser();
     $ID = $user->Add($arUserFields);
     if (intval($ID) > 0) {
         $arUserFields["UID"] = $ID;
     } else {
         echo "<hr/>" . $user->LAST_ERROR;
     }
     print_r($arUserFields);
     return $arUserFields;
 }
开发者ID:raffiz,项目名称:my_home_tests,代码行数:19,代码来源:add.php

示例7: CUser

		{
			if(ExecuteModuleEventEx($arEvent, array(&$arResult['VALUES'])) === false)
			{
				if($err = $APPLICATION->GetException())
					$arResult['ERRORS'][] = $err->GetString();

				$bOk = false;
				break;
			}
		}

		$ID = 0;
		$user = new CUser();
		if ($bOk)
		{
			$ID = $user->Add($arResult["VALUES"]);
		}

		if (intval($ID) > 0)
		{
			$register_done = true;

			// authorize user
			if ($arParams["AUTH"] == "Y" && $arResult["VALUES"]["ACTIVE"] == "Y")
			{
				if (!$arAuthResult = $USER->Login($arResult["VALUES"]["LOGIN"], $arResult["VALUES"]["PASSWORD"]))
					$arResult["ERRORS"][] = $arAuthResult;
			}

			$arResult['VALUES']["USER_ID"] = $ID;
开发者ID:ASDAFF,项目名称:open_bx,代码行数:30,代码来源:component.php

示例8: uniqid

            if ($registerNewUser === true) {
                $userPassword = uniqid();

                $newUser = new CUser;
                $arFields = array(
                    "NAME"              => ICrmOrderActions::fromJSON($order['customer']['firstName']),
                    "LAST_NAME"         => ICrmOrderActions::fromJSON($order['customer']['lastName']),
                    "EMAIL"             => $order['customer']['email'],
                    "LOGIN"             => $login,
                    "LID"               => "ru",
                    "ACTIVE"            => "Y",
                    "PASSWORD"          => $userPassword,
                    "CONFIRM_PASSWORD"  => $userPassword
                );
                $registeredUserID = $newUser->Add($arFields);
                if ($registeredUserID === false) {
                    ICrmOrderActions::eventLog('ICrmOrderActions::orderHistory', 'CUser::Register', 'Error register user');
                    die();
                }

                try {
                    $api->customerFixExternalIds(array(array('id' => $order['customer']['id'], 'externalId' => $registeredUserID)));
                } catch (\IntaroCrm\Exception\CurlException $e) {
                    ICrmOrderActions::eventLog(
                        'ICrmOrderActions::orderHistory', 'RetailCrm\RestApi::customerFixExternalIds::CurlException',
                        $e->getCode() . ': ' . $e->getMessage()
                    );

                    die();
                }
开发者ID:Ksenobyte,项目名称:bitrix-module,代码行数:30,代码来源:history.php

示例9: OnPostForm

 function OnPostForm()
 {
     $wizard =& $this->GetWizard();
     if ($wizard->IsNextButtonClick()) {
         $arResult = $wizard->GetVars(true);
         COption::SetOptionString("sale", "order_email", $arResult["orderEmail"]);
         COption::SetOptionString("sale", "delete_after", $arResult["saveBasket"]);
         COption::SetOptionString("sale", "default_currency", $arResult["currencyID"]);
         $arFields["LID"] = $arResult["siteID"];
         $arFields["CURRENCY"] = $arResult["currencyID"];
         CSaleLang::Update($arResult["siteID"], array("LID" => $arResult["siteID"], "CURRENCY" => $arResult["currencyID"]));
         CSaleGroupAccessToSite::DeleteBySite($arResult["siteID"]);
         foreach ($arResult["groupID"] as $v) {
             CSaleGroupAccessToSite::Add(array("SITE_ID" => $arResult["siteID"], "GROUP_ID" => $v));
         }
         if (!empty($arResult["1C_GROUP_PERMISSIONS"])) {
             COption::SetOptionString("catalog", "1C_GROUP_PERMISSIONS", implode(",", $arResult["1C_GROUP_PERMISSIONS"]));
         }
         COption::SetOptionString("catalog", "1C_ELEMENT_ACTION", $arResult["1C_ELEMENT_ACTION"]);
         COption::SetOptionString("catalog", "1C_SECTION_ACTION", $arResult["1C_SECTION_ACTION"]);
         COption::SetOptionString("catalog", "1C_INTERVAL", $arResult["1C_INTERVAL"]);
         COption::SetOptionString("catalog", "1C_FILE_SIZE_LIMIT", $arResult["1C_FILE_SIZE_LIMIT"]);
         COption::SetOptionString("catalog", "1C_SITE_LIST", $arResult["siteID"]);
         if (!empty($arResult["1C_GROUP_PERMISSIONS"])) {
             COption::SetOptionString("sale", "1C_SALE_GROUP_PERMISSIONS", implode(",", $arResult["1C_GROUP_PERMISSIONS"]));
         }
         COption::SetOptionString("sale", "1C_EXPORT_PAYED_ORDERS", $arResult["1C_EXPORT_PAYED_ORDERS"]);
         COption::SetOptionString("sale", "1C_EXPORT_ALLOW_DELIVERY_ORDERS", $arResult["1C_EXPORT_ALLOW_DELIVERY_ORDERS"]);
         COption::SetOptionString("sale", "1C_EXPORT_FINAL_ORDERS", $arResult["1C_EXPORT_FINAL_ORDERS"]);
         COption::SetOptionString("sale", "1C_FINAL_STATUS_ON_DELIVERY", $arResult["1C_FINAL_STATUS_ON_DELIVERY"]);
         COption::SetOptionString("sale", "1C_SALE_SITE_LIST", $arResult["siteID"]);
         foreach ($arResult["groupID"] as $v) {
             $perm = $GLOBALS["APPLICATION"]->GetGroupRight("sale", $v);
             if ($perm != "W") {
                 $GLOBALS["APPLICATION"]->SetGroupRight("sale", $v, "U");
             }
         }
         $dbStatus = CSaleStatus::GetList(array("SORT" => "ASC"), array("LID" => $arResult["siteID"]), false, false, array("ID", "LID", "SORT"));
         while ($arStatus = $dbStatus->Fetch()) {
             $arPerms = array();
             foreach ($arResult["groupID"] as $v) {
                 $arPerms[] = array("GROUP_ID" => $v, "PERM_VIEW" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_DELETE"] == "Y" || $arResult["perm"][$arStatus["ID"]][$v]["PERM_UPDATE"] == "Y" || $arResult["perm"][$arStatus["ID"]][$v]["PERM_PAYMENT"] == "Y" || $arResult["perm"][$arStatus["ID"]][$v]["PERM_DELIVERY"] == "Y" || $arResult["perm"][$arStatus["ID"]][$v]["PERM_CANCEL"] == "Y" ? "Y" : $arResult["perm"][$arStatus["ID"]][$v]["PERM_VIEW"], "PERM_CANCEL" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_CANCEL"], "PERM_MARK" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_MARK"], "PERM_DEDUCTION" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_DEDUCTION"], "PERM_DELIVERY" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_DELIVERY"], "PERM_PAYMENT" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_PAYMENT"], "PERM_STATUS" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_STATUS"], "PERM_STATUS_FROM" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_STATUS_FROM"], "PERM_UPDATE" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_UPDATE"], "PERM_DELETE" => $arResult["perm"][$arStatus["ID"]][$v]["PERM_DELETE"]);
             }
             CSaleStatus::Update($arStatus["ID"], array("PERMS" => $arPerms, "SORT" => $arStatus["SORT"]));
         }
         $paySystemID = array();
         $paySystem = array();
         foreach ($arResult["paySystem"] as $pType => $pSystem) {
             if (!empty($pSystem)) {
                 foreach ($pSystem as $v) {
                     $paySystem[$v][] = $pType;
                     if (!in_array($v, $paySystemID)) {
                         $paySystemID[] = $v;
                     }
                 }
             }
         }
         $dbPaySys = CSalePaySystem::GetList(array(), array("ACTIVE" => "Y"), false, false, array("ID", "ACTIVE"));
         while ($arPaySys = $dbPaySys->Fetch()) {
             if (!in_array($arPaySys["ID"], $paySystemID)) {
                 CSalePaySystem::Update($arPaySys["ID"], array("ACTIVE" => "N"));
             }
         }
         foreach ($paySystem as $pID => $value) {
             $dbPaySysAction = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $pID));
             while ($arPaySysAction = $dbPaySysAction->Fetch()) {
                 if (!in_array($arPaySysAction["PERSON_TYPE_ID"], $value)) {
                     CSalePaySystemAction::Delete($arPaySysAction["ID"]);
                 }
             }
         }
         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];
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:wizard.php

示例10: randString

         }
     } else {
         $arIntranetUsersEmails[] = $email["EMAIL"];
         continue;
     }
 } else {
     //creating user with specified e-mail
     $password = randString($password_min_length, $password_chars);
     $checkword = randString(8);
     $name = $last_name = "";
     if (strlen($email["NAME"]) > 0) {
         list($name, $last_name) = explode(" ", $email["NAME"]);
     }
     $arFields = array("EMAIL" => $email["EMAIL"], "LOGIN" => $email["EMAIL"], "NAME" => $name, "LAST_NAME" => $last_name, "ACTIVE" => "Y", "GROUP_ID" => CExtranet::GetExtranetUserGroupID() > 0 ? array(2, CExtranet::GetExtranetUserGroupID()) : array(2), "PASSWORD" => $password, "CONFIRM_PASSWORD" => $password, "CHECKWORD" => $checkword, "LID" => SITE_ID);
     $user = new CUser();
     $NEW_USER_ID = $user->Add($arFields);
     if (intval($NEW_USER_ID) > 0) {
         $arUserIDs[] = $userID = $NEW_USER_ID;
     } else {
         $strError = $user->LAST_ERROR;
         if ($GLOBALS["APPLICATION"]->GetException()) {
             $err = $GLOBALS["APPLICATION"]->GetException();
             $strError .= $err->GetString();
             $GLOBALS["APPLICATION"]->ResetException();
         }
         $warningMessage .= str_replace("#EMAIL#", HtmlSpecialCharsEx($email["EMAIL"]), GetMessage("SONET_GCE_CANNOT_USER_ADD") . $strError);
     }
 }
 //sending invitation to new user ($userID) with this e-mail
 if ($userID > 0 && (empty($arUser) || strlen($arUser["LAST_LOGIN"]) <= 0 && strlen($arUser["LAST_ACTIVITY_DATE"]) <= 0)) {
     $rel = CSocNetUserToGroup::GetUserRole($userID, $arResult["GROUP_ID"]);
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:component.php

示例11: createUser

 public static function createUser($providerName, $userProfile)
 {
     global $USER;
     COption::SetOptionString("main", "captcha_registration", "N");
     $default_group = COption::GetOptionString("main", "new_user_registration_def_group");
     if (!empty($default_group)) {
         $arrGroups = explode(",", $default_group);
     }
     $password = mb_substr(md5(uniqid(rand(), true)), 0, 8);
     $birthday = $userProfile["birthDay"] . "." . $userProfile["birthMonth"] . "." . $userProfile["birthYear"];
     if (strlen($birthday) != 10) {
         $birthday = "";
     }
     $email = "";
     if (!empty($userProfile["email"])) {
         $email = $userProfile["email"];
     } else {
         if (!empty($userProfile["emailVerified"])) {
             $email = $userProfile["emailVerified"];
         }
     }
     if (empty($userProfile["firstName"]) && empty($userProfile["lastName"])) {
         $userProfile["firstName"] = $userProfile["displayName"];
     }
     $cUser = new \CUser();
     $arFields = array("NAME" => $userProfile["firstName"], "LAST_NAME" => $userProfile["lastName"], "EMAIL" => $email, "LOGIN" => $email, "PERSONAL_GENDER" => strtoupper(substr($userProfile["gender"], 0, 1)), "PERSONAL_WWW" => $arResult['USER']["URL"], "PERSONAL_BIRTHDAY" => $birthday, "ACTIVE" => "Y", "GROUP_ID" => $arrGroups, "EXTERNAL_AUTH_ID" => $providerName . $userProfile["identifier"], "PASSWORD" => $password, "CONFIRM_PASSWORD" => $password, "PERSONAL_PHONE" => $userProfile["phone"], "PERSONAL_CITY" => $userProfile["home_town"]);
     //$json = file_get_contents('https://graph.facebook.com/'.$userProfile["identifier"].'/picture?type=large');
     //$file = $_SERVER["DOCUMENT_ROOT"].'/upload/avatar/'.$userProfile["identifier"].'.jpg';
     if (!empty($userProfile["photoURL"])) {
         if ($providerName == "facebook") {
             $img = file_get_contents('https://graph.facebook.com/' . $userProfile["identifier"] . '/picture?type=large');
             $file = $_SERVER["DOCUMENT_ROOT"] . '/upload/avatar/' . $userProfile["identifier"] . '.jpg';
             file_put_contents($file, $img);
         } else {
             if ($providerName == "yandex") {
                 $img = file_get_contents('https://avatars.yandex.net/get-yapic/' . $userProfile["identifier"] . '/islands-200');
                 $file = $_SERVER["DOCUMENT_ROOT"] . '/upload/avatar/' . $userProfile["identifier"] . '.jpg';
                 file_put_contents($file, $img);
             } else {
                 if ($providerName == "linkedin") {
                     $img = file_get_contents($userProfile["photoURL"]);
                     $file = $_SERVER["DOCUMENT_ROOT"] . '/upload/avatar/' . $userProfile["identifier"] . '.jpg';
                     file_put_contents($file, $img);
                 } else {
                     $file = $userProfile["photoURL"];
                 }
             }
         }
         $arImage = \CFile::MakeFileArray($file);
         $arImage["MODULE_ID"] = "main";
         $arFields["PERSONAL_PHOTO"] = $arImage;
     }
     $USER_ID = $cUser->Add($arFields);
     if ($USER_ID) {
         \CUser::SendUserInfo($USER_ID, SITE_ID, "Приветствуем Вас как нового пользователя нашего сайта!");
         if (!empty($email)) {
             \CUserEx::capacityAdd($USER_ID, 1);
             // за мэйл +1ГБ
             $fields = array();
             $fields["EXTERNAL_AUTH_ID"] = "";
             $fields["PASSWORD"] = $password;
             $fields["CONFIRM_PASSWORD"] = $password;
             $сuser = new \CUser();
             $сuser->Update($USER_ID, $fields);
             $arEventFields = array("USER_NAME" => trim($userProfile["firstName"] . " " . $userProfile["lastName"]), "PASSWORD" => $password, "EMAIL" => $email);
             CEvent::Send("USER_PASS_CHANGED_PROFILE", SITE_ID, $arEventFields);
             $USER->Login($email, $password, 'N');
         }
         //Бонус за регистрацию
         \CUserEx::capacityAdd($USER_ID, BONUS_FOR_REGISTRATION);
         self::connectToUser($USER_ID, $providerName, $userProfile);
     } else {
         echo $cUser->LAST_ERROR;
     }
     COption::SetOptionString("main", "captcha_registration", "Y");
     return $USER_ID;
 }
开发者ID:Hawkart,项目名称:megatv,代码行数:77,代码来源:CSocialAuth.php

示例12: OnBeforeIBlockElementAddHandler

    /**
     * функция перед добавлениемредактированием элемента в инфоблок
     * @param $arFields поля элемента ифоблока
     * для страницы Объявления
     * создает нового пользователя
     * отправляет логини и пароль по почтовому шаблону
     * добавляет цену и количество в Торговый каталог
     */
    function OnBeforeIBlockElementAddHandler(&$arFields)
    {


        if (
        ((
                ($arFields["IBLOCK_ID"] == 2)
                ||
                ($arFields["IBLOCK_ID"] == 15)
                ||
                ($arFields["IBLOCK_ID"] == 14)
                ||
                ($arFields["IBLOCK_ID"] == 16)
                ||
                ($arFields["IBLOCK_ID"] == 19)
            )
            &&
            (strstr($_SERVER['REQUEST_URI'],'/personal/moy-magazin/')))
            &&
            ((!$_REQUEST['active'])&&(!$_REQUEST['deactive']))
        ||
        (

                ($arFields["IBLOCK_ID"] == 16)

            &&
            (strstr($_SERVER['REQUEST_URI'],'/obyavleniya/add-ads/')))
            &&
            ((!$_REQUEST['active'])&&(!$_REQUEST['deactive']))

        )
        {

            $rsUser = CUser::GetByID(CUser::GetID());
            $arUser = $rsUser->Fetch();
            $ID=$arUser['ID'];
            $arSelect = Array("ID", "IBLOCK_ID", "NAME","PROPERTY_*");
            $arFilter = Array("IBLOCK_ID"=>9, "ACTIVE"=>"Y","PROPERTY_PARTNER"=>intval($ID));
            $res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>1), $arSelect);
            while($ob = $res->GetNextElement()){
                $arFields_partner = $ob->GetFields();
                $id_block_partner=$arFields_partner['ID'];
            }
            if($id_block_partner){
                switch($arFields["IBLOCK_ID"]){
                    case 2:
                            $arFields["PROPERTY_VALUES"][59]["VALUE"]=$id_block_partner;
                        break;
                    case 14:
                            $arFields["PROPERTY_VALUES"][66]["VALUE"]=$id_block_partner;
                        break;
                    case 15:
                            $arFields["PROPERTY_VALUES"][71]["VALUE"]=$id_block_partner;
                    break;
                    case 16:
                            $arFields["PROPERTY_VALUES"][104]["VALUE"]=$id_block_partner;
                    break;
                    case 19:
                        $arFields["PROPERTY_VALUES"][105]["VALUE"]=$id_block_partner;
                    break;
                }
            }
        }


        if (
            (

            (($arFields["IBLOCK_ID"] == 16))
            )
            &&
            CModule::IncludeModule("catalog")
            &&
            CModule::IncludeModule("sale")
            &&
            ((strstr($_SERVER['REQUEST_URI'],'/obyavleniya/add-ads/')))
            &&
            ((!$_REQUEST['active'])&&(!$_REQUEST['deactive']))
        )
        {
                if(($arFields['PROPERTY_VALUES'][81]==7)||($arFields['PROPERTY_VALUES'][81]=="Y")){
                   //$arFields['PROPERTY_VALUES'][81]=40;
                    //$_SESSION['field_after2']="первый";
                }elseif($arFields['PROPERTY_VALUES'][81]==9){
                    //$_SESSION['field_after1']="второй";
                    //$arFields['PROPERTY_VALUES'][81]=46;
                }

                $arSelect16 = Array("ID", "IBLOCK_ID", "NAME","PROPERTY_*");
                $arFilter16 = Array("IBLOCK_ID"=>18,"ACTIVE"=>"Y","CODE "=>"standart-ads");
                $res16 = CIBlockElement::GetList(Array(), $arFilter16, false, Array("nPageSize"=>1), $arSelect16);
                while($ob16 = $res16->GetNextElement()){
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:gpbitrix,代码行数:101,代码来源:class.php

示例13: execute


//.........这里部分代码省略.........
         $group = $ob['ID'];
     }
     //выбираем список статусов
     $statusList = [];
     $rsData = \CUserTypeEntity::GetList([], ['ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_TD_ORG_STATUS']);
     if ($fob = $rsData->GetNext()) {
         $ar = ['newby' => 'НОВИЧКИ', 'pretty_boy' => 'КРАСАВЧИКИ', 'catching' => 'ДОГОНЯЮЩИЕ', 'redneck' => 'ДЕРЕВНИ'];
         $res = \CUserFieldEnum::GetList([], ['USER_FIELD_ID' => $fob['ID']]);
         while ($ob = $res->Fetch()) {
             if (empty($ar[$ob['XML_ID']])) {
                 continue;
             }
             $statusList[$ar[$ob['XML_ID']]] = $ob['ID'];
         }
     }
     //список стран для заполнения
     $countries = GetCountryArray();
     $countries = array_combine($countries['reference'], $countries['reference_id']);
     $currentStatus = null;
     while (($data = fgetcsv($fh)) !== false) {
         //если заполнена только вторая колонка то это статус
         if (empty($data[1]) && !empty($data[0]) && isset($statusList[$data[0]])) {
             $currentStatus = $statusList[$data[1]];
             continue;
         }
         //массив для загрузки данных пользователя
         $arLoad = ['ACTIVE' => 'Y', 'PERSONAL_COUNTRY' => isset($countries['Россия']) ? $countries['Россия'] : null, 'PERSONAL_CITY' => $data[0], 'LAST_NAME' => $data[1], 'WORK_POSITION' => $data[3], 'PERSONAL_MOBILE' => $data[4], 'PERSONAL_STREET' => $data[6], 'PERSONAL_WWW' => $data[8], 'PASSWORD' => 'Test,user,passwr0d', 'CONFIRM_PASSWORD' => 'Test,user,passwr0d', 'UF_TD_ORG_STATUS' => $currentStatus, 'GROUP_ID' => [2, $group]];
         //пробуем разбить email
         if (strpos($data[5], ',')) {
             $explode = array_map('trim', explode(',', $data[5]));
             $arLoad['EMAIL'] = $explode[0];
             unset($explode[0]);
             $arLoad['PERSONAL_NOTES'] = implode(', ', $explode);
         } elseif (strpos($data[5], 'и')) {
             $explode = array_map('trim', explode('и', $data[5]));
             $arLoad['EMAIL'] = $explode[0];
             unset($explode[0]);
             $arLoad['PERSONAL_NOTES'] = implode(', ', $explode);
         } elseif (strpos($data[5], ';')) {
             $explode = array_map('trim', explode(';', $data[5]));
             $arLoad['EMAIL'] = $explode[0];
             unset($explode[0]);
             $arLoad['PERSONAL_NOTES'] = implode(', ', $explode);
         } elseif (strpos($data[5], ' ')) {
             $explode = array_map('trim', explode(' ', $data[5]));
             $arLoad['EMAIL'] = $explode[0];
             unset($explode[0]);
             $arLoad['PERSONAL_NOTES'] = implode(', ', $explode);
         } else {
             $arLoad['EMAIL'] = trim($data[5]);
         }
         //пробуем разбить фамилию и имя
         if (strpos($data[2], ' ')) {
             $explode = explode(' ', trim($data[2]));
             $arLoad['NAME'] = $explode[0];
             $arLoad['SECOND_NAME'] = $explode[1];
         } else {
             $arLoad['NAME'] = trim($data[2]);
         }
         //пробуем завести дату в базу
         if (($time = strtotime($data[7])) !== false) {
             $arLoad['PERSONAL_BIRTHDAY'] = ConvertTimeStamp($time, 'SHORT', 'ru');
         }
         //пробуем найти страну, чтобы привязать пользователя к городу
         $country = \bxpimple\Locator::$item->get('countryFinder')->mergeFilterWith(['NAME' => 'Россия'])->one();
         if ($country) {
             //если нашли страну, то пробуем найти и город
             $city = \bxpimple\Locator::$item->get('cityFinder')->mergeFilterWith(['NAME' => trim($data[0]), 'PROPERTY_TOTALDICT_GEO_CITIES_COUNTRY' => $country->getAttribute('ID')->getValue()])->one();
             if ($city) {
                 //если нашли город, то привязываем пользователя
                 $arLoad['UF_TD_CITY_IB'] = $city->getAttribute('ID')->getValue();
             }
         }
         //задаем логин, по умолчанию используем email
         $arLoad['LOGIN'] = $arLoad['EMAIL'];
         //пробуем найти пользователя по его логину
         $user = new \CUser();
         $res = \CUser::GetList($by = '', $order = '', ['LOGIN_EQUAL' => $arLoad['LOGIN']]);
         if ($ob = $res->Fetch()) {
             $arGroups = \CUser::GetUserGroup($ob['ID']);
             if (is_array($arGroups)) {
                 $arLoad['GROUP_ID'] = array_unique(array_merge($arLoad['GROUP_ID'], $arGroups));
             }
             //обновляем
             if (!$user->Update($ob['ID'], $arLoad)) {
                 $output->writeln('<error>User ' . $arLoad['LOGIN'] . ' error: ' . $user->LAST_ERROR . '</error>');
             } else {
                 $output->writeln('<info>User ' . $arLoad['LOGIN'] . ' updated</info>');
             }
         } else {
             //создаем нового
             if (!$user->Add($arLoad)) {
                 $output->writeln('<error>User ' . $arLoad['LOGIN'] . ' error: ' . $user->LAST_ERROR . '</error>');
             } else {
                 $output->writeln('<info>New user ' . $arLoad['LOGIN'] . ' added</info>');
             }
         }
     }
     fclose($fh);
 }
开发者ID:bfday,项目名称:1c_bitrix_initial_repo,代码行数:101,代码来源:ImportUsersExpertsRussia.php

示例14: 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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:84,代码来源:ldap.php

示例15: ImportUser

 function ImportUser()
 {
     if ($this->isErrorOccured) {
         return false;
     }
     $this->errorMessage = "";
     $defaultEmail = $this->GetDefaultEmail();
     if (!($arUser = $this->csv->FetchDelimiter())) {
         return false;
     }
     $arFields = array();
     foreach ($this->arHeader as $index => $key) {
         if (($f = trim($arUser[$index])) != '') {
             $arFields[$key] = $f;
         }
     }
     if (!array_key_exists("NAME", $arFields) || strlen($arFields["NAME"]) < 1) {
         $this->errorMessage = GetMessage("CSV_IMPORT_NO_NAME") . " (" . implode(", ", $arFields) . ").<br>";
         return true;
     }
     if (!array_key_exists("LAST_NAME", $arFields) || strlen($arFields["LAST_NAME"]) < 1) {
         $this->errorMessage = GetMessage("CSV_IMPORT_NO_LASTNAME") . " (" . implode(", ", $arFields) . ").<br>";
         return true;
     }
     if (!array_key_exists("PASSWORD", $arFields) || strlen($arFields["PASSWORD"]) < 1) {
         $arFields["PASSWORD"] = $this->GenerateUserPassword(6);
     }
     $arFields["CONFIRM_PASSWORD"] = $arFields["PASSWORD"];
     if (!array_key_exists("EMAIL", $arFields) || strlen($arFields["EMAIL"]) < 3 || !check_email($arFields["EMAIL"])) {
         $arFields["EMAIL"] = $defaultEmail;
     }
     if (!array_key_exists("LOGIN", $arFields)) {
         $arFields["LOGIN"] = ToLower($arFields["NAME"] . " " . $arFields["LAST_NAME"]);
     }
     if (array_key_exists("PERSONAL_BIRTHDAY", $arFields) && (strlen($arFields["PERSONAL_BIRTHDAY"]) < 2 || !CheckDateTime($arFields["PERSONAL_BIRTHDAY"]))) {
         unset($arFields["PERSONAL_BIRTHDAY"]);
     }
     if (array_key_exists("DATE_REGISTER", $arFields) && (strlen($arFields["DATE_REGISTER"]) < 2 || !CheckDateTime($arFields["DATE_REGISTER"]))) {
         unset($arFields["DATE_REGISTER"]);
     }
     if ($this->externalAuthID !== null && !array_key_exists("EXTERNAL_AUTH_ID", $arFields)) {
         $arFields["EXTERNAL_AUTH_ID"] = $this->externalAuthID;
     }
     if (!array_key_exists("XML_ID", $arFields)) {
         $arFields["XML_ID"] = md5(uniqid(rand(), true));
     }
     if (!array_key_exists("CHECKWORD", $arFields) || strlen($arFields["CHECKWORD"]) <= 0) {
         $arFields["CHECKWORD"] = md5(CMain::GetServerUniqID() . uniqid());
     }
     if ($this->imageFilePath !== null) {
         if (array_key_exists("PERSONAL_PHOTO", $arFields) && strlen($arFields["PERSONAL_PHOTO"]) > 0) {
             $arFile = CFile::MakeFileArray($this->imageFilePath . "/" . $arFields["PERSONAL_PHOTO"]);
             $arFile["MODULE_ID"] = "main";
             $arFields["PERSONAL_PHOTO"] = $arFile;
         }
         if (array_key_exists("WORK_LOGO", $arFields) && strlen($arFields["WORK_LOGO"]) > 0) {
             $arFile = CFile::MakeFileArray($this->imageFilePath . "/" . $arFields["WORK_LOGO"]);
             $arFile["MODULE_ID"] = "main";
             $arFields["WORK_LOGO"] = $arFile;
         }
     } else {
         unset($arFields["PERSONAL_PHOTO"]);
         unset($arFields["WORK_LOGO"]);
     }
     $arFields["GROUP_ID"] = $this->userGroups;
     $user = new CUser();
     $userID = (int) $user->Add($arFields);
     if ($userID <= 0) {
         if ($user->LAST_ERROR != '') {
             $this->errorMessage = $arFields["NAME"] . " " . $arFields["LAST_NAME"] . ": " . $user->LAST_ERROR;
         }
     }
     if ($userID <= 0 && $this->ignoreDuplicate === false) {
         $postFix = 2;
         $login = $arFields["LOGIN"];
         do {
             $rsUser = CUser::GetByLogin($arFields["LOGIN"]);
             if (!$rsUser->Fetch()) {
                 break;
             }
             $arFields["LOGIN"] = $login . $postFix;
             $userID = (int) $user->Add($arFields);
             if ($userID > 1) {
                 break;
             }
             $postFix++;
         } while (true);
     }
     if ($userID > 0) {
         if ($this->attachIBlockID > 0) {
             $iblockSectionID = $this->__GetIBlockSectionID($arFields);
             if ($iblockSectionID > 0) {
                 if (!$this->isUserPropertyCreate) {
                     $this->isUserPropertyCreate = $this->__CreateUserProperty();
                 }
                 $arUpdate = array();
                 $arUpdate[$this->userPropertyName] = array($iblockSectionID);
                 $user->Update($userID, $arUpdate);
             }
         }
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:csv_user_import.php


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