1
0
mirror of synced 2024-11-29 08:46:09 +03:00

Merge branch 'exportICMLSize'

This commit is contained in:
m.korolev 2014-01-31 20:11:52 +04:00
commit 8910c7ef37

View File

@ -34,9 +34,43 @@ class ICMLLoader {
public function Load() public function Load()
{ {
global $USER; if(!isset($_SESSION["SESS_AUTH"]["USER_ID"]) || !$_SESSION["SESS_AUTH"]["USER_ID"]) {
if(!isset($USER)) // for agent; to add order User
$USER = new CUser; $rsUser = CUser::GetByLogin('intarocrm');
if($arUser = $rsUser->Fetch()) {
$USER = new CUser;
$USER->Authorize($arUser['ID']);
} else {
$login = 'intarocrm';
$serverName = 0 < strlen(SITE_SERVER_NAME)? SITE_SERVER_NAME : 'server.com';
$email = $login . '@' . $serverName;
$userPassword = randString(10);
$user = new CUser;
$arFields = array(
"NAME" => $login,
"LAST_NAME" => $login,
"EMAIL" => $email,
"LOGIN" => $login,
"LID" => "ru",
"ACTIVE" => "Y",
"GROUP_ID" => array(2),
"PASSWORD" => $userPassword,
"CONFIRM_PASSWORD" => $userPassword
);
$id = $user->Add($arFields);
if (!$id) {
self::eventLog('ICrmOrderActions::orderHistory', 'USER', $user->LAST_ERROR);
return;
}
$USER = new CUser;
$USER->Authorize($id);
}
}
$this->isLogged = true; $this->isLogged = true;