Ejemplo n.º 1
0
 /**
  * @return Array|null
  */
 public function fetch()
 {
     $result = null;
     if ($this->resource) {
         $result = $this->resource->fetch();
     } elseif ($this->resourceCDBResult) {
         $result = $this->resourceCDBResult->Fetch();
     }
     if ($result) {
         $result = $this->fetchModifierFields($result);
     }
     return $result && count($result) > 0 ? $result : null;
 }
Ejemplo n.º 2
0
 public function GetNotifyList($arParams)
 {
     global $DB;
     $iNumPage = 1;
     if (isset($arParams['PAGE']) && intval($arParams['PAGE']) > 0) {
         $iNumPage = intval($arParams['PAGE']);
     }
     $bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N' ? false : true;
     $sqlStr = "\n\t\t\tSELECT COUNT(M.ID) as CNT\n\t\t\tFROM b_im_relation R\n\t\t\tINNER JOIN b_im_message M ON M.NOTIFY_READ = 'Y' AND M.CHAT_ID = R.CHAT_ID\n\t\t\tWHERE R.USER_ID = " . $this->user_id . " AND R.MESSAGE_TYPE = '" . IM_MESSAGE_SYSTEM . "'\n\t\t";
     $res_cnt = $DB->Query($sqlStr);
     $res_cnt = $res_cnt->Fetch();
     $cnt = $res_cnt["CNT"];
     $arNotify = array();
     if ($cnt > 0) {
         if (!$bTimeZone) {
             CTimeZone::Disable();
         }
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tM.ID,\n\t\t\t\t\tM.CHAT_ID,\n\t\t\t\t\tM.MESSAGE,\n\t\t\t\t\tM.MESSAGE_OUT,\n\t\t\t\t\t" . $DB->DateToCharFunction('M.DATE_CREATE') . " DATE_CREATE,\n\t\t\t\t\tM.NOTIFY_TYPE,\n\t\t\t\t\tM.NOTIFY_MODULE,\n\t\t\t\t\tM.NOTIFY_TITLE,\n\t\t\t\t\tM.NOTIFY_BUTTONS,\n\t\t\t\t\tM.NOTIFY_TAG,\n\t\t\t\t\tM.NOTIFY_SUB_TAG,\n\t\t\t\t\tM.NOTIFY_READ,\n\t\t\t\t\tR.LAST_ID,\n\t\t\t\t\tR.USER_ID TO_USER_ID,\n\t\t\t\t\tM.AUTHOR_ID FROM_USER_ID\n\t\t\t\tFROM b_im_relation R\n\t\t\t\tINNER JOIN b_im_message M ON M.NOTIFY_READ = 'Y' AND M.CHAT_ID = R.CHAT_ID\n\t\t\t\tWHERE R.USER_ID = " . $this->user_id . " AND R.MESSAGE_TYPE = '" . IM_MESSAGE_SYSTEM . "'\n\t\t\t\tORDER BY M.DATE_CREATE DESC, ID DESC\n\t\t\t";
         if (!$bTimeZone) {
             CTimeZone::Enable();
         }
         $dbRes = new CDBResult();
         $dbRes->NavQuery($strSql, $cnt, array('iNumPage' => $iNumPage, 'nPageSize' => 20));
         while ($arRes = $dbRes->Fetch()) {
             if ($this->bHideLink) {
                 $arRes['HIDE_LINK'] = 'Y';
             }
             $arNotify[$arRes['ID']] = self::GetFormatNotify($arRes);
         }
     }
     return $arNotify;
 }
Ejemplo n.º 3
0
 /**
  * Gets array with one row of selected data.
  * Calls CDBResult->Fetch()
  * 
  * @return array|false
  */
 public function fetch()
 {
     if (is_null($this->selectResult)) {
         $this->getResult();
     }
     return $this->selectResult->Fetch();
 }
Ejemplo n.º 4
0
Archivo: tools.php Proyecto: gitkv/bash
/**
 * Returns HTML multiple "select"
 *
 * @param string $strBoxName Input name
 * @param CDBResult $a DB result with items
 * @param array $arr Selected values
 * @param string $strDetText Empty item text
 * @param bool $strDetText_selected Allow to choose an empty item
 * @param string $size Size attribute
 * @param string $field1 Additional attributes
 * @return string
 */
