コード例 #1
0
ファイル: ajax.php プロジェクト: mrdeadmouse/u136006
 protected function processActionShowSubFolders()
 {
     if (!$this->checkRequiredPostParams(array('objectId'))) {
         $this->sendJsonErrorResponse();
     }
     $showOnlyDeleted = (bool) $this->request->getPost('showOnlyDeleted');
     $isRoot = (bool) $this->request->getPost('isRoot');
     /** @var Folder $folder */
     $folder = Folder::loadById((int) $this->request->getPost('objectId'), array('STORAGE'));
     if (!$folder) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_BREADCRUMBS_ERROR_COULD_NOT_FIND_FOLDER'), self::ERROR_COULD_NOT_FIND_FOLDER)));
         $this->sendJsonErrorResponse();
     }
     $securityContext = $folder->getStorage()->getCurrentUserSecurityContext();
     $subFolders = array();
     $filter = array('TYPE' => ObjectTable::TYPE_FOLDER);
     if ($showOnlyDeleted) {
         $filter['!=DELETED_TYPE'] = ObjectTable::DELETED_TYPE_NONE;
     }
     if ($showOnlyDeleted && $isRoot) {
         $filter['DELETED_TYPE'] = ObjectTable::DELETED_TYPE_ROOT;
         $children = $folder->getDescendants($securityContext, array('filter' => $filter));
     } else {
         $children = $folder->getChildren($securityContext, array('filter' => $filter));
     }
     foreach ($children as $subFolder) {
         /** @var Folder $subFolder */
         $subFolders[] = array('id' => $subFolder->getId(), 'name' => $subFolder->getName(), 'isLink' => $subFolder->isLink());
     }
     unset($subFolder);
     \Bitrix\Main\Type\Collection::sortByColumn($subFolders, 'name');
     $this->sendJsonSuccessResponse(array('items' => $subFolders));
 }
コード例 #2
0
ファイル: measureratio.php プロジェクト: DarneoStudio/bitrix
 /**
  * Return ratio for product list.
  *
  * @param array|int $product			Product id list.
  * @return array|bool
  * @throws Main\ArgumentException
  */
 public static function getCurrentRatio($product)
 {
     if (!is_array($product)) {
         $product = array($product);
     }
     Main\Type\Collection::normalizeArrayValuesByInt($product, true);
     if (empty($product)) {
         return false;
     }
     $result = array_fill_keys($product, 1);
     $ratioRows = array_chunk($product, 500);
     foreach ($ratioRows as &$row) {
         $ratioIterator = self::getList(array('select' => array('PRODUCT_ID', 'RATIO'), 'filter' => array('@PRODUCT_ID' => $row)));
         while ($ratio = $ratioIterator->fetch()) {
             $ratio['PRODUCT_ID'] = (int) $ratio['PRODUCT_ID'];
             $ratioInt = (int) $ratio['RATIO'];
             $ratioFloat = (double) $ratio['RATIO'];
             $ratioResult = $ratioFloat > $ratioInt ? $ratioFloat : $ratioInt;
             if (abs($ratioResult) < CATALOG_VALUE_EPSILON || $ratioResult < 0) {
                 continue;
             }
             $result[$ratio['PRODUCT_ID']] = $ratioResult;
         }
         unset($module, $moduleIterator);
     }
     unset($row, $ratioRows);
     return $result;
 }
コード例 #3
0
ファイル: class.php プロジェクト: mrdeadmouse/u136006
 private function getGridData($gridId)
 {
     $grid = array('ID' => $gridId);
     $securityContext = $this->storage->getCurrentUserSecurityContext();
     $parameters = array('with' => array('FILE', 'CREATE_USER'), 'filter' => array('IS_EXPIRED' => false, 'OBJECT.STORAGE_ID' => $this->storage->getId(), 'CREATED_BY' => $this->getUser()->getId()));
     $parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('OBJECT_ID', 'OBJECT.CREATED_BY'));
     $items = ExternalLink::getModelList($parameters);
     Collection::sortByColumn($items, array('CREATE_TIME' => array(SORT_NUMERIC, SORT_ASC)));
     $urlManager = Driver::getInstance()->getUrlManager();
     $rows = array();
     foreach ($items as $externalLink) {
         /** @var ExternalLink $externalLink */
         $exportData = $externalLink->toArray();
         $nameSpecialChars = htmlspecialcharsbx($externalLink->getFile()->getName());
         $createDateText = htmlspecialcharsbx((string) $externalLink->getCreateTime());
         $columnName = "\n\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$externalLink->getId()}\" class=\"draggable bx-file-icon-container-small bx-disk-file-icon\"></div></td>\n\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$externalLink->getId()}\" href=\"\" data-bx-dateModify=\"{$createDateText}\">{$nameSpecialChars}</a></td>\n\t\t\t\t</tr></table>\n\t\t\t";
         $createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $externalLink->getCreatedBy()));
         $rows[] = array('data' => $exportData, 'columns' => array('CREATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'UPDATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'NAME' => $columnName, 'FORMATTED_SIZE' => CFile::formatSize($externalLink->getFile()->getSize()), 'CREATE_USER' => "\n\t\t\t\t\t\t<div class=\"bx-disk-user-link\"><a target='_blank' href=\"{$createdByLink}\" id=\"\">" . htmlspecialcharsbx($externalLink->getCreateUser()->getFormattedName()) . "</a></div>\n\t\t\t\t\t"), 'actions' => array(array("PSEUDO_NAME" => "download", "DEFAULT" => true, "ICONCLASS" => "download", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DOWNLOAD'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $urlManager->getUrlForDownloadFile($externalLink->getFile()) . "')"), array("PSEUDO_NAME" => "disable_external_link", "ICONCLASS" => "disable_external_link", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK'), "SHORT_TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK_SHORT'), "ONCLICK" => "BX.Disk['ExternalLinkListClass_{$this->getComponentId()}'].disableExternalLink({$externalLink->getId()}, {$externalLink->getObjectId()})")));
     }
     unset($externalLink);
     $grid['MODE'] = 'list';
     $grid['HEADERS'] = array(array('id' => 'ID', 'name' => 'ID', 'default' => false, 'show_checkbox' => true), array('id' => 'NAME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_NAME'), 'default' => true), array('id' => 'CREATE_TIME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_TIME'), 'default' => true), array('id' => 'CREATE_USER', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_USER'), 'default' => false), array('id' => 'FORMATTED_SIZE', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_FORMATTED_SIZE'), 'default' => true));
     $grid['ROWS'] = $rows;
     $grid['ROWS_COUNT'] = count($rows);
     $grid['FOOTER'] = array();
     return $grid;
 }
コード例 #4
0
ファイル: ajax.php プロジェクト: mrdeadmouse/u136006
 protected function processActionGetListStorage()
 {
     $this->checkRequiredPostParams(array('proxyType'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $proxyTypePost = $this->request->getPost('proxyType');
     $diskSecurityContext = $this->getSecurityContextByUser($this->getUser());
     $siteId = null;
     $siteDir = null;
     if ($this->request->getPost('siteId')) {
         $siteId = $this->request->getPost('siteId');
     }
     if ($this->request->getPost('siteDir')) {
         $siteDir = rtrim($this->request->getPost('siteDir'), '/');
     }
     $result = array();
     $filterReadableList = array();
     $checkSiteId = false;
     if ($proxyTypePost == 'user') {
         $result['TITLE'] = Loc::getMessage('DISK_AGGREGATOR_USER_TITLE');
         $filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\User::className());
     } elseif ($proxyTypePost == 'group') {
         $checkSiteId = true;
         $result['TITLE'] = Loc::getMessage('DISK_AGGREGATOR_GROUP_TITLE');
         $filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className());
     }
     foreach (Storage::getReadableList($diskSecurityContext, array('filter' => $filterReadableList)) as $storage) {
         if ($checkSiteId) {
             $groupObject = CSocNetGroup::getList(array(), array('ID' => $storage->getEntityId()), false, false, array('SITE_ID'));
             $group = $groupObject->fetch();
             if (!empty($group) && $group['SITE_ID'] != $siteId) {
                 continue;
             }
         }
         $proxyType = $storage->getProxyType();
         $result['DATA'][] = array("TITLE" => $proxyType->getEntityTitle(), "URL" => $siteDir . $proxyType->getBaseUrlFolderList(), "ICON" => $proxyType->getEntityImageSrc(64, 64));
     }
     if (!empty($result['DATA'])) {
         Collection::sortByColumn($result['DATA'], array('TITLE' => SORT_ASC));
         $this->sendJsonSuccessResponse(array('listStorage' => $result['DATA'], 'title' => $result['TITLE']));
     } else {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_AGGREGATOR_ERROR_COULD_NOT_FIND_DATA'))));
         $this->sendJsonErrorResponse();
     }
 }
コード例 #5
0
ファイル: authmanager.php プロジェクト: Satariall/izurit
 protected static function AppyUserSettings($suffix)
 {
     $arAuthServices = self::$arAuthServices;
     //user settings: sorting, active
     $arServices = unserialize(COption::GetOptionString("socialservices", "auth_services" . $suffix, ""));
     if (is_array($arServices)) {
         $i = 0;
         foreach ($arServices as $serv => $active) {
             if (isset($arAuthServices[$serv])) {
                 $arAuthServices[$serv]["__sort"] = $i++;
                 $arAuthServices[$serv]["__active"] = $active == "Y";
             }
         }
         \Bitrix\Main\Type\Collection::sortByColumn($arAuthServices, "__sort");
     }
     return $arAuthServices;
 }
コード例 #6
0
 protected function __construct()
 {
     $event = new Main\Event("main", "OnApplicationsBuildList");
     $event->send();
     foreach ($event->getResults() as $eventResult) {
         $result = $eventResult->getParameters();
         if (is_array($result)) {
             if (!is_array($result[0])) {
                 $result = array($result);
             }
             foreach ($result as $app) {
                 $this->applications[$app["ID"]] = $app;
             }
         }
     }
     Main\Type\Collection::sortByColumn($this->applications, "SORT");
 }
