Esempio n. 1
0
 /**
  * @param Entity\Event $event
  * @return Entity\EventResult
  */
 public static function onBeforeAdd(Entity\Event $event)
 {
     $result = new Entity\EventResult();
     $data = $event->getParameter('fields');
     if (isset($data['TOKEN_EXPIRES_IN'])) {
         $dateTime = new Type\DateTime();
         $dateTime->add('+ ' . $data['TOKEN_EXPIRES_IN'] . ' sec');
         $result->modifyFields(['TOKEN_FINAL_DATE' => $dateTime]);
     }
     return $result;
 }
 public function getDateTimeToDbFunction(\Bitrix\Main\Type\DateTime $value, $type = \Bitrix\Main\Type\DateTime::DATE_WITH_TIME)
 {
     $customOffset = $value->getOffset();
     $serverTime = new \Bitrix\Main\Type\DateTime();
     $serverOffset = $serverTime->getOffset();
     $diff = $customOffset - $serverOffset;
     $valueTmp = clone $value;
     $valueTmp->sub(new \DateInterval(sprintf("PT%sS", $diff)));
     $format = $type == \Bitrix\Main\Type\DateTime::DATE_WITHOUT_TIME ? "Y-m-d" : "Y-m-d H:i:s";
     $date = "CONVERT(datetime, '" . $valueTmp->format($format) . "', 120)";
     return $date;
 }
Esempio n. 3
0
 /**
  * @param FieldType $fieldType Document field type.
  * @param mixed $value Field value.
  * @param string $toTypeClass Type class name.
  * @return null|mixed
  */
 public static function convertTo(FieldType $fieldType, $value, $toTypeClass)
 {
     /** @var Base $toTypeClass */
     $type = $toTypeClass::getType();
     switch ($type) {
         case FieldType::BOOL:
             $value = (bool) $value ? 'Y' : 'N';
             break;
         case FieldType::DATE:
             $value = date(Main\Type\Date::convertFormatToPhp(\FORMAT_DATE), (int) $value);
             break;
         case FieldType::DATETIME:
             $value = date(Main\Type\DateTime::convertFormatToPhp(\FORMAT_DATETIME), (int) $value);
             break;
         case FieldType::DOUBLE:
             $value = (double) $value;
             break;
         case FieldType::INT:
             $value = (int) $value;
             break;
         case FieldType::STRING:
         case FieldType::TEXT:
             $value = (string) $value;
             break;
         case FieldType::USER:
             $value = 'user_' . (int) $value;
             break;
         default:
             $value = null;
     }
     return $value;
 }
Esempio n. 4
0
 /**
  * @param FieldType $fieldType Document field type.
  * @param mixed $value Field value.
  * @param string $toTypeClass Type class name.
  * @return null|mixed
  */
 public static function convertTo(FieldType $fieldType, $value, $toTypeClass)
 {
     /** @var Base $toTypeClass */
     $type = $toTypeClass::getType();
     switch ($type) {
         case FieldType::DOUBLE:
         case FieldType::INT:
             $value = $value ? (int) strtotime($value) : 0;
             break;
         case FieldType::DATE:
             $value = date(Type\Date::convertFormatToPhp(\FORMAT_DATE), strtotime($value));
             break;
         case FieldType::DATETIME:
             $value = date(Type\DateTime::convertFormatToPhp(\FORMAT_DATETIME), strtotime($value));
             break;
         case FieldType::STRING:
         case FieldType::TEXT:
             $value = (string) $value;
             if ($value) {
                 $format = static::getType() == FieldType::DATE ? \FORMAT_DATE : \FORMAT_DATETIME;
                 $value = date(Type\DateTime::convertFormatToPhp($format), strtotime($value));
             }
             break;
         default:
             $value = null;
     }
     return $value;
 }
Esempio n. 5
0
 public static function onGenerateInitialData(Date $from, Date $to)
 {
     $data = array();
     // 1. Payments
     $result = \CSaleOrder::GetList(array(), array('PAYED' => 'Y', 'CANCELED' => 'N', '>=DATE_PAYED' => $from, '<=DATE_PAYED' => $to), false, false, array('LID', 'DATE_PAYED', 'PRICE', 'CURRENCY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_PAYED']);
         $sum = Config::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_payment_add_day'] += 1;
             $counters['sale_payment_sum_add'] += $sum;
         } else {
             $counters = array('sale_payment_add_day' => 1, 'sale_payment_sum_add' => $sum);
         }
     }
     // 2. Orders
     $result = \CSaleOrder::GetList(array(), array('CANCELED' => 'N', '>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_INSERT']);
         $sum = Config::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_order_add_day'] += 1;
             $counters['sale_order_sum_add'] += $sum;
         } else {
             $counters = array('sale_order_add_day' => 1, 'sale_order_sum_add' => $sum);
         }
     }
     // 3. Cart
     $result = \CSaleBasket::GetList(array(), array('>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY', 'QUANTITY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_INSERT']);
         $sum = Config::convertToBaseCurrency($row['PRICE'] * $row['QUANTITY'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_cart_add_day'] += 1;
             $counters['sale_cart_sum_add'] += $sum;
         } else {
             $counters = array('sale_cart_add_day' => 1, 'sale_cart_sum_add' => $sum);
         }
     }
     // Result
     unset($counters);
     $result = array();
     foreach ($data as $siteId => $dayCounters) {
         $result[] = array('ATTRIBUTES' => array('conversion_site' => $siteId), 'DAY_COUNTERS' => $dayCounters);
     }
     return $result;
 }
