public static function UploadFile($hash, &$file, &$package, &$upload, &$error) { $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList()->toArray(); $post['PARAMS'] = CUtil::JsObjectToPhp($post['REG_PARAMS']); $chatId = intval($post['REG_CHAT_ID']); if (intval($chatId) <= 0) { return false; } $chatRelation = CIMChat::GetRelationById($chatId); if (!$chatRelation[self::GetUserId()]) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } $folderModel = self::GetFolderModel($chatId); if (!$folderModel) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } $fileId = $post['PARAMS'][$file["id"]]; if (!$fileId) { return false; } $fileModel = \Bitrix\Disk\File::getById($fileId); if (!$fileModel || $fileModel->getParentId() != $folderModel->getId()) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } $resultUpdate = $fileModel->uploadVersion($file["files"]["default"], self::GetUserId()); if (!$resultUpdate) { return false; } $file['fileId'] = $fileId; $file['fileTmpId'] = $file["id"]; $file['fileMessageId'] = $messageId; $file['fileChatId'] = $chatId; $file['fileParams'] = self::GetFileParams($chatId, $fileModel); $messageId = intval($post['REG_MESSAGE_ID']); if (CModule::IncludeModule('pull')) { foreach ($chatRelation as $relation) { CPullStack::AddByUser($relation['USER_ID'], array('module_id' => 'im', 'command' => 'fileUpload', 'params' => array('fileChatId' => $file['fileChatId'], 'fileId' => $file['fileId'], 'fileTmpId' => $file["id"], 'fileMessageId' => $file["fileMessageId"], 'fileParams' => $file['fileParams']))); } } $arFiles[$fileId] = $file['fileParams']; $file['fileMessageOut'] = CIMMessenger::GetFormatFilesMessageOut($arFiles); CIMMessage::UpdateMessageOut($messageId, $file['fileMessageOut']); foreach (GetModuleEvents("im", "OnAfterFileUpload", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(array('CHAT_ID' => $file['fileChatId'], 'FILE_ID' => $file['fileId'], 'MESSAGE_ID' => $file['fileMessageId'], 'MESSAGE_OUT' => $file['fileMessageOut'], 'FILE' => $file['fileParams']))); } return true; }
/** * Retrieves last used department from socialnetwork/log_destination UserOption * @deprecated */ public static function GetLastDepartment() { $arLastSelected = CUserOptions::GetOption("socialnetwork", "log_destination", array()); $arLastSelected = is_array($arLastSelected) && strlen($arLastSelected['department']) > 0 && $arLastSelected['department'] != '"{}"' ? array_reverse(CUtil::JsObjectToPhp($arLastSelected['department'])) : array(); $count = 0; $arDepartment = array(); foreach ($arLastSelected as $depId) { if ($count < 4) { $count++; } else { break; } $arDepartment[$depId] = $depId; } return array_reverse($arDepartment); }
public function GetCurrentUser() { if($this->access_token === false) return false; $result = CHTTP::sGet(self::GRAPH_URL.'/me?access_token='.$this->access_token."&fields=picture,id,name,first_name,last_name,gender,birthday,email"); if(!defined("BX_UTF")) $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); return CUtil::JsObjectToPhp($result); }
public function GetUserInfo($user_id) { $result = CHTTP::sGet(self::API_URL.'users/show.json?user_id='.$user_id); if(!defined("BX_UTF")) $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); return CUtil::JsObjectToPhp($result); }
{ if (is_array($item)) { $ar = array(); foreach ($item as $k => $v) { $ar[$GLOBALS["APPLICATION"]->ConvertCharset($k, "UTF-8", LANG_CHARSET)] = BPasDecodeArrayKeys($v); } return $ar; } else { return $item; } } $_POST = BPasDecodeArrayKeys($_POST); } foreach (array('arWorkflowTemplate', 'arWorkflowParameters', 'arWorkflowVariables', 'arWorkflowConstants') as $k) { if (!is_array($_POST[$k])) { $_POST[$k] = (array) CUtil::JsObjectToPhp($_POST[$k]); } } $arFields = array("DOCUMENT_TYPE" => array(MODULE_ID, ENTITY, $document_type), "AUTO_EXECUTE" => $_POST["workflowTemplateAutostart"], "NAME" => $_POST["workflowTemplateName"], "DESCRIPTION" => $_POST["workflowTemplateDescription"], "TEMPLATE" => $_POST["arWorkflowTemplate"], "PARAMETERS" => $_POST["arWorkflowParameters"], "VARIABLES" => $_POST["arWorkflowVariables"], "CONSTANTS" => $_POST["arWorkflowConstants"], "USER_ID" => intval($USER->GetID()), "MODIFIER_USER" => new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser)); if (!is_array($arFields["VARIABLES"])) { $arFields["VARIABLES"] = array(); } if (!is_array($arFields["CONSTANTS"])) { $arFields["CONSTANTS"] = array(); } function wfeexception_handler($e) { // PHP 5.2.1 bug http://bugs.php.net/bug.php?id=40456 //print_r($e); ?> <script>
$id = intval($id); $userId = intval($userId); $paySystemId = intval($paySystemId); $buyerTypeId = intval($buyerTypeId); $location = intval($location); $locationID = intval($locationID); $locationZip = intval($locationZip); $locationZipID = intval($locationZipID); $WEIGHT_UNIT = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_unit', "", $LID)); $WEIGHT_KOEF = htmlspecialcharsbx(COption::GetOptionString('sale', 'weight_koef', 1, $LID)); $arDelivery = array(); $recomMore = ($recomMore == "Y") ? "Y" : "N"; $recalcOrder = ($recalcOrder == "Y") ? "Y" : "N"; $cartFix = ('Y' == $cartFix ? 'Y' : 'N'); $arOrderProduct = CUtil::JsObjectToPhp($product); $arCoupon = fGetCoupon($coupon); $arOrderOptions = array( 'CART_FIX' => $cartFix ); $arOrderProductPrice = fGetUserShoppingCart($arOrderProduct, $LID, $recalcOrder); foreach ($arOrderProductPrice as &$arItem) // tmp hack not to update basket quantity data from catalog { $arItem["ID_TMP"] = $arItem["ID"]; unset($arItem["ID"]); } unset($arItem);
public function GetCurrentUser() { if($this->access_token === false) return false; $result = CHTTP::sGet(self::CONTACTS_URL."?access_token=".urlencode($this->access_token)); if(!defined("BX_UTF")) $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); return CUtil::JsObjectToPhp($result); }
public function getNewAccessToken($refreshToken = false, $userId = 0, $save = false) { if ($this->appID == false || $this->appSecret == false) { return false; } if ($refreshToken == false) { $refreshToken = $this->refresh_token; } $result = CHTTP::sPostHeader(static::TOKEN_URL, array("refresh_token" => $refreshToken, "client_id" => $this->appID, "client_secret" => $this->appSecret, "grant_type" => "refresh_token"), array(), $this->httpTimeout); $this->arResult = CUtil::JsObjectToPhp($result); if (isset($this->arResult["access_token"]) && $this->arResult["access_token"] != '') { $this->access_token = $this->arResult["access_token"]; $this->accessTokenExpires = $this->arResult["expires_in"] + time(); if ($save && intval($userId) > 0) { $dbSocservUser = CSocServAuthDB::GetList(array(), array('USER_ID' => intval($userId), "EXTERNAL_AUTH_ID" => static::SERVICE_ID), false, false, array("ID")); if ($arOauth = $dbSocservUser->Fetch()) { CSocServAuthDB::Update($arOauth["ID"], array("OATOKEN" => $this->access_token, "OATOKEN_EXPIRES" => $this->accessTokenExpires)); } } return true; } return false; }
CVoxImplantTransfer::Answer($_POST['PARAMS']['CALL_ID']); } else { if ($_POST['COMMAND'] == 'waitTransfer') { $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); CVoxImplantTransfer::Wait($_POST['PARAMS']['CALL_ID']); } else { if ($_POST['COMMAND'] == 'declineTransfer') { $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); CVoxImplantTransfer::Decline($_POST['PARAMS']['CALL_ID']); } else { if ($_POST['COMMAND'] == 'cancelTransfer') { $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); CVoxImplantTransfer::Cancel($_POST['PARAMS']['CALL_ID']); } else { if ($_POST['COMMAND'] == 'timeoutTransfer') { $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']); CVoxImplantTransfer::Timeout($_POST['PARAMS']['CALL_ID']); } } } } } } } } } } } } } }
echo CUtil::PhpToJsObject(array('USER_ID' => htmlspecialcharsbx($_POST['USER_ID']), 'ERROR' => '')); } else { if ($_POST['IM_CHAT_ADD'] == 'Y') { $_POST['USERS'] = CUtil::JsObjectToPhp($_POST['USERS']); $errorMessage = ""; $CIMChat = new CIMChat(); $chatId = $CIMChat->Add('', $_POST['USERS']); if (!$chatId) { if ($e = $GLOBALS["APPLICATION"]->GetException()) { $errorMessage = $e->GetString(); } } echo CUtil::PhpToJsObject(array('CHAT_ID' => intval($chatId), 'ERROR' => $errorMessage)); } else { if ($_POST['IM_CHAT_EXTEND'] == 'Y') { $_POST['USERS'] = CUtil::JsObjectToPhp($_POST['USERS']); $errorMessage = ""; $CIMChat = new CIMChat(); $result = $CIMChat->AddUser($_POST['CHAT_ID'], $_POST['USERS']); if (!$result) { if ($e = $GLOBALS["APPLICATION"]->GetException()) { $errorMessage = $e->GetString(); } } echo CUtil::PhpToJsObject(array('ERROR' => $errorMessage)); } else { if ($_POST['IM_CHAT_LEAVE'] == 'Y') { $CIMChat = new CIMChat(); $result = $CIMChat->DeleteUser($_POST['CHAT_ID'], intval($_POST['USER_ID']) > 0 ? intval($_POST['USER_ID']) : $USER->GetID()); echo CUtil::PhpToJsObject(array('CHAT_ID' => intval($_POST['CHAT_ID']), 'USER_ID' => intval($_POST['USER_ID']), 'ERROR' => $result ? '' : 'AUTHORIZE_ERROR')); } else {
private function RefreshToken($socServUserId) { $result = CHTTP::sPostHeader(self::TOKEN_URL, array("refresh_token" => $this->refresh_token, "client_id" => $this->appID, "client_secret" => $this->appSecret, "grant_type" => "refresh_token"), array(), $this->httpTimeout); $arResult = CUtil::JsObjectToPhp($result); if (isset($arResult["access_token"]) && $arResult["access_token"] != '') { $this->access_token = $arResult["access_token"]; CSocServAuthDB::Update($socServUserId, array("OATOKEN" => $arResult["access_token"])); return true; } return false; }
public function GetCurrentUser() { if($this->access_token === false) return false; $result = CHTTP::sGet(self::CONTACTS_URL.'contacts/default/full?v=3.0&alt=json&oauth_token='.urlencode($this->access_token)); return CUtil::JsObjectToPhp($result); }
public function SendTwit($socServUserId, $message, $messageId) { $isSetOauthKeys = true; if (!$this->token || !$this->tokenSecret) { $isSetOauthKeys = self::SetOauthKeys($socServUserId); } if ($isSetOauthKeys === false) { CSocServMessage::Delete($messageId); return false; } if (strlen($message) > 139) { $message = substr($message, 0, 137) . "..."; } if (!defined("BX_UTF")) { $message = CharsetConverter::ConvertCharset($message, LANG_CHARSET, "utf-8"); } $arParams = array_merge($this->GetDefParams(), array("oauth_token" => $this->token, "status" => $message)); $arParams["oauth_signature"] = urlencode($this->BuildSignature($this->GetSignatureString($arParams, $this::POST_URL))); $arHeaders = array("Authorization" => 'OAuth oauth_consumer_key="' . $arParams["oauth_consumer_key"] . '", oauth_nonce="' . $arParams["oauth_nonce"] . '", oauth_signature="' . $arParams["oauth_signature"] . '", oauth_signature_method="HMAC-SHA1", oauth_timestamp="' . $arParams["oauth_timestamp"] . '", oauth_token="' . $this->token . '", oauth_version="1.0"'); $arPost = array("status" => $message); $result = @CHTTP::sPostHeader($this::POST_URL, $arPost, $arHeaders, $this->httpTimeout); if ($result !== false) { if (!defined("BX_UTF")) { $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); } return CUtil::JsObjectToPhp($result); } else { return false; } }
public function getNewAccessToken($refreshToken = false, $userId = 0, $save = false, $scope = array()) { if ($this->appID == false || $this->appSecret == false) { return false; } if ($refreshToken == false) { $refreshToken = $this->refresh_token; } if ($scope != null) { $this->addScope($scope); } $http = new \Bitrix\Main\Web\HttpClient(array('socketTimeout' => $this->httpTimeout)); $result = $http->get(self::NET_URL . self::TOKEN_URL . '?' . http_build_query(array('client_id' => $this->appID, 'client_secret' => $this->appSecret, 'refresh_token' => $refreshToken, 'scope' => implode(',', $this->getScope()), 'grant_type' => 'refresh_token'))); $arResult = CUtil::JsObjectToPhp($result); if (isset($arResult["access_token"]) && $arResult["access_token"] != '') { $this->access_token = $arResult["access_token"]; $this->accessTokenExpires = time() + $arResult["expires_in"]; $this->refresh_token = $arResult["refresh_token"]; if ($save && intval($userId) > 0) { $dbSocservUser = CSocServAuthDB::GetList(array(), array("USER_ID" => intval($userId), "EXTERNAL_AUTH_ID" => CSocServBitrix24Net::ID), false, false, array("ID")); $arOauth = $dbSocservUser->Fetch(); if ($arOauth) { CSocServAuthDB::Update($arOauth["ID"], array("OATOKEN" => $this->access_token, "OATOKEN_EXPIRES" => $this->accessTokenExpires, "REFRESH_TOKEN" => $this->refresh_token)); } } return true; } return false; }
foreach ($_POST[$field][$name]["Options"] as $k => $v) { $newarr[$GLOBALS["APPLICATION"]->ConvertCharset($k, "UTF-8", LANG_CHARSET)] = $v; } $_POST[$field][$name]["Options"] = $newarr; } } } } else { $_POST[$field] = CUtil::JsObjectToPhp($_POST[$field]); if (!is_array($_POST[$field])) { $_POST[$field] = array(); } } } if (!is_array($_POST['arWorkflowTemplate'])) { $_POST['arWorkflowTemplate'] = CUtil::JsObjectToPhp($_POST['arWorkflowTemplate']); } $arWorkflowParameters = $_POST['arWorkflowParameters']; $arWorkflowVariables = $_POST['arWorkflowVariables']; $arWorkflowConstants = $_POST['arWorkflowConstants']; try { $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), array(MODULE_ID, ENTITY, $_POST['document_type'])); } catch (Exception $e) { $canWrite = false; } if (!$canWrite || !check_bitrix_sessid()) { ShowError(GetMessage("ACCESS_DENIED")); die; } if ($_POST["save"] == "Y") { $perms = array();
public function GetUserInfo($user_id) { $result = CHTTP::sGet(self::API_URL.'users/show.json?user_id='.$user_id); return CUtil::JsObjectToPhp($result); }
protected function prepareAnswer($result) { if(!defined("BX_UTF")) $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); return CUtil::JsObjectToPhp($result); }
if (!empty($ownerType) && $ownerID > 0) { $enableDiscount = false; $enableTax = false; if (isset($_POST['PRODUCT_ROW_SETTINGS']) && is_array($_POST['PRODUCT_ROW_SETTINGS'])) { $settings = $_POST['PRODUCT_ROW_SETTINGS']; $enableDiscount = isset($settings['ENABLE_DISCOUNT']) ? $settings['ENABLE_DISCOUNT'] === 'Y' : false; $enableTax = isset($settings['ENABLE_TAX']) ? $settings['ENABLE_TAX'] === 'Y' : false; } $settings = CCrmProductRow::LoadSettings($ownerType, $ownerID); $settings['ENABLE_DISCOUNT'] = $enableDiscount; $settings['ENABLE_TAX'] = $enableTax; CCrmProductRow::SaveSettings($ownerType, $ownerID, $settings); unset($settings); } $prodJson = isset($_POST['PRODUCT_ROW_DATA']) ? strval($_POST['PRODUCT_ROW_DATA']) : ''; $arProducts = $arResult['PRODUCT_ROWS'] = strlen($prodJson) > 0 ? CUtil::JsObjectToPhp($prodJson) : array(); if ($perms->HavePerm($ownerName, BX_CRM_PERM_NONE, 'WRITE')) { echo CUtil::PhpToJSObject(array('ERROR' => 'PERMISSION_DENIED')); die; } $arProductRows = array(); foreach ($arProducts as $arProduct) { $fields = array(); $ID = isset($arProduct['ID']) ? intval($arProduct['ID']) : 0; $fields['ID'] = $ID; // Custom products are allowed (PRODUCT_ID === 0) $productID = isset($arProduct['PRODUCT_ID']) ? intval($arProduct['PRODUCT_ID']) : 0; if ($productID > 0) { $fields['PRODUCT_ID'] = $productID; } $productName = isset($arProduct['PRODUCT_NAME']) ? trim($arProduct['PRODUCT_NAME']) : '';
protected function query($url) { if ($this->access_token === false) { return false; } $http = new HttpClient(); $http->setHeader("authorization", "Bearer " . $this->access_token); $result = $http->get($url); if (!defined("BX_UTF")) { $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); } $result = CUtil::JsObjectToPhp($result); return $result; }
{ $errorMessage = ""; $arSettings = CUtil::JsObjectToPhp($_POST['SETTINGS']); CIMSettings::SetSetting(CIMSettings::SETTINGS, $arSettings); echo CUtil::PhpToJsObject(Array( 'ERROR' => $errorMessage )); } else if ($_POST['IM_SETTINGS_SAVE'] == 'Y') { $errorMessage = ""; $arSettings = CUtil::JsObjectToPhp($_POST['SETTINGS']); $arOldSettings = CUserOptions::GetOption('IM', CIMSettings::SETTINGS, Array()); if ($arOldSettings['notifyScheme'] == 'expert' && $arSettings['notifyScheme'] == 'simple') { $arNotifyValues = CIMSettings::GetSimpleNotifyBlocked(); $arSettings['notify'] = Array(); foreach ($arNotifyValues as $settingName => $value) { $arSettings['notify'][CIMSettings::CLIENT_SITE.'|'.$settingName] = false; $arSettings['notify'][CIMSettings::CLIENT_XMPP.'|'.$settingName] = false; $arSettings['notify'][CIMSettings::CLIENT_MAIL.'|'.$settingName] = false; } } if (array_key_exists('notify', $arSettings))
function JsObjectToPhp($data, $bSkipNative=false) { $arResult = array(); $bSkipNative |= !function_exists('json_decode'); if(!$bSkipNative) { // php > 5.2.0 + php_json global $APPLICATION; $bUtf = defined("BX_UTF"); $dataUTF = ($bUtf? $data : $APPLICATION->ConvertCharset($data, LANG_CHARSET, 'UTF-8')); // json_decode recognize only UTF strings // the name and value must be enclosed in double quotes // single quotes are not valid $arResult = json_decode($dataUTF, true); if($arResult === null) $bSkipNative = true; elseif(!$bUtf) $arResult = $APPLICATION->ConvertCharsetArray($arResult, 'UTF-8', LANG_CHARSET); } if ($bSkipNative) { $data = preg_replace('/[\s]*([{}\[\]\"])[\s]*/', '\1', $data); $data = trim($data); if (substr($data, 0, 1) == '{') // object { $arResult = array(); $depth = 0; $end_pos = 0; $arCommaPos = array(); $bStringStarted = false; $prev_symbol = ""; $string_delimiter = ''; for ($i = 1, $len = strlen($data); $i < $len; $i++) { $cur_symbol = substr($data, $i, 1); if ($cur_symbol == '"' || $cur_symbol == "'") { if ( $prev_symbol != '\\' && ( !$string_delimiter || $string_delimiter == $cur_symbol ) ) { if ($bStringStarted = !$bStringStarted) $string_delimiter = $cur_symbol; else $string_delimiter = ''; } } elseif ($cur_symbol == '{' || $cur_symbol == '[') $depth++; elseif ($cur_symbol == ']') $depth--; elseif ($cur_symbol == '}') { if ($depth == 0) { $end_pos = $i; break; } else { $depth--; } } elseif ($cur_symbol == ',' && $depth == 0 && !$bStringStarted) { $arCommaPos[] = $i; } $prev_symbol = $cur_symbol; } if ($end_pos == 0) return false; $token = substr($data, 1, $end_pos-1); $arTokens = array(); if (count($arCommaPos) > 0) { $prev_index = 0; foreach ($arCommaPos as $pos) { $arTokens[] = substr($token, $prev_index, $pos - $prev_index - 1); $prev_index = $pos; } $arTokens[] = substr($token, $prev_index); } else { $arTokens[] = $token; } foreach ($arTokens as $token) { $arTokenData = explode(":", $token, 2); $q = substr($arTokenData[0], 0, 1); if ($q == '"' || $q == '"') $arTokenData[0] = substr($arTokenData[0], 1, -1); $arResult[CUtil::JsObjectToPhp($arTokenData[0], true)] = CUtil::JsObjectToPhp($arTokenData[1], true); } } elseif (substr($data, 0, 1) == '[') // array { $arResult = array(); $depth = 0; $end_pos = 0; $arCommaPos = array(); $bStringStarted = false; $prev_symbol = ""; $string_delimiter = ""; for ($i = 1, $len = strlen($data); $i < $len; $i++) { $cur_symbol = substr($data, $i, 1); if ($cur_symbol == '"' || $cur_symbol == "'") { if ( $prev_symbol != '\\' && ( !$string_delimiter || $string_delimiter == $cur_symbol ) ) { if ($bStringStarted = !$bStringStarted) $string_delimiter = $cur_symbol; else $string_delimiter = ''; } } elseif ($cur_symbol == '{' || $cur_symbol == '[') $depth++; elseif ($cur_symbol == '}') $depth--; elseif ($cur_symbol == ']') { if ($depth == 0) { $end_pos = $i; break; } else { $depth--; } } elseif ($cur_symbol == ',' && $depth == 0 && !$bStringStarted) { $arCommaPos[] = $i; } $prev_symbol = $cur_symbol; } if ($end_pos == 0) return false; $token = substr($data, 1, $end_pos-1); if (count($arCommaPos) > 0) { $prev_index = 0; foreach ($arCommaPos as $pos) { $arResult[] = CUtil::JsObjectToPhp(substr($token, $prev_index, $pos - $prev_index - 1), true); $prev_index = $pos; } $arResult[] = CUtil::JsObjectToPhp(substr($token, $prev_index), true); } else { $arResult[] = CUtil::JsObjectToPhp($token, true); } } else // scalar { $q = substr($data, 0, 1); if ($q == '"' || $q == "'") $data = substr($data, 1, -1); //\u0412\u0430\u0434\u0438\u043c if(strpos($data, '\u') !== false) $data = preg_replace_callback("/\\\u([0-9A-F]{2})([0-9A-F]{2})/i", array('CUtil', 'DecodeUtf16'), $data); $arResult = $data; } } return $arResult; }
public function GetCurrentUser() { if ($this->access_token === false) { return false; } $sign = md5("app_id=" . $this->appID . "method=users.getInfosecure=1session_key=" . $this->access_token . $this->appSecret); $result = CHTTP::sGetHeader(self::CONTACTS_URL . '?method=users.getInfo&secure=1&app_id=' . $this->appID . '&session_key=' . urlencode($this->access_token) . '&sig=' . $sign, array(), $this->httpTimeout); if (!defined("BX_UTF")) { $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); } return CUtil::JsObjectToPhp($result); }
$enableSaleDiscount = false; $calcOptions = array(); if ($bTaxMode) { $calcOptions['LOCATION_ID'] = $arFields['LOCATION_ID']; } $result = CCrmSaleHelper::Calculate($arProd, $currencyID, $personTypeId, $enableSaleDiscount, SITE_ID, $calcOptions); $arFields['OPPORTUNITY'] = isset($result['PRICE']) ? round(doubleval($result['PRICE']), 2) : 1.0; $arFields['TAX_VALUE'] = isset($result['TAX_VALUE']) ? round(doubleval($result['TAX_VALUE']), 2) : 0.0; } } // Product row settings $productRowSettings = array(); $productRowSettingsFieldName = $productDataFieldName . '_SETTINGS'; if (array_key_exists($productRowSettingsFieldName, $_POST)) { $settingsJson = isset($_POST[$productRowSettingsFieldName]) ? strval($_POST[$productRowSettingsFieldName]) : ''; $arSettings = strlen($settingsJson) > 0 ? CUtil::JsObjectToPhp($settingsJson) : array(); if (is_array($arSettings)) { $productRowSettings['ENABLE_DISCOUNT'] = isset($arSettings['ENABLE_DISCOUNT']) ? $arSettings['ENABLE_DISCOUNT'] === 'Y' : false; $productRowSettings['ENABLE_TAX'] = isset($arSettings['ENABLE_TAX']) ? $arSettings['ENABLE_TAX'] === 'Y' : false; } } unset($productRowSettingsFieldName, $settingsJson, $arSettings); /*if (!$bEdit) { $originatorId = intval($_POST["EXTERNAL_SALE_ID"]); $originId = intval($_POST["SYNC_ORDER_ID"]); } else { $originatorId = intval($arResult['ELEMENT']["ORIGINATOR_ID"]); $originId = intval($arResult['ELEMENT']["ORIGIN_ID"]);
public function GetCurrentUserFriends($limit, &$next) { if ($this->access_token === false) { return false; } $url = self::FRIENDS_URL . '?uids=' . $this->userID . '&fields=uid,first_name,last_name,nickname,screen_name,photo_200_orig,contacts,email&access_token=' . urlencode($this->access_token); if ($limit > 0) { $url .= "&count=" . intval($limit) . "&offset=" . intval($next); } $result = CHTTP::sGetHeader($url, array(), $this->httpTimeout); if (!defined("BX_UTF")) { $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); } $result = CUtil::JsObjectToPhp($result); $next = $limit + $next; return $result; }
protected function prepareAnswer($result) { if (!defined("BX_UTF")) { $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); } $res = CUtil::JsObjectToPhp($result); if (!$res) { AddMessage2Log('Strange answer from Network! ' . $result . print_r($res, 1)); } return $res; }
public static function UploadFile($hash, &$file, &$package, &$upload, &$error) { $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList()->toArray(); $post['PARAMS'] = CUtil::JsObjectToPhp($post['REG_PARAMS']); $chatId = intval($post['REG_CHAT_ID']); if (intval($chatId) <= 0) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } $chatRelation = CIMChat::GetRelationById($chatId); if (!$chatRelation[self::GetUserId()]) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } $folderModel = self::GetFolderModel($chatId); if (!$folderModel) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } $fileId = $post['PARAMS'][$file["id"]]; if (!$fileId) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } if (!$file["files"]["default"]) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } /** @var $fileModel \Bitrix\Disk\File */ $fileModel = \Bitrix\Disk\File::getById($fileId); if (!$fileModel || $fileModel->getParentId() != $folderModel->getId()) { $error = GetMessage('IM_DISK_ERR_UPLOAD'); return false; } $resultUpdate = $fileModel->uploadVersion($file["files"]["default"], self::GetUserId()); if (!$resultUpdate) { $errors = $fileModel->getErrors(); $message = ''; foreach ($errors as $errorCode) { $message = $message . ' ' . $errorCode->getMessage(); } $message = trim($message); if (strlen($message) > 0) { $error = $message; } return false; } $messageId = intval($post['REG_MESSAGE_ID']); $file['fileId'] = $fileId; $file['fileTmpId'] = $file["id"]; $file['fileMessageId'] = $messageId; $file['fileChatId'] = $chatId; $file['fileParams'] = self::GetFileParams($chatId, $fileModel); foreach ($chatRelation as $relation) { if ($relation['MESSAGE_TYPE'] != IM_MESSAGE_PRIVATE) { break; } if (self::GetUserId() == $relation['USER_ID']) { continue; } \Bitrix\Disk\Driver::getInstance()->getRecentlyUsedManager()->push($relation['USER_ID'], $fileId); } if (CModule::IncludeModule('pull')) { $pullMessage = array('module_id' => 'im', 'command' => 'fileUpload', 'params' => array('fileChatId' => $file['fileChatId'], 'fileId' => $file['fileId'], 'fileTmpId' => $file["id"], 'fileMessageId' => $file["fileMessageId"], 'fileParams' => $file['fileParams'])); CPullStack::AddByUsers(array_keys($chatRelation), $pullMessage); $orm = \Bitrix\Im\ChatTable::getById($chatId); $chat = $orm->fetch(); if ($chat['TYPE'] == IM_MESSAGE_OPEN) { CPullWatch::AddToStack('IM_PUBLIC_' . $chat['ID'], $pullMessage); } } $arFiles[$fileId] = $file['fileParams']; $file['fileMessageOut'] = CIMMessenger::GetFormatFilesMessageOut($arFiles); CIMMessage::UpdateMessageOut($messageId, $file['fileMessageOut']); foreach (GetModuleEvents("im", "OnAfterFileUpload", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(array('CHAT_ID' => $file['fileChatId'], 'FILE_ID' => $file['fileId'], 'MESSAGE_ID' => $file['fileMessageId'], 'MESSAGE_OUT' => $file['fileMessageOut'], 'FILE' => $file['fileParams']))); } return true; }
public function SendFeed($socServUserId, $message, $messageId) { $isSetOauthKeys = true; if (!$this->access_token || !$this->userId) { $isSetOauthKeys = self::SetOauthKeys($socServUserId); } if ($isSetOauthKeys === false) { CSocServMessage::Delete($messageId); return false; } $message = CharsetConverter::ConvertCharset($message, LANG_CHARSET, "utf-8"); $arPost = array("access_token" => $this->access_token, "message" => $message); $result = @CHTTP::sPostHeader($this::GRAPH_URL . "/" . $this->userId . "/feed", $arPost, array(), $this->httpTimeout); if ($result !== false) { if (!defined("BX_UTF")) { $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); } return CUtil::JsObjectToPhp($result); } else { return false; } }
public function GetCurrentUser() { if($this->access_token === false) return false; $result = CHTTP::sGetHeader(self::CONTACTS_URL.'?uids='.$this->userID.'&fields=uid,first_name,last_name,nickname,screen_name,sex,bdate,city,country,timezone,photo,photo_medium,photo_big,photo_rec&access_token='.urlencode($this->access_token), array(), $this->httpTimeout); if(!defined("BX_UTF")) $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); return CUtil::JsObjectToPhp($result); }
private function _process() { if (!$this->bProcess) { if (strlen($this->result_text) > 0) { $this->result = CUtil::JsObjectToPhp($this->result_text); if (!is_array($this->result)) { $this->result = null; } else { $this->result_code = intval($this->result['error']); if ($this->result_code >= 400) { $this->result_error = $this->result['error_message']; } } } $this->bProcess = true; } }
public function GetCurrentUser() { if($this->access_token === false) return false; $result = CHTTP::sGetHeader(self::USERINFO_URL.'?format=json&oauth_token='.urlencode($this->access_token), array(), $this->httpTimeout); if(!defined("FX_UTF")) $result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET); $result = CUtil::JsObjectToPhp($result); if(is_array($result)) { $result["access_token"] = $this->access_token; $result["refresh_token"] = $this->refresh_token; $result["expires_in"] = $this->accessTokenExpires; } return $result; }