コード例 #7
0
 /**
  * Fixes cold start, when we don't have any data in RecentlyUsedTable.
  * @param mixed|int|User|\CAllUser $user User.
  * @return bool
  * @throws \Bitrix\Main\ArgumentException
  */
 private function fixColdStart($user)
 {
     $userId = User::resolveUserId($user);
     if (!$userId) {
         $this->errorCollection->addOne(new Error('Could not get user id.'));
         return false;
     }
     $storage = Driver::getInstance()->getStorageByUserId($userId);
     if (!$storage) {
         $this->errorCollection->addOne(new Error('Could not get storage by user id.'));
         return false;
     }
     $fromDate = DateTime::createFromTimestamp(time() - 14 * 24 * 3600);
     $objects = array();
     $query = FileTable::getList(array('select' => array('ID', 'UPDATE_TIME'), 'filter' => array('STORAGE_ID' => $storage->getId(), 'TYPE' => ObjectTable::TYPE_FILE, 'DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE, '>UPDATE_TIME' => $fromDate, array('LOGIC' => 'OR', array('CREATED_BY' => $userId), array('UPDATED_BY' => $userId))), 'order' => array('UPDATE_TIME' => 'DESC'), 'limit' => RecentlyUsedTable::MAX_COUNT_FOR_USER));
     while ($row = $query->fetch()) {
         $objects[] = array('USER_ID' => $userId, 'OBJECT_ID' => $row['ID'], 'CREATE_TIME' => $row['UPDATE_TIME']);
     }
     unset($row, $query, $fromDate);
     Collection::sortByColumn($objects, array('CREATE_TIME' => SORT_ASC));
     RecentlyUsedTable::insertBatch($objects);
     return true;
 }
コード例 #8
0
ファイル: iblock_edit.php プロジェクト: Satariall/izurit
function __AddPropCellType($intOFPropID, $strPrefix, $arPropInfo)
{
    static $arUserTypeList = null;
    if ($arUserTypeList === null) {
        $arUserTypeList = CIBlockProperty::GetUserType();
        \Bitrix\Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
    }
    $boolUserPropExist = !empty($arUserTypeList);
    ob_start();
    ?>
<select name="<?php 
    echo $strPrefix . $intOFPropID;
    ?>
_PROPERTY_TYPE" id="<?php 
    echo $strPrefix . $intOFPropID;
    ?>
_PROPERTY_TYPE" style="width:150px"><?php 
    if ($boolUserPropExist) {
        ?>
<optgroup label="<?php 
        echo GetMessage('IB_E_PROP_BASE_TYPE_GROUP');
        ?>
"><?php 
    }
    ?>
	<option value="S" <?php 
    if ($arPropInfo['PROPERTY_TYPE'] == "S" && !$arPropInfo['USER_TYPE']) {
        echo " selected";
    }
    ?>
><?php 
    echo GetMessage("IB_E_PROP_TYPE_S");
    ?>
</option>
	<option value="N" <?php 
    if ($arPropInfo['PROPERTY_TYPE'] == "N" && !$arPropInfo['USER_TYPE']) {
        echo " selected";
    }
    ?>
><?php 
    echo GetMessage("IB_E_PROP_TYPE_N");
    ?>
</option>
	<option value="L" <?php 
    if ($arPropInfo['PROPERTY_TYPE'] == "L" && !$arPropInfo['USER_TYPE']) {
        echo " selected";
    }
    ?>
><?php 
    echo GetMessage("IB_E_PROP_TYPE_L");
    ?>
</option>
	<option value="F" <?php 
    if ($arPropInfo['PROPERTY_TYPE'] == "F" && !$arPropInfo['USER_TYPE']) {
        echo " selected";
    }
    ?>
><?php 
    echo GetMessage("IB_E_PROP_TYPE_F");
    ?>
</option>
	<option value="G" <?php 
    if ($arPropInfo['PROPERTY_TYPE'] == "G" && !$arPropInfo['USER_TYPE']) {
        echo " selected";
    }
    ?>
><?php 
    echo GetMessage("IB_E_PROP_TYPE_G");
    ?>
</option>
	<option value="E" <?php 
    if ($arPropInfo['PROPERTY_TYPE'] == "E" && !$arPropInfo['USER_TYPE']) {
        echo " selected";
    }
    ?>
><?php 
    echo GetMessage("IB_E_PROP_TYPE_E");
    ?>
</option>
	<?php 
    if ($boolUserPropExist) {
        ?>
</optgroup><optgroup label="<?php 
        echo GetMessage('IB_E_PROP_USER_TYPE_GROUP');
        ?>
"><?php 
    }
    foreach ($arUserTypeList as $ar) {
        ?>
<option value="<?php 
        echo htmlspecialcharsbx($ar["PROPERTY_TYPE"] . ":" . $ar["USER_TYPE"]);
        ?>
" <?php 
        if ($arPropInfo['PROPERTY_TYPE'] == $ar["PROPERTY_TYPE"] && $arPropInfo['USER_TYPE'] == $ar["USER_TYPE"]) {
            echo " selected";
        }
        ?>
><?php 
        echo htmlspecialcharsbx($ar["DESCRIPTION"]);
        ?>
</option>
		<?php 
    }
    if ($boolUserPropExist) {
        ?>
</optgroup><?php 
    }
    ?>
	</select><?php 
    $strResult = ob_get_contents();
    ob_end_clean();
    return $strResult;
}
コード例 #9
0
ファイル: result_modifier.php プロジェクト: AlexPrya/iShop
								$arItem['OFFERS'][$keyOffer]['TREE'] = array();
							$arItem['OFFERS'][$keyOffer]['TREE']['PROP_'.$arSKUPropList[$strOneCode]['ID']] = $arMatrix[$keyOffer][$strOneCode]['VALUE'];
							$arItem['OFFERS'][$keyOffer]['SKU_SORT_'.$strOneCode] = $arMatrix[$keyOffer][$strOneCode]['SORT'];
							$arUsedFields[$strOneCode] = true;
							$arSortFields['SKU_SORT_'.$strOneCode] = SORT_NUMERIC;
						}
						else
						{
							unset($arMatrix[$keyOffer][$strOneCode]);
						}
					}
				}
				$arItem['OFFERS_PROP'] = $arUsedFields;
				$arItem['OFFERS_PROP_CODES'] = (!empty($arUsedFields) ? base64_encode(serialize(array_keys($arUsedFields))) : '');

				Collection::sortByColumn($arItem['OFFERS'], $arSortFields);

				$arMatrix = array();
				$intSelected = -1;
				$arItem['MIN_PRICE'] = false;
				$arItem['MIN_BASIS_PRICE'] = false;
				foreach ($arItem['OFFERS'] as $keyOffer => $arOffer)
				{
					if (empty($arItem['MIN_PRICE']) && $arOffer['CAN_BUY'])
					{
						$intSelected = $keyOffer;
						$arItem['MIN_PRICE'] = (isset($arOffer['RATIO_PRICE']) ? $arOffer['RATIO_PRICE'] : $arOffer['MIN_PRICE']);
						$arItem['MIN_BASIS_PRICE'] = $arOffer['MIN_PRICE'];
					}
					$arSKUProps = false;
					if (!empty($arOffer['DISPLAY_PROPERTIES']))
コード例 #10
0
ファイル: discount.php プロジェクト: DarneoStudio/bitrix
 public function CheckFields($ACTION, &$arFields)
 {
     global $DB, $APPLICATION, $USER;
     if (empty($arFields) || !is_array($arFields)) {
         return false;
     }
     $ACTION = strtoupper($ACTION);
     if ('UPDATE' != $ACTION && 'ADD' != $ACTION) {
         return false;
     }
     $discountID = 0;
     if ($ACTION == 'UPDATE') {
         if (isset($arFields['ID'])) {
             $discountID = (int) $arFields['ID'];
         }
         if ($discountID <= 0) {
             return false;
         }
     }
     $clearFields = array('ID', '~ID', 'UNPACK', '~UNPACK', '~CONDITIONS', 'APPLICATION', '~APPLICATION', '~ACTIONS', 'USE_COUPONS', '~USE_COUPONS', 'HANDLERS', '~HANDLERS', '~VERSION', 'TIMESTAMP_X', 'DATE_CREATE', '~DATE_CREATE', '~MODIFIED_BY', '~CREATED_BY', 'EXECUTE_MODULE', '~EXECUTE_MODULE');
     if ($ACTION == 'UPDATE') {
         $clearFields[] = 'CREATED_BY';
     }
     foreach ($clearFields as &$fieldName) {
         if (array_key_exists($fieldName, $arFields)) {
             unset($arFields[$fieldName]);
         }
     }
     unset($fieldName);
     unset($clearFields);
     if ((is_set($arFields, "ACTIVE") || $ACTION == "ADD") && $arFields["ACTIVE"] != "Y") {
         $arFields["ACTIVE"] = "N";
     }
     if ((is_set($arFields, "DISCOUNT_TYPE") || $ACTION == "ADD") && $arFields["DISCOUNT_TYPE"] != self::OLD_DSC_TYPE_PERCENT) {
         $arFields["DISCOUNT_TYPE"] = self::OLD_DSC_TYPE_FIX;
     }
     if ((is_set($arFields, "SORT") || $ACTION == "ADD") && intval($arFields["SORT"]) <= 0) {
         $arFields["SORT"] = 100;
     }
     if ((is_set($arFields, "LID") || $ACTION == "ADD") && strlen($arFields["LID"]) <= 0) {
         return false;
     }
     if (is_set($arFields, "LID")) {
         $dbSite = CSite::GetByID($arFields["LID"]);
         if (!$dbSite->Fetch()) {
             $APPLICATION->ThrowException(Loc::getMessage('SKGD_NO_SITE', array('#ID#' => $arFields['LID'])), 'ERROR_NO_SITE');
             return false;
         }
         $arFields['CURRENCY'] = CSaleLang::GetLangCurrency($arFields["LID"]);
     }
     if ((is_set($arFields, "CURRENCY") || $ACTION == "ADD") && strlen($arFields["CURRENCY"]) <= 0) {
         return false;
     }
     if (is_set($arFields, "CURRENCY")) {
         if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
             $APPLICATION->ThrowException(Loc::getMessage('SKGD_NO_CURRENCY', array('#ID#' => $arFields['CURRENCY'])), 'ERROR_NO_CURRENCY');
             return false;
         }
     }
     if (is_set($arFields, "DISCOUNT_VALUE") || $ACTION == "ADD") {
         if (!is_set($arFields["DISCOUNT_VALUE"])) {
             $arFields["DISCOUNT_VALUE"] = '';
         }
         $arFields["DISCOUNT_VALUE"] = str_replace(",", ".", $arFields["DISCOUNT_VALUE"]);
         $arFields["DISCOUNT_VALUE"] = doubleval($arFields["DISCOUNT_VALUE"]);
     }
     if (is_set($arFields, "PRICE_FROM")) {
         $arFields["PRICE_FROM"] = str_replace(",", ".", $arFields["PRICE_FROM"]);
         $arFields["PRICE_FROM"] = doubleval($arFields["PRICE_FROM"]);
     }
     if (is_set($arFields, "PRICE_TO")) {
         $arFields["PRICE_TO"] = str_replace(",", ".", $arFields["PRICE_TO"]);
         $arFields["PRICE_TO"] = doubleval($arFields["PRICE_TO"]);
     }
     if ((is_set($arFields, "ACTIVE_FROM") || $ACTION == "ADD") && !$DB->IsDate($arFields["ACTIVE_FROM"], false, LANGUAGE_ID, "FULL")) {
         $arFields["ACTIVE_FROM"] = false;
     }
     if ((is_set($arFields, "ACTIVE_TO") || $ACTION == "ADD") && !$DB->IsDate($arFields["ACTIVE_TO"], false, LANGUAGE_ID, "FULL")) {
         $arFields["ACTIVE_TO"] = false;
     }
     if ((is_set($arFields, 'PRIORITY') || $ACTION == 'ADD') && intval($arFields['PRIORITY']) <= 0) {
         $arFields['PRIORITY'] = 1;
     }
     if ((is_set($arFields, 'LAST_DISCOUNT') || $ACTION == 'ADD') && $arFields["LAST_DISCOUNT"] != "N") {
         $arFields["LAST_DISCOUNT"] = 'Y';
     }
     $arFields['VERSION'] = self::VERSION_NEW;
     $useConditions = array_key_exists('CONDITIONS', $arFields) || $ACTION == 'ADD';
     $useActions = array_key_exists('ACTIONS', $arFields) || $ACTION == 'ADD';
     $updateData = $useConditions || $useActions;
     $usedHandlers = array();
     $usedEntities = array();
     $executeModule = '';
     $conditionData = array('HANDLERS' => array(), 'ENTITY' => array(), 'EXECUTE_MODULE' => array());
     $actionData = array('HANDLERS' => array(), 'ENTITY' => array(), 'EXECUTE_MODULE' => array());
     if ($useConditions) {
         if (!isset($arFields['CONDITIONS']) || empty($arFields['CONDITIONS'])) {
             $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_EMPTY_CONDITIONS"), "CONDITIONS");
             return false;
         } else {
             $arFields['UNPACK'] = '';
             if (!self::prepareDiscountConditions($arFields['CONDITIONS'], $arFields['UNPACK'], $conditionData, self::PREPARE_CONDITIONS, $arFields['LID'])) {
                 return false;
             }
         }
     }
     if ($useActions) {
         if (!isset($arFields['ACTIONS']) || empty($arFields['ACTIONS'])) {
             $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_EMPTY_ACTIONS_EXT"), "ACTIONS");
             return false;
         } else {
             $arFields['APPLICATION'] = '';
             if (!self::prepareDiscountConditions($arFields['ACTIONS'], $arFields['APPLICATION'], $actionData, self::PREPARE_ACTIONS, $arFields['LID'])) {
                 return false;
             }
         }
     }
     if ($updateData) {
         if (!$useConditions) {
             $rsDiscounts = CSaleDiscount::GetList(array(), array('ID' => $discountID), false, false, array('ID', 'CONDITIONS', 'LID'));
             if ($discountInfo = $rsDiscounts->Fetch()) {
                 $discountInfo['UNPACK'] = '';
                 if (!self::prepareDiscountConditions($discountInfo['CONDITIONS'], $discountInfo['UNPACK'], $conditionData, self::PREPARE_CONDITIONS, $discountInfo['LID'])) {
                     return false;
                 }
             } else {
                 return false;
             }
         }
         if (!$useActions) {
             $rsDiscounts = CSaleDiscount::GetList(array(), array('ID' => $discountID), false, false, array('ID', 'ACTIONS', 'LID'));
             if ($discountInfo = $rsDiscounts->Fetch()) {
                 $discountInfo['APPLICATION'] = '';
                 if (!self::prepareDiscountConditions($discountInfo['ACTIONS'], $discountInfo['APPLICATION'], $actionData, self::PREPARE_ACTIONS, $discountInfo['LID'])) {
                     return false;
                 }
             } else {
                 return false;
             }
         }
         if (!empty($conditionData['HANDLERS']) || !empty($actionData['HANDLERS'])) {
             if (!empty($conditionData['HANDLERS'])) {
                 $usedHandlers = $conditionData['HANDLERS'];
             }
             if (!empty($actionData['HANDLERS'])) {
                 if (empty($usedHandlers)) {
                     $usedHandlers = $actionData['HANDLERS'];
                 } else {
                     $usedHandlers['MODULES'] = array_unique(array_merge($usedHandlers['MODULES'], $actionData['HANDLERS']['MODULES']));
                     $usedHandlers['EXT_FILES'] = array_unique(array_merge($usedHandlers['EXT_FILES'], $actionData['HANDLERS']['EXT_FILES']));
                 }
             }
         }
         if (!empty($conditionData['EXECUTE_MODULE']) || !empty($actionData['EXECUTE_MODULE'])) {
             $executeModuleList = array();
             if (!empty($conditionData['EXECUTE_MODULE'])) {
                 $executeModuleList = $conditionData['EXECUTE_MODULE'];
             }
             if (!empty($actionData['EXECUTE_MODULE'])) {
                 $executeModuleList = empty($executeModuleList) ? $actionData['EXECUTE_MODULE'] : array_merge($executeModuleList, $actionData['EXECUTE_MODULE']);
             }
             $executeModuleList = array_unique($executeModuleList);
             if (count($executeModuleList) > 1) {
                 $APPLICATION->ThrowException(Loc::getMessage('BX_SALE_DISC_ERR_MULTIPLE_EXECUTE_MODULE'), 'DISCOUNT');
                 return false;
             }
             $executeModule = current($executeModuleList);
             unset($executeModuleList);
         }
         if (!empty($conditionData['ENTITY']) || !empty($actionData['ENTITY'])) {
             if (!empty($conditionData['ENTITY'])) {
                 $usedEntities = $conditionData['ENTITY'];
             }
             if (!empty($actionData['ENTITY'])) {
                 $usedEntities = empty($usedEntities) ? $actionData['ENTITY'] : array_merge($usedEntities, $actionData['ENTITY']);
             }
         }
     }
     if ($ACTION == 'ADD' && $executeModule == '') {
         $executeModule = 'all';
     }
     if ($executeModule != '') {
         $arFields['EXECUTE_MODULE'] = $executeModule;
     }
     if (!empty($usedHandlers)) {
         $arFields['HANDLERS'] = $usedHandlers;
     }
     if (!empty($usedEntities)) {
         $arFields['ENTITIES'] = $usedEntities;
     }
     if ((is_set($arFields, 'USE_COUPONS') || $ACTION == 'ADD') && 'Y' != $arFields['USE_COUPONS']) {
         $arFields['USE_COUPONS'] = 'N';
     }
     if (array_key_exists('USER_GROUPS', $arFields) || $ACTION == "ADD") {
         Collection::normalizeArrayValuesByInt($arFields['USER_GROUPS']);
         if (empty($arFields['USER_GROUPS']) || !is_array($arFields['USER_GROUPS'])) {
             $APPLICATION->ThrowException(Loc::getMessage("BT_MOD_SALE_DISC_ERR_USER_GROUPS_ABSENT_SHORT"), "USER_GROUPS");
             return false;
         }
     }
     $intUserID = 0;
     $boolUserExist = isset($USER) && $USER instanceof CUser;
     if ($boolUserExist) {
         $intUserID = (int) $USER->GetID();
     }
     $strDateFunction = $DB->GetNowFunction();
     $arFields['~TIMESTAMP_X'] = $strDateFunction;
     if ($boolUserExist) {
         if (!array_key_exists('MODIFIED_BY', $arFields) || (int) $arFields["MODIFIED_BY"] <= 0) {
             $arFields["MODIFIED_BY"] = $intUserID;
         }
     }
     if ($ACTION == 'ADD') {
         $arFields['~DATE_CREATE'] = $strDateFunction;
         if ($boolUserExist) {
             if (!array_key_exists('CREATED_BY', $arFields) || (int) $arFields["CREATED_BY"] <= 0) {
                 $arFields["CREATED_BY"] = $intUserID;
             }
         }
     }
     return true;
 }
コード例 #11
0
		<tr>
			<td width="40%">ID:</td>
			<td width="60%"><?php 
    echo 0 < intval($arProperty['ID']) ? $arProperty['ID'] : GetMessage("BT_ADM_IEP_PROP_NEW");
    ?>
</td>
		</tr>
		<tr>
			<td width="40%"><?php 
    echo GetMessage('BT_ADM_IEP_PROPERTY_TYPE');
    ?>