Esempio n. 6
0
 /**
  * Возвращает дату в формате прошедшего времени. Например, "15 минут назад", "2 часа назад", "вчера", ...
  * @param \Bitrix\Main\Type\DateTime $datetime
  * @return string
  */
 public static function passed(\Bitrix\Main\Type\DateTime $datetime, $formatDateTime = 'd.m.Y H:i', $formatDay = 'H:i')
 {
     $time = $datetime->getTimestamp();
     $diff = time() - $time;
     //
     if (self::passedYesterday($time, $output)) {
         return $output;
     } elseif ($diff < 60) {
         return "только что";
     } elseif ($diff < 60 * 60) {
         return self::passedMinutes(0, $diff);
     } elseif ($diff < 60 * 60 * 24) {
         return self::passedHours(0, $diff);
     } else {
         return $datetime->format($formatDateTime);
     }
 }
Esempio n. 7
0
 public static function generateInitialData(Date $from)
 {
     if (($to = Option::get('conversion', 'START_DATE_TIME', 'undefined')) != 'undefined' && DateTime::isCorrect($to, 'Y-m-d H:i:s') && ($to = new DateTime($to, 'Y-m-d H:i:s')) && $to->format('Y-m-d H:i:s') > $from->format('Y-m-d H:i:s') && Option::get('conversion', 'GENERATE_INITIAL_DATA', 'undefined') == 'undefined') {
         Option::set('conversion', 'GENERATE_INITIAL_DATA', 'generated');
         $context = new self();
         // generate data
         $data = array();
         foreach (EventManager::getInstance()->findEventHandlers('conversion', 'OnGenerateInitialData') as $handler) {
             $result = ExecuteModuleEventEx($handler, array($from, $to));
             // TODO validate
             foreach ($result as $row) {
                 $context->id = null;
                 $context->attributes = array();
                 $context->setAttributes($row['ATTRIBUTES']);
                 $context->save();
                 if ($dayCounters =& $data[$context->id]) {
                     self::appendDayCounters($dayCounters, $row['DAY_COUNTERS']);
                 } else {
                     $dayCounters = $row['DAY_COUNTERS'];
                 }
             }
         }
         unset($dayCounters);
         // save data to database
         $numerators = CounterManager::getTypes(array('GROUP' => 'day'));
         unset($numerators['conversion_visit_day']);
         foreach ($data as $id => $dayCounters) {
             $context->id = $id;
             foreach ($dayCounters as $day => $counters) {
                 $day = new Date($day, 'Y-m-d');
                 $visitSum = 0;
                 $visitQuantity = 0;
                 unset($counters['conversion_visit_day']);
                 foreach ($counters as $name => $value) {
                     $context->addCounter($day, $name, $value);
                     if ($numerators[$name]) {
                         $visitSum += $value;
                         $visitQuantity += 1;
                     }
                 }
                 $context->addCounter($day, 'conversion_visit_day', $visitQuantity ? round($visitSum / $visitQuantity * 100) + 1 : 1);
             }
         }
     }
 }
 public function externalize()
 {
     $result = array('srcEntityTypeID' => $this->srcEntityTypeID, 'dstEntityTypeID' => $this->dstEntityTypeID, 'time' => $this->time->format(\DateTime::ISO8601), 'items' => array());
     if ($this->srcIndex !== null) {
         foreach ($this->srcIndex as $item) {
             $result['items'][] = $item->externalize();
         }
     }
     return $result;
 }
 protected static function modifyToDb($data)
 {
     $result = array();
     foreach ($data as $name => $value) {
         if ($name == 'date' && $value instanceof \DateTime) {
             $value = DateTime::createFromPhp($value);
         }
         if (in_array($name, array('originalData', 'updateData'))) {
             $value = \WS\Migrations\arrayToJson($value);
         }
         $result[$name] = $value;
     }
     return $result;
 }