function SelectBoxM($strBoxName, $a, $arr, $strDetText = "", $strDetText_selected = false, $size = "5", $field1 = "class=\"typeselect\"")
{
    $strReturnBox = "<select " . $field1 . " multiple name=\"" . $strBoxName . "\" id=\"" . $strBoxName . "\" size=\"" . $size . "\">";
    if ($strDetText != '') {
        $strReturnBox = $strReturnBox . "<option ";
        if ($strDetText_selected) {
            $strReturnBox = $strReturnBox . " selected ";
        }
        $strReturnBox = $strReturnBox . " value='NOT_REF'>" . $strDetText . "</option>";
    }
    while ($ar = $a->Fetch()) {
        $reference_id = $ar["REFERENCE_ID"];
        $reference = $ar["REFERENCE"];
        if ($reference_id == '') {
            $reference_id = $ar["reference_id"];
        }
        if ($reference == '') {
            $reference = $ar["reference"];
        }
        $sel = is_array($arr) && in_array($reference_id, $arr) ? "selected" : "";
        $strReturnBox = $strReturnBox . "<option " . $sel;
        $strReturnBox = $strReturnBox . " value=\"" . htmlspecialcharsbx($reference_id) . "\">" . htmlspecialcharsbx($reference) . "</option>";
    }
    return $strReturnBox . "</select>";
}
Ejemplo n.º 5
0
 function Fetch()
 {
     static $arSite = array();
     $r = parent::Fetch();
     if ($r) {
         $site_id = $r["SITE_ID"];
         if (!isset($arSite[$site_id])) {
             $rsSite = CSite::GetList($b, $o, array("ID" => $site_id));
             $arSite[$site_id] = $rsSite->Fetch();
         }
         $r["DIR"] = $arSite[$site_id]["DIR"];
         $r["SERVER_NAME"] = $arSite[$site_id]["SERVER_NAME"];
         if (strlen($r["SITE_URL"]) > 0) {
             $r["URL"] = $r["SITE_URL"];
         }
         if (substr($r["URL"], 0, 1) == "=") {
             foreach (GetModuleEvents("search", "OnSearchGetURL", true) as $arEvent) {
                 $r["URL"] = ExecuteModuleEventEx($arEvent, array($r));
             }
         }
         $r["URL"] = str_replace(array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"), array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]), $r["URL"]);
         $r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]);
         unset($r["SITE_URL"]);
     }
     return $r;
 }
Ejemplo n.º 6
0
 public static function Fetch()
 {
     global $DB;
     $res = parent::Fetch();
     if (!is_object($this)) {
         return $res;
     }
     if ($res) {
         if (isset($res["USER_ID"])) {
             $USER_ID = intval($res["USER_ID"]);
         } elseif (isset($res["LAST_USER_ID"])) {
             $USER_ID = intval($res["LAST_USER_ID"]);
         } else {
             $USER_ID = 0;
         }
         if ($USER_ID > 0 && !isset($res["LOGIN"])) {
             $rsUser = $DB->Query("\n\t\t\t\t\tSELECT LOGIN, " . $DB->Concat($DB->IsNull("NAME", "''"), "' '", $DB->IsNull("LAST_NAME", "''")) . " USER_NAME\n\t\t\t\t\tFROM b_user\n\t\t\t\t\tWHERE ID = " . $USER_ID . "\n\t\t\t\t");
             $arUser = $rsUser->Fetch();
             if (is_array($arUser)) {
                 $res["LOGIN"] = $arUser["LOGIN"];
                 $res["USER_NAME"] = $arUser["USER_NAME"];
             } else {
                 $res["LOGIN"] = "";
                 $res["USER_NAME"] = " ";
             }
         }
     }
     return $res;
 }
Ejemplo n.º 7
0
function getList($blockId, $fields, $order, $filers)
{
    $entity_requests_data_class = connectToBlock($blockId);
    $main_query_requests = new Entity\Query($entity_requests_data_class);
    $main_query_requests->setSelect($fields);
    //$main_query_requests->setSelect(array('ID','UF_TITLE'));
    if (!empty($order)) {
        $main_query_requests->setOrder($order);
    }
    if (!empty($filers)) {
        $main_query_requests->setFilter($filers);
        /*$main_query_requests->setFilter(
              array(
                  'UF_NAME'=>'Александр',
              )
          );*/
    }
    $result_requests = $main_query_requests->exec();
    $result_requests = new CDBResult($result_requests);
    $requests = array();
    while ($row_requests = $result_requests->Fetch()) {
        $requests[] = $row_requests;
        //массив выбранных элементов
    }
    return $requests;
}
Ejemplo n.º 8
0
 function Fetch()
 {
     $a = parent::Fetch();
     if ($a && defined("BX_COMP_MANAGED_CACHE")) {
         $GLOBALS["CACHE_MANAGER"]->RegisterTag("iblock_property_enum_" . $a["PROPERTY_ID"]);
     }
     return $a;
 }
Ejemplo n.º 9
0
	function Fetch()
	{
		$r = parent::Fetch();
		if($r)
		{
			$r["ID"] = $r["CITY_ID"];
			$r["NAME"] = $r["CITY_NAME"];
		}

		return $r;
	}