</td>
			<td width="60%">
			<?php 
    $arUserTypeList = CIBlockProperty::GetUserType();
    \Bitrix\Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
    $boolUserPropExist = !empty($arUserTypeList);
    ?>
			<select name="PROPERTY_PROPERTY_TYPE" onchange="reloadForm();">
			<?php 
    if ($boolUserPropExist) {
        ?>
<optgroup label="<?php 
        echo GetMessage('BT_ADM_IEP_PROPERTY_BASE_TYPE_GROUP');
        ?>
"><?php 
    }
    ?>
				<option value="S" <?php 
    if ($PROPERTY_TYPE == "S") {
        echo " selected";
コード例 #12
0
     foreach ($arMatrix as $keyOffer => $arRow) {
         if ($boolExist) {
             if (!isset($arItem['OFFERS'][$keyOffer]['TREE'])) {
                 $arItem['OFFERS'][$keyOffer]['TREE'] = array();
             }
             $arItem['OFFERS'][$keyOffer]['TREE']['PROP_' . $arSKUPropList[$strOneCode]['ID']] = $arMatrix[$keyOffer][$strOneCode]['VALUE'];
             $arItem['OFFERS'][$keyOffer]['SKU_SORT_' . $strOneCode] = $arMatrix[$keyOffer][$strOneCode]['SORT'];
             $arUsedFields[$strOneCode] = true;
             $arSortFields['SKU_SORT_' . $strOneCode] = SORT_NUMERIC;
         } else {
             unset($arMatrix[$keyOffer][$strOneCode]);
         }
     }
 }
 $arItem['OFFERS_PROP'] = $arUsedFields;
 \Bitrix\Main\Type\Collection::sortByColumn($arItem['OFFERS'], $arSortFields);
 // Find Selected offer
 foreach ($arItem['OFFERS'] as $ind => $offer) {
     if ($offer['SELECTED']) {
         $arItem['OFFERS_SELECTED'] = $ind;
         break;
     }
 }
 $arMatrix = array();
 $intSelected = -1;
 $arItem['MIN_PRICE'] = false;
 /*foreach ($arItem['OFFERS'] as $keyOffer => $arOffer)
 			{
 				if (empty($arItem['MIN_PRICE']) && $arOffer['CAN_BUY'])
 				{
 					$intSelected = $keyOffer;
コード例 #13
0
 public static function ImportTemplate($id, $documentType, $autoExecute, $name, $description, $datum, $systemCode = null, $systemImport = false)
 {
     $id = intval($id);
     if ($id <= 0) {
         $id = 0;
     }
     $datumTmp = CheckSerializedData($datum) ? @unserialize($datum) : null;
     if (!is_array($datumTmp) || is_array($datumTmp) && !array_key_exists("TEMPLATE", $datumTmp)) {
         if (function_exists("gzcompress")) {
             $datumTmp = @gzuncompress($datum);
             $datumTmp = CheckSerializedData($datumTmp) ? @unserialize($datumTmp) : null;
         }
     }
     if (!is_array($datumTmp) || is_array($datumTmp) && !array_key_exists("TEMPLATE", $datumTmp)) {
         throw new Exception(GetMessage("BPCGWTL_WRONG_TEMPLATE"));
     }
     if (array_key_exists("VERSION", $datumTmp) && $datumTmp["VERSION"] == 2) {
         $datumTmp["TEMPLATE"] = self::ConvertArrayCharset($datumTmp["TEMPLATE"], BP_EI_DIRECTION_IMPORT);
         $datumTmp["PARAMETERS"] = self::ConvertArrayCharset($datumTmp["PARAMETERS"], BP_EI_DIRECTION_IMPORT);
         $datumTmp["VARIABLES"] = self::ConvertArrayCharset($datumTmp["VARIABLES"], BP_EI_DIRECTION_IMPORT);
         $datumTmp["CONSTANTS"] = isset($datumTmp["CONSTANTS"]) ? self::ConvertArrayCharset($datumTmp["CONSTANTS"], BP_EI_DIRECTION_IMPORT) : array();
         $datumTmp["DOCUMENT_FIELDS"] = self::ConvertArrayCharset($datumTmp["DOCUMENT_FIELDS"], BP_EI_DIRECTION_IMPORT);
     }
     if (!$systemImport) {
         if (!self::WalkThroughWorkflowTemplate($datumTmp["TEMPLATE"], array("CBPWorkflowTemplateLoader", "ImportTemplateChecker"), new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser))) {
             return false;
         }
     } elseif ($id > 0 && !empty($datumTmp["CONSTANTS"])) {
         $userConstants = self::getTemplateConstants($id);
         if (!empty($userConstants)) {
             foreach ($userConstants as $constantName => $constantData) {
                 if (isset($datumTmp["CONSTANTS"][$constantName])) {
                     $datumTmp["CONSTANTS"][$constantName]['Default'] = $constantData['Default'];
                 }
             }
         }
     }
     $templateData = array("DOCUMENT_TYPE" => $documentType, "AUTO_EXECUTE" => $autoExecute, "NAME" => $name, "DESCRIPTION" => $description, "TEMPLATE" => $datumTmp["TEMPLATE"], "PARAMETERS" => $datumTmp["PARAMETERS"], "VARIABLES" => $datumTmp["VARIABLES"], "CONSTANTS" => $datumTmp["CONSTANTS"], "USER_ID" => $systemImport ? 1 : $GLOBALS["USER"]->GetID(), "MODIFIER_USER" => new CBPWorkflowTemplateUser($systemImport ? 1 : CBPWorkflowTemplateUser::CurrentUser));
     if (!is_null($systemCode)) {
         $templateData["SYSTEM_CODE"] = $systemCode;
     }
     if ($id <= 0) {
         $templateData['ACTIVE'] = 'Y';
     }
     if ($id > 0) {
         self::Update($id, $templateData, $systemImport);
     } else {
         $id = self::Add($templateData, $systemImport);
     }
     $runtime = CBPRuntime::GetRuntime();
     $runtime->StartRuntime();
     $documentService = $runtime->GetService("DocumentService");
     $arDocumentFields = $documentService->GetDocumentFields($documentType);
     if (is_array($datumTmp["DOCUMENT_FIELDS"])) {
         $len = strlen("_PRINTABLE");
         $arFieldsTmp = array();
         foreach ($datumTmp["DOCUMENT_FIELDS"] as $code => $field) {
             if (!array_key_exists($code, $arDocumentFields) && strtoupper(substr($code, -$len)) != "_PRINTABLE") {
                 $arFieldsTmp[$code] = array("name" => $field["Name"], "code" => $code, "type" => $field["Type"], "multiple" => $field["Multiple"], "required" => $field["Required"]);
                 if (is_array($field["Options"]) && count($field["Options"]) > 0) {
                     foreach ($field["Options"] as $k => $v) {
                         $arFieldsTmp[$code]["options"] .= "[" . $k . "]" . $v . "\n";
                     }
                 }
                 unset($field["Name"], $field["Type"], $field["Multiple"], $field["Required"], $field["Options"]);
                 $arFieldsTmp[$code] = array_merge($arFieldsTmp[$code], $field);
             }
         }
         if (!empty($arFieldsTmp)) {
             \Bitrix\Main\Type\Collection::sortByColumn($arFieldsTmp, "sort");
             foreach ($arFieldsTmp as $fieldTmp) {
                 $documentService->AddDocumentField($documentType, $fieldTmp);
             }
         }
     }
     return $id;
 }
コード例 #14
0
 /**
  * Save coupons applyed info.
  *
  * @param array $coupons				Coupons list.
  * @param int $userId					User id.
  * @param Main\Type\DateTime $currentTime	Current datetime.
  * @return array|bool
  */
 public static function saveApplied($coupons, $userId, Main\Type\DateTime $currentTime)
 {
     $currentTimestamp = $currentTime->getTimestamp();
     if ($userId === null || (int) $userId == 0) {
         return false;
     }
     $userId = (int) $userId;
     if (!is_array($coupons)) {
         $coupons = array($coupons);
     }
     if (empty($coupons)) {
         return false;
     }
     Main\Type\Collection::normalizeArrayValuesByInt($coupons);
     if (empty($coupons)) {
         return false;
     }
     $deactivateCoupons = array();
     $incrementalCoupons = array();
     $limitedCoupons = array();
     $couponIterator = self::getList(array('select' => array('ID', 'COUPON', 'DISCOUNT_ID', 'TYPE', 'ACTIVE', 'MAX_USE', 'USE_COUNT', 'USER_ID', 'ACTIVE_TO', 'ACTIVE_FROM', 'DISCOUNT_ACTIVE' => 'DISCOUNT.ACTIVE', 'DISCOUNT_ACTIVE_FROM' => 'DISCOUNT.ACTIVE_FROM', 'DISCOUNT_ACTIVE_TO' => 'DISCOUNT.ACTIVE_TO'), 'filter' => array('@ID' => $coupons, '=ACTIVE' => 'Y'), 'order' => array('ID' => 'ASC')));
     while ($existCoupon = $couponIterator->fetch()) {
         if ($existCoupon['DISCOUNT_ACTIVE'] != 'Y') {
             continue;
         }
         if ($existCoupon['DISCOUNT_ACTIVE_FROM'] instanceof Main\Type\DateTime && $existCoupon['DISCOUNT_ACTIVE_FROM']->getTimestamp() > $currentTimestamp || $existCoupon['DISCOUNT_ACTIVE_TO'] instanceof Main\Type\DateTime && $existCoupon['DISCOUNT_ACTIVE_TO']->getTimestamp() < $currentTimestamp) {
             continue;
         }
         $existCoupon['USER_ID'] = (int) $existCoupon['USER_ID'];
         if ($existCoupon['USER_ID'] > 0 && $existCoupon['USER_ID'] != $userId) {
             continue;
         }
         if ($existCoupon['ACTIVE_FROM'] instanceof Main\Type\DateTime && $existCoupon['ACTIVE_FROM']->getTimestamp() > $currentTimestamp || $existCoupon['ACTIVE_TO'] instanceof Main\Type\DateTime && $existCoupon['ACTIVE_TO']->getTimestamp() < $currentTimestamp) {
             continue;
         }
         if ($existCoupon['TYPE'] == self::TYPE_BASKET_ROW || $existCoupon['TYPE'] == self::TYPE_ONE_ORDER) {
             $deactivateCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
         } elseif ($existCoupon['TYPE'] == self::TYPE_MULTI_ORDER) {
             $existCoupon['MAX_USE'] = (int) $existCoupon['MAX_USE'];
             $existCoupon['USE_COUNT'] = (int) $existCoupon['USE_COUNT'];
             if ($existCoupon['MAX_USE'] > 0 && $existCoupon['USE_COUNT'] >= $existCoupon['MAX_USE']) {
                 continue;
             }
             if ($existCoupon['MAX_USE'] > 0 && $existCoupon['USE_COUNT'] >= $existCoupon['MAX_USE'] - 1) {
                 $limitedCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
             } else {
                 $incrementalCoupons[$existCoupon['COUPON']] = $existCoupon['ID'];
             }
         }
     }
     unset($existCoupon, $couponIterator, $coupons);
     if (!empty($deactivateCoupons) || !empty($limitedCoupons) || !empty($incrementalCoupons)) {
         $conn = Application::getConnection();
         $helper = $conn->getSqlHelper();
         $tableName = $helper->quote(self::getTableName());
         if (!empty($deactivateCoupons)) {
             $conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('ACTIVE') . ' = \'N\', ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $deactivateCoupons) . ')');
         }
         if (!empty($incrementalCoupons)) {
             $conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ', ' . $helper->quote('USE_COUNT') . ' = ' . $helper->quote('USE_COUNT') . ' + 1' . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $incrementalCoupons) . ')');
         }
         if (!empty($limitedCoupons)) {
             $conn->queryExecute('update ' . $tableName . ' set ' . $helper->quote('DATE_APPLY') . ' = ' . $helper->getCurrentDateTimeFunction() . ', ' . $helper->quote('ACTIVE') . ' = \'N\', ' . $helper->quote('USE_COUNT') . ' = ' . $helper->quote('USE_COUNT') . ' + 1' . ' where ' . $helper->quote('ID') . ' in (' . implode(',', $limitedCoupons) . ')');
         }
         unset($tableName, $helper);
     }
     return array('DEACTIVATE' => $deactivateCoupons, 'LIMITED' => $limitedCoupons, 'INCREMENT' => $incrementalCoupons);
 }