Esempio n. 10
0
 /**
  * @param FieldType $fieldType Document field type.
  * @param mixed $value Field value.
  * @param string $toTypeClass Type class name.
  * @return null|mixed
  */
 public static function convertTo(FieldType $fieldType, $value, $toTypeClass)
 {
     /** @var Base $toTypeClass */
     $type = $toTypeClass::getType();
     switch ($type) {
         case FieldType::BOOL:
             $value = strtolower((string) $value);
             $value = in_array($value, array('y', 'yes', 'true', '1')) ? 'Y' : 'N';
             break;
         case FieldType::DATE:
             $value = date(Main\Type\Date::convertFormatToPhp(\FORMAT_DATE), strtotime($value));
             break;
         case FieldType::DATETIME:
             $value = date(Main\Type\DateTime::convertFormatToPhp(\FORMAT_DATETIME), strtotime($value));
             break;
         case FieldType::DOUBLE:
             $value = str_replace(' ', '', str_replace(',', '.', $value));
             $value = (double) $value;
             break;
         case FieldType::INT:
             $value = str_replace(' ', '', $value);
             $value = (int) $value;
             break;
         case FieldType::STRING:
         case FieldType::TEXT:
             $value = (string) $value;
             break;
         case FieldType::USER:
             $value = trim($value);
             if (strpos($value, 'user_') === false && strpos($value, 'group_') === false && !preg_match('#^[0-9]+$#', $value)) {
                 $value = null;
             }
             break;
         default:
             $value = null;
     }
     return $value;
 }
Esempio n. 11
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;
 }
Esempio n. 12
0
 protected static function getHourlyCompanyActivitySince(Type\DateTime $hour = null)
 {
     $query = new Entity\Query('Bitrix\\Intranet\\UStat\\UserHourTable');
     // set all activity columns
     $uStatFields = UserHourTable::getEntity()->getFields();
     foreach ($uStatFields as $uStatField) {
         if ($uStatField instanceof Entity\ScalarField && !$uStatField->isPrimary()) {
             $query->addSelect(new Entity\ExpressionField($uStatField->getName() . '_SUM', 'SUM(%s)', $uStatField->getName()));
         }
     }
     // add & automatically group by hour
     $query->addSelect('HOUR');
     // add filter by date
     if ($hour !== null) {
         $query->setFilter(array('>=HOUR' => \ConvertTimeStamp($hour->getTimestamp(), 'FULL')));
     }
     // collect activity
     $activity = array();
     $result = $query->exec();
     while ($row = $result->fetch()) {
         foreach ($row as $k => $v) {
             if (substr($k, -4) === '_SUM') {
                 $row[substr($k, 0, -4)] = $v;
                 unset($row[$k]);
             }
         }
         $activity[] = $row;
     }
     return $activity;
 }
Esempio n. 13
0
	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"]);
		}
	}
	if ($arParams["ADD_ELEMENT_CHAIN"])
	{
		if ($arResult["IPROPERTY_VALUES"]["ELEMENT_PAGE_TITLE"] != "")
			$APPLICATION->AddChainItem($arResult["IPROPERTY_VALUES"]["ELEMENT_PAGE_TITLE"]);
		else
			$APPLICATION->AddChainItem($arResult["NAME"]);
	}

	if ($arParams["SET_LAST_MODIFIED"] && $arResult["TIMESTAMP_X"])
	{
		Context::getCurrent()->getResponse()->setLastModified(DateTime::createFromUserTime($arResult["TIMESTAMP_X"]));
	}

	return $arResult["ID"];
}
else
{
	return 0;
}
?>
Esempio n. 14
0
 /**
  * @param array            $userfield
  * @param Type\Date|string $value
  *
  * @return Type\Date
  */
 public function onBeforeSave($userfield, $value)
 {
     if (strlen($value) && !$value instanceof Type\Date) {
         // try both site's format - short and full
         try {
             $value = new Type\Date($value);
         } catch (Main\ObjectException $e) {
             $value = new Type\Date($value, Type\DateTime::getFormat());
         }
     }
     return $value;
 }