Ejemplo n.º 10
0
	public function Fetch()
	{
		$r = parent::Fetch();

		if($r)
		{
			if(strlen($r["SITE_URL"])>0)
				$r["URL"] = $r["SITE_URL"];

			if(substr($r["URL"], 0, 1)=="=")
			{
				$events = GetModuleEvents("search", "OnSearchGetURL");
				while ($arEvent = $events->Fetch())
					$r["URL"] = ExecuteModuleEventEx($arEvent, array($r));
			}

			$r["URL"] = str_replace(
				array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"),
				array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]),
				$r["URL"]
			);
			$r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]);

			$r["NAME"] = htmlspecialcharsex($r["TITLE"]);

			$preg_template = "/(^|[^".$this->_arStemFunc["pcre_letters"]."])(".str_replace("/", "\\/", implode("|", array_map('preg_quote', array_keys($this->_arPhrase)))).")/i".BX_UTF_PCRE_MODIFIER;
			if(preg_match_all($preg_template, ToUpper($r["NAME"]), $arMatches, PREG_OFFSET_CAPTURE))
			{
				$c = count($arMatches[2]);
				if(defined("BX_UTF"))
				{
					for($j = $c-1; $j >= 0; $j--)
					{
						$prefix = mb_substr($r["NAME"], 0, $arMatches[2][$j][1], 'latin1');
						$instr  = mb_substr($r["NAME"], $arMatches[2][$j][1], mb_strlen($arMatches[2][$j][0], 'latin1'), 'latin1');
						$suffix = mb_substr($r["NAME"], $arMatches[2][$j][1] + mb_strlen($arMatches[2][$j][0], 'latin1'), mb_strlen($r["NAME"], 'latin1'), 'latin1');
						$r["NAME"] = $prefix."<b>".$instr."</b>".$suffix;
					}
				}
				else
				{
					for($j = $c-1; $j >= 0; $j--)
					{
						$prefix = substr($r["NAME"], 0, $arMatches[2][$j][1]);
						$instr  = substr($r["NAME"], $arMatches[2][$j][1], strlen($arMatches[2][$j][0]));
						$suffix = substr($r["NAME"], $arMatches[2][$j][1]+strlen($arMatches[2][$j][0]));
						$r["NAME"] = $prefix."<b>".$instr."</b>".$suffix;
					}
				}
			}
		}

		return $r;
	}
Ejemplo n.º 11
0
 /**
  * Convert CDBResult to array.
  *
  */
 public static function CDBResultToArray(CDBResult $CDBResult)
 {
     if ($CDBResult->SelectedRowsCount() == 0) {
         return array();
     }
     $ret = array();
     while ($row = $CDBResult->Fetch()) {
         $ret[] = $row;
     }
     return $ret;
 }
Ejemplo n.º 12
0
 public static function Fetch()
 {
     global $DB;
     $ar = parent::Fetch();
     if ($ar) {
         if (isset($ar["Tables_in_" . $DB->DBName])) {
             $ar = array("TABLE_NAME" => $ar["Tables_in_" . $DB->DBName], "ENGINE_TYPE" => "", "NUM_ROWS" => "", "BYTES" => "");
         } else {
             $ar = array("TABLE_NAME" => $ar["Name"], "ENGINE_TYPE" => $ar["Comment"] === "VIEW" ? "VIEW" : $ar["Engine"], "NUM_ROWS" => $ar["Rows"], "BYTES" => $ar["Data_length"]);
         }
     }
     return $ar;
 }
Ejemplo n.º 13
0
 function elemGetEx($elemId = false)
 {
     $hlHandler = $this->hlHandler;
     $getList = new Entity\Query($hlHandler);
     $getList->setSelect(array('*'));
     $getList->setOrder(array("ID" => "ASC"));
     if (!empty($elemId)) {
         $getList->setFilter(array("ID" => $elemId));
     }
     $result = $getList->exec();
     $result = new CDBResult($result);
     $arRes = array();
     while ($row = $result->Fetch()) {
         $arRes[] = $row;
     }
     return $arRes;
 }
Ejemplo n.º 14
0
 function Fetch()
 {
     $res = parent::Fetch();
     if ($res && $res["USER_TYPE"] != "") {
         $arUserType = CIBlockProperty::GetUserType($res["USER_TYPE"]);
         if (array_key_exists("ConvertFromDB", $arUserType)) {
             if (array_key_exists("VALUE", $res)) {
                 $value = array("VALUE" => $res["VALUE"], "DESCRIPTION" => "");
                 $value = call_user_func_array($arUserType["ConvertFromDB"], array($res, $value));
                 $res["VALUE"] = $value["VALUE"];
             }
             if (array_key_exists("DEFAULT_VALUE", $res)) {
                 $value = array("VALUE" => $res["DEFAULT_VALUE"], "DESCRIPTION" => "");
                 $value = call_user_func_array($arUserType["ConvertFromDB"], array($res, $value));
                 $res["DEFAULT_VALUE"] = $value["VALUE"];
             }
         }
         if (strlen($res["USER_TYPE_SETTINGS"])) {
             $res["USER_TYPE_SETTINGS"] = unserialize($res["USER_TYPE_SETTINGS"]);
         }
     }
     return $res;
 }
Ejemplo n.º 15
0
    public static function GetCityList() {

        $arResult = array();

        $rsData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter'=>array('NAME'=>CITY_LIST_HLB)));
        if ( !($arData = $rsData->fetch()) ){
            echo 'Инфоблок не найден';
        } else {
            $Entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arData);

            $Query = new \Bitrix\Main\Entity\Query($Entity);
            $Query->setSelect(array('*'));

            $result = $Query->exec();
            $result = new CDBResult($result);

            while ($row = $result->Fetch()){
                $arResult[$row['UF_CITY_CODE']] = $row['UF_CITY_NAME'];
            }

        }
        return $arResult;

    }