コード例 #15
0
	if ($arParams["SET_META_KEYWORDS"] === 'Y')
	{
		$metaKeywords = Collection::firstNotEmpty(
			$arResult["PROPERTIES"], array($arParams["META_KEYWORDS"], "VALUE")
			,$arResult["IPROPERTY_VALUES"], "ELEMENT_META_KEYWORDS"
		);
		if (is_array($metaKeywords))
			$APPLICATION->SetPageProperty("keywords", implode(" ", $metaKeywords), $arTitleOptions);
		elseif ($metaKeywords != "")
			$APPLICATION->SetPageProperty("keywords", $metaKeywords, $arTitleOptions);
	}

	if ($arParams["SET_META_DESCRIPTION"] === 'Y')
	{
		$metaDescription = Collection::firstNotEmpty(
			$arResult["PROPERTIES"], array($arParams["META_DESCRIPTION"], "VALUE")
			,$arResult["IPROPERTY_VALUES"], "ELEMENT_META_DESCRIPTION"
		);
		if (is_array($metaDescription))
			$APPLICATION->SetPageProperty("description", implode(" ", $metaDescription), $arTitleOptions);
		elseif ($metaDescription != "")
			$APPLICATION->SetPageProperty("description", $metaDescription, $arTitleOptions);
	}

	if ($arParams["ADD_SECTIONS_CHAIN"] && !empty($arResult["SECTION"]["PATH"]) && is_array($arResult["SECTION"]["PATH"]))
	{
		foreach($arResult["SECTION"]["PATH"] as $arPath)
		{
			if ($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"] != "")
				$APPLICATION->AddChainItem($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"], $arPath["~SECTION_PAGE_URL"]);
			else
				$APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);
コード例 #16
0
ファイル: section_property.php プロジェクト: rasuldev/torino
 public static function GetArray($IBLOCK_ID, $SECTION_ID = 0, $bNewSection = false)
 {
     global $DB;
     $IBLOCK_ID = intval($IBLOCK_ID);
     $SECTION_ID = intval($SECTION_ID);
     $result = array();
     if ($SECTION_ID > 0) {
         $rs = $DB->Query($s = "\n\t\t\t\tSELECT\n\t\t\t\t\tB.SECTION_PROPERTY,\n\t\t\t\t\tBP.ID PROPERTY_ID,\n\t\t\t\t\tBSP.SECTION_ID LINK_ID,\n\t\t\t\t\tBSP.SMART_FILTER,\n\t\t\t\t\tBP.SORT,\n\t\t\t\t\tBS.LEFT_MARGIN,\n\t\t\t\t\tBS.NAME LINK_TITLE\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock B\n\t\t\t\t\tINNER JOIN b_iblock_property BP ON BP.IBLOCK_ID = B.ID\n\t\t\t\t\tINNER JOIN b_iblock_section M ON M.ID = " . $SECTION_ID . "\n\t\t\t\t\tINNER JOIN b_iblock_section BS ON BS.IBLOCK_ID = M.IBLOCK_ID\n\t\t\t\t\t\tAND M.LEFT_MARGIN >= BS.LEFT_MARGIN\n\t\t\t\t\t\tAND M.RIGHT_MARGIN <= BS.RIGHT_MARGIN\n\t\t\t\t\tINNER JOIN b_iblock_section_property BSP ON BSP.IBLOCK_ID = BS.IBLOCK_ID AND BSP.SECTION_ID = BS.ID AND BSP.PROPERTY_ID = BP.ID\n\t\t\t\tWHERE\n\t\t\t\t\tB.ID = " . $IBLOCK_ID . "\n\t\t\t\tORDER BY\n\t\t\t\t\tBP.SORT ASC, BP.ID ASC, BS.LEFT_MARGIN DESC\n\t\t\t");
         while ($ar = $rs->Fetch()) {
             $result[$ar["PROPERTY_ID"]] = array("PROPERTY_ID" => $ar["PROPERTY_ID"], "SMART_FILTER" => $ar["SMART_FILTER"], "INHERITED" => $SECTION_ID == $ar["LINK_ID"] ? "N" : "Y", "INHERITED_FROM" => $ar["LINK_ID"], "SORT" => $ar["SORT"], "LEFT_MARGIN" => $ar["LEFT_MARGIN"], "LINK_TITLE" => $ar["LINK_TITLE"]);
         }
     }
     if ($SECTION_ID >= 0) {
         $rs = $DB->Query("\n\t\t\t\tSELECT\n\t\t\t\t\tB.SECTION_PROPERTY,\n\t\t\t\t\tBP.ID PROPERTY_ID,\n\t\t\t\t\tBSP.SECTION_ID LINK_ID,\n\t\t\t\t\tBSP.SMART_FILTER,\n\t\t\t\t\tBP.SORT,\n\t\t\t\t\t0 LEFT_MARGIN,\n\t\t\t\t\tB.NAME LINK_TITLE\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock B\n\t\t\t\t\tINNER JOIN b_iblock_property BP ON BP.IBLOCK_ID = B.ID\n\t\t\t\t\tLEFT JOIN b_iblock_section_property BSP ON BSP.SECTION_ID = 0 AND BSP.PROPERTY_ID = BP.ID\n\t\t\t\tWHERE\n\t\t\t\t\tB.ID = " . $IBLOCK_ID . "\n\t\t\t\tORDER BY\n\t\t\t\t\tBP.SORT ASC, BP.ID ASC\n\t\t\t");
         while ($ar = $rs->Fetch()) {
             if ($ar["SECTION_PROPERTY"] === "Y") {
                 if (strlen($ar["LINK_ID"])) {
                     $result[$ar["PROPERTY_ID"]] = array("PROPERTY_ID" => $ar["PROPERTY_ID"], "SMART_FILTER" => $ar["SMART_FILTER"], "INHERITED" => $SECTION_ID == 0 && !$bNewSection ? "N" : "Y", "INHERITED_FROM" => 0, "SORT" => $ar["SORT"], "LEFT_MARGIN" => $ar["LEFT_MARGIN"], "LINK_TITLE" => $ar["LINK_TITLE"]);
                 }
             } else {
                 $result[$ar["PROPERTY_ID"]] = array("PROPERTY_ID" => $ar["PROPERTY_ID"], "SMART_FILTER" => "N", "INHERITED" => $SECTION_ID == 0 && !$bNewSection ? "N" : "Y", "INHERITED_FROM" => 0, "SORT" => $ar["SORT"], "LEFT_MARGIN" => $ar["LEFT_MARGIN"], "LINK_TITLE" => $ar["LINK_TITLE"]);
             }
         }
         if (!empty($result)) {
             \Bitrix\Main\Type\Collection::sortByColumn($result, array("SORT" => SORT_ASC, "PROPERTY_ID" => SORT_ASC), '', null, true);
         }
     }
     return $result;
 }
コード例 #17
0
ファイル: objectpath.php プロジェクト: mrdeadmouse/u136006
 /**
  * Get ancestors objects of $objectId.
  * PARENT_ID not really! Be careful :)
  * @param     $objectId
  * @param int $orderDepthLevel SORT_ASC | SORT_DESC
  * @throws \Bitrix\Main\ArgumentOutOfRangeException
  * @throws \Bitrix\Main\ArgumentException
  * @throws \Exception
  * @return array
  */
 public static function getAncestors($objectId, $orderDepthLevel = SORT_ASC)
 {
     $objectId = (int) $objectId;
     $objectPaths = static::getList(array('select' => array('ID', 'PARENT_ID', 'OBJECT_ID', 'DEPTH_LEVEL'), 'filter' => array('OBJECT_ID' => $objectId, '!PARENT_ID' => $objectId)))->fetchAll();
     Collection::sortByColumn($objectPaths, array('DEPTH_LEVEL' => $orderDepthLevel));
     return $objectPaths;
 }
コード例 #18
0
ファイル: class.php プロジェクト: mrdeadmouse/u136006
    private function getGridData($gridId, $showDeleted = false)
    {
        $grid = array('ID' => $gridId);
        $gridOptions = new CGridOptions($grid['ID']);
        $gridSort = $gridOptions->getSorting(array('sort' => array('NAME' => 'ASC'), 'vars' => array('by' => 'by', 'order' => 'order')));
        $filter = array();
        $grid['SORT'] = $gridSort['sort'];
        $grid['SORT_VARS'] = $gridSort['vars'];
        $grid['MODE'] = $this->getViewMode();
        $possibleColumnForSorting = array('UPDATE_TIME' => array('ALIAS' => 'UPDATE_TIME', 'LABEL' => Loc::getMessage('DISK_FOLDER_LIST_SORT_BY_UPDATE_TIME')), 'NAME' => array('ALIAS' => 'NAME', 'LABEL' => Loc::getMessage('DISK_FOLDER_LIST_SORT_BY_NAME')), 'FORMATTED_SIZE' => array('ALIAS' => 'SIZE', 'LABEL' => Loc::getMessage('DISK_FOLDER_LIST_SORT_BY_FORMATTED_SIZE')));
        $byColumn = key($grid['SORT']);
        if (!isset($possibleColumnForSorting[$byColumn]) || strtolower($grid['SORT'][$byColumn]) !== 'desc' && strtolower($grid['SORT'][$byColumn]) !== 'asc') {
            $grid['SORT'] = array();
        }
        $order = $grid['SORT'];
        $byColumn = key($order);
        $sortingColumns = array('TYPE' => array(SORT_NUMERIC, SORT_ASC), $possibleColumnForSorting[$byColumn]['ALIAS'] => strtolower($order[$byColumn]) === 'asc' ? SORT_ASC : SORT_DESC);
        if ($byColumn !== 'NAME') {
            $sortingColumns[$possibleColumnForSorting['NAME']['ALIAS']] = SORT_ASC;
        }
        $securityContext = $this->storage->getCurrentUserSecurityContext();
        $proxyType = $this->storage->getProxyType();
        $isStorageCurrentUser = $proxyType instanceof ProxyType\User && $proxyType->getTitleForCurrentUser() != $proxyType->getTitle();
        $parameters = array('with' => array('CREATE_USER'), 'filter' => array('PARENT_ID' => $this->folder->getRealObjectId(), 'DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE));
        $parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('ID', 'CREATED_BY'));
        $needPagination = $this->needPagination();
        $pageNumber = (int) $this->request->getQuery('pageNumber');
        if ($pageNumber <= 0) {
            $pageNumber = 1;
        }
        if ($needPagination) {
            $parameters['order'] = array();
            foreach ($sortingColumns as $columnName => $columnData) {
                if (is_array($columnData)) {
                    $parameters['order'][$columnName] = in_array(SORT_DESC, $columnData, true) ? 'DESC' : 'ASC';
                } else {
                    $parameters['order'][$columnName] = SORT_DESC === $columnData ? 'DESC' : 'ASC';
                }
            }
            unset($columnName, $columnData);
            $parameters['limit'] = self::COUNT_ON_PAGE + 1;
            // +1 because we want to know about existence next page
            $parameters['offset'] = self::COUNT_ON_PAGE * ($pageNumber - 1);
        }
        $this->folder->preloadOperationsForChildren($securityContext);
        $sharedObjectIds = $this->getUserShareObjectIds();
        $isDesktopDiskInstall = \Bitrix\Disk\Desktop::isDesktopDiskInstall();
        $nowTime = time() + CTimeZone::getOffset();
        $fullFormatWithoutSec = preg_replace('/:s$/', '', CAllDatabase::dateFormatToPHP(CSite::GetDateFormat("FULL")));
        $urlManager = Driver::getInstance()->getUrlManager();
        $rows = array();
        $storageTitle = $proxyType->getTitle();
        $isEnabledShowExtendedRights = $this->storage->isEnabledShowExtendedRights();
        $result = $this->folder->getList($parameters);
        $countObjectsOnPage = 0;
        $needShowNextPagePagination = false;
        while ($row = $result->fetch()) {
            $countObjectsOnPage++;
            if ($needPagination && $countObjectsOnPage > self::COUNT_ON_PAGE) {
                $needShowNextPagePagination = true;
                break;
            }
            $object = BaseObject::buildFromArray($row);
            /** @var File|Folder $object */
            $name = $object->getName();
            $objectId = $object->getId();
            $exportData = array('TYPE' => $object->getType(), 'NAME' => $name, 'ID' => $objectId);
            $relativePath = trim($this->arParams['RELATIVE_PATH'], '/');
            $detailPageFile = CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_FILE_VIEW'], array('FILE_ID' => $objectId, 'FILE_PATH' => ltrim($relativePath . '/' . $name, '/')));
            $listingPage = rtrim(CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_FOLDER_LIST'], array('PATH' => $relativePath)), '/');
            $isFolder = $object instanceof Folder;
            $actions = $tileActions = $columns = array();
            if ($object->canRead($securityContext)) {
                $exportData['OPEN_URL'] = $urlManager->encodeUrn($isFolder ? $listingPage . '/' . $name . '/' : $detailPageFile);
                $actions[] = array("PSEUDO_NAME" => "open", "DEFAULT" => true, "ICONCLASS" => "show", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_OPEN'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $exportData['OPEN_URL'] . "')");
                if (!$object->canChangeRights($securityContext) && !$object->canShare($securityContext)) {
                    $actions[] = array("PSEUDO_NAME" => "share", "ICONCLASS" => "share", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_SHOW_SHARING_DETAIL_2'), "ONCLICK" => "BX.Disk.showSharingDetailWithoutEdit({\n\t\t\t\t\t\t\t\tajaxUrl: '/bitrix/components/bitrix/disk.folder.list/ajax.php',\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})");
                } elseif ($object->canChangeRights($securityContext)) {
                    $actions[] = array("PSEUDO_NAME" => "share", "ICONCLASS" => "share", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_SHOW_SHARING_DETAIL_2'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].showSharingDetailWithChangeRights({\n\t\t\t\t\t\t\t\tajaxUrl: '/bitrix/components/bitrix/disk.folder.list/ajax.php',\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})");
                } elseif ($object->canShare($securityContext)) {
                    $actions[] = array("PSEUDO_NAME" => "share", "ICONCLASS" => "share", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_SHOW_SHARING_DETAIL_2'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].showSharingDetailWithSharing({\n\t\t\t\t\t\t\t\tajaxUrl: '/bitrix/components/bitrix/disk.folder.list/ajax.php',\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})");
                }
                if ($isEnabledShowExtendedRights && !$object->isLink() && $object->canChangeRights($securityContext)) {
                    $actions[] = array("PSEUDO_NAME" => "rights", "ICONCLASS" => "rights", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_RIGHTS_SETTINGS'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].showRightsOnObjectDetail({\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})");
                }
                if (!$isFolder) {
                    $actions[] = array("PSEUDO_NAME" => "download", "ICONCLASS" => "download", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_DOWNLOAD'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $urlManager->getUrlForDownloadFile($object) . "')");
                }
                $actions[] = array("PSEUDO_NAME" => "copy", "ICONCLASS" => "copy", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_COPY'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].openCopyModalWindow({\n\t\t\t\t\t\tid: {$this->storage->getRootObjectId()},\n\t\t\t\t\t\tname: '" . CUtil::JSEscape($storageTitle) . "'\n\t\t\t\t\t}, {\n\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\tname: '" . CUtil::JSEscape($name) . "'\n\t\t\t\t\t});");
                if ($object->canDelete($securityContext)) {
                    $actions[] = array("PSEUDO_NAME" => "move", "ICONCLASS" => "move", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_MOVE'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].openMoveModalWindow({\n\t\t\t\t\t\t\tid: {$this->storage->getRootObjectId()},\n\t\t\t\t\t\t\tname: '" . CUtil::JSEscape($storageTitle) . "'\n\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\tname: '" . CUtil::JSEscape($name) . "'\n\t\t\t\t\t\t});");
                }
                if (!$isStorageCurrentUser && (!isset($sharedObjectIds[$object->getRealObjectId()]) || $sharedObjectIds[$object->getRealObjectId()]['TO_ENTITY'] != Sharing::CODE_USER . $this->getUser()->getId())) {
                    $actions[] = array("PSEUDO_NAME" => "connect", "ICONCLASS" => "connect", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_CONNECT'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].connectObjectToDisk({\n\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\tname: '" . CUtil::JSEscape($name) . "',\n\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});");
                }
                if (!$isFolder) {
                    $actions[] = array("ICONCLASS" => "show", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_GET_EXT_LINK'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].getExternalLink({$objectId});");
                    $downloadLink = $urlManager->getUrlForShowFile($object, array(), true);
                    $actions[] = array("ICONCLASS" => "show", 'PSEUDO_NAME' => 'internal_link', 'PSEUDO_VALUE' => $downloadLink, "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_COPY_INTERNAL_LINK'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].getInternalLink('{$downloadLink}');");
                    $actions[] = array("ICONCLASS" => "history", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_SHOW_HISTORY'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $exportData['OPEN_URL'] . "#tab-history')");
                }
            }
            if ($object->canRename($securityContext)) {
                $actions[] = array("TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_RENAME'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].renameInline({$objectId})");
            }
            if ((!empty($sharedObjectIds[$objectId]) || $object->isLink()) && $object->canRead($securityContext)) {
                $tileActions['SHARE_INFO'] = array("ICONCLASS" => "show", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_DETAIL_SHARE_INFO'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].showShareInfoSmallView({\n\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t }\n\t\t\t\t\t})");
            }
            $columnsBizProc = array('BIZPROC' => '');
            $bizprocIcon = array('BIZPROC' => '');
            if ($this->arParams['STATUS_BIZPROC'] && !$isFolder) {
                list($actions, $columnsBizProc, $bizprocIcon) = $this->getBizProcData($object, $securityContext, $actions, $columnsBizProc, $bizprocIcon, $exportData);
            }
            if ($object->canDelete($securityContext)) {
                if ($object->isLink()) {
                    $actions[] = array("PSEUDO_NAME" => "detach", "ICONCLASS" => "detach", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_DETACH_BUTTON'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].openConfirmDetach({\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t})");
                } elseif ($object->getCode() !== Folder::CODE_FOR_UPLOADED_FILES) {
                    $actions[] = array("PSEUDO_NAME" => "delete", "ICONCLASS" => "delete", "TEXT" => Loc::getMessage('DISK_FOLDER_LIST_ACT_MARK_DELETED'), "ONCLICK" => "BX.Disk['FolderListClass_{$this->componentId}'].openConfirmDelete({\n\t\t\t\t\t\t\t\tobject: {\n\t\t\t\t\t\t\t\t\tid: {$objectId},\n\t\t\t\t\t\t\t\t\tname: '{$name}',\n\t\t\t\t\t\t\t\t\tisFolder: " . ($isFolder ? 'true' : 'false') . "\n\t\t\t\t\t\t\t\t },\n\t\t\t\t\t\t\t\tcanDelete: {$object->canDelete($securityContext)}\n\t\t\t\t\t\t\t})");
                }
            }
            $iconClass = Ui\Icon::getIconClassByObject($object, !empty($sharedObjectIds[$objectId]));
            $dataAttributesForViewer = '';
            if ($isFolder) {
                $dataAttributesForViewer = Ui\Viewer::getAttributesByObject($object);
                if ($grid['MODE'] === 'tile') {
                    $exportData['VIEWER_ATTRS'] = $dataAttributesForViewer;
                    $dataAttributesForViewer = '';
                }
                $nameSpecialChars = htmlspecialcharsbx($name);
                $columnName = "\n\t\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$objectId}\" class=\"draggable bx-file-icon-container-small {$iconClass}\"></div></td>\n\t\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$objectId}\" href=\"{$exportData['OPEN_URL']}\" {$dataAttributesForViewer}>{$nameSpecialChars}</a></td>\n\t\t\t\t\t</tr></table>\n\t\t\t\t";
            } else {
                $externalId = '';
                if ($isDesktopDiskInstall && $isStorageCurrentUser) {
                    $externalId = "st{$this->storage->getId()}|{$this->storage->getRootObjectId()}|f{$objectId}";
                }
                $dataAttributesForViewer = Ui\Viewer::getAttributesByObject($object, array('canUpdate' => $object->canUpdate($securityContext), 'relativePath' => $relativePath . '/' . $name, 'externalId' => $externalId));
                if ($grid['MODE'] === 'tile') {
                    $exportData['VIEWER_ATTRS'] = $dataAttributesForViewer;
                    $dataAttributesForViewer = '';
                }
                $nameSpecialChars = htmlspecialcharsbx($name);
                $columnName = "\n\t\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$objectId}\" class=\"draggable bx-file-icon-container-small {$iconClass}\"></div></td>\n\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$objectId}\" href=\"{$exportData['OPEN_URL']}\" {$dataAttributesForViewer}>{$nameSpecialChars}</a></td>\n\t\t\t\t\t\t<td>{$bizprocIcon['BIZPROC']}</td>\n\t\t\t\t\t</tr></table>\n\t\t\t\t";
            }
            $createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $object->getCreatedBy()));
            $timestampCreate = $object->getCreateTime()->toUserTime()->getTimestamp();
            $timestampUpdate = $object->getUpdateTime()->toUserTime()->getTimestamp();
            $columns = array('CREATE_TIME' => $nowTime - $timestampCreate > 158400 ? formatDate($fullFormatWithoutSec, $timestampCreate, $nowTime) : formatDate('x', $timestampCreate, $nowTime), 'UPDATE_TIME' => $nowTime - $timestampCreate > 158400 ? formatDate($fullFormatWithoutSec, $timestampUpdate, $nowTime) : formatDate('x', $timestampUpdate, $nowTime), 'NAME' => $columnName, 'FORMATTED_SIZE' => $isFolder ? '' : CFile::formatSize($object->getSize()), 'CREATE_USER' => "\n\t\t\t\t\t<div class=\"bx-disk-user-link\"><a target='_blank' href=\"{$createdByLink}\" id=\"\">" . htmlspecialcharsbx($object->getCreateUser()->getFormattedName()) . "</a></div>\n\t\t\t\t");
            if ($this->arParams['STATUS_BIZPROC']) {
                $columns['BIZPROC'] = $columnsBizProc["BIZPROC"];
            }
            $exportData['ICON_CLASS'] = $iconClass;
            if ($grid['MODE'] === 'tile') {
                $exportData['IS_IMAGE'] = $isFolder ? false : \Bitrix\Disk\TypeFile::isImage($object);
                if ($exportData['IS_IMAGE']) {
                    $exportData['SRC_IMAGE'] = $urlManager->getUrlForShowFile($object, array('exact' => 'Y', 'width' => 64, 'height' => 64));
                }
                $exportData['UPDATE_TIME'] = $columns['UPDATE_TIME'];
            }
            $exportData['IS_SHARED'] = !empty($sharedObjectIds[$objectId]);
            $exportData['IS_LINK'] = $object->isLink();
            $tildaExportData = array();
            foreach ($exportData as $exportName => $exportValue) {
                $tildaExportData['~' . $exportName] = $exportValue;
            }
            unset($exportRow);
            $rows[] = array('data' => array_merge($exportData, $tildaExportData), 'columns' => $columns, 'actions' => $actions, 'tileActions' => $tileActions, 'TYPE' => $exportData['TYPE'], 'NAME' => $exportData['NAME'], 'UPDATE_TIME' => $object->getUpdateTime()->getTimestamp(), 'SIZE' => $isFolder ? 0 : $object->getSize());
        }
        unset($object);
        if (!$needPagination) {
            Collection::sortByColumn($rows, $sortingColumns);
        }
        $grid['HEADERS'] = array(array('id' => 'ID', 'name' => 'ID', 'sort' => isset($possibleColumnForSorting['ID']) ? 'ID' : false, 'default' => false), array('id' => 'NAME', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_NAME'), 'sort' => isset($possibleColumnForSorting['NAME']) ? 'NAME' : false, 'default' => true, 'editable' => array('size' => 45)), array('id' => 'CREATE_TIME', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_CREATE_TIME'), 'sort' => isset($possibleColumnForSorting['CREATE_TIME']) ? 'CREATE_TIME' : false, 'default' => false), array('id' => 'UPDATE_TIME', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_UPDATE_TIME'), 'sort' => isset($possibleColumnForSorting['UPDATE_TIME']) ? 'UPDATE_TIME' : false, 'default' => true), array('id' => 'CREATE_USER', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_CREATE_USER'), 'sort' => isset($possibleColumnForSorting['CREATE_USER']) ? 'CREATE_USER' : false, 'default' => false), array('id' => 'FORMATTED_SIZE', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_FORMATTED_SIZE'), 'sort' => isset($possibleColumnForSorting['FORMATTED_SIZE']) ? 'FORMATTED_SIZE' : false, 'default' => true));
        if ($this->arParams['STATUS_BIZPROC']) {
            $grid['HEADERS'][] = array('id' => 'BIZPROC', 'name' => Loc::getMessage('DISK_FOLDER_LIST_COLUMN_BIZPROC'), 'default' => false);
        }
        $grid['DATA_FOR_PAGINATION'] = array('ENABLED' => $needPagination);
        if ($needPagination) {
            $grid['DATA_FOR_PAGINATION']['SHOW_NEXT_PAGE'] = $needShowNextPagePagination;
            $grid['DATA_FOR_PAGINATION']['CURRENT_PAGE'] = $pageNumber;
        }
        $grid['COLUMN_FOR_SORTING'] = $possibleColumnForSorting;
        $grid['ROWS'] = $rows;
        $grid['ROWS_COUNT'] = count($rows);
        $grid['FOOTER'] = array();
        if (isModuleInstalled('bitrix24')) {
            list($freeSpace, $diskSize) = $this->getDiskSpace();
            $freeSpace = CFile::formatSize($freeSpace);
            $diskSize = CFile::formatSize($diskSize);
            $grid['FOOTER'] = array(array('custom_html' => '
						<td class="tar" style="width: 100%;">' . Loc::getMessage('DISK_FOLDER_LIST_B24_LABEL_DISK_SPACE', array('#FREE_SPACE#' => '<span>' . $freeSpace, '#DISK_SIZE#' => $diskSize . '</span>')) . '</span></td>
					'), array('custom_html' => '
						<td class="tar"><a class="bx-disk-mp-link-addhdd" href="' . Loc::getMessage('DISK_FOLDER_LIST_B24_URL_DISK_SPACE') . '" target="_blank">+ <span>' . Loc::getMessage('DISK_FOLDER_LIST_B24_APPEND_DISK_SPACE') . '</span></a></td>
					'));
        }
        return $grid;
    }
コード例 #19
0
ファイル: product_edit.php プロジェクト: DarneoStudio/bitrix
                        if ($arPriceBoundaries[$i]["FROM"] < $arPrice["QUANTITY_FROM"] && $arPriceBoundaries[$i]["TO"] >= $arPrice["QUANTITY_TO"] && $arPrice["QUANTITY_TO"] != 0) {
                            $arPriceBoundariesError[] = str_replace("#TYPE#", $arPrice["CATALOG_GROUP_NAME"], str_replace("#RIGHT#", $arPrice["QUANTITY_TO"], str_replace("#LEFT#", $arPrice["QUANTITY_FROM"], GetMessage("C2IT_BOUND_DIAP"))));
                            $bNewSegment = false;
                            break;
                        }
                    }
                }
                if ($bNewSegment) {
                    $arPriceBoundaries[] = array("FROM" => $arPrice["QUANTITY_FROM"], "TO" => $arPrice["QUANTITY_TO"]);
                }
            }
        }
    }
    if (!empty($arPriceBoundaries)) {
        if (count($arPriceBoundaries) > 1) {
            Main\Type\Collection::sortByColumn($arPriceBoundaries, array('FROM' => SORT_ASC));
        } else {
            $arPriceBoundaries[0]['FROM'] = false;
            $arPriceBoundaries[0]['TO'] = false;
        }
    }
    // prices tab
    $tabControl1->BeginNextTab();
    $arCatPricesExist = array();
    // attr for exist prices for range
    $bUseExtendedPrice = $bVarsFromForm ? $price_useextform == 'Y' : count($arPriceBoundaries) > 1;
    $str_CAT_VAT_ID = $bVarsFromForm ? $CAT_VAT_ID : ($arBaseProduct['VAT_ID'] == 0 ? $arMainCatalog['VAT_ID'] : $arBaseProduct['VAT_ID']);
    $str_CAT_VAT_INCLUDED = $bVarsFromForm ? $CAT_VAT_INCLUDED : $arBaseProduct['VAT_INCLUDED'];
    ?>
<input type="hidden" name="price_useextform" id="price_useextform_N" value="N" />
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="edit-table" id="catalog_vat_table">
コード例 #20
0
ファイル: discountgroup.php プロジェクト: DarneoStudio/bitrix
 /**
  * Returns discount list by user groups.
  *
  * @param array $groupList			User group list.
  * @param array $filter				Additional filter.
  * @return array
  */
 public static function getDiscountByGroups($groupList, $filter = array())
 {
     $result = array();
     if (!empty($groupList) && is_array($groupList)) {
         Main\Type\Collection::normalizeArrayValuesByInt($groupList);
         if (!empty($groupList)) {
             if (!is_array($filter)) {
                 $filter = array();
             }
             $groupRows = array_chunk($groupList, 500);
             foreach ($groupRows as &$row) {
                 $filter['@GROUP_ID'] = $row;
                 $groupIterator = self::getList(array('select' => array('DISCOUNT_ID'), 'filter' => $filter));
                 while ($group = $groupIterator->fetch()) {
                     $group['DISCOUNT_ID'] = (int) $group['DISCOUNT_ID'];
                     $result[$group['DISCOUNT_ID']] = true;
                 }
                 unset($group, $groupIterator);
             }
             unset($row, $groupRows);
             if (!empty($result)) {
                 $result = array_keys($result);
             }
         }
     }
     return $result;
 }
コード例 #21
0
ファイル: timeman.php プロジェクト: DarneoStudio/bitrix
     } else {
         $res = array('DEFAULTS' => CTimeMan::GetModuleSettings($arNeededSettings), 'DEPARTMENTS' => array(), 'USERS' => array());
         foreach ($_REQUEST['DEPARTMENTS'] as $dpt) {
             $res['DEPARTMENTS'][] = array('ID' => $dpt, 'SETTINGS' => CTimeMan::GetSectionPersonalSettings($dpt, true, $arNeededSettings), 'SETTINGS_ALL' => CTimeMan::GetSectionSettings($dpt, $arNeededSettings));
         }
         foreach ($_REQUEST['USERS'] as $user) {
             $TMUSER = new CTimeManUser($user);
             $res['USERS'][] = array('ID' => $user, 'SETTINGS' => $TMUSER->GetPersonalSettings($arNeededSettings), 'SETTINGS_ALL' => $TMUSER->GetSettings($arNeededSettings));
         }
     }
     break;
 case 'admin_data':
     $obReport = new CTimeManAdminReport(array('show_all' => $_REQUEST['show_all'] == 'Y', 'ts' => $_REQUEST['ts'], 'page' => $_REQUEST['page'], 'amount' => 30, 'department' => $_REQUEST['department'], 'path_user' => COption::GetOptionString('intranet', 'path_user', '/company/personal/user/#USER_ID#/', $site_id), 'nav_handler' => 'window.BXTMREPORT.Page'));
     $bReturnRes = true;
     $res = $obReport->GetData();
     \Bitrix\Main\Type\Collection::sortByColumn($res['USERS'], array('HEAD' => SORT_DESC, 'NAME' => SORT_ASC));
     $res['DEPARTMENTS'] = array_values($res['DEPARTMENTS']);
     break;
 case 'admin_save':
     $ID = intval($_REQUEST['ID']);
     $arEntry = null;
     if (CTimeManEntry::Approve($ID, true)) {
         if ($_REQUEST['INFO']) {
             $arFields = array();
             if (isset($_REQUEST['INFO']['TIME_START'])) {
                 $arFields['TIME_START'] = intval($_REQUEST['INFO']['TIME_START']);
             }
             if (isset($_REQUEST['INFO']['TIME_FINISH'])) {
                 $arFields['TIME_FINISH'] = intval($_REQUEST['INFO']['TIME_FINISH']);
             }
             if (isset($_REQUEST['INFO']['TIME_LEAKS'])) {
コード例 #22
0
 function setIBlock($IBLOCK_ID, $propertyID = array())
 {
     $this->VERSION = CIBlockElement::GetIBVersion($IBLOCK_ID);
     if (!empty($propertyID)) {
         Collection::normalizeArrayValuesByInt($propertyID);
     }
     $this->arProperties = array();
     if (!empty($propertyID) || empty($propertyID) && !isset(self::$propertiesCache[$IBLOCK_ID])) {
         $propertyIterator = PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'ACTIVE', 'SORT', 'CODE', 'DEFAULT_VALUE', 'PROPERTY_TYPE', 'MULTIPLE', 'LINK_IBLOCK_ID', 'VERSION', 'USER_TYPE', 'USER_TYPE_SETTINGS'), 'filter' => empty($propertyID) ? array('IBLOCK_ID' => $IBLOCK_ID) : array('ID' => $propertyID, 'IBLOCK_ID' => $IBLOCK_ID), 'order' => array('ID' => 'ASC')));
         while ($property = $propertyIterator->fetch()) {
             if ($property['USER_TYPE']) {
                 $userType = CIBlockProperty::GetUserType($property['USER_TYPE']);
                 if (isset($userType["ConvertFromDB"])) {
                     if (array_key_exists("DEFAULT_VALUE", $property)) {
                         $value = array("VALUE" => $property["DEFAULT_VALUE"], "DESCRIPTION" => "");
                         $value = call_user_func_array($userType["ConvertFromDB"], array($property, $value));
                         $property["DEFAULT_VALUE"] = $value["VALUE"];
                     }
                 }
             }
             if ($property['USER_TYPE_SETTINGS'] !== '' || $property['USER_TYPE_SETTINGS'] !== null) {
                 $property['USER_TYPE_SETTINGS'] = unserialize($property['USER_TYPE_SETTINGS']);
             }
             $this->arProperties[$property['ID']] = $property;
         }
         unset($property, $propertyIterator);
         if (empty($propertyID)) {
             self::$propertiesCache[$IBLOCK_ID] = $this->arProperties;
         }
     } else {
         $this->arProperties = self::$propertiesCache[$IBLOCK_ID];
     }
 }
コード例 #23
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
         $arItem["SORT"] = $arSetItemsDefaultID[$arItem["ID"]];
         $arResult["SET_ITEMS"]["DEFAULT"][] = $arItem;
         if ($arParams['CONVERT_CURRENCY'] == 'Y') {
             $arResult["SET_ITEMS"]["PRICE"] += $arItem["PRICE_DISCOUNT_VALUE"];
             $arResult["SET_ITEMS"]["OLD_PRICE"] += $arItem["PRICE_VALUE"];
             $arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"] += $arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"];
         }
     } else {
         if ($arItem['CATALOG_AVAILABLE'] == 'Y') {
             $arItem["SORT"] = $arSetItemsOtherID[$arItem["ID"]];
             $arResult["SET_ITEMS"]["OTHER"][] = $arItem;
         }
     }
 }
 Type\Collection::sortByColumn($arResult["SET_ITEMS"]["DEFAULT"], array('SORT' => SORT_ASC));
 Type\Collection::sortByColumn($arResult["SET_ITEMS"]["OTHER"], array('SORT' => SORT_ASC));
 if ($arParams['CONVERT_CURRENCY'] == 'N') {
     //convert all prices to main element currency
     foreach ($arResult["SET_ITEMS"]["DEFAULT"] as $key => $arItem) {
         $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem['PRICE_DISCOUNT_VALUE'], $arItem["PRICE_CURRENCY"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
         $arResult["SET_ITEMS"]["PRICE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"];
         $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_VALUE"], $arItem["PRICE_CURRENCY"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
         $arResult["SET_ITEMS"]["OLD_PRICE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_VALUE"];
         $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"], $arItem["PRICE_CURRENCY"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
         $arResult["SET_ITEMS"]["PRICE_DISCOUNT_DIFFERENCE"] += $arResult["SET_ITEMS"]["DEFAULT"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"];
     }
     foreach ($arResult["SET_ITEMS"]["OTHER"] as $key => $arItem) {
         $arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_DISCOUNT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem['PRICE_DISCOUNT_VALUE'], $arItem["PRICE_CURRENCY"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
         $arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_VALUE"], $arItem["PRICE_CURRENCY"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
         $arResult["SET_ITEMS"]["OTHER"][$key]["PRICE_CONVERT_DISCOUNT_DIFFERENCE_VALUE"] = CCurrencyRates::ConvertCurrency($arItem["PRICE_DISCOUNT_DIFFERENCE_VALUE"], $arItem["PRICE_CURRENCY"], $arResult["ELEMENT"]["PRICE_CURRENCY"]);
     }
コード例 #24
0
         if ($boolExist) {
             if (!isset($arResult['OFFERS'][$keyOffer]['TREE'])) {
                 $arResult['OFFERS'][$keyOffer]['TREE'] = array();
             }
             $arResult['OFFERS'][$keyOffer]['TREE']['PROP_' . $arSKUPropList[$strOneCode]['ID']] = $arMatrix[$keyOffer][$strOneCode]['VALUE'];
             $arResult['OFFERS'][$keyOffer]['SKU_SORT_' . $strOneCode] = $arMatrix[$keyOffer][$strOneCode]['SORT'];
             $arUsedFields[$strOneCode] = true;
             $arSortFields['SKU_SORT_' . $strOneCode] = SORT_NUMERIC;
         } else {
             unset($arMatrix[$keyOffer][$strOneCode]);
         }
     }
 }
 $arResult['OFFERS_PROP'] = $arUsedFields;
 $arResult['OFFERS_PROP_CODES'] = !empty($arUsedFields) ? base64_encode(serialize(array_keys($arUsedFields))) : '';
 Collection::sortByColumn($arResult['OFFERS'], $arSortFields);
 $offerSet = array();
 if (!empty($arIDS) && CBXFeatures::IsFeatureEnabled('CatCompleteSet')) {
     $offerSet = array_fill_keys($arIDS, false);
     $rsSets = CCatalogProductSet::getList(array(), array('@OWNER_ID' => $arIDS, '=SET_ID' => 0, '=TYPE' => CCatalogProductSet::TYPE_GROUP), false, false, array('ID', 'OWNER_ID'));
     while ($arSet = $rsSets->Fetch()) {
         $arSet['OWNER_ID'] = (int) $arSet['OWNER_ID'];
         $offerSet[$arSet['OWNER_ID']] = true;
         $arResult['OFFER_GROUP'] = true;
     }
     if ($offerSet[$arResult['ID']]) {
         foreach ($offerSet as &$setOfferValue) {
             if ($setOfferValue === false) {
                 $setOfferValue = true;
             }
         }
コード例 #25
0
ファイル: component.php プロジェクト: rasuldev/torino
    if (is_array($browserTitle)) {
        $APPLICATION->SetPageProperty("title", implode(" ", $browserTitle), $arTitleOptions);
    } elseif ($browserTitle != "") {
        $APPLICATION->SetPageProperty("title", $browserTitle, $arTitleOptions);
    }
}
if ($arParams["SET_META_KEYWORDS"] === 'Y') {
    $metaKeywords = \Bitrix\Main\Type\Collection::firstNotEmpty($arResult, $arParams["META_KEYWORDS"], $arResult["IPROPERTY_VALUES"], "SECTION_META_KEYWORDS");
    if (is_array($metaKeywords)) {
        $APPLICATION->SetPageProperty("keywords", implode(" ", $metaKeywords), $arTitleOptions);
    } elseif ($metaKeywords != "") {
        $APPLICATION->SetPageProperty("keywords", $metaKeywords, $arTitleOptions);
    }
}
if ($arParams["SET_META_DESCRIPTION"] === 'Y') {
    $metaDescription = \Bitrix\Main\Type\Collection::firstNotEmpty($arResult, $arParams["META_DESCRIPTION"], $arResult["IPROPERTY_VALUES"], "SECTION_META_DESCRIPTION");
    if (is_array($metaDescription)) {
        $APPLICATION->SetPageProperty("description", implode(" ", $metaDescription), $arTitleOptions);
    } elseif ($metaDescription != "") {
        $APPLICATION->SetPageProperty("description", $metaDescription, $arTitleOptions);
    }
}
if (!empty($arResult['BACKGROUND_IMAGE']) && is_array($arResult['BACKGROUND_IMAGE'])) {
    $APPLICATION->SetPageProperty("backgroundImage", 'style="background-image: url(\'' . $arResult['BACKGROUND_IMAGE']['SRC'] . '\')"');
}
if ($arParams["ADD_SECTIONS_CHAIN"] && isset($arResult["PATH"]) && is_array($arResult["PATH"])) {
    foreach ($arResult["PATH"] as $arPath) {
        if ($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"] != "") {
            $APPLICATION->AddChainItem($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"], $arPath["~SECTION_PAGE_URL"]);
        } else {
            $APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);
コード例 #26
0
ファイル: product.php プロジェクト: DarneoStudio/bitrix
 /**
  * Returns list of recommended products for specific product.
  *
  * @param int $USER_ID							User id.
  * @param string $LID							Site id.
  * @param array $arFilterRecomendet				Recomendation filter.
  * @param string $recomMore						Get more.
  * @param int $cntProductDefault				Max count.
  * @return array
  */
 function GetRecommendetProduct($USER_ID, $LID, $arFilterRecomendet = array(), $recomMore = 'N', $cntProductDefault = 2)
 {
     $arRecomendetResult = array();
     if (CModule::IncludeModule('catalog') && !empty($arFilterRecomendet)) {
         $arRecomendet = array();
         if (!is_array($arFilterRecomendet)) {
             $arFilterRecomendet = array($arFilterRecomendet);
         }
         Main\Type\Collection::normalizeArrayValuesByInt($arFilterRecomendet);
         if (empty($arFilterRecomendet)) {
             return $arRecomendetResult;
         }
         $iblockRecommended = array();
         $productIterator = Iblock\ElementTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@ID' => $arFilterRecomendet, '=ACTIVE' => 'Y')));
         while ($product = $productIterator->fetch()) {
             $product['ID'] = (int) $product['ID'];
             $product['IBLOCK_ID'] = (int) $product['IBLOCK_ID'];
             if (!isset($iblockRecommended[$product['IBLOCK_ID']])) {
                 $iblockRecommended[$product['IBLOCK_ID']] = array();
             }
             $iblockRecommended[$product['IBLOCK_ID']][] = $product['ID'];
         }
         unset($product, $productIterator);
         if (empty($iblockRecommended)) {
             return $arRecomendetResult;
         }
         $propertyList = array();
         $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@IBLOCK_ID' => array_keys($iblockRecommended), '=CODE' => 'RECOMMEND', '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_ELEMENT)));
         while ($property = $propertyIterator->fetch()) {
             $property['ID'] = (int) $property['ID'];
             $property['IBLOCK_ID'] = (int) $property['IBLOCK_ID'];
             $propertyList[$property['IBLOCK_ID']] = $property['ID'];
         }
         unset($property, $propertyIterator);
         if (empty($propertyList)) {
             return $arRecomendetResult;
         }
         foreach ($propertyList as $iblockID => $propertyID) {
             $propertyValue = 'PROPERTY_' . $propertyID;
             $filter = array('ID' => $iblockRecommended[$iblockID], 'IBLOCK_ID' => $iblockID);
             $select = array('ID', 'IBLOCK_ID', $propertyValue);
             $propertyValue .= '_VALUE';
             $elementIterator = CIBlockElement::GetList(array(), $filter, false, false, $select);
             while ($element = $elementIterator->Fetch()) {
                 if (empty($element[$propertyValue])) {
                     continue;
                 }
                 if (is_array($element[$propertyValue])) {
                     foreach ($element[$propertyValue] as &$recId) {
                         $recId = (int) $recId;
                         if ($recId > 0) {
                             $arRecomendet[$recId] = true;
                         }
                     }
                     unset($recId);
                 } else {
                     $recId = (int) $element[$propertyValue];
                     if ($recId > 0) {
                         $arRecomendet[$recId] = true;
                     }
                 }
             }
         }
         unset($element, $elementIterator, $select, $filter, $propertyValue, $propertyID, $iblockID, $propertyList);
         if (!empty($arRecomendet)) {
             $arRecomendet = array_keys($arRecomendet);
             $arBuyerGroups = CUser::GetUserGroup($USER_ID);
             $arFilter = array("ID" => $arRecomendet, "ACTIVE" => "Y");
             $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, array("NAME", "ID", "LID", 'IBLOCK_ID', 'IBLOCK_SECTION_ID', "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL"));
             $currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
             $currentUseDiscount = CCatalogProduct::getUseDiscount();
             CCatalogProduct::setUseDiscount(true);
             CCatalogProduct::setPriceVatIncludeMode(true);
             CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency($LID));
             $i = 0;
             while ($arElement = $rsElement->GetNext()) {
                 if (in_array($arElement["ID"], $arFilterRecomendet)) {
                     continue;
                 }
                 if ($recomMore == "N" && $i < $cntProductDefault || $recomMore == "Y") {
                     $arElement["MODULE"] = "catalog";
                     $arElement["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
                     $arElement["PRODUCT_ID"] = $arElement["ID"];
                     $arPrice = CCatalogProduct::GetOptimalPrice($arElement["ID"], 1, $arBuyerGroups, "N", array(), $LID, array());
                     $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
                     $arElement["PRICE"] = $currentPrice;
                     $arElement["CURRENCY"] = $arPrice["RESULT_PRICE"]["CURRENCY"];
                     $arElement["DISCOUNT_PRICE"] = $arPrice['RESULT_PRICE']['DISCOUNT'];
                     if ($arElement["IBLOCK_ID"] > 0 && $arElement["IBLOCK_SECTION_ID"] > 0) {
                         $arElement["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElement["IBLOCK_ID"], $arElement["PRODUCT_ID"], array("find_section_section" => $arElement["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
                     }
                     $arRecomendetResult[] = $arElement;
                     $i++;
                 }
             }
             CCatalogProduct::clearUsedCurrency();
             CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
             CCatalogProduct::setUseDiscount($currentUseDiscount);
             unset($currentUseDiscount, $currentVatMode);
         }
     }
     return $arRecomendetResult;
 }
コード例 #27
0
ファイル: discount_save.php プロジェクト: Satariall/izurit
 public function GetDiscount($arParams = array(), $getAll = false)
 {
     global $DB, $USER;
     $adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true;
     $arResult = array();
     if (!CCatalog::IsUserExists() || !$USER->IsAuthorized() || !self::IsEnabled()) {
         return $arResult;
     }
     foreach (GetModuleEvents("catalog", "OnGetDiscountSave", true) as $arEvent) {
         $mxResult = ExecuteModuleEventEx($arEvent, $arParams);
         if ($mxResult !== true) {
             return $mxResult;
         }
     }
     if (empty($arParams) || !is_array($arParams)) {
         return $arResult;
     }
     $intUserID = 0;
     $arUserGroups = array();
     $strSiteID = false;
     if (isset($arParams['USER_ID'])) {
         $intUserID = (int) $arParams['USER_ID'];
     }
     if (isset($arParams['USER_GROUPS'])) {
         $arUserGroups = $arParams['USER_GROUPS'];
     }
     if (isset($arParams['SITE_ID'])) {
         $strSiteID = $arParams['SITE_ID'];
     }
     if (self::GetDiscountUserID() > 0) {
         $intUserID = (int) self::GetDiscountUserID();
         $arUserGroups = array();
     }
     if ($intUserID <= 0 && !$adminSection) {
         $intUserID = (int) $USER->GetID();
         $arUserGroups = array();
     }
     if (empty($arUserGroups)) {
         if (!isset(self::$userGroups[$intUserID])) {
             self::$userGroups[$intUserID] = $USER->GetUserGroup($intUserID);
         }
         $arUserGroups = self::$userGroups[$intUserID];
     }
     if (empty($arUserGroups) || !is_array($arUserGroups) || $intUserID <= 0) {
         return $arResult;
     }
     $key = array_search(2, $arUserGroups);
     if ($key !== false) {
         unset($arUserGroups[$key]);
     }
     if (empty($arUserGroups)) {
         return $arResult;
     }
     Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true);
     if (empty($arUserGroups)) {
         return $arResult;
     }
     if ($strSiteID === false) {
         $strSiteID = SITE_ID;
     }
     $cacheKey = md5('U' . implode('_', $arUserGroups));
     if (!isset(self::$discountFilterCache[$cacheKey])) {
         self::$discountFilterCache[$cacheKey] = CCatalogDiscountSave::__GetDiscountIDByGroup($arUserGroups);
     }
     if (empty(self::$discountFilterCache[$cacheKey])) {
         return $arResult;
     }
     $arCurrentDiscountID = self::$discountFilterCache[$cacheKey];
     if (isset($arParams['ID'])) {
         Main\Type\Collection::normalizeArrayValuesByInt($arUserGroups, true);
         if (!empty($arParams['ID'])) {
             $arCurrentDiscountID = array_intersect($arCurrentDiscountID, $arParams['ID']);
         }
     }
     if (!empty($arCurrentDiscountID)) {
         $getAll = $getAll === true;
         $intCurrentTime = getmicrotime();
         $strDate = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCurrentTime);
         $arFilter = array('ID' => $arCurrentDiscountID, 'SITE_ID' => $strSiteID, 'TYPE' => self::ENTITY_ID, 'ACTIVE' => 'Y', '+<=ACTIVE_FROM' => $strDate, '+>=ACTIVE_TO' => $strDate);
         CTimeZone::Disable();
         $rsDiscSaves = CCatalogDiscountSave::GetList(array(), $arFilter);
         CTimeZone::Enable();
         while ($arDiscSave = $rsDiscSaves->Fetch()) {
             $arDiscSave['ACTION_SIZE'] = (int) $arDiscSave['ACTION_SIZE'];
             $arDiscSave['COUNT_SIZE'] = (int) $arDiscSave['COUNT_SIZE'];
             $arDiscSave['ACTIVE_FROM_UT'] = false;
             $arDiscSave['ACTIVE_TO_UT'] = false;
             $arDiscSave['COUNT_FROM_UT'] = false;
             $arDiscSave['COUNT_TO_UT'] = false;
             $arDiscSave['TYPE'] = (int) $arDiscSave['TYPE'];
             $arDiscSave['MODULE_ID'] = 'catalog';
             $strCountPeriod = self::COUNT_TIME_ALL;
             $strActionPeriod = self::ACTION_TIME_ALL;
             $arCountPeriodBack = array();
             $arActionPeriodBack = array();
             $arActionPeriod = array();
             $arStartDate = false;
             $arOldOrderSumm = false;
             $arOrderSumm = false;
             $boolPeriodInsert = true;
             $intCountTime = $intCurrentTime;
             $arOrderFilter = array('USER_ID' => $intUserID, 'LID' => $arDiscSave['SITE_ID'], 'PAYED' => 'Y', 'CANCELED' => 'N');
             $arOldOrderFilter = $arOrderFilter;
             if (!empty($arDiscSave['ACTIVE_FROM']) || !empty($arDiscSave['ACTIVE_TO'])) {
                 $strActionPeriod = self::ACTION_TIME_INTERVAL;
                 if (!empty($arDiscSave['ACTIVE_FROM'])) {
                     $arDiscSave['ACTIVE_FROM_UT'] = MakeTimeStamp($arDiscSave['ACTIVE_FROM']);
                 }
                 if (!empty($arDiscSave['ACTIVE_TO'])) {
                     $arDiscSave['ACTIVE_TO_UT'] = MakeTimeStamp($arDiscSave['ACTIVE_TO']);
                 }
             } elseif ($arDiscSave['ACTION_SIZE'] > 0 && in_array($arDiscSave['ACTION_TYPE'], array('D', 'M', 'Y'))) {
                 $strActionPeriod = self::ACTION_TIME_PERIOD;
                 $arActionPeriodBack = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['ACTION_SIZE'], $arDiscSave['ACTION_TYPE']);
                 $arActionPeriod = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['ACTION_SIZE'], $arDiscSave['ACTION_TYPE'], true);
             }
             if (!empty($arDiscSave['COUNT_FROM']) || !empty($arDiscSave['COUNT_TO'])) {
                 $strCountPeriod = self::COUNT_TIME_INTERVAL;
                 if (!empty($arDiscSave['COUNT_FROM'])) {
                     $arDiscSave['COUNT_FROM_UT'] = MakeTimeStamp($arDiscSave['COUNT_FROM']);
                 }
                 if (!empty($arDiscSave['COUNT_TO'])) {
                     $arDiscSave['COUNT_TO_UT'] = MakeTimeStamp($arDiscSave['COUNT_TO']);
                     if ($arDiscSave['COUNT_TO_UT'] > $intCountTime) {
                         $arDiscSave['COUNT_TO_UT'] = $intCountTime;
                         $arDiscSave['COUNT_TO'] = ConvertTimeStamp($intCountTime, 'FULL');
                     }
                 }
             } elseif ($arDiscSave['COUNT_SIZE'] > 0 && in_array($arDiscSave['COUNT_TYPE'], array('D', 'M', 'Y'))) {
                 $strCountPeriod = self::COUNT_TIME_PERIOD;
                 $arCountPeriodBack = CCatalogDiscountSave::__GetTimeStampArray($arDiscSave['COUNT_SIZE'], $arDiscSave['COUNT_TYPE']);
             }
             if ($strCountPeriod == self::COUNT_TIME_INTERVAL) {
                 if (false !== $arDiscSave['COUNT_FROM_UT']) {
                     if ($arDiscSave['COUNT_FROM_UT'] > $intCountTime) {
                         continue;
                     }
                     if (false !== $arDiscSave['COUNT_TO_UT'] && $arDiscSave['COUNT_TO_UT'] <= $arDiscSave['COUNT_FROM_UT']) {
                         continue;
                     }
                     if (false !== $arDiscSave['ACTIVE_TO_UT'] && $arDiscSave['COUNT_FROM_UT'] >= $arDiscSave['ACTIVE_TO_UT']) {
                         continue;
                     }
                 }
                 if (false !== $arDiscSave['COUNT_TO_UT']) {
                     if ($strActionPeriod == self::ACTION_TIME_PERIOD && $arDiscSave['COUNT_TO_UT'] < AddToTimeStamp($arActionPeriodBack, $intCountTime)) {
                         continue;
                     }
                 }
             }
             if ($strActionPeriod == self::ACTION_TIME_PERIOD) {
                 if ($strCountPeriod == self::COUNT_TIME_PERIOD) {
                     $arStartDate = CCatalogDiscountSave::__GetUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriodBack, $intCountTime))));
                     if (is_array($arStartDate) && !empty($arStartDate)) {
                         $arOldOrderFilter['<DATE_INSERT'] = $arStartDate['ACTIVE_FROM_FORMAT'];
                         $arOldOrderFilter['>=DATE_INSERT'] = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arCountPeriodBack, MakeTimeStamp($arStartDate['ACTIVE_FROM_FORMAT'])));
                         $arOldOrderSumm = CCatalogDiscountSave::__SaleOrderSumm($arOldOrderFilter, $arDiscSave['CURRENCY']);
                     }
                 } else {
                     $arStartDate = CCatalogDiscountSave::__GetUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID), array('ACTIVE_FROM' => false, 'DELETE' => false));
                     if (is_array($arStartDate) && !empty($arStartDate)) {
                         $intTimeStart = MakeTimeStamp($arStartDate['ACTIVE_FROM_FORMAT']);
                         $intTimeFinish = MakeTimeStamp($arStartDate['ACTIVE_TO_FORMAT']);
                         if (!($intTimeStart <= $intCountTime && $intTimeFinish >= $intCountTime)) {
                             continue;
                         } else {
                             $boolPeriodInsert = false;
                         }
                     }
                 }
             }
             $intTimeStart = false;
             $intTimeFinish = false;
             if ($strCountPeriod == self::COUNT_TIME_INTERVAL) {
                 $intTimeStart = !empty($arDiscSave['COUNT_FROM']) ? $arDiscSave['COUNT_FROM'] : false;
                 $intTimeFinish = !empty($arDiscSave['COUNT_TO']) ? $arDiscSave['COUNT_TO'] : false;
             } elseif ($strCountPeriod == self::COUNT_TIME_PERIOD) {
                 $intTimeStart = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arCountPeriodBack, $intCountTime));
             }
             if ($intTimeStart) {
                 $arOrderFilter['>=DATE_INSERT'] = $intTimeStart;
             }
             if ($intTimeFinish) {
                 $arOrderFilter['<DATE_INSERT'] = $intTimeFinish;
             }
             $arOrderSumm = CCatalogDiscountSave::__SaleOrderSumm($arOrderFilter, $arDiscSave['CURRENCY']);
             if (is_array($arOldOrderSumm) && 0 < $arOldOrderSumm['RANGE_SUMM']) {
                 if ($arOrderSumm['RANGE_SUMM'] <= $arOldOrderSumm['RANGE_SUMM']) {
                     $arOrderSumm = $arOldOrderSumm;
                 } else {
                     $arOldOrderSumm = false;
                 }
             }
             $rsRanges = CCatalogDiscountSave::GetRangeByDiscount(array('RANGE_FROM' => 'DESC'), array('DISCOUNT_ID' => $arDiscSave['ID'], '<=RANGE_FROM' => $arOrderSumm['RANGE_SUMM']), false, array('nTopCount' => 1));
             $arRange = $rsRanges->Fetch();
             if (!empty($arRange) || $getAll) {
                 if (!empty($arRange)) {
                     if ($strActionPeriod == self::ACTION_TIME_PERIOD) {
                         if ($strCountPeriod == self::COUNT_TIME_PERIOD) {
                             if (!is_array($arOldOrderSumm)) {
                                 CCatalogDiscountSave::__UpdateUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCountTime), 'ACTIVE_TO' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriod, $intCountTime)), 'RANGE_FROM' => -1));
                             }
                         } else {
                             if ($boolPeriodInsert) {
                                 CCatalogDiscountSave::__UpdateUserInfoByDiscount(array('DISCOUNT_ID' => $arDiscSave['ID'], 'USER_ID' => $intUserID, 'ACTIVE_FROM' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), $intCountTime), 'ACTIVE_TO' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), AddToTimeStamp($arActionPeriod, $intCountTime)), 'RANGE_FROM' => -1), array('SEARCH' => true, 'DELETE' => false));
                             }
                         }
                     }
                 }
                 unset($arDiscSave['ACTIVE_FROM_UT'], $arDiscSave['ACTIVE_TO_UT'], $arDiscSave['COUNT_FROM_UT'], $arDiscSave['COUNT_TO_UT']);
                 $arOneResult = $arDiscSave;
                 if (!empty($arRange)) {
                     $arOneResult['VALUE'] = $arRange['VALUE'];
                     $arOneResult['VALUE_TYPE'] = $arRange['TYPE'];
                     $arOneResult['RANGE_FROM'] = $arRange['RANGE_FROM'];
                     $arOneResult['MAX_DISCOUNT'] = 0;
                 } else {
                     $arOneResult['VALUE'] = 0;
                     $arOneResult['VALUE_TYPE'] = self::TYPE_PERCENT;
                     $arOneResult['MAX_DISCOUNT'] = 0;
                     $rsRanges = CCatalogDiscountSave::GetRangeByDiscount(array('RANGE_FROM' => 'ASC'), array('DISCOUNT_ID' => $arDiscSave['ID']), false, array('nTopCount' => 1));
                     $arRange = $rsRanges->Fetch();
                     $arOneResult['NEXT_RANGE_FROM'] = $arRange['RANGE_FROM'];
                     $arOneResult['NEXT_VALUE'] = $arRange['VALUE'];
                     $arOneResult['NEXT_VALUE_TYPE'] = $arRange['TYPE'];
                 }
                 $arOneResult['SUMM'] = $arOrderSumm['SUMM'];
                 $arOneResult['SUMM_CURRENCY'] = $arOrderSumm['CURRENCY'];
                 $arOneResult['RANGE_SUMM'] = $arOrderSumm['RANGE_SUMM'];
                 $arOneResult['LAST_ORDER_DATE'] = $arOrderSumm['LAST_ORDER_DATE'];
                 $arResult[] = $arOneResult;
             }
         }
     }
     return $arResult;
 }