Esempio n. 15
0
 function SearchDateChatMessage($searchDate, $chatId, $bTimeZone = true)
 {
     global $DB;
     $chatId = IntVal($chatId);
     $sqlHelper = Bitrix\Main\Application::getInstance()->getConnection()->getSqlHelper();
     try {
         $dateStart = \Bitrix\Main\Type\DateTime::createFromUserTime($searchDate);
         $sqlDateStart = $sqlHelper->getCharToDateFunction($dateStart->format("Y-m-d H:i:s"));
         $dateEnd = $dateStart->add('1 DAY');
         $sqlDateEnd = $sqlHelper->getCharToDateFunction($dateEnd->format("Y-m-d H:i:s"));
     } catch (\Bitrix\Main\ObjectException $e) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_HISTORY_SEARCH_DATE_EMPTY"), "ERROR_SEARCH_EMPTY");
         return false;
     }
     $limitById = '';
     $ar = \CIMChat::GetRelationById($chatId, $this->user_id);
     if ($ar && $ar['START_ID'] > 0) {
         $limitById = 'AND M.ID >= ' . intval($ar['START_ID']);
     }
     if (!$bTimeZone) {
         CTimeZone::Disable();
     }
     $strSql = "\n\t\t\tSELECT\n\t\t\t\tM.ID,\n\t\t\t\tM.CHAT_ID,\n\t\t\t\tM.MESSAGE,\n\t\t\t\t" . $DB->DatetimeToTimestampFunction('M.DATE_CREATE') . " DATE_CREATE,\n\t\t\t\tM.AUTHOR_ID\n\t\t\tFROM b_im_relation R1\n\t\t\tINNER JOIN b_im_message M ON M.CHAT_ID = R1.CHAT_ID\n\t\t\tWHERE\n\t\t\t\tR1.USER_ID = " . $this->user_id . "\n\t\t\tAND R1.CHAT_ID = " . $chatId . "\n\t\t\tAND R1.MESSAGE_TYPE <> '" . IM_MESSAGE_PRIVATE . "'\n\t\t\tAND M.DATE_CREATE >= " . $sqlDateStart . " AND M.DATE_CREATE <=  " . $sqlDateEnd . "\n\t\t\t\t" . $limitById . "\n\t\t\tORDER BY M.DATE_CREATE DESC, M.ID DESC\n\t\t";
     if (!$bTimeZone) {
         CTimeZone::Enable();
     }
     $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $arMessages = array();
     $arMessageId = array();
     $arUnreadMessage = array();
     $usersMessage = array();
     $CCTP = new CTextParser();
     $CCTP->MaxStringLen = 200;
     $CCTP->allow = array("HTML" => "N", "ANCHOR" => $this->bHideLink ? "N" : "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "LIST" => "N", "SMILES" => $this->bHideLink ? "N" : "Y", "NL2BR" => "Y", "VIDEO" => "N", "TABLE" => "N", "CUT_ANCHOR" => "N", "ALIGN" => "N");
     while ($arRes = $dbRes->Fetch()) {
         $arMessages[$arRes['ID']] = array('id' => $arRes['ID'], 'chatId' => $arRes['CHAT_ID'], 'senderId' => $arRes['AUTHOR_ID'], 'recipientId' => $arRes['CHAT_ID'], 'date' => $arRes['DATE_CREATE'], 'text' => $CCTP->convertText(htmlspecialcharsbx($arRes['MESSAGE'])));
         $usersMessage[$arRes['CHAT_ID']][] = $arRes['ID'];
         $arMessageId[] = $arRes['ID'];
     }
     $params = CIMMessageParam::Get($arMessageId);
     $arFiles = array();
     foreach ($params as $messageId => $param) {
         $arMessages[$messageId]['params'] = $param;
         if (isset($param['FILE_ID'])) {
             foreach ($param['FILE_ID'] as $fileId) {
                 $arFiles[$fileId] = $fileId;
             }
         }
     }
     $arMessageFiles = CIMDisk::GetFiles($chatId, $arFiles);
     return array('chatId' => $chatId, 'message' => $arMessages, 'unreadMessage' => $arUnreadMessage, 'usersMessage' => $usersMessage, 'files' => $arMessageFiles);
 }
Esempio n. 16
0
	/**
	 * Sets default timezone.
	 *
	 * @return DateTime
	 */
	public function setDefaultTimeZone()
	{
		$time = new \DateTime();
		$this->setTimezone($time->getTimezone());
		return $this;
	}
 public static function parseDateString($str)
 {
     if ($str === '') {
         return null;
     }
     try {
         $date = new Date($str, Date::convertFormatToPhp(FORMAT_DATE));
     } catch (Main\ObjectException $e) {
         try {
             $date = new DateTime($str, Date::convertFormatToPhp(FORMAT_DATETIME));
             $date->setTime(0, 0, 0);
         } catch (Main\ObjectException $e) {
             return null;
         }
     }
     return $date;
 }