Ejemplo n.º 16
0
 function GetMoreChatMessage($pageId, $chatId, $bTimeZone = true)
 {
     global $DB;
     $iNumPage = 1;
     if (intval($pageId) > 0) {
         $iNumPage = intval($pageId);
     }
     $chatId = IntVal($chatId);
     $limitById = '';
     $ar = \CIMChat::GetRelationById($chatId, $this->user_id);
     if ($ar && $ar['START_ID'] > 0) {
         $limitById = 'AND M.ID >= ' . intval($ar['START_ID']);
     }
     $strSql = "\n\t\t\tSELECT COUNT(M.ID) as CNT\n\t\t\tFROM b_im_message M\n\t\t\tINNER JOIN b_im_relation R1 ON M.CHAT_ID = R1.CHAT_ID\n\t\t\tWHERE R1.CHAT_ID = " . $chatId . " AND R1.USER_ID = " . $this->user_id . " " . $limitById . "\n\t\t";
     $res_cnt = $DB->Query($strSql);
     $res_cnt = $res_cnt->Fetch();
     $cnt = $res_cnt["CNT"];
     $arMessages = array();
     $arMessageFiles = array();
     $arMessageId = array();
     $usersMessage = array();
     if ($cnt > 0 && ceil($cnt / 20) >= $iNumPage) {
         if (!$bTimeZone) {
             CTimeZone::Disable();
         }
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tM.ID,\n\t\t\t\t\tM.CHAT_ID,\n\t\t\t\t\tM.MESSAGE,\n\t\t\t\t\t" . $DB->DatetimeToTimestampFunction('M.DATE_CREATE') . " DATE_CREATE,\n\t\t\t\t\tM.AUTHOR_ID\n\t\t\t\tFROM b_im_message M\n\t\t\t\tINNER JOIN b_im_relation R1 ON M.CHAT_ID = R1.CHAT_ID\n\t\t\t\tWHERE R1.CHAT_ID = " . $chatId . " AND R1.USER_ID = " . $this->user_id . " " . $limitById . "\n\t\t\t\tORDER BY M.DATE_CREATE DESC, M.ID DESC\n\t\t\t";
         if (!$bTimeZone) {
             CTimeZone::Enable();
         }
         $dbRes = new CDBResult();
         $dbRes->NavQuery($strSql, $cnt, array('iNumPage' => $iNumPage, 'nPageSize' => 20));
         $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'], 'system' => $arRes['AUTHOR_ID'] > 0 ? 'N' : 'Y', '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, 'usersMessage' => $usersMessage, 'files' => $arMessageFiles);
 }
Ejemplo n.º 17
0
 function Fetch()
 {
     $res = parent::Fetch();
     if ($res) {
         if (array_key_exists("DOCUMENT_TYPE", $res)) {
             $res["DOCUMENT_TYPE"] = array($res["MODULE_ID"], $res["ENTITY"], $res["DOCUMENT_TYPE"]);
         }
         if (array_key_exists("TEMPLATE", $res)) {
             $res["TEMPLATE"] = $this->GetFromSerializedForm($res["TEMPLATE"]);
         }
         if (array_key_exists("VARIABLES", $res)) {
             $res["VARIABLES"] = $this->GetFromSerializedForm($res["VARIABLES"]);
         }
         if (array_key_exists("CONSTANTS", $res)) {
             $res["CONSTANTS"] = $this->GetFromSerializedForm($res["CONSTANTS"]);
         }
         if (array_key_exists("PARAMETERS", $res)) {
             $res["PARAMETERS"] = $this->GetFromSerializedForm($res["PARAMETERS"]);
             $arParametersKeys = array_keys($res["PARAMETERS"]);
             foreach ($arParametersKeys as $parameterKey) {
                 $res["PARAMETERS"][$parameterKey]["Type"] = $res["PARAMETERS"][$parameterKey]["Type"];
             }
         }
     }
     return $res;
 }