コード例 #28
0
ファイル: component.php プロジェクト: Satariall/izurit
     } else {
         if (!$setItem['ITEM_DATA']['CAN_BUY']) {
             $resort = true;
         }
         $arResult['SET_ITEMS']['OTHER'][] = $setItem['ITEM_DATA'];
     }
     $found = true;
 }
 unset($setItem, $currentSet);
 if (!$found || empty($arResult['SET_ITEMS']['DEFAULT'])) {
     $this->AbortResultCache();
     return;
 }
 unset($found);
 if ($resort) {
     Main\Type\Collection::sortByColumn($arResult['SET_ITEMS']['OTHER'], array('CAN_BUY' => SORT_DESC, 'SET_SORT' => SORT_ASC));
 }
 unset($resort);
 if (defined('BX_COMP_MANAGED_CACHE') && (!empty($tagIblockList) || !empty($tagCurrencyList))) {
     $taggedCache = Application::getInstance()->getTaggedCache();
     if (!empty($tagIblockList)) {
         foreach ($tagIblockList as &$iblock) {
             $taggedCache->registerTag('iblock_id_' . $iblock);
         }
         unset($iblock);
     }
     if (!empty($tagCurrencyList)) {
         foreach ($tagCurrencyList as &$currency) {
             $taggedCache->registerTag('currency_id_' . $currency);
         }
         unset($currency);
コード例 #29
0
 /**
  * Returns modules by discount list.
  *
  * @param array $discountList			Discount list.
  * @param array $filter				Additional filter.
  * @return array
  */
 public static function getByDiscount($discountList, $filter = array())
 {
     $result = array();
     if (!empty($discountList) && is_array($discountList)) {
         Main\Type\Collection::normalizeArrayValuesByInt($discountList);
         if (!empty($discountList)) {
             if (!is_array($filter)) {
                 $filter = array();
             }
             $discountRows = array_chunk($discountList, 500);
             foreach ($discountRows as &$row) {
                 $filter['@DISCOUNT_ID'] = $row;
                 $moduleIterator = self::getList(array('select' => array('DISCOUNT_ID', 'MODULE_ID'), 'filter' => $filter));
                 while ($module = $moduleIterator->fetch()) {
                     $module['DISCOUNT_ID'] = (int) $module['DISCOUNT_ID'];
                     if (!isset($result[$module['DISCOUNT_ID']])) {
                         $result[$module['DISCOUNT_ID']] = array();
                     }
                     $result[$module['DISCOUNT_ID']][] = $module['MODULE_ID'];
                 }
                 unset($module, $moduleIterator);
             }
             unset($row, $discountRows);
         }
     }
     return $result;
 }
コード例 #30
0
ファイル: iblockelement.php プロジェクト: DarneoStudio/bitrix
 public static function GetPropertyValuesArray(&$result, $iblockID, $filter, $propertyFilter = array())
 {
     $iblockExtVersion = CIBlockElement::GetIBVersion($iblockID) == 2;
     $propertiesList = array();
     $mapCodes = array();
     $userTypesList = array();
     $existList = array();
     $selectListMultiply = array('SORT' => SORT_ASC, 'VALUE' => SORT_STRING);
     $selectAllMultiply = array('PROPERTY_VALUE_ID' => SORT_ASC);
     $propertyListFilter = array('IBLOCK_ID' => $iblockID);
     $propertyID = array();
     if (isset($propertyFilter['ID'])) {
         $propertyID = is_array($propertyFilter['ID']) ? $propertyFilter['ID'] : array($propertyFilter['ID']);
         Collection::normalizeArrayValuesByInt($propertyID);
     }
     if (!empty($propertyID)) {
         $propertyListFilter['@ID'] = $propertyID;
     } elseif (isset($propertyFilter['CODE'])) {
         if (!is_array($propertyFilter['CODE'])) {
             $propertyFilter['CODE'] = array($propertyFilter['CODE']);
         }
         $propertyCodes = array();
         if (!empty($propertyFilter['CODE'])) {
             foreach ($propertyFilter['CODE'] as &$code) {
                 $code = (string) $code;
                 if ($code !== '') {
                     $propertyCodes[] = $code;
                 }
             }
             unset($code);
         }
         if (!empty($propertyCodes)) {
             $propertyListFilter['@CODE'] = $propertyCodes;
         }
         unset($propertyCodes);
     }
     $propertyListFilter['=ACTIVE'] = isset($propertyFilter['ACTIVE']) && ($propertyFilter['ACTIVE'] == 'Y' || $propertyFilter['ACTIVE'] == 'N') ? $propertyFilter['ACTIVE'] : 'Y';
     $propertyID = array();
     $propertyIterator = PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'ACTIVE', 'SORT', 'CODE', 'DEFAULT_VALUE', 'PROPERTY_TYPE', 'ROW_COUNT', 'COL_COUNT', 'LIST_TYPE', 'MULTIPLE', 'XML_ID', 'FILE_TYPE', 'MULTIPLE_CNT', 'LINK_IBLOCK_ID', 'WITH_DESCRIPTION', 'SEARCHABLE', 'FILTRABLE', 'IS_REQUIRED', 'VERSION', 'USER_TYPE', 'USER_TYPE_SETTINGS', 'HINT'), 'filter' => $propertyListFilter, 'order' => array('SORT' => 'ASC', 'ID' => 'ASC')));
     while ($property = $propertyIterator->fetch()) {
         $propertyID[] = (int) $property['ID'];
         $property['CODE'] = trim((string) $property['CODE']);
         if ($property['CODE'] === '') {
             $property['CODE'] = $property['ID'];
         }
         $code = $property['CODE'];
         $property['~NAME'] = $property['NAME'];
         if (preg_match("/[;&<>\"]/", $property['NAME'])) {
             $property['NAME'] = htmlspecialcharsex($property['NAME']);
         }
         if ($property['USER_TYPE']) {
             $userType = CIBlockProperty::GetUserType($property['USER_TYPE']);
             if (isset($userType['ConvertFromDB'])) {
                 $userTypesList[$property['ID']] = $userType;
                 if (array_key_exists("DEFAULT_VALUE", $property)) {
                     $value = array("VALUE" => $property["DEFAULT_VALUE"], "DESCRIPTION" => "");
                     $value = call_user_func_array($userType["ConvertFromDB"], array($property, $value));
                     $property["DEFAULT_VALUE"] = $value["VALUE"];
                 }
             }
         }
         if ($property['USER_TYPE_SETTINGS'] !== '' || $property['USER_TYPE_SETTINGS'] !== null) {
             $property['USER_TYPE_SETTINGS'] = unserialize($property['USER_TYPE_SETTINGS']);
         }
         $property['~DEFAULT_VALUE'] = $property['DEFAULT_VALUE'];
         if (is_array($property['DEFAULT_VALUE']) || preg_match("/[;&<>\"]/", $property['DEFAULT_VALUE'])) {
             $property['DEFAULT_VALUE'] = htmlspecialcharsex($property['DEFAULT_VALUE']);
         }
         if ($property['PROPERTY_TYPE'] == PropertyTable::TYPE_LIST) {
             $existList[] = $property['ID'];
         }
         $mapCodes[$property['ID']] = $code;
         $propertiesList[$code] = $property;
     }
     unset($property, $propertyIterator);
     if (empty($propertiesList)) {
         return;
     }
     if (!empty($existList)) {
         $enumList = array();
         $enumIterator = PropertyEnumerationTable::getList(array('select' => array('ID', 'PROPERTY_ID', 'VALUE', 'SORT', 'XML_ID'), 'filter' => array('PROPERTY_ID' => $existList), 'order' => array('PROPERTY_ID' => 'ASC', 'SORT' => 'ASC', 'VALUE' => 'ASC')));
         while ($enum = $enumIterator->fetch()) {
             if (!isset($enumList[$enum['PROPERTY_ID']])) {
                 $enumList[$enum['PROPERTY_ID']] = array();
             }
             $enumList[$enum['PROPERTY_ID']][$enum['ID']] = array('ID' => $enum['ID'], 'VALUE' => $enum['VALUE'], 'SORT' => $enum['SORT'], 'XML_ID' => $enum['XML_ID']);
         }
         unset($enum, $enumIterator);
     }
     $valuesRes = !empty($propertyID) ? CIBlockElement::GetPropertyValues($iblockID, $filter, true, array('ID' => $propertyID)) : CIBlockElement::GetPropertyValues($iblockID, $filter, true);
     while ($value = $valuesRes->Fetch()) {
         $elementID = $value['IBLOCK_ELEMENT_ID'];
         if (!isset($result[$elementID])) {
             continue;
         }
         $elementValues = array();
         $existDescription = isset($value['DESCRIPTION']);
         foreach ($propertiesList as $code => $property) {
             $existElementDescription = isset($value['DESCRIPTION']) && array_key_exists($property['ID'], $value['DESCRIPTION']);
             $existElementPropertyID = isset($value['PROPERTY_VALUE_ID']) && array_key_exists($property['ID'], $value['PROPERTY_VALUE_ID']);
             $elementValues[$code] = $property;
             $elementValues[$code]['VALUE_ENUM'] = null;
             $elementValues[$code]['VALUE_XML_ID'] = null;
             $elementValues[$code]['VALUE_SORT'] = null;
             $elementValues[$code]['VALUE'] = null;
             if ('Y' === $property['MULTIPLE']) {
                 $elementValues[$code]['PROPERTY_VALUE_ID'] = false;
                 if (!isset($value[$property['ID']]) || empty($value[$property['ID']])) {
                     $elementValues[$code]['DESCRIPTION'] = false;
                     $elementValues[$code]['VALUE'] = false;
                     $elementValues[$code]['~DESCRIPTION'] = false;
                     $elementValues[$code]['~VALUE'] = false;
                     if ('L' == $property['PROPERTY_TYPE']) {
                         $elementValues[$code]['VALUE_ENUM_ID'] = false;
                         $elementValues[$code]['VALUE_ENUM'] = false;
                         $elementValues[$code]['VALUE_XML_ID'] = false;
                         $elementValues[$code]['VALUE_SORT'] = false;
                     }
                 } else {
                     if ($existElementPropertyID) {
                         $elementValues[$code]['PROPERTY_VALUE_ID'] = $value['PROPERTY_VALUE_ID'][$property['ID']];
                     }
                     if (isset($userTypesList[$property['ID']])) {
                         foreach ($value[$property['ID']] as $valueKey => $oneValue) {
                             $raw = call_user_func_array($userTypesList[$property['ID']]['ConvertFromDB'], array($property, array('VALUE' => $oneValue, 'DESCRIPTION' => $existElementDescription ? $value['DESCRIPTION'][$property['ID']][$valueKey] : '')));
                             $value[$property['ID']][$valueKey] = $raw['VALUE'];
                             if (!$existDescription) {
                                 $value['DESCRIPTION'] = array();
                                 $existDescription = true;
                             }
                             if (!$existElementDescription) {
                                 $value['DESCRIPTION'][$property['ID']] = array();
                                 $existElementDescription = true;
                             }
                             $value['DESCRIPTION'][$property['ID']][$valueKey] = (string) $raw['DESCRIPTION'];
                         }
                         if (isset($oneValue)) {
                             unset($oneValue);
                         }
                     }
                     if ('L' == $property['PROPERTY_TYPE']) {
                         if (empty($value[$property['ID']])) {
                             $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']];
                             $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array();
                         } else {
                             $selectedValues = array();
                             foreach ($value[$property['ID']] as $listKey => $listValue) {
                                 if (isset($enumList[$property['ID']][$listValue])) {
                                     $selectedValues[$listKey] = $enumList[$property['ID']][$listValue];
                                     $selectedValues[$listKey]['DESCRIPTION'] = $existElementDescription && array_key_exists($listKey, $value['DESCRIPTION'][$property['ID']]) ? $value['DESCRIPTION'][$property['ID']][$listKey] : '';
                                     $selectedValues[$listKey]['PROPERTY_VALUE_ID'] = $existElementPropertyID && array_key_exists($listKey, $value['PROPERTY_VALUE_ID'][$property['ID']]) ? $value['PROPERTY_VALUE_ID'][$property['ID']][$listKey] : '';
                                 }
                             }
                             if (empty($selectedValues)) {
                                 $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']];
                                 $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array();
                             } else {
                                 Collection::sortByColumn($selectedValues, $selectListMultiply);
                                 $elementValues[$code]['VALUE_ENUM_ID'] = array();
                                 $elementValues[$code]['VALUE'] = array();
                                 $elementValues[$code]['VALUE_ENUM'] = array();
                                 $elementValues[$code]['VALUE_XML_ID'] = array();
                                 $elementValues[$code]['DESCRIPTION'] = array();
                                 $elementValues[$code]['PROPERTY_VALUE_ID'] = array();
                                 foreach ($selectedValues as $listValue) {
                                     if (!isset($elementValues[$code]['VALUE_SORT'])) {
                                         $elementValues[$code]['VALUE_SORT'] = array($listValue['SORT']);
                                     }
                                     $elementValues[$code]['VALUE_ENUM_ID'][] = $listValue['ID'];
                                     $elementValues[$code]['VALUE'][] = $listValue['VALUE'];
                                     $elementValues[$code]['VALUE_ENUM'][] = $listValue['VALUE'];
                                     $elementValues[$code]['VALUE_XML_ID'][] = $listValue['XML_ID'];
                                     $elementValues[$code]['PROPERTY_VALUE_ID'][] = $listValue['PROPERTY_VALUE_ID'];
                                     $elementValues[$code]['DESCRIPTION'][] = $listValue['DESCRIPTION'];
                                 }
                                 unset($selectedValues);
                             }
                         }
                     } else {
                         if (empty($value[$property['ID']]) || !$existElementPropertyID || isset($userTypesList[$property['ID']])) {
                             $elementValues[$code]['VALUE'] = $value[$property['ID']];
                             $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array();
                         } else {
                             $selectedValues = array();
                             foreach ($value['PROPERTY_VALUE_ID'][$property['ID']] as $propKey => $propValueID) {
                                 $selectedValues[$propKey] = array('PROPERTY_VALUE_ID' => $propValueID, 'VALUE' => $value[$property['ID']][$propKey]);
                                 if ($existElementDescription) {
                                     $selectedValues[$propKey]['DESCRIPTION'] = $value['DESCRIPTION'][$property['ID']][$propKey];
                                 }
                             }
                             unset($propValueID, $propKey);
                             Collection::sortByColumn($selectedValues, $selectAllMultiply);
                             $elementValues[$code]['PROPERTY_VALUE_ID'] = array();
                             $elementValues[$code]['VALUE'] = array();
                             $elementValues[$code]['DESCRIPTION'] = array();
                             foreach ($selectedValues as &$propValue) {
                                 $elementValues[$code]['PROPERTY_VALUE_ID'][] = $propValue['PROPERTY_VALUE_ID'];
                                 $elementValues[$code]['VALUE'][] = $propValue['VALUE'];
                                 if ($existElementDescription) {
                                     $elementValues[$code]['DESCRIPTION'][] = $propValue['DESCRIPTION'];
                                 }
                             }
                             unset($propValue, $selectedValues);
                         }
                     }
                 }
                 $elementValues[$code]['~VALUE'] = $elementValues[$code]['VALUE'];
                 if (is_array($elementValues[$code]['VALUE'])) {
                     foreach ($elementValues[$code]['VALUE'] as &$oneValue) {
                         $isArr = is_array($oneValue);
                         if ($isArr || '' !== $oneValue && null !== $oneValue) {
                             if ($isArr || preg_match("/[;&<>\"]/", $oneValue)) {
                                 $oneValue = htmlspecialcharsEx($oneValue);
                             }
                         }
                     }
                     if (isset($oneValue)) {
                         unset($oneValue);
                     }
                 } else {
                     if ('' !== $elementValues[$code]['VALUE'] && null !== $elementValues[$code]['VALUE']) {
                         if (preg_match("/[;&<>\"]/", $elementValues[$code]['VALUE'])) {
                             $elementValues[$code]['VALUE'] = htmlspecialcharsEx($elementValues[$code]['VALUE']);
                         }
                     }
                 }
                 $elementValues[$code]['~DESCRIPTION'] = $elementValues[$code]['DESCRIPTION'];
                 if (is_array($elementValues[$code]['DESCRIPTION'])) {
                     foreach ($elementValues[$code]['DESCRIPTION'] as &$oneDescr) {
                         $isArr = is_array($oneDescr);
                         if ($isArr || !$isArr && '' !== $oneDescr && null !== $oneDescr) {
                             if ($isArr || preg_match("/[;&<>\"]/", $oneDescr)) {
                                 $oneDescr = htmlspecialcharsEx($oneDescr);
                             }
                         }
                     }
                     if (isset($oneDescr)) {
                         unset($oneDescr);
                     }
                 } else {
                     if ('' !== $elementValues[$code]['DESCRIPTION'] && null !== $elementValues[$code]['DESCRIPTION']) {
                         if (preg_match("/[;&<>\"]/", $elementValues[$code]['DESCRIPTION'])) {
                             $elementValues[$code]['DESCRIPTION'] = htmlspecialcharsEx($elementValues[$code]['DESCRIPTION']);
                         }
                     }
                 }
             } else {
                 $elementValues[$code]['VALUE_ENUM'] = $iblockExtVersion ? '' : null;
                 $elementValues[$code]['PROPERTY_VALUE_ID'] = $iblockExtVersion ? $elementID . ':' . $property['ID'] : null;
                 if (!isset($value[$property['ID']]) || false === $value[$property['ID']]) {
                     $elementValues[$code]['DESCRIPTION'] = '';
                     $elementValues[$code]['VALUE'] = '';
                     $elementValues[$code]['~DESCRIPTION'] = '';
                     $elementValues[$code]['~VALUE'] = '';
                     if ('L' == $property['PROPERTY_TYPE']) {
                         $elementValues[$code]['VALUE_ENUM_ID'] = null;
                     }
                 } else {
                     if ($existElementPropertyID) {
                         $elementValues[$code]['PROPERTY_VALUE_ID'] = $value['PROPERTY_VALUE_ID'][$property['ID']];
                     }
                     if (isset($userTypesList[$property['ID']])) {
                         $raw = call_user_func_array($userTypesList[$property['ID']]['ConvertFromDB'], array($property, array('VALUE' => $value[$property['ID']], 'DESCRIPTION' => $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : '')));
                         $value[$property['ID']] = $raw['VALUE'];
                         if (!$existDescription) {
                             $value['DESCRIPTION'] = array();
                             $existDescription = true;
                         }
                         $value['DESCRIPTION'][$property['ID']] = (string) $raw['DESCRIPTION'];
                         $existElementDescription = true;
                     }
                     if ('L' == $property['PROPERTY_TYPE']) {
                         $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']];
                         if (isset($enumList[$property['ID']][$value[$property['ID']]])) {
                             $elementValues[$code]['VALUE'] = $enumList[$property['ID']][$value[$property['ID']]]['VALUE'];
                             $elementValues[$code]['VALUE_ENUM'] = $elementValues[$code]['VALUE'];
                             $elementValues[$code]['VALUE_XML_ID'] = $enumList[$property['ID']][$value[$property['ID']]]['XML_ID'];
                             $elementValues[$code]['VALUE_SORT'] = $enumList[$property['ID']][$value[$property['ID']]]['SORT'];
                         }
                         $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : null;
                     } else {
                         $elementValues[$code]['VALUE'] = $value[$property['ID']];
                         $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : '';
                     }
                 }
                 $elementValues[$code]['~VALUE'] = $elementValues[$code]['VALUE'];
                 $isArr = is_array($elementValues[$code]['VALUE']);
                 if ($isArr || '' !== $elementValues[$code]['VALUE'] && null !== $elementValues[$code]['VALUE']) {
                     if ($isArr || preg_match("/[;&<>\"]/", $elementValues[$code]['VALUE'])) {
                         $elementValues[$code]['VALUE'] = htmlspecialcharsEx($elementValues[$code]['VALUE']);
                     }
                 }
                 $elementValues[$code]['~DESCRIPTION'] = $elementValues[$code]['DESCRIPTION'];
                 $isArr = is_array($elementValues[$code]['DESCRIPTION']);
                 if ($isArr || '' !== $elementValues[$code]['DESCRIPTION'] && null !== $elementValues[$code]['DESCRIPTION']) {
                     if ($isArr || preg_match("/[;&<>\"]/", $elementValues[$code]['DESCRIPTION'])) {
                         $elementValues[$code]['DESCRIPTION'] = htmlspecialcharsEx($elementValues[$code]['DESCRIPTION']);
                     }
                 }
             }
         }
         if (isset($result[$elementID]['PROPERTIES'])) {
             $result[$elementID]['PROPERTIES'] = $elementValues;
         } else {
             $result[$elementID] = $elementValues;
         }
         unset($elementValues);
     }
 }