Esempio n. 18
0
 /**
  * <p>Преобразует дату из одного заданного формата в другой заданный формат. В формате допустимы следующие обозначения:</p> <p> </p> <table width="100%" class="tnormal"> <tr> <th width="40%">Обозначение</th> <th width="60%">Описание</th> </tr> <tr> <td>YYYY</td> <td>Год (0001 - 9999)</td> </tr> <tr> <td>MM</td> <td>Месяц (01 - 12)</td> </tr> <tr> <td>DD</td> <td>День (01 - 31)</td> </tr> <tr> <td>HH</td> <td>Часы (00 - 24)</td> </tr> <tr> <td>MI</td> <td>Минуты (00 - 59)</td> </tr> <tr> <td>SS</td> <td>Секунды (00 - 59)</td> </tr> </table> <p>Динамичный метод.</p>
  *
  *
  * @param string $date  Год (0001 - 9999)</b
  *
  * @param string $format = "DD.MM.YYYY Месяц (01 - 12)</bo
  *
  * @param H $H  День (01 - 31)</b
  *
  * @param M $I  Часы (00 - 24)</bo
  *
  * @param S $S  Минуты (00 - 59)</b
  *
  * @param  $string  Секунды (00 - 59)</bod
  *
  * @param new_forma $t = "DD.MM.YYYY 
  *
  * @param H $H  Дата для конвертации.
  *
  * @param M $I  Текущий формат даты. <br>Необязательный. По умолчанию - "DD.MM.YYYY HH:MI:SS".
  *
  * @param S $S  В какой формат необходимо преобразовать. <br>Необязательный. По
  * умолчанию - "DD.MM.YYYY HH:MI:SS".
  *
  * @return string 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * // зададим дату
  * $date = "31.12.2007";
  * 
  * // укажем формат этой даты
  * $format = "DD.MM.YYYY";
  * 
  * // получим формат текущего сайта
  * $new_format = CSite::GetDateFormat("SHORT"); // YYYY-MM-DD
  * 
  * // переведем дату из одного формата в другой
  * $new_date = $DB-&gt;<b>FormatDate</b>($date, $format, $new_format);
  * 
  * // в результате получим дату в новом формате
  * echo $new_date; // 2007-12-31
  * ?&gt;
  * 
  * 
  * &lt;?
  * // конвертация даты из формата одного сайта в формат другого
  * 
  * // получим формат сайта ru
  * $format_ru = CSite::GetDateFormat("SHORT", "ru"); // DD.MM.YYYY
  * 
  * // получим формат сайта en
  * $format_en = CSite::GetDateFormat("SHORT", "en"); // YYYY-MM-DD
  * 
  * // переведем дату из формата сайта ru в формат сайта en
  * $new_date = $DB-&gt;<b>FormatDate</b>($date, $format_ru, $format_en);
  * 
  * // в результате получим дату в новом формате
  * echo $date; // 2007-12-31
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cdatabase/dateformattophp.php">CDatabase::DateFormatToPHP</a>
  * </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/csite/getdateformat.php">CSite::GetDateFormat</a>
  * </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/date/convertdatetime.php">ConvertDateTime</a> </li>
  * <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/date/index.php">Функции для работы с
  * датой и временем</a> </li> </ul> <a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cdatabase/formatdate.php
  * @author Bitrix
  */
 public static function FormatDate($strDate, $format = "DD.MM.YYYY HH:MI:SS", $new_format = "DD.MM.YYYY HH:MI:SS")
 {
     if (empty($strDate)) {
         return false;
     }
     if ($format === false && defined("FORMAT_DATETIME")) {
         $format = FORMAT_DATETIME;
     }
     $fromPhpFormat = Main\Type\Date::convertFormatToPhp($format);
     $time = false;
     try {
         $time = new Main\Type\DateTime($strDate, $fromPhpFormat);
     } catch (Main\ObjectException $e) {
     }
     if ($time !== false) {
         //Compatibility issue
         $fixed_format = preg_replace(array("/(?<!Y)Y(?!Y)/i", "/(?<!M)M(?!M|I)/i", "/(?<!D)D(?!D)/i", "/(?<!H)H:I:S/i"), array("YYYY", "MM", "DD", "HH:MI:SS"), strtoupper($new_format));
         $toPhpFormat = Main\Type\Date::convertFormatToPhp($fixed_format);
         return $time->format($toPhpFormat);
     }
     return false;
 }
Esempio n. 19
0
        ksort($params);
        $check = base64_encode(sha1($key, implode("|", array_values($params))));
        if ($check != $_SERVER['HTTP_X_API_SIGNATURE']) {
            qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_AUTH);
        }
    } else {
        qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_AUTH);
    }
}
list($orderId, $paymentId) = explode(':', $_POST['bill_id']);
/** @var \Bitrix\Sale\Order $order */
$order = Order::load($orderId);
if ($order) {
    $arOrder = $order->getFieldValues();
    $payment = $order->getPaymentCollection()->getItemById($paymentId);
    $paidInfo = array("PS_STATUS" => $_POST['status'] == "paid" ? "Y" : "N", "PS_STATUS_CODE" => substr($_POST['status'], 0, 5), "PS_STATUS_MESSAGE" => Loc::getMessage("SALE_QWH_STATUS_MESSAGE_" . strtoupper($_POST['status'])), "PS_RESPONSE_DATE" => \Bitrix\Main\Type\DateTime::createFromTimestamp(time()), "PS_SUM" => (double) $_POST['amount'], "PS_CURRENCY" => $_POST['ccy'], "PS_STATUS_DESCRIPTION" => "");
    if ((int) $_POST['error']) {
        $paidInfo['PS_STATUS_DESCRIPTION'] = "Error: " . Loc::getMessage("SALE_QWH_ERROR_CODE_" . $_POST['error']);
        $payment->setFields($paidInfo);
        qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_OTHER);
    }
    foreach ($_POST as $key => $value) {
        $paidInfo['PS_STATUS_DESCRIPTION'] .= "{$key}:{$value}, ";
    }
    $payment->setFields($paidInfo);
    $changeStatusPay = CSalePaySystemAction::GetParamValue("CHANGE_STATUS_PAY") == "Y";
    if ($_POST['status'] == "paid" && $changeStatusPay) {
        $resPayment = $payment->setField('PAID', 'Y');
        if ($resPayment->isSuccess()) {
            qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_NONE);
        }