Ejemplo n.º 18
0
 /**
  * @param  \CDBResult $dbResultList
  * @return array
  */
 protected function makeItemsFromDbResult(\CDBResult $dbResultList)
 {
     $arItemsResult = $arProductIds = array();
     while ($arItem = $dbResultList->Fetch()) {
         if ($arItem['TYPE'] != 'S') {
             $arProductIds[] = $arItem['ID'];
             $arItem['PROPERTIES'] = $this->getItemProperies($arItem['ID']);
         }
         $arItemsResult[$arItem['ID']] = $arItem;
     }
     if (!empty($arProductIds)) {
         $dbCatalogProduct = \CCatalogProduct::GetList(array(), array("ID" => $arProductIds));
         while ($arCatalogProduct = $dbCatalogProduct->fetch()) {
             $arItemsResult[$arCatalogProduct["ID"]]['PRODUCT'] = $arCatalogProduct;
         }
         $offersExistsIds = \CCatalogSKU::getExistOffers($arProductIds, $this->getIblockId());
         $noOffersIds = array();
         if ($offersExistsIds === false) {
             $noOffersIds = $arProductIds;
         } else {
             $this->loadAllSku(array_keys(array_filter($offersExistsIds)));
             foreach ($offersExistsIds as $id => $bExists) {
                 $arItem =& $arItemsResult[$id];
                 if ($bExists) {
                     $arItem['SKU_ITEMS'] = $this->getProductSku($arItem);
                 } else {
                     $noOffersIds[] = $id;
                 }
             }
         }
         if (!empty($noOffersIds)) {
             $priceIds = $this->getVisiblePrices();
             foreach ($priceIds as $priceId) {
                 $dbPrice = \CPrice::GetList(array(), array('PRODUCT_ID' => $noOffersIds, 'CATALOG_GROUP_ID' => $priceId), false, false, array('PRODUCT_ID', 'PRICE', 'CURRENCY'));
                 while ($arPrice = $dbPrice->fetch()) {
                     $arItemsResult[$arPrice["PRODUCT_ID"]]['PRICES'][$priceId] = array('PRICE' => $arPrice['PRICE'], 'CURRENCY' => $arPrice['CURRENCY']);
                 }
             }
             if ($this->getStoreId()) {
                 $dbStoreProduct = \CCatalogStoreProduct::GetList(array(), array("PRODUCT_ID" => $noOffersIds, "STORE_ID" => $this->getStoreId()));
                 while ($arStoreProduct = $dbStoreProduct->Fetch()) {
                     $arItemsResult[$arStoreProduct["PRODUCT_ID"]]['PRODUCT']['STORE_AMOUNT'] = $arStoreProduct["AMOUNT"];
                 }
             }
             $groupsIterator = CCatalogProductSet::getList(array(), array('OWNER_ID' => $noOffersIds, 'SET_ID' => 0, 'TYPE' => \CCatalogProductSet::TYPE_GROUP), false, false, array('ID', 'OWNER_ID', 'ITEM_ID', 'SET_ID', 'TYPE'));
             while ($group = $groupsIterator->Fetch()) {
                 if ($group['OWNER_ID'] == $group['ITEM_ID']) {
                     $arItemsResult[$group['OWNER_ID']]['PRODUCT']['IS_GROUP'] = true;
                 }
             }
         }
     }
     return $arItemsResult;
 }
Ejemplo n.º 19
0
 function Fetch()
 {
     $arr = array();
     $arr_lid = array();
     $arr_lids = array();
     if ($res = parent::Fetch()) {
         if ($this->type != "none") {
             $db_res_ = CEventType::GetList(array("EVENT_NAME" => $res["EVENT_NAME"]));
             if ($db_res_ && ($res_ = $db_res_->Fetch())) {
                 do {
                     $arr[$res_["ID"]] = $res_;
                     $arr_lid[] = $res_["LID"];
                     $arr_lids[$res_["LID"]] = $res_;
                 } while ($res_ = $db_res_->Fetch());
             }
             $res["ID"] = array_keys($arr);
             $res["LID"] = $arr_lid;
             $res["NAME"] = empty($arr_lids[$this->LID]["NAME"]) ? $arr_lids["en"]["NAME"] : $arr_lids[$this->LID]["NAME"];
             $res["SORT"] = empty($arr_lids[$this->LID]["SORT"]) ? $arr_lids["en"]["SORT"] : $arr_lids[$this->LID]["SORT"];
             $res["DESCRIPTION"] = empty($arr_lids[$this->LID]["DESCRIPTION"]) ? $arr_lids["en"]["DESCRIPTION"] : $arr_lids[$this->LID]["DESCRIPTION"];
             $res["TYPE"] = $arr;
             if ($this->type != "type") {
                 $arr = array();
                 $db_res_ = CEventMessage::GetList($sort = "sort", $by = "asc", array("EVENT_NAME" => $res["EVENT_NAME"]));
                 if ($db_res_ && ($res_ = $db_res_->Fetch())) {
                     do {
                         $arr[$res_["ID"]] = $res_;
                     } while ($res_ = $db_res_->Fetch());
                 }
                 $res["TEMPLATES"] = $arr;
             }
         }
     }
     return $res;
 }
