示例#1
0
 /**
  * @param array $fileData
  * @param string $siteID
  * @param array $params
  * @return int|false
  */
 public static function saveFile(array $fileData, $storageTypeID = 0, $siteID = '', $params = array())
 {
     if (!is_integer($storageTypeID)) {
         $storageTypeID = (int) $storageTypeID;
     }
     if (!StorageType::isDefined($storageTypeID)) {
         $storageTypeID = StorageType::getDefaultTypeID();
     }
     if ($storageTypeID === StorageType::Disk) {
         return DiskManager::saveFile($fileData, $siteID, $params);
     } elseif ($storageTypeID === StorageType::WebDav) {
         return \CCrmWebDavHelper::saveFile($fileData, $siteID, $params);
     }
     throw new Main\NotSupportedException("Storage type: '{$storageTypeID}' is not supported in current context");
 }
示例#2
0
 public static function SetDefaultStorageTypeID($storageTypeID)
 {
     $storageTypeID = (int) $storageTypeID;
     if (!StorageType::isDefined($storageTypeID)) {
         $storageTypeID = StorageType::getDefaultTypeID();
     }
     if ($storageTypeID === self::$STORAGE_TYPE_ID) {
         return;
     }
     self::$STORAGE_TYPE_ID = $storageTypeID;
     CUserOptions::SetOption('crm', 'activity_storage_type_id', $storageTypeID);
 }
示例#3
0
     die;
 } elseif (is_dir($actionFilePath)) {
     $actionFilePath = $actionFilePath . '/payment.php';
     if (!file_exists($actionFilePath)) {
         echo CUtil::PhpToJSObject(array('ERROR' => 'COULD NOT FIND PAYMENT SYSTEM ACTION FILE!'));
         die;
     }
 }
 CSalePaySystemAction::InitParamArrays($paymentData['ORDER'], 0, $paySysActionFields['PARAMS'], array("PROPERTIES" => $paymentData['PROPERTIES'], "BASKET_ITEMS" => $paymentData['CART_ITEMS'], "TAX_LIST" => $paymentData["TAX_LIST"]));
 $pdfContent = (include $actionFilePath);
 $fileName = "quote_{$quoteID}.pdf";
 $fileData = array('name' => $fileName, 'type' => 'file', 'content' => $pdfContent, 'MODULE_ID' => 'crm');
 $fileID = CFile::SaveFile($fileData, 'crm');
 if ($fileID > 0) {
     $fileArray = CFile::GetFileArray($fileID);
     $storageTypeID = \Bitrix\Crm\Integration\StorageType::getDefaultTypeID();
     if ($storageTypeID !== \Bitrix\Crm\Integration\StorageType::File) {
         $storageFileID = \Bitrix\Crm\Integration\StorageManager::saveEmailAttachment($fileArray, $storageTypeID);
         $fileInfo = $storageFileID > 0 ? \Bitrix\Crm\Integration\StorageManager::getFileInfo($storageFileID, $storageTypeID) : null;
         if (is_array($fileInfo)) {
             if ($storageTypeID === \Bitrix\Crm\Integration\StorageType::WebDav) {
                 echo CUtil::PhpToJSObject(array('webdavelement' => $fileInfo));
             } elseif ($storageTypeID === \Bitrix\Crm\Integration\StorageType::Disk) {
                 echo CUtil::PhpToJSObject(array('diskfile' => $fileInfo));
             }
         }
     } else {
         echo CUtil::PhpToJSObject(array('file' => array("fileName" => $fileArray['FILE_NAME'], "fileID" => $fileID, "fileSize" => CFile::FormatSize($fileArray['FILE_SIZE']), "src" => $fileArray['SRC'])));
     }
 }
 die;
示例#4
0
 public static function PrepareStorageElementInfo(&$arFields)
 {
     $storageTypeID = isset($arFields['STORAGE_TYPE_ID']) ? (int) $arFields['STORAGE_TYPE_ID'] : StorageType::Undefined;
     if (!StorageType::IsDefined($storageTypeID)) {
         $storageTypeID = self::GetDefaultStorageTypeID();
     }
     $storageElementIDs = isset($arFields['STORAGE_ELEMENT_IDS']) && is_array($arFields['STORAGE_ELEMENT_IDS']) ? $arFields['STORAGE_ELEMENT_IDS'] : array();
     if ($storageTypeID === StorageType::File) {
         $arFields['FILES'] = array();
         foreach ($storageElementIDs as $fileID) {
             $arData = CFile::GetFileArray($fileID);
             if (is_array($arData)) {
                 $arFields['FILES'][] = array('fileID' => $arData['ID'], 'fileName' => $arData['FILE_NAME'], 'fileURL' => CCrmUrlUtil::UrnEncode($arData['SRC']), 'fileSize' => $arData['FILE_SIZE']);
             }
         }
     } elseif ($storageTypeID === StorageType::WebDav || $storageTypeID === StorageType::Disk) {
         $infos = array();
         foreach ($storageElementIDs as $elementID) {
             $infos[] = StorageManager::getFileInfo($elementID, $storageTypeID);
         }
         $arFields[$storageTypeID === StorageType::Disk ? 'DISK_FILES' : 'WEBDAV_ELEMENTS'] =& $infos;
         unset($infos);
     }
 }
示例#5
0
    $actionFilePath = "{$actionPath}/payment.php";
    if (!(is_dir($actionPath) && file_exists($actionFilePath))) {
        __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_FIND_PAY_SYSTEM_HANDLER')));
    }
    //HACK: params for pdf handler
    $_REQUEST['pdf'] = 'Y';
    $_REQUEST['GET_CONTENT'] = 'Y';
    $content = (include $actionFilePath);
    if ($content === '') {
        __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_NO_PDF_CONTENT')));
    }
    $accountNumber = isset($order['ACCOUNT_NUMBER']) ? $order['ACCOUNT_NUMBER'] : '';
    if ($accountNumber !== '') {
        $accountNumber = preg_replace('/[^a-zA-Z0-9_-]/', '', $accountNumber);
    }
    if ($accountNumber === '') {
        $accountNumber = strval($ID);
    }
    $fileID = CFile::SaveFile(array('name' => "invoice_{$accountNumber}.pdf", 'type' => 'file', 'content' => $content, 'MODULE_ID' => 'crm'), 'crm');
    if (!(is_int($fileID) && $fileID > 0)) {
        __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_CREATE_FILE')));
    }
    $storageTypeID = StorageType::getDefaultTypeID();
    $elementID = StorageManager::saveEmailAttachment(CFile::GetFileArray($fileID), $storageTypeID);
    if (!(is_int($elementID) && $elementID > 0)) {
        __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_CREATE_WEBDAV_ELEMENT')));
    }
    __CrmMobileInvoiceEditEndResonse(array('RESULT_DATA' => array('ELEMENT_INFO' => StorageManager::getFileInfo($elementID, $storageTypeID))));
} else {
    __CrmMobileInvoiceEditEndResonse(array('ERROR' => 'Action is not supported in current context.'));
}