Esempio n. 20
0
            CCurrency::updateAllCurrencyBaseRate();
            LocalRedirect($APPLICATION->GetCurPage() . '?lang=' . LANGUAGE_ID . '&mid=' . $module_id . '&' . $systemTabControl->ActiveTabParam());
        }
        if (isset($_POST['agents']) && $_POST['agents'] == 'Y' && isset($_POST['action']) && !empty($_POST['action'])) {
            $action = (string) $_POST['action'];
            switch ($action) {
                case 'activate':
                case 'deactivate':
                    $agentIterator = CAgent::GetList(array(), array('MODULE_ID' => 'currency', '=NAME' => '\\Bitrix\\Currency\\CurrencyTable::currencyBaseRateAgent();'));
                    if ($currencyAgent = $agentIterator->Fetch()) {
                        $active = $action == 'activate' ? 'Y' : 'N';
                        CAgent::Update($currencyAgent['ID'], array('ACTIVE' => $active));
                    }
                    break;
                case 'create':
                    $checkDate = DateTime::createFromTimestamp(strtotime('tomorrow 00:01:00'));
                    CAgent::AddAgent('\\Bitrix\\Currency\\CurrencyTable::currencyBaseRateAgent();', 'currency', 'Y', 86400, '', 'Y', $checkDate->toString(), 100, false, true);
                    break;
            }
            LocalRedirect($APPLICATION->GetCurPage() . '?lang=' . LANGUAGE_ID . '&mid=' . $module_id . '&' . $systemTabControl->ActiveTabParam());
        }
    }
    $baseCurrency = Currency\CurrencyManager::getBaseCurrency();
    $tabControl->Begin();
    ?>
	<form method="POST" action="<?php 
    echo $APPLICATION->GetCurPage();
    ?>
?lang=<?php 
    echo LANGUAGE_ID;
    ?>
Esempio n. 21
0
 public static function getDateTimeToDbFunction(\Bitrix\Main\Type\DateTime $value, $type = \Bitrix\Main\Type\DateTime::DATE_WITH_TIME)
 {
     $customOffset = $value->getValue()->getOffset();
     $serverTime = new \Bitrix\Main\Type\DateTime();
     $serverOffset = $serverTime->getValue()->getOffset();
     $diff = $customOffset - $serverOffset;
     $valueTmp = clone $value;
     $valueTmp->getValue()->sub(new \DateInterval(sprintf("PT%sS", $diff)));
     $format = $type == \Bitrix\Main\Type\DateTime::DATE_WITHOUT_TIME ? "Y-m-d" : "Y-m-d H:i:s";
     $formatDb = $type == \Bitrix\Main\Type\DateTime::DATE_WITHOUT_TIME ? "YYYY-MM-DD" : "YYYY-MM-DD HH24:MI:SS";
     $date = "TO_DATE('" . $valueTmp->format($format) . "', '" . $formatDb . "')";
     return $date;
 }
Esempio n. 22
0
 /**
  * @param string $action
  * @return array
  */
 protected function toView($action = null)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     $error = $this->checkRequirements();
     if ($error) {
         return array('MESSAGE' => $error);
     }
     $result = array();
     switch ($action) {
         case 'download':
             $codes = $this->getRecoveryCodes(true, true);
             $response = '';
             $counter = 0;
             foreach ($codes as $code) {
                 $counter++;
                 $response .= sprintf("%d. %s\r\n", $counter, $code['VALUE']);
             }
             $result['PLAIN_RESPONSE'] = $response;
             break;
         case 'print':
             $result['CODES'] = $this->getRecoveryCodes(true, true);
             break;
         case 'view':
         default:
             $result['CODES'] = $this->getRecoveryCodes(false, true);
             break;
     }
     $result['ISSUER'] = Option::get('main', 'server_name');
     if (!$result['ISSUER']) {
         $result['ISSUER'] = Option::get('security', 'otp_issuer', 'Bitrix');
     }
     $result['CREATE_DATE'] = CUserOptions::GetOption('security', 'recovery_codes_generated', null);
     if ($result['CREATE_DATE']) {
         $result['CREATE_DATE'] = Type\DateTime::createFromTimestamp($result['CREATE_DATE']);
     }
     return $result;
 }