Ejemplo n.º 20
0
}
use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;
global $USER_FIELD_MANAGER;
// hlblock info
$hlblock_id = $arParams['BLOCK_ID'];
if (empty($hlblock_id)) {
    ShowError(GetMessage('HLBLOCK_VIEW_NO_ID'));
    return 0;
}
$hlblock = HL\HighloadBlockTable::getById($hlblock_id)->fetch();
if (empty($hlblock)) {
    ShowError('404');
    return 0;
}
$entity = HL\HighloadBlockTable::compileEntity($hlblock);
// row data
$main_query = new Entity\Query($entity);
$main_query->setSelect(array('*'));
$main_query->setFilter(array('=ID' => $arParams['ROW_ID']));
$result = $main_query->exec();
$result = new CDBResult($result);
$row = $result->Fetch();
$fields = $USER_FIELD_MANAGER->getUserFieldsWithReadyData('HLBLOCK_' . $hlblock['ID'], $row, LANGUAGE_ID);
if (empty($row)) {
    ShowError(sprintf(GetMessage('HLBLOCK_VIEW_NO_ROW'), $arParams['ROW_ID']));
    return 0;
}
$arResult['fields'] = $fields;
$arResult['row'] = $row;
$this->IncludeComponentTemplate();
Ejemplo n.º 21
0
 /**
  * @return array
  */
 public static function Fetch()
 {
     $res = parent::Fetch();
     if (!empty($res)) {
         if (array_key_exists('MEASURE_TITLE', $res) && $res["MEASURE_TITLE"] == '') {
             $tmpTitle = CCatalogMeasureClassifier::getMeasureTitle($res["CODE"], 'MEASURE_TITLE');
             $res["MEASURE_TITLE"] = $tmpTitle == '' ? $res["SYMBOL_INTL"] : $tmpTitle;
         }
         if (array_key_exists('SYMBOL_RUS', $res) && $res["SYMBOL_RUS"] == '') {
             $tmpSymbol = CCatalogMeasureClassifier::getMeasureTitle($res["CODE"], 'SYMBOL_RUS');
             $res["SYMBOL_RUS"] = $tmpSymbol == '' ? $res["SYMBOL_INTL"] : $tmpSymbol;
         }
     }
     return $res;
 }
Ejemplo n.º 22
0
 public static function Fetch()
 {
     if ($res = parent::Fetch()) {
         $res["ADMIN_PASSWORD"] = CLdapUtil::Decrypt($res["ADMIN_PASSWORD"]);
         $res["FIELD_MAP"] = unserialize($res["FIELD_MAP"]);
         if (!is_array($res["FIELD_MAP"])) {
             $res["FIELD_MAP"] = array();
         }
     }
     return $res;
 }