Esempio n. 23
0
 /**
  * Convertation property for creation agent in queue through the old and dirty Bitrix API.
  */
 protected function convertation()
 {
     if ($this->executionTime instanceof DateTime) {
         $this->executionTime = $this->executionTime->toString();
     } elseif ($this->executionTime === null) {
         $time = new DateTime();
         $this->executionTime = $time->toString();
     }
     foreach (['periodically', 'active'] as $property) {
         if ($this->{$property} === true) {
             $this->{$property} = 'Y';
         } else {
             $this->{$property} = 'N';
         }
     }
 }
Esempio n. 24
0
 /**
  * @param int $days
  *
  * @return bool
  */
 public static function deleteOld($days)
 {
     $expired = new Main\Type\DateTime();
     $expired->add('-' . $days . 'days');
     $expiredValue = $expired->format('Y-m-d H:i:s');
     /** @var Main\DB\Connection $connection */
     $connection = Main\Application::getConnection();
     /** @var Main\DB\SqlHelper $sqlHelper */
     $sqlHelper = $connection->getSqlHelper();
     $sqlExpiredDate = $sqlHelper->getDateToCharFunction("'" . $expiredValue . "'");
     if ($connection instanceof Main\DB\MysqlCommonConnection) {
         $query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t SELECT ID FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\t\t\t \t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
         $connection->queryExecute($query);
         $query = "DELETE FROM b_sale_basket\tWHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
         $connection->queryExecute($query);
     } elseif ($connection instanceof Main\DB\MssqlConnection) {
         $query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n     \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE b_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)";
         $connection->queryExecute($query);
         $query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t)";
         $connection->queryExecute($query);
     } elseif ($connection instanceof Main\DB\OracleConnection) {
         $query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n     \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
         $connection->queryExecute($query);
         $query = "DELETE FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n     \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n     \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
         $connection->queryExecute($query);
     }
     return true;
 }
Esempio n. 25
0
 /**
  * Ping from the agent to inform that it still works correctly. Use this method if your agent
  * works more 10 minutes, otherwise Bitrix will be consider your agent as non-working.
  *
  * Usage:
  * ```php
  * public function executeAgent($param1, $param2)
  * {
  *      // start a heavy (big) cycle
  *
  *          $this->pingAgent(20, ['executeAgent => [$param1, $param2]]);
  *
  *      // end of cycle
  * }
  * ```
  *
  * @param int $interval The time in minutes after which the agent will be considered non-working.
  * @param array $callChain Array with the call any methods from Agent class.
  */
 protected function pingAgent($interval, array $callChain)
 {
     if (!$this->isAgentMode()) {
         return;
     }
     $name = $this->getAgentName($callChain);
     $model = new \CAgent();
     $rsAgent = $model->GetList([], ['NAME' => $name]);
     if ($agent = $rsAgent->Fetch()) {
         $dateCheck = DateTime::createFromTimestamp(time() + $interval * 60);
         $pingResult = $model->Update($agent['ID'], ['DATE_CHECK' => $dateCheck->toString()]);
         if (!$pingResult) {
             // @todo warning
         }
     } else {
         // @todo warning
     }
 }
Esempio n. 26
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
use Bitrix\Main\Type;
CModule::IncludeModule('intranet');
$nowDate = new Type\DateTime();
$toDate = new Type\DateTime();
// parse period
switch ($arParams['PERIOD']) {
    case 'year':
        $fromDate = $last12months = Type\DateTime::createFromTimestamp(mktime(0, 0, 0, date('n') - 12, 1));
        $interval = 'month';
        $dateFormat = 'Y-m';
        $axisDateFormat = "M\nY";
        $axisCursorDateFormat = "f\nY";
        break;
    case 'month':
        $fromDate = Type\DateTime::createFromTimestamp(mktime(0, 0, 0, date('n'), date('j') - 30));
        $interval = 'day';
        $dateFormat = 'Y-m-d';
        $axisDateFormat = "D\nd.m";
        $axisCursorDateFormat = "l\nd M Y";
        break;
    case 'week':
        $fromDate = Type\DateTime::createFromTimestamp(mktime(0, 0, 0, date('n'), date('j') - 7));
        $interval = 'day';
        $dateFormat = 'Y-m-d';
        $axisDateFormat = "D\nd.m";
        $axisCursorDateFormat = "l\nd M Y";
Esempio n. 27
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);
 }
Esempio n. 28
0
    $templateListHtml = \Bitrix\Sender\Preset\Template::getTemplateListHtml();
}
if ($step == 'chain_send_type') {
    $ID = $MAILING_CHAIN_ID;
    IncludeModuleLangFile(dirname(__FILE__) . "/mailing_chain_edit.php");
    $DAYS_OF_WEEK = empty($DAYS_OF_WEEK) ? '' : implode(',', $DAYS_OF_WEEK);
    if ($REQUEST_METHOD == "POST" && !$isPostedFormProcessed && check_bitrix_sessid()) {
        $arFields = array("REITERATE" => "N", "AUTO_SEND_TIME" => "", "DAYS_OF_WEEK" => "", "DAYS_OF_MONTH" => "", "TIMES_OF_DAY" => "");
        switch ($SEND_TYPE) {
            case 'MANUAL':
                break;
            case 'TIME':
                if (empty($AUTO_SEND_TIME)) {
                    $arError[] = GetMessage("sender_chain_edit_error_empty_time");
                }
                if (!\Bitrix\Main\Type\DateTime::isCorrect($AUTO_SEND_TIME)) {
                    $arError[] = GetMessage("sender_chain_edit_error_time_format");
                } else {
                    $arFields["AUTO_SEND_TIME"] = new \Bitrix\Main\Type\DateTime($AUTO_SEND_TIME);
                }
                if ($ID <= 0) {
                    $arFields["STATUS"] = \Bitrix\Sender\MailingChainTable::STATUS_SEND;
                } else {
                    $arMailingChainOld = \Bitrix\Sender\MailingChainTable::getRowById(array('ID' => $ID));
                    if ($arMailingChainOld['STATUS'] == \Bitrix\Sender\MailingChainTable::STATUS_NEW) {
                        $arFields["STATUS"] = \Bitrix\Sender\MailingChainTable::STATUS_SEND;
                    }
                }
                break;
            case 'REITERATE':
                if (empty($DAYS_OF_WEEK) && empty($DAYS_OF_MONTH)) {
Esempio n. 29
0
             $arItem['CATALOG_MEASURE'] = 0;
         }
         if (!isset($arItem['CATALOG_MEASURE_NAME'])) {
             $arItem['CATALOG_MEASURE_NAME'] = '';
         }
         $arItem['CATALOG_MEASURE_NAME'] = $arDefaultMeasure['SYMBOL_RUS'];
         $arItem['~CATALOG_MEASURE_NAME'] = $arDefaultMeasure['~SYMBOL_RUS'];
         if (0 < $arItem['CATALOG_MEASURE']) {
             if (!isset($arMeasureMap[$arItem['CATALOG_MEASURE']])) {
                 $arMeasureMap[$arItem['CATALOG_MEASURE']] = array();
             }
             $arMeasureMap[$arItem['CATALOG_MEASURE']][] = $intKey;
         }
     }
     if ($arParams["SET_LAST_MODIFIED"]) {
         $time = DateTime::createFromUserTime($arItem["TIMESTAMP_X"]);
         if (!isset($arResult["ITEMS_TIMESTAMP_X"]) || $time->getTimestamp() > $arResult["ITEMS_TIMESTAMP_X"]->getTimestamp()) {
             $arResult["ITEMS_TIMESTAMP_X"] = $time;
         }
     }
     $arResult["ITEMS"][$intKey] = $arItem;
     $arResult["ELEMENTS"][$intKey] = $arItem["ID"];
     $arElementLink[$arItem['ID']] =& $arResult["ITEMS"][$intKey];
     $intKey++;
 }
 $arResult['MODULES'] = $arResultModules;
 $navComponentParameters = array();
 if ($arParams["PAGER_BASE_LINK_ENABLE"] === "Y") {
     $pagerBaseLink = trim($arParams["PAGER_BASE_LINK"]);
     if ($pagerBaseLink === "") {
         $pagerBaseLink = $arResult["SECTION_PAGE_URL"];
Esempio n. 30
0
 public static function getMap()
 {
     $date = new DateTime();
     $yesterday = Application::getConnection()->getSqlHelper()->getCharToDateFunction($date->add('-1 DAY')->format("Y-m-d H:i:s"));
     return array('ID' => array('data_type' => 'integer', 'primary' => true, 'autocomplete' => true), 'TOKEN' => array('data_type' => 'string', 'required' => true, 'validation' => array(__CLASS__, 'validateToken')), 'FILENAME' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateFilename')), 'CONTENT_TYPE' => array('data_type' => 'string', 'validation' => array(__CLASS__, 'validateContentType')), 'PATH' => array('data_type' => 'string', 'required' => true, 'validation' => array(__CLASS__, 'validatePath')), 'BUCKET_ID' => array('data_type' => 'integer'), 'SIZE' => array('data_type' => 'integer'), 'WIDTH' => array('data_type' => 'integer'), 'HEIGHT' => array('data_type' => 'integer'), 'IS_CLOUD' => array('data_type' => 'boolean', 'values' => array(0, 1), 'default_value' => 0), 'IRRELEVANT' => array('data_type' => 'boolean', 'expression' => array("CASE WHEN (%s < {$yesterday}) THEN 1 ELSE 0 END", 'CREATE_TIME'), 'values' => array(0, 1)), 'CREATED_BY' => array('data_type' => 'integer'), 'CREATE_USER' => array('data_type' => 'Bitrix\\Main\\UserTable', 'reference' => array('=this.CREATED_BY' => 'ref.ID')), 'CREATE_TIME' => array('data_type' => 'datetime', 'required' => true, 'default_value' => new DateTime()));
 }