Ejemplo n.º 23
0
 function Fetch()
 {
     /** @global CCacheManager $CACHE_MANAGER */
     global $CACHE_MANAGER;
     /** @global CDatabase $DB */
     global $DB;
     $res = parent::Fetch();
     if (!is_object($this)) {
         return $res;
     }
     $arUpdate = array();
     if ($res) {
         if (is_array($this->arIBlockLongProps)) {
             foreach ($res as $k => $v) {
                 if (preg_match("#^ALIAS_(\\d+)_(.*)\$#", $k, $match)) {
                     $res[$this->arIBlockLongProps[$match[1]] . $match[2]] = $v;
                     unset($res[$k]);
                 }
             }
         }
         if (isset($res["IBLOCK_ID"]) && defined("BX_COMP_MANAGED_CACHE") && $res["IBLOCK_ID"] != $this->_LAST_IBLOCK_ID) {
             CIBlock::registerWithTagCache($res["IBLOCK_ID"]);
             $this->_LAST_IBLOCK_ID = $res["IBLOCK_ID"];
         }
         if (isset($res["ID"]) && $res["ID"] != "" && is_array($this->arIBlockMultProps)) {
             foreach ($this->arIBlockMultProps as $field_name => $db_prop) {
                 if (array_key_exists($field_name, $res)) {
                     if (is_object($res[$field_name])) {
                         $res[$field_name] = $res[$field_name]->load();
                     }
                     if (preg_match("/(_VALUE)\$/", $field_name)) {
                         $descr_name = preg_replace("/(_VALUE)\$/", "_DESCRIPTION", $field_name);
                     } else {
                         $descr_name = preg_replace("/^(PROPERTY_)/", "DESCRIPTION_", $field_name);
                     }
                     if (strlen($res[$field_name]) <= 0) {
                         $strSql = "\n\t\t\t\t\t\t\t\tSELECT VALUE,DESCRIPTION\n\t\t\t\t\t\t\t\tFROM b_iblock_element_prop_m" . $db_prop["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tIBLOCK_ELEMENT_ID = " . intval($res["ID"]) . "\n\t\t\t\t\t\t\t\t\tAND IBLOCK_PROPERTY_ID = " . intval($db_prop["ORIG_ID"]) . "\n\t\t\t\t\t\t\t\tORDER BY ID\n\t\t\t\t\t\t\t";
                         $rs = $DB->Query($strSql);
                         $res[$field_name] = array();
                         $res[$descr_name] = array();
                         while ($ar = $rs->Fetch()) {
                             $res[$field_name][] = $ar["VALUE"];
                             $res[$descr_name][] = $ar["DESCRIPTION"];
                         }
                         $arUpdate["b_iblock_element_prop_s" . $db_prop["IBLOCK_ID"]]["PROPERTY_" . $db_prop["ORIG_ID"]] = serialize(array("VALUE" => $res[$field_name], "DESCRIPTION" => $res[$descr_name]));
                     } else {
                         $tmp = unserialize($res[$field_name]);
                         $res[$field_name] = $tmp["VALUE"];
                         $res[$descr_name] = $tmp["DESCRIPTION"];
                     }
                     if (is_array($res[$field_name]) && $db_prop["PROPERTY_TYPE"] == "L") {
                         $arTemp = array();
                         foreach ($res[$field_name] as $key => $val) {
                             $arEnum = CIBlockPropertyEnum::GetByID($val);
                             if ($arEnum !== false) {
                                 $arTemp[$val] = $arEnum["VALUE"];
                             }
                         }
                         $res[$field_name] = $arTemp;
                     }
                 }
             }
             foreach ($arUpdate as $strTable => $arFields) {
                 $strUpdate = $DB->PrepareUpdate($strTable, $arFields);
                 if ($strUpdate != "") {
                     $strSql = "UPDATE " . $strTable . " SET " . $strUpdate . " WHERE IBLOCK_ELEMENT_ID = " . intval($res["ID"]);
                     $DB->QueryBind($strSql, $arFields);
                 }
             }
         }
         if (is_array($this->arIBlockConvProps)) {
             foreach ($this->arIBlockConvProps as $strFieldName => $arCallback) {
                 if (is_array($res[$strFieldName])) {
                     foreach ($res[$strFieldName] as $key => $value) {
                         $arValue = call_user_func_array($arCallback["ConvertFromDB"], array($arCallback["PROPERTY"], array("VALUE" => $value, "DESCRIPTION" => "")));
                         $res[$strFieldName][$key] = $arValue["VALUE"];
                     }
                 } else {
                     $arValue = call_user_func_array($arCallback["ConvertFromDB"], array($arCallback["PROPERTY"], array("VALUE" => $res[$strFieldName], "DESCRIPTION" => "")));
                     $res[$strFieldName] = $arValue["VALUE"];
                 }
             }
         }
         if (is_array($this->arIBlockNumProps)) {
             foreach ($this->arIBlockNumProps as $field_name => $db_prop) {
                 if (strlen($res[$field_name]) > 0) {
                     $res[$field_name] = htmlspecialcharsex(CIBlock::NumberFormat($res[$field_name]));
                 }
             }
         }
         if (isset($res["UC_ID"])) {
             $res["CREATED_BY_FORMATTED"] = CUser::FormatName($this->nameTemplate, array("NAME" => $res["UC_NAME"], "LAST_NAME" => $res["UC_LAST_NAME"], "SECOND_NAME" => $res["UC_SECOND_NAME"], "EMAIL" => $res["UC_EMAIL"], "ID" => $res["UC_ID"], "LOGIN" => $res["UC_LOGIN"]), true, false);
             unset($res["UC_NAME"]);
             unset($res["UC_LAST_NAME"]);
             unset($res["UC_SECOND_NAME"]);
             unset($res["UC_EMAIL"]);
             unset($res["UC_ID"]);
             unset($res["UC_LOGIN"]);
         }
     } elseif (defined("BX_COMP_MANAGED_CACHE") && $this->_LAST_IBLOCK_ID == "" && count($this->_FILTER_IBLOCK_ID)) {
         foreach ($this->_FILTER_IBLOCK_ID as $iblock_id => $t) {
             CIBlock::registerWithTagCache($iblock_id);
         }
     }
     return $res;
 }
Ejemplo n.º 24
0
 function Fetch()
 {
     static $index = false;
     $r = parent::Fetch();
     if ($r) {
         if (strlen($r["SITE_URL"]) > 0) {
             $r["URL"] = $r["SITE_URL"];
         }
         if (substr($r["URL"], 0, 1) == "=") {
             foreach ($this->m_events as $arEvent) {
                 $r["URL"] = ExecuteModuleEventEx($arEvent, array($r));
             }
         }
         $r["URL"] = str_replace(array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"), array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]), $r["URL"]);
         $r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]);
         if (defined("BX_DISABLE_INDEX_PAGE") && BX_DISABLE_INDEX_PAGE) {
             if (!$index) {
                 $index = "#/(" . str_replace(" ", "|", preg_quote(implode(" ", GetDirIndexArray()), "#")) . ")\$#";
             }
             $r["URL"] = preg_replace($index, "/", $r["URL"]);
         }
         //Remove anchor otherwise Google will ignore this link
         $p = strpos($r["URL"], "#");
         if ($p !== false) {
             $r["URL"] = substr($r["URL"], 0, $p);
         }
     }
     return $r;
 }
Ejemplo n.º 25
0
 public static function Fetch()
 {
     if ($res = parent::Fetch()) {
         if ($res["LAMP"] == "yellow" && !empty($res["CHANNEL_ID"])) {
             $res["LAMP"] = $res["ID"] == CVote::GetActiveVoteId($res["CHANNEL_ID"]) ? "green" : "red";
         }
     }
     return $res;
 }
Ejemplo n.º 26
0
	function Fetch()
	{
		if($arr_log = parent::Fetch())
			return CMailLog::ConvertRow($arr_log);

		return false;
	}
Ejemplo n.º 27
0
	public function GetNotifyList($arParams)
	{
		global $DB;

		$iNumPage = 1;
		if (isset($arParams['PAGE']) && intval($arParams['PAGE']) >= 0)
			$iNumPage = intval($arParams['PAGE']);

		$bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N'? false: true;

		$sqlStr = "
			SELECT COUNT(M.ID) as CNT, M.CHAT_ID
			FROM b_im_relation R
			INNER JOIN b_im_message M ON M.CHAT_ID = R.CHAT_ID
			WHERE R.USER_ID = ".$this->user_id." AND R.MESSAGE_TYPE = '".IM_MESSAGE_SYSTEM."'
			GROUP BY M.CHAT_ID
		";
		$res_cnt = $DB->Query($sqlStr);
		$res_cnt = $res_cnt->Fetch();
		$cnt = $res_cnt["CNT"];
		$chatId = $res_cnt["CHAT_ID"];

		$arNotify = Array();
		if ($cnt > 0)
		{
			if (!$bTimeZone)
				CTimeZone::Disable();

			$strSql ="
				SELECT
					M.ID,
					M.CHAT_ID,
					M.MESSAGE,
					M.MESSAGE_OUT,
					".$DB->DatetimeToTimestampFunction('M.DATE_CREATE')." DATE_CREATE,
					M.NOTIFY_TYPE,
					M.NOTIFY_MODULE,
					M.NOTIFY_EVENT,
					M.NOTIFY_TITLE,
					M.NOTIFY_BUTTONS,
					M.NOTIFY_TAG,
					M.NOTIFY_SUB_TAG,
					M.NOTIFY_READ,
					$this->user_id TO_USER_ID,
					M.AUTHOR_ID FROM_USER_ID
				FROM b_im_message M
				WHERE M.CHAT_ID = ".$chatId." #LIMIT#
				ORDER BY M.DATE_CREATE DESC, ID DESC
			";
			if (!$bTimeZone)
				CTimeZone::Enable();

			if ($iNumPage == 0)
			{
				$dbType = strtolower($DB->type);
				if ($dbType== "mysql")
					$sqlLimit = " AND M.DATE_CREATE > DATE_SUB(NOW(), INTERVAL 30 DAY)";
				else if ($dbType == "mssql")
					$sqlLimit = " AND M.DATE_CREATE > dateadd(day, -30, getdate())";
				else if ($dbType == "oracle")
					$sqlLimit = " AND M.DATE_CREATE > SYSDATE-30";

				$strSql = $DB->TopSql($strSql, 20);
				$dbRes = $DB->Query(str_replace("#LIMIT#", $sqlLimit, $strSql), false, "File: ".__FILE__."<br>Line: ".__LINE__);
			}
			else
			{
				$dbRes = new CDBResult();
				$dbRes->NavQuery(str_replace("#LIMIT#", "", $strSql), $cnt, Array('iNumPage' => $iNumPage, 'nPageSize' => 20));
			}

			$arGetUsers = Array();
			while ($arRes = $dbRes->Fetch())
			{
				if ($this->bHideLink)
					$arRes['HIDE_LINK'] = 'Y';

				$arNotify[$arRes['ID']] = $arRes;
				$arGetUsers[] = $arRes['FROM_USER_ID'];
			}
			if (empty($arNotify))
				return $arNotify;

			$arUsers = CIMContactList::GetUserData(Array('ID' => $arGetUsers, 'DEPARTMENT' => 'N', 'USE_CACHE' => 'Y', 'CACHE_TTL' => 86400));
			$arGetUsers = $arUsers['users'];

			foreach ($arNotify as $key => $value)
			{
				$value['FROM_USER_DATA'] = $arGetUsers;
				$arNotify[$key] = self::GetFormatNotify($value);
			}
		}
		return $arNotify;
	}
Ejemplo n.º 28
0
	/**
	 * Функция Fetch.
	 *
	 * <p>Десериализует поле SETTINGS.</p>
	 * @return array возвращает false в случае последней записи выборки.
	 */
	function Fetch()
	{
		$res = parent::Fetch();
		if($res && strlen($res["SETTINGS"])>0)
		{
			$res["SETTINGS"] = unserialize($res["SETTINGS"]);
		}
		return $res;
	}
Ejemplo n.º 29
0
 function Fetch()
 {
     global $DB;
     if ($res = parent::Fetch()) {
         $res["~TIMESTAMP_X"] = $res["TIMESTAMP_X"];
         $res["TIMESTAMP_X"] = ConvertTimeStamp($res["~TIMESTAMP_X"], "FULL");
     }
     return $res;
 }
Ejemplo n.º 30
0
 function Fetch()
 {
     if ($result = parent::Fetch()) {
         if (array_key_exists('SETTINGS', $result)) {
             $result['SETTINGS'] = is_string($result['SETTINGS']) ? unserialize($result['SETTINGS']) : array();
         }
         if ($this->selectCommunications) {
             $result['COMMUNICATIONS'] = CCrmActivity::GetCommunications($result['ID']);
         }
     }
     return $result;
 }