当前位置: 首页>>代码示例>>PHP>>正文


PHP CUserTypeSQL::SetOrder方法代码示例

本文整理汇总了PHP中CUserTypeSQL::SetOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP CUserTypeSQL::SetOrder方法的具体用法?PHP CUserTypeSQL::SetOrder怎么用?PHP CUserTypeSQL::SetOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUserTypeSQL的用法示例。


在下文中一共展示了CUserTypeSQL::SetOrder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetList

 public static function GetList($arOrder = array("SORT" => "ASC"), $arFilter = array(), $bIncCnt = false, $arSelect = array(), $arNavStartParams = false)
 {
     global $DB, $USER, $USER_FIELD_MANAGER;
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     if (isset($arFilter["IBLOCK_ID"]) && $arFilter["IBLOCK_ID"] > 0) {
         $obUserFieldsSql = new CUserTypeSQL();
         $obUserFieldsSql->SetEntity("IBLOCK_" . $arFilter["IBLOCK_ID"] . "_SECTION", "BS.ID");
         $obUserFieldsSql->SetSelect($arSelect);
         $obUserFieldsSql->SetFilter($arFilter);
         $obUserFieldsSql->SetOrder($arOrder);
     } else {
         foreach ($arFilter as $key => $val) {
             $res = CIBlock::MkOperationFilter($key);
             if (preg_match("/^UF_/", $res["FIELD"])) {
                 trigger_error("arFilter parameter of the CIBlockSection::GetList contains user fields, but has no IBLOCK_ID field.", E_USER_WARNING);
                 break;
             }
         }
     }
     $arJoinProps = array();
     $bJoinFlatProp = false;
     $arSqlSearch = CIBlockSection::GetFilter($arFilter);
     $bCheckPermissions = !array_key_exists("CHECK_PERMISSIONS", $arFilter) || $arFilter["CHECK_PERMISSIONS"] !== "N";
     $bIsAdmin = is_object($USER) && $USER->IsAdmin();
     if ($bCheckPermissions && !$bIsAdmin) {
         $arSqlSearch[] = CIBlockSection::_check_rights_sql($arFilter["MIN_PERMISSION"]);
     }
     if (array_key_exists("PROPERTY", $arFilter)) {
         $val = $arFilter["PROPERTY"];
         foreach ($val as $propID => $propVAL) {
             $res = CIBlock::MkOperationFilter($propID);
             $propID = $res["FIELD"];
             $cOperationType = $res["OPERATION"];
             if ($db_prop = CIBlockProperty::GetPropertyArray($propID, CIBlock::_MergeIBArrays($arFilter["IBLOCK_ID"], $arFilter["IBLOCK_CODE"]))) {
                 $bSave = false;
                 if (array_key_exists($db_prop["ID"], $arJoinProps)) {
                     $iPropCnt = $arJoinProps[$db_prop["ID"]];
                 } elseif ($db_prop["VERSION"] != 2 || $db_prop["MULTIPLE"] == "Y") {
                     $bSave = true;
                     $iPropCnt = count($arJoinProps);
                 }
                 if (!is_array($propVAL)) {
                     $propVAL = array($propVAL);
                 }
                 if ($db_prop["PROPERTY_TYPE"] == "N" || $db_prop["PROPERTY_TYPE"] == "G" || $db_prop["PROPERTY_TYPE"] == "E") {
                     if ($db_prop["VERSION"] == 2 && $db_prop["MULTIPLE"] == "N") {
                         $r = CIBlock::FilterCreate("FPS.PROPERTY_" . $db_prop["ORIG_ID"], $propVAL, "number", $cOperationType);
                         $bJoinFlatProp = $db_prop["IBLOCK_ID"];
                     } else {
                         $r = CIBlock::FilterCreate("FPV" . $iPropCnt . ".VALUE_NUM", $propVAL, "number", $cOperationType);
                     }
                 } else {
                     if ($db_prop["VERSION"] == 2 && $db_prop["MULTIPLE"] == "N") {
                         $r = CIBlock::FilterCreate("FPS.PROPERTY_" . $db_prop["ORIG_ID"], $propVAL, "string", $cOperationType);
                         $bJoinFlatProp = $db_prop["IBLOCK_ID"];
                     } else {
                         $r = CIBlock::FilterCreate("FPV" . $iPropCnt . ".VALUE", $propVAL, "string", $cOperationType);
                     }
                 }
                 if (strlen($r) > 0) {
                     if ($bSave) {
                         $db_prop["iPropCnt"] = $iPropCnt;
                         $arJoinProps[$db_prop["ID"]] = $db_prop;
                     }
                     $arSqlSearch[] = $r;
                 }
             }
         }
     }
     $strSqlSearch = "";
     foreach ($arSqlSearch as $r) {
         if (strlen($r) > 0) {
             $strSqlSearch .= "\n\t\t\t\tAND  (" . $r . ") ";
         }
     }
     if (isset($obUserFieldsSql)) {
         $r = $obUserFieldsSql->GetFilter();
         if (strlen($r) > 0) {
             $strSqlSearch .= "\n\t\t\t\tAND (" . $r . ") ";
         }
     }
     $strProp1 = "";
     foreach ($arJoinProps as $propID => $db_prop) {
         if ($db_prop["VERSION"] == 2) {
             $strTable = "b_iblock_element_prop_m" . $db_prop["IBLOCK_ID"];
         } else {
             $strTable = "b_iblock_element_property";
         }
         $i = $db_prop["iPropCnt"];
         $strProp1 .= "\n\t\t\t\tLEFT JOIN b_iblock_property FP" . $i . " ON FP" . $i . ".IBLOCK_ID=B.ID AND\n\t\t\t\t" . (IntVal($propID) > 0 ? " FP" . $i . ".ID=" . IntVal($propID) . " " : " FP" . $i . ".CODE='" . $DB->ForSQL($propID, 200) . "' ") . "\n\t\t\t\tLEFT JOIN " . $strTable . " FPV" . $i . " ON FP" . $i . ".ID=FPV" . $i . ".IBLOCK_PROPERTY_ID AND FPV" . $i . ".IBLOCK_ELEMENT_ID=BE.ID ";
     }
     if ($bJoinFlatProp) {
         $strProp1 .= "\n\t\t\t\tLEFT JOIN b_iblock_element_prop_s" . $bJoinFlatProp . " FPS ON FPS.IBLOCK_ELEMENT_ID = BE.ID\n\t\t\t";
     }
     $arFields = array("ID" => "BS.ID", "CODE" => "BS.CODE", "XML_ID" => "BS.XML_ID", "EXTERNAL_ID" => "BS.XML_ID", "IBLOCK_ID" => "BS.IBLOCK_ID", "IBLOCK_SECTION_ID" => "BS.IBLOCK_SECTION_ID", "TIMESTAMP_X" => $DB->DateToCharFunction("BS.TIMESTAMP_X"), "TIMESTAMP_X_UNIX" => 'UNIX_TIMESTAMP(BS.TIMESTAMP_X)', "SORT" => "BS.SORT", "NAME" => "BS.NAME", "ACTIVE" => "BS.ACTIVE", "GLOBAL_ACTIVE" => "BS.GLOBAL_ACTIVE", "PICTURE" => "BS.PICTURE", "DESCRIPTION" => "BS.DESCRIPTION", "DESCRIPTION_TYPE" => "BS.DESCRIPTION_TYPE", "LEFT_MARGIN" => "BS.LEFT_MARGIN", "RIGHT_MARGIN" => "BS.RIGHT_MARGIN", "DEPTH_LEVEL" => "BS.DEPTH_LEVEL", "SEARCHABLE_CONTENT" => "BS.SEARCHABLE_CONTENT", "MODIFIED_BY" => "BS.MODIFIED_BY", "DATE_CREATE" => $DB->DateToCharFunction("BS.DATE_CREATE"), "DATE_CREATE_UNIX" => 'UNIX_TIMESTAMP(BS.DATE_CREATE)', "CREATED_BY" => "BS.CREATED_BY", "DETAIL_PICTURE" => "BS.DETAIL_PICTURE", "TMP_ID" => "BS.TMP_ID", "LIST_PAGE_URL" => "B.LIST_PAGE_URL", "SECTION_PAGE_URL" => "B.SECTION_PAGE_URL", "IBLOCK_TYPE_ID" => "B.IBLOCK_TYPE_ID", "IBLOCK_CODE" => "B.CODE", "IBLOCK_EXTERNAL_ID" => "B.XML_ID", "SOCNET_GROUP_ID" => "BS.SOCNET_GROUP_ID");
     $arSqlSelect = array();
     foreach ($arSelect as $field) {
         $field = strtoupper($field);
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:iblocksection.php

示例2: GetList


//.........这里部分代码省略.........
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cuser/index.php">Поля CUser</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cuser/getbyid.php">CUser::GetByID</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cuser/getbylogin.php">CUser::GetByLogin</a> </li> </ul></b<a
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cuser/getlist.php
  * @author Bitrix
  */
 public static function GetList(&$by, &$order, $arFilter = array(), $arParams = array())
 {
     /** @global CUserTypeManager $USER_FIELD_MANAGER */
     global $DB, $USER_FIELD_MANAGER;
     $err_mess = CUser::err_mess() . "<br>Function: GetList<br>Line: ";
     if (is_array($by)) {
         $bSingleBy = false;
         $arOrder = $by;
     } else {
         $bSingleBy = true;
         $arOrder = array($by => $order);
     }
     static $obUserFieldsSql;
     if (!isset($obUserFieldsSql)) {
         $obUserFieldsSql = new CUserTypeSQL();
         $obUserFieldsSql->SetEntity("USER", "U.ID");
         $obUserFieldsSql->obWhere->AddFields(array("F_LAST_NAME" => array("TABLE_ALIAS" => "U", "FIELD_NAME" => "U.LAST_NAME", "MULTIPLE" => "N", "FIELD_TYPE" => "string", "JOIN" => false)));
     }
     $obUserFieldsSql->SetSelect($arParams["SELECT"]);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     $arFields_m = array("ID", "ACTIVE", "LAST_LOGIN", "LOGIN", "EMAIL", "NAME", "LAST_NAME", "SECOND_NAME", "TIMESTAMP_X", "PERSONAL_BIRTHDAY", "IS_ONLINE");
     $arFields = array("DATE_REGISTER", "PERSONAL_PROFESSION", "PERSONAL_WWW", "PERSONAL_ICQ", "PERSONAL_GENDER", "PERSONAL_PHOTO", "PERSONAL_PHONE", "PERSONAL_FAX", "PERSONAL_MOBILE", "PERSONAL_PAGER", "PERSONAL_STREET", "PERSONAL_MAILBOX", "PERSONAL_CITY", "PERSONAL_STATE", "PERSONAL_ZIP", "PERSONAL_COUNTRY", "PERSONAL_NOTES", "WORK_COMPANY", "WORK_DEPARTMENT", "WORK_POSITION", "WORK_WWW", "WORK_PHONE", "WORK_FAX", "WORK_PAGER", "WORK_STREET", "WORK_MAILBOX", "WORK_CITY", "WORK_STATE", "WORK_ZIP", "WORK_COUNTRY", "WORK_PROFILE", "WORK_NOTES", "ADMIN_NOTES", "XML_ID", "LAST_NAME", "SECOND_NAME", "STORED_HASH", "CHECKWORD_TIME", "EXTERNAL_AUTH_ID", "CONFIRM_CODE", "LOGIN_ATTEMPTS", "LAST_ACTIVITY_DATE", "AUTO_TIME_ZONE", "TIME_ZONE", "TIME_ZONE_OFFSET", "PASSWORD", "CHECKWORD", "LID", "TITLE");
     $arFields_all = array_merge($arFields_m, $arFields);
     $arSelectFields = array();
     $online_interval = array_key_exists("ONLINE_INTERVAL", $arParams) && intval($arParams["ONLINE_INTERVAL"]) > 0 ? $arParams["ONLINE_INTERVAL"] : 120;
     if (isset($arParams['FIELDS']) && is_array($arParams['FIELDS']) && count($arParams['FIELDS']) > 0 && !in_array("*", $arParams['FIELDS'])) {
         foreach ($arParams['FIELDS'] as $field) {
             $field = strtoupper($field);
             if ($field == 'TIMESTAMP_X') {
                 $arSelectFields[$field] = $DB->DateToCharFunction("U.TIMESTAMP_X") . " TIMESTAMP_X";
             } elseif ($field == 'IS_ONLINE') {
                 $arSelectFields[$field] = "IF(U.LAST_ACTIVITY_DATE > DATE_SUB(NOW(), INTERVAL " . $online_interval . " SECOND), 'Y', 'N') IS_ONLINE";
             } elseif ($field == 'DATE_REGISTER') {
                 $arSelectFields[$field] = $DB->DateToCharFunction("U.DATE_REGISTER") . " DATE_REGISTER";
             } elseif ($field == 'LAST_LOGIN') {
                 $arSelectFields[$field] = $DB->DateToCharFunction("U.LAST_LOGIN") . " LAST_LOGIN";
             } elseif ($field == 'PERSONAL_BIRTHDAY') {
                 $arSelectFields[$field] = $DB->DateToCharFunction("U.PERSONAL_BIRTHDAY", "SHORT") . " PERSONAL_BIRTHDAY";
             } elseif (in_array($field, $arFields_all)) {
                 $arSelectFields[$field] = 'U.' . $field;
             }
         }
     }
     if (empty($arSelectFields)) {
         $arSelectFields[] = 'U.*';
         $arSelectFields['TIMESTAMP_X'] = $DB->DateToCharFunction("U.TIMESTAMP_X") . " TIMESTAMP_X";
         $arSelectFields['IS_ONLINE'] = "IF(U.LAST_ACTIVITY_DATE > DATE_SUB(NOW(), INTERVAL " . $online_interval . " SECOND), 'Y', 'N') IS_ONLINE";
         $arSelectFields['DATE_REGISTER'] = $DB->DateToCharFunction("U.DATE_REGISTER") . " DATE_REGISTER";
         $arSelectFields['LAST_LOGIN'] = $DB->DateToCharFunction("U.LAST_LOGIN") . " LAST_LOGIN";
         $arSelectFields['PERSONAL_BIRTHDAY'] = $DB->DateToCharFunction("U.PERSONAL_BIRTHDAY", "SHORT") . " PERSONAL_BIRTHDAY";
     }
     $arSqlSearch = array();
开发者ID:rasuldev,项目名称:torino,代码行数:67,代码来源:user.php

示例3: GetList

 public static function GetList($arOrder = array(), $arFilter = array(), $arSelect = array(), $arParams = array())
 {
     global $DB, $USER, $USER_FIELD_MANAGER;
     $bIgnoreErrors = false;
     $nPageTop = false;
     $bGetZombie = false;
     if (!is_array($arParams)) {
         $nPageTop = $arParams;
         $arParams = false;
     } else {
         if (isset($arParams['nPageTop'])) {
             $nPageTop = $arParams['nPageTop'];
         }
         if (isset($arParams['bIgnoreErrors'])) {
             $bIgnoreErrors = (bool) $arParams['bIgnoreErrors'];
         }
         if (isset($arParams['bGetZombie'])) {
             $bGetZombie = (bool) $arParams['bGetZombie'];
         }
     }
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("TASKS_TASK", "T.ID");
     $obUserFieldsSql->SetSelect($arSelect);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     if (is_array($arParams) && array_key_exists('USER_ID', $arParams) && $arParams['USER_ID'] > 0) {
         $userID = (int) $arParams['USER_ID'];
     } else {
         $userID = is_object($USER) ? intval($USER->GetID()) : 0;
     }
     $arFields = array("ID" => "T.ID", "TITLE" => "T.TITLE", "DESCRIPTION" => "T.DESCRIPTION", "DESCRIPTION_IN_BBCODE" => "T.DESCRIPTION_IN_BBCODE", "DECLINE_REASON" => "T.DECLINE_REASON", "PRIORITY" => "T.PRIORITY", "STATUS" => "\n\t\t\t\tCASE\n\t\t\t\t\tWHEN\n\t\t\t\t\t\tT.DEADLINE < " . $DB->CurrentTimeFunction() . " AND T.STATUS != '4' AND T.STATUS != '5' AND (T.STATUS != '7' OR T.RESPONSIBLE_ID != " . $userID . ")\n\t\t\t\t\tTHEN\n\t\t\t\t\t\t'-1'\n\t\t\t\t\tWHEN\n\t\t\t\t\t\tTV.USER_ID IS NULL\n\t\t\t\t\t\tAND\n\t\t\t\t\t\tT.CREATED_BY != " . $userID . "\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t(T.STATUS = 1 OR T.STATUS = 2)\n\t\t\t\t\tTHEN\n\t\t\t\t\t\t'-2'\n\t\t\t\t\tELSE\n\t\t\t\t\t\tT.STATUS\n\t\t\t\tEND\n\t\t\t", "STATUS_COMPLETE" => "\n\t\t\t\tCASE\n\t\t\t\t\tWHEN\n\t\t\t\t\t\tT.STATUS = '5'\n\t\t\t\t\tTHEN\n\t\t\t\t\t\t'2'\n\t\t\t\t\tELSE\n\t\t\t\t\t\t'1'\n\t\t\t\t\tEND\n\t\t\t", "REAL_STATUS" => "T.STATUS", "MULTITASK" => "T.MULTITASK", "RESPONSIBLE_ID" => "T.RESPONSIBLE_ID", "RESPONSIBLE_NAME" => "RU.NAME", "RESPONSIBLE_LAST_NAME" => "RU.LAST_NAME", "RESPONSIBLE_SECOND_NAME" => "RU.SECOND_NAME", "RESPONSIBLE_LOGIN" => "RU.LOGIN", "RESPONSIBLE_WORK_POSITION" => "RU.WORK_POSITION", "RESPONSIBLE_PHOTO" => "RU.PERSONAL_PHOTO", "DATE_START" => $DB->DateToCharFunction("T.DATE_START", "FULL"), "DURATION_PLAN" => "T.DURATION_PLAN", "DURATION_TYPE" => "T.DURATION_TYPE", "DURATION_FACT" => "(SELECT SUM(TE.MINUTES) FROM b_tasks_elapsed_time TE WHERE TE.TASK_ID = T.ID GROUP BY TE.TASK_ID)", "TIME_ESTIMATE" => "T.TIME_ESTIMATE", "TIME_SPENT_IN_LOGS" => "(SELECT SUM(TE.SECONDS) FROM b_tasks_elapsed_time TE WHERE TE.TASK_ID = T.ID GROUP BY TE.TASK_ID)", "REPLICATE" => "T.REPLICATE", "DEADLINE" => $DB->DateToCharFunction("T.DEADLINE", "FULL"), "DEADLINE_ORIG" => "T.DEADLINE", "START_DATE_PLAN" => $DB->DateToCharFunction("T.START_DATE_PLAN", "FULL"), "END_DATE_PLAN" => $DB->DateToCharFunction("T.END_DATE_PLAN", "FULL"), "CREATED_BY" => "T.CREATED_BY", "CREATED_BY_NAME" => "CU.NAME", "CREATED_BY_LAST_NAME" => "CU.LAST_NAME", "CREATED_BY_SECOND_NAME" => "CU.SECOND_NAME", "CREATED_BY_LOGIN" => "CU.LOGIN", "CREATED_BY_WORK_POSITION" => "CU.WORK_POSITION", "CREATED_BY_PHOTO" => "CU.PERSONAL_PHOTO", "CREATED_DATE" => $DB->DateToCharFunction("T.CREATED_DATE", "FULL"), "CHANGED_BY" => "T.CHANGED_BY", "CHANGED_DATE" => $DB->DateToCharFunction("T.CHANGED_DATE", "FULL"), "STATUS_CHANGED_BY" => "T.CHANGED_BY", "STATUS_CHANGED_DATE" => 'CASE WHEN T.STATUS_CHANGED_DATE IS NULL THEN ' . $DB->DateToCharFunction("T.CHANGED_DATE", "FULL") . ' ELSE ' . $DB->DateToCharFunction("T.STATUS_CHANGED_DATE", "FULL") . ' END ', "CLOSED_BY" => "T.CLOSED_BY", "CLOSED_DATE" => $DB->DateToCharFunction("T.CLOSED_DATE", "FULL"), 'GUID' => 'T.GUID', "XML_ID" => "T.XML_ID", "MARK" => "T.MARK", "ALLOW_CHANGE_DEADLINE" => "T.ALLOW_CHANGE_DEADLINE", 'ALLOW_TIME_TRACKING' => 'T.ALLOW_TIME_TRACKING', "TASK_CONTROL" => "T.TASK_CONTROL", "ADD_IN_REPORT" => "T.ADD_IN_REPORT", "GROUP_ID" => "CASE WHEN T.GROUP_ID IS NULL THEN 0 ELSE T.GROUP_ID END", "FORUM_TOPIC_ID" => "T.FORUM_TOPIC_ID", "PARENT_ID" => "T.PARENT_ID", "COMMENTS_COUNT" => "FT.POSTS", "FORUM_ID" => "FT.FORUM_ID", "SITE_ID" => "T.SITE_ID", "SUBORDINATE" => ($strSql = CTasks::GetSubordinateSql('', $arParams)) ? "CASE WHEN EXISTS(" . $strSql . ") THEN 'Y' ELSE 'N' END" : "'N'", "EXCHANGE_MODIFIED" => "T.EXCHANGE_MODIFIED", "EXCHANGE_ID" => "T.EXCHANGE_ID", "OUTLOOK_VERSION" => "T.OUTLOOK_VERSION", "VIEWED_DATE" => $DB->DateToCharFunction("TV.VIEWED_DATE", "FULL"), 'DEADLINE_COUNTED' => 'T.DEADLINE_COUNTED', 'FORKED_BY_TEMPLATE_ID' => 'T.FORKED_BY_TEMPLATE_ID');
     if ($bGetZombie) {
         $arFields['ZOMBIE'] = 'T.ZOMBIE';
     }
     if (count($arSelect) <= 0 || in_array("*", $arSelect)) {
         $arSelect = array_keys($arFields);
     } elseif (!in_array("ID", $arSelect)) {
         $arSelect[] = "ID";
     }
     // If DESCRIPTION selected, than BBCODE flag must be selected too
     if (in_array('DESCRIPTION', $arSelect) && !in_array('DESCRIPTION_IN_BBCODE', $arSelect)) {
         $arSelect[] = 'DESCRIPTION_IN_BBCODE';
     }
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     $arSqlOrder = array();
     foreach ($arOrder as $by => $order) {
         $needle = null;
         $by = strtolower($by);
         $order = strtolower($order);
         if ($by === 'deadline') {
             if (!in_array($order, array('asc', 'desc', 'asc,nulls', 'desc,nulls'), true)) {
                 $order = 'asc,nulls';
             }
         } else {
             if ($order !== 'asc') {
                 $order = 'desc';
             }
         }
         switch ($by) {
             case 'id':
                 $arSqlOrder[] = " ID " . $order . " ";
                 break;
             case 'title':
                 $arSqlOrder[] = " TITLE " . $order . " ";
                 $needle = 'TITLE';
                 break;
             case 'date_start':
                 $arSqlOrder[] = " T.DATE_START " . $order . " ";
                 $needle = 'DATE_START';
                 break;
             case 'created_date':
                 $arSqlOrder[] = " T.CREATED_DATE " . $order . " ";
                 $needle = 'CREATED_DATE';
                 break;
             case 'changed_date':
                 $arSqlOrder[] = " T.CHANGED_DATE " . $order . " ";
                 $needle = 'CHANGED_DATE';
                 break;
             case 'closed_date':
                 $arSqlOrder[] = " T.CLOSED_DATE " . $order . " ";
                 $needle = 'CLOSED_DATE';
                 break;
             case 'start_date_plan':
                 $arSqlOrder[] = " T.START_DATE_PLAN " . $order . " ";
                 $needle = 'START_DATE_PLAN';
                 break;
             case 'deadline':
                 $orderClause = self::getOrderSql('T.DEADLINE', $order, $default_order = 'asc,nulls', $nullable = true);
                 $needle = 'DEADLINE_ORIG';
                 if (!is_array($orderClause)) {
                     $arSqlOrder[] = $orderClause;
                 } else {
                     //         COLUMN ALIAS      COLUMN EXPRESSION
                     $arFields[$orderClause[1]] = $orderClause[0];
                     if (!in_array($orderClause[1], $arSelect)) {
                         $arSelect[] = $orderClause[1];
                     }
                     $arSqlOrder[] = $orderClause[2];
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:task.php

示例4: GetList

	function GetList($arOrder = Array("ID" => "DESC"), $arFilter = Array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
	{
		global $DB, $USER_FIELD_MANAGER, $USER;

		$obUserFieldsSql = new CUserTypeSQL;
		$obUserFieldsSql->SetEntity("BLOG_POST", "P.ID");
		$obUserFieldsSql->SetSelect($arSelectFields);
		$obUserFieldsSql->SetFilter($arFilter);
		$obUserFieldsSql->SetOrder($arOrder);

		if (isset($arFilter["DATE_PUBLISH_DAY"]) && isset($arFilter["DATE_PUBLISH_MONTH"]) && isset($arFilter["DATE_PUBLISH_YEAR"]))
		{
			if (strlen($arFilter["DATE_PUBLISH_YEAR"]) == 2)
				$arFilter["DATE_PUBLISH_YEAR"] = "20".$arFilter["DATE_PUBLISH_YEAR"];
			$date1 = mktime(0, 0, 0, $arFilter["DATE_PUBLISH_MONTH"], $arFilter["DATE_PUBLISH_DAY"], $arFilter["DATE_PUBLISH_YEAR"]);
			$date2 = mktime(0, 0, 0, $arFilter["DATE_PUBLISH_MONTH"], $arFilter["DATE_PUBLISH_DAY"] + 1, $arFilter["DATE_PUBLISH_YEAR"]);
			$arFilter[">=DATE_PUBLISH"] = ConvertTimeStamp($date1, "SHORT", SITE_ID);
			$arFilter["<DATE_PUBLISH"] = ConvertTimeStamp($date2, "SHORT", SITE_ID);

			unset($arFilter["DATE_PUBLISH_DAY"]);
			unset($arFilter["DATE_PUBLISH_MONTH"]);
			unset($arFilter["DATE_PUBLISH_YEAR"]);
		}
		elseif (isset($arFilter["DATE_PUBLISH_MONTH"]) && isset($arFilter["DATE_PUBLISH_YEAR"]))
		{
			if (strlen($arFilter["DATE_PUBLISH_YEAR"]) == 2)
				$arFilter["DATE_PUBLISH_YEAR"] = "20".$arFilter["DATE_PUBLISH_YEAR"];
			$date1 = mktime(0, 0, 0, $arFilter["DATE_PUBLISH_MONTH"], 1, $arFilter["DATE_PUBLISH_YEAR"]);
			$date2 = mktime(0, 0, 0, $arFilter["DATE_PUBLISH_MONTH"] + 1, 1, $arFilter["DATE_PUBLISH_YEAR"]);
			$arFilter[">=DATE_PUBLISH"] = ConvertTimeStamp($date1, "SHORT", SITE_ID);
			$arFilter["<DATE_PUBLISH"] = ConvertTimeStamp($date2, "SHORT", SITE_ID);

			unset($arFilter["DATE_PUBLISH_MONTH"]);
			unset($arFilter["DATE_PUBLISH_YEAR"]);
		}
		elseif (isset($arFilter["DATE_PUBLISH_YEAR"]))
		{
			if (strlen($arFilter["DATE_PUBLISH_YEAR"]) == 2)
				$arFilter["DATE_PUBLISH_YEAR"] = "20".$arFilter["DATE_PUBLISH_YEAR"];
			$date1 = mktime(0, 0, 0, 1, 1, $arFilter["DATE_PUBLISH_YEAR"]);
			$date2 = mktime(0, 0, 0, 1, 1, $arFilter["DATE_PUBLISH_YEAR"] + 1);
			$arFilter[">=DATE_PUBLISH"] = ConvertTimeStamp($date1, "SHORT", SITE_ID);
			$arFilter["<DATE_PUBLISH"] = ConvertTimeStamp($date2, "SHORT", SITE_ID);

			unset($arFilter["DATE_PUBLISH_YEAR"]);
		}

		if (count($arSelectFields) <= 0)
			$arSelectFields = array("ID", "TITLE", "BLOG_ID", "AUTHOR_ID", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "DATE_CREATE", "DATE_PUBLISH", "KEYWORDS", "PUBLISH_STATUS", "ATRIBUTE", "ATTACH_IMG", "ENABLE_TRACKBACK", "ENABLE_COMMENTS", "VIEWS", "NUM_COMMENTS", "CODE", "MICRO");
		if(in_array("*", $arSelectFields))
			$arSelectFields = array("ID", "TITLE", "BLOG_ID", "AUTHOR_ID", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "DATE_CREATE", "DATE_PUBLISH", "KEYWORDS", "PUBLISH_STATUS", "ATRIBUTE", "ATTACH_IMG", "ENABLE_TRACKBACK", "ENABLE_COMMENTS", "NUM_COMMENTS", "NUM_TRACKBACKS", "VIEWS", "FAVORITE_SORT", "CATEGORY_ID", "PERMS", "AUTHOR_LOGIN", "AUTHOR_NAME", "AUTHOR_LAST_NAME", "AUTHOR_SECOND_NAME", "AUTHOR_EMAIL", "AUTHOR", "BLOG_USER_ALIAS", "BLOG_USER_AVATAR", "BLOG_URL", "BLOG_OWNER_ID", "BLOG_ACTIVE", "BLOG_GROUP_ID", "BLOG_GROUP_SITE_ID", "BLOG_SOCNET_GROUP_ID", "BLOG_ENABLE_RSS", "BLOG_USE_SOCNET", "CODE", "MICRO");

		if((array_key_exists("BLOG_GROUP_SITE_ID", $arFilter) || in_array("BLOG_GROUP_SITE_ID", $arSelectFields)) && !in_array("BLOG_URL", $arSelectFields))
			$arSelectFields[] = "BLOG_URL";

		// FIELDS -->
		$arFields = array(
			"ID" => array("FIELD" => "P.ID", "TYPE" => "int"),
			"TITLE" => array("FIELD" => "P.TITLE", "TYPE" => "string"),
			"CODE" => array("FIELD" => "P.CODE", "TYPE" => "string"),
			"BLOG_ID" => array("FIELD" => "P.BLOG_ID", "TYPE" => "int"),
			"AUTHOR_ID" => array("FIELD" => "P.AUTHOR_ID", "TYPE" => "int"),
			"PREVIEW_TEXT" => array("FIELD" => "P.PREVIEW_TEXT", "TYPE" => "string"),
			"PREVIEW_TEXT_TYPE" => array("FIELD" => "P.PREVIEW_TEXT_TYPE", "TYPE" => "string"),
			"DETAIL_TEXT" => array("FIELD" => "P.DETAIL_TEXT", "TYPE" => "string"),
			"DETAIL_TEXT_TYPE" => array("FIELD" => "P.DETAIL_TEXT_TYPE", "TYPE" => "string"),
			"DATE_CREATE" => array("FIELD" => "P.DATE_CREATE", "TYPE" => "datetime"),
			"DATE_PUBLISH" => array("FIELD" => "P.DATE_PUBLISH", "TYPE" => "datetime"),
			"KEYWORDS" => array("FIELD" => "P.KEYWORDS", "TYPE" => "string"),
			"PUBLISH_STATUS" => array("FIELD" => "P.PUBLISH_STATUS", "TYPE" => "string"),
			"ATRIBUTE" => array("FIELD" => "P.ATRIBUTE", "TYPE" => "string"),
			"ATTACH_IMG" => array("FIELD" => "P.ATTACH_IMG", "TYPE" => "int"),
			"ENABLE_TRACKBACK" => array("FIELD" => "P.ENABLE_TRACKBACK", "TYPE" => "string"),
			"ENABLE_COMMENTS" => array("FIELD" => "P.ENABLE_COMMENTS", "TYPE" => "string"),
			"NUM_COMMENTS" => array("FIELD" => "P.NUM_COMMENTS", "TYPE" => "int"),
			"NUM_TRACKBACKS" => array("FIELD" => "P.NUM_TRACKBACKS", "TYPE" => "int"),
			"VIEWS" => array("FIELD" => "P.VIEWS", "TYPE" => "int"),
			"FAVORITE_SORT" => array("FIELD" => "P.FAVORITE_SORT", "TYPE" => "int"),
			"CATEGORY_ID" => array("FIELD" => "P.CATEGORY_ID", "TYPE" => "string"),
			"PATH" => array("FIELD" => "P.PATH", "TYPE" => "string"),
			"MICRO" => array("FIELD" => "P.MICRO", "TYPE" => "string"),
			"HAS_IMAGES" => array("FIELD" => "P.HAS_IMAGES", "TYPE" => "string"),
			"HAS_PROPS" => array("FIELD" => "P.HAS_PROPS", "TYPE" => "string"),
			"HAS_TAGS" => array("FIELD" => "P.HAS_TAGS", "TYPE" => "string"),
			"HAS_COMMENT_IMAGES" => array("FIELD" => "P.HAS_COMMENT_IMAGES", "TYPE" => "string"),
			"HAS_SOCNET_ALL" => array("FIELD" => "P.HAS_SOCNET_ALL", "TYPE" => "string"),
			"SEO_TITLE" => array("FIELD" => "P.SEO_TITLE", "TYPE" => "string"),
			"SEO_TAGS" => array("FIELD" => "P.SEO_TAGS", "TYPE" => "string"),
			"SEO_DESCRIPTION" => array("FIELD" => "P.SEO_DESCRIPTION", "TYPE" => "string"),

			"PERMS" => array(),

			"AUTHOR_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
			"AUTHOR_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
			"AUTHOR_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
			"AUTHOR_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
			"AUTHOR_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),
			"AUTHOR" => array("FIELD" => "U.LOGIN, U.NAME, U.LAST_NAME, U.EMAIL, U.ID", "WHERE_ONLY" => "Y", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (P.AUTHOR_ID = U.ID)"),

			"CATEGORY_NAME" => array("FIELD" => "PCN.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_category PCN ON (P.CATEGORY_ID = PCN.ID)"),
//.........这里部分代码省略.........
开发者ID:akniyev,项目名称:arteva.ru,代码行数:101,代码来源:blog_post.php

示例5: Prepare

 public function Prepare($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arOptions = array())
 {
     global $DB;
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     // ID must present in select (If select is empty it will be filled by CSqlUtil::PrepareSql)
     if (!is_array($arSelectFields)) {
         $arSelectFields = array();
     }
     if (count($arSelectFields) > 0 && !in_array('*', $arSelectFields, true) && !in_array('ID', $arSelectFields, true)) {
         $arSelectFields[] = 'ID';
     }
     if (!is_array($arOptions)) {
         $arOptions = array();
     }
     $arOptions['DB_TYPE'] = $this->dbType;
     $isExternalContext = isset($arOptions['IS_EXTERNAL_CONTEXT']) && ($arOptions['IS_EXTERNAL_CONTEXT'] === true || $arOptions['IS_EXTERNAL_CONTEXT'] === 'Y');
     if ($isExternalContext) {
         // Sanitizing of filter data
         if (isset($arFilter['__JOINS'])) {
             unset($arFilter['__JOINS']);
         }
         if (isset($arFilter['CHECK_PERMISSIONS'])) {
             unset($arFilter['CHECK_PERMISSIONS']);
         }
     }
     // Processing of special fields
     if ($this->fmEntityID !== '' && isset($arFilter['FM'])) {
         CCrmFieldMulti::PrepareExternalFilter($arFilter, array('ENTITY_ID' => $this->fmEntityID, 'MASTER_ALIAS' => $this->tableAlias, 'MASTER_IDENTITY' => 'ID'));
     }
     // Processing user fields
     $ufSelectSql = null;
     $ufFilterSql = null;
     if ($this->ufEntityID !== '') {
         $ufSelectSql = new CUserTypeSQL();
         $ufSelectSql->SetEntity($this->ufEntityID, $this->tableAlias . '.ID');
         $ufSelectSql->SetSelect($arSelectFields);
         $ufSelectSql->SetOrder($arOrder);
         $ufFilterSql = new CUserTypeSQL();
         $ufFilterSql->SetEntity($this->ufEntityID, $this->tableAlias . '.ID');
         $ufFilterSql->SetFilter($arFilter);
         $userType = new CCrmUserType($GLOBALS['USER_FIELD_MANAGER'], $this->ufEntityID);
         $userType->ListPrepareFilter($arFilter);
     }
     $this->sqlData = CSqlUtil::PrepareSql($this->fields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $arOptions);
     $this->sqlData['SELECT'] = str_replace('%%_DISTINCT_%% ', '', $this->sqlData['SELECT']);
     // 'Joins' implement custom filter logic
     $joins = array();
     if (isset($arFilter['__JOINS'])) {
         if (is_array($arFilter['__JOINS'])) {
             $joins = $arFilter['__JOINS'];
         }
         unset($arFilter['__JOINS']);
     }
     if (count($joins) > 0) {
         foreach ($joins as &$join) {
             // INNER JOINs will be added tostart
             $this->Add2SqlData($join['SQL'], 'FROM', !isset($join['TYPE']) || $join['TYPE'] === 'INNER', isset($join['REPLACE']) ? $join['REPLACE'] : '');
         }
         unset($join);
     }
     // Apply user permission logic
     if (count($this->permissionCallback) > 0) {
         if ((!array_key_exists('CHECK_PERMISSIONS', $arFilter) || $arFilter['CHECK_PERMISSIONS'] !== 'N') && !CCrmPerms::IsAdmin()) {
             $arPermType = !isset($arFilter['PERMISSION']) ? 'READ' : (is_array($arFilter['PERMISSION']) ? $arFilter['PERMISSION'] : array($arFilter['PERMISSION']));
             $permissionSql = call_user_func_array($this->permissionCallback, array($this->tableAlias, $arPermType, $arOptions));
             if (is_bool($permissionSql) && !$permissionSql) {
                 $CDBResult = new CDBResult();
                 $CDBResult->InitFromArray(array());
                 return $CDBResult;
             }
             if ($permissionSql !== '') {
                 $sqlType = isset($arOptions['PERMISSION_SQL_TYPE']) && $arOptions['PERMISSION_SQL_TYPE'] === 'FROM' ? 'FROM' : 'WHERE';
                 $this->Add2SqlData($permissionSql, $sqlType, $sqlType === 'FROM');
             }
         }
     }
     // Apply custom SQL logic
     if (count($this->afterPrepareSqlCallback) > 0) {
         $arUserSql = call_user_func_array($this->afterPrepareSqlCallback, array($this, $arOrder, $arFilter, $arGroupBy, $arSelectFields));
         if (is_array($arUserSql)) {
             if (isset($arUserSql['FROM'])) {
                 $this->Add2SqlData($arUserSql['FROM'], 'FROM');
             }
             if (isset($arUserSql['WHERE'])) {
                 $this->Add2SqlData($arUserSql['WHERE'], 'WHERE');
             }
         }
     }
     if ($ufSelectSql) {
         // Adding user fields to SELECT
         $this->Add2SqlData($ufSelectSql->GetSelect(), 'SELECT');
         // Adding user fields to ORDER BY
         if (is_array($arOrder)) {
             foreach ($arOrder as $orderKey => $order) {
                 $orderSql = $ufSelectSql->GetOrder($orderKey);
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:crm_entity_list_builder.php

示例6: GetList

	function GetList($arOrder = Array("ID" => "DESC"), $arFilter = Array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arParams = array())
	{
		global $DB, $arSocNetAllowedEntityTypes, $USER, $USER_FIELD_MANAGER;

		$arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();

		$obUserFieldsSql = new CUserTypeSQL;
		$obUserFieldsSql->SetEntity("SONET_COMMENT", "LC.ID");
		$obUserFieldsSql->SetSelect($arSelectFields);
		$obUserFieldsSql->SetFilter($arFilter);
		$obUserFieldsSql->SetOrder($arOrder);

		if (count($arSelectFields) <= 0)
			$arSelectFields = array(
				"ID", "LOG_ID", "SOURCE_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "LOG_DATE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID",
				"GROUP_NAME", "GROUP_OWNER_ID", "GROUP_VISIBLE", "GROUP_OPENED", "GROUP_IMAGE_ID",
				"USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER",
				"CREATED_BY_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LOGIN", "CREATED_BY_PERSONAL_PHOTO", "CREATED_BY_PERSONAL_GENDER",
				"LOG_SITE_ID", "LOG_SOURCE_ID", "LOG_USER_ID",
				"RATING_TYPE_ID", "RATING_ENTITY_ID", "RATING_TOTAL_VALUE", "RATING_TOTAL_VOTES", "RATING_TOTAL_POSITIVE_VOTES", "RATING_TOTAL_NEGATIVE_VOTES", "RATING_USER_VOTE_VALUE"
			);

		static $arFields1 = array(
			"ID" => Array("FIELD" => "LC.ID", "TYPE" => "int"),
			"LOG_ID" => Array("FIELD" => "LC.LOG_ID", "TYPE" => "int"),
			"SOURCE_ID" => Array("FIELD" => "LC.SOURCE_ID", "TYPE" => "int"),
			"ENTITY_TYPE" => Array("FIELD" => "LC.ENTITY_TYPE", "TYPE" => "string"),
			"ENTITY_ID" => Array("FIELD" => "LC.ENTITY_ID", "TYPE" => "int"),
			"USER_ID" => Array("FIELD" => "LC.USER_ID", "TYPE" => "int"),
			"EVENT_ID" => Array("FIELD" => "LC.EVENT_ID", "TYPE" => "string"),
			"LOG_DATE" => Array("FIELD" => "LC.LOG_DATE", "TYPE" => "datetime"),
			"LOG_DATE_TS" => Array("FIELD" => "UNIX_TIMESTAMP(LC.LOG_DATE)", "TYPE" => "int"),
			"TITLE" => Array("FIELD" => "LC.TITLE", "TYPE" => "string"),
			"MESSAGE" => Array("FIELD" => "LC.MESSAGE", "TYPE" => "string"),
			"TEXT_MESSAGE" => Array("FIELD" => "LC.TEXT_MESSAGE", "TYPE" => "string"),
			"URL" => Array("FIELD" => "LC.URL", "TYPE" => "string"),
			"MODULE_ID" => Array("FIELD" => "LC.MODULE_ID", "TYPE" => "string"),
			"LOG_SOURCE_ID" => Array("FIELD" => "L.SOURCE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_log L ON (LC.LOG_ID = L.ID)"),
			"LOG_USER_ID" => Array("FIELD" => "L.USER_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_log L ON (LC.LOG_ID = L.ID)"),
			"LOG_TITLE" => Array("FIELD" => "L1.TITLE", "TYPE" => "string", "FROM" => "INNER JOIN b_sonet_log L1 ON (LC.LOG_ID = L1.ID)"),
			"LOG_URL" => Array("FIELD" => "L1.URL", "TYPE" => "string", "FROM" => "INNER JOIN b_sonet_log L1 ON (LC.LOG_ID = L1.ID)"),
			"LOG_PARAMS" => Array("FIELD" => "L1.PARAMS", "TYPE" => "string", "FROM" => "INNER JOIN b_sonet_log L1 ON (LC.LOG_ID = L1.ID)"),
			"GROUP_NAME" => Array("FIELD" => "G.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (LC.ENTITY_TYPE = 'G' AND LC.ENTITY_ID = G.ID)"),
			"GROUP_OWNER_ID" => Array("FIELD" => "G.OWNER_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (LC.ENTITY_TYPE = 'G' AND LC.ENTITY_ID = G.ID)"),
			"GROUP_VISIBLE" => Array("FIELD" => "G.VISIBLE", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (LC.ENTITY_TYPE = 'G' AND LC.ENTITY_ID = G.ID)"),
			"GROUP_OPENED" => Array("FIELD" => "G.OPENED", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (LC.ENTITY_TYPE = 'G' AND LC.ENTITY_ID = G.ID)"),
			"GROUP_IMAGE_ID" => Array("FIELD" => "G.IMAGE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (LC.ENTITY_TYPE = 'G' AND LC.ENTITY_ID = G.ID)"),
			"USER_NAME" => Array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (LC.ENTITY_TYPE = 'U' AND LC.ENTITY_ID = U.ID)"),
			"USER_LAST_NAME" => Array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (LC.ENTITY_TYPE = 'U' AND LC.ENTITY_ID = U.ID)"),
			"USER_SECOND_NAME" => Array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (LC.ENTITY_TYPE = 'U' AND LC.ENTITY_ID = U.ID)"),
			"USER_LOGIN" => Array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (LC.ENTITY_TYPE = 'U' AND LC.ENTITY_ID = U.ID)"),
			"USER_PERSONAL_PHOTO" => Array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U ON (LC.ENTITY_TYPE = 'U' AND LC.ENTITY_ID = U.ID)"),
			"USER_PERSONAL_GENDER" => Array("FIELD" => "U.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (LC.ENTITY_TYPE = 'U' AND LC.ENTITY_ID = U.ID)"),
			"CREATED_BY_NAME" => Array("FIELD" => "U1.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON LC.USER_ID = U1.ID"),
			"CREATED_BY_LAST_NAME" => Array("FIELD" => "U1.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON LC.USER_ID = U1.ID"),
			"CREATED_BY_SECOND_NAME" => Array("FIELD" => "U1.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON LC.USER_ID = U1.ID"),
			"CREATED_BY_LOGIN" => Array("FIELD" => "U1.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON LC.USER_ID = U1.ID"),
			"CREATED_BY_PERSONAL_PHOTO" => Array("FIELD" => "U1.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U1 ON LC.USER_ID = U1.ID"),
			"CREATED_BY_PERSONAL_GENDER" => Array("FIELD" => "U1.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON LC.USER_ID = U1.ID"),
		);

		if (array_key_exists("LOG_SITE_ID", $arFilter))
		{
			$arFields["LOG_SITE_ID"] = Array("FIELD" => "SLS.SITE_ID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_site SLS ON LC.LOG_ID = SLS.LOG_ID");
			$strDistinct = " DISTINCT ";
			foreach ($arSelectFields as $i => $strFieldTmp)
				if ($strFieldTmp == "LOG_SITE_ID")
					unset($arSelectFields[$i]);

			foreach ($arOrder as $by => $order)
				if (!in_array($by, $arSelectFields))
					$arSelectFields[] = $by;
		}
		else
		{
			$arFields["LOG_SITE_ID"] = Array("FIELD" => "L.SITE_ID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log L ON (LC.LOG_ID = L.ID)");
			$strDistinct = " ";
		}

		$arFields["RATING_TYPE_ID"] = Array("FIELD" => "LC.RATING_TYPE_ID", "TYPE" => "string");
		$arFields["RATING_ENTITY_ID"] = Array("FIELD" => "LC.RATING_ENTITY_ID", "TYPE" => "int");
		$arFields["RATING_TOTAL_VALUE"] = Array("FIELD" => $DB->IsNull('RG.TOTAL_VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON LC.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND LC.RATING_ENTITY_ID = RG.ENTITY_ID");
		$arFields["RATING_TOTAL_VOTES"] = Array("FIELD" => $DB->IsNull('RG.TOTAL_VOTES', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON LC.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND LC.RATING_ENTITY_ID = RG.ENTITY_ID");
		$arFields["RATING_TOTAL_POSITIVE_VOTES"] = Array("FIELD" => $DB->IsNull('RG.TOTAL_POSITIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON LC.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND LC.RATING_ENTITY_ID = RG.ENTITY_ID");
		$arFields["RATING_TOTAL_NEGATIVE_VOTES"] = Array("FIELD" => $DB->IsNull('RG.TOTAL_NEGATIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON LC.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND LC.RATING_ENTITY_ID = RG.ENTITY_ID");
		if (isset($USER) && is_object($USER))
			$arFields["RATING_USER_VOTE_VALUE"] = Array("FIELD" => $DB->IsNull('RV.VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_vote RV ON LC.RATING_TYPE_ID = RV.ENTITY_TYPE_ID AND LC.RATING_ENTITY_ID = RV.ENTITY_ID AND RV.USER_ID = ".intval($USER->GetId()));

		if (array_key_exists("LOG_RIGHTS", $arFilter))
		{
			$Rights = array();
			if(is_array($arFilter["LOG_RIGHTS"]))
			{
				foreach($arFilter["LOG_RIGHTS"] as $str)
					if(trim($str))
						$Rights[] = trim($str);
			}
			elseif(trim($arFilter["LOG_RIGHTS"]))
				$Rights = trim($arFilter["LOG_RIGHTS"]);

//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:101,代码来源:log_comments.php

示例7: GetList

 function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arParams = array())
 {
     global $DB, $arSocNetAllowedEntityTypes, $USER, $USER_FIELD_MANAGER;
     $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("SONET_LOG", "L.ID");
     $obUserFieldsSql->SetSelect($arSelectFields);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "TMP_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "LOG_DATE", "LOG_UPDATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "EXTERNAL_ID", "SITE_ID", "PARAMS", "COMMENTS_COUNT", "ENABLE_COMMENTS", "SOURCE_ID", "GROUP_NAME", "GROUP_OWNER_ID", "GROUP_INITIATE_PERMS", "GROUP_VISIBLE", "GROUP_OPENED", "GROUP_IMAGE_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER", "CREATED_BY_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LOGIN", "CREATED_BY_PERSONAL_PHOTO", "CREATED_BY_PERSONAL_GENDER", "RATING_TYPE_ID", "RATING_ENTITY_ID", "RATING_TOTAL_VALUE", "RATING_TOTAL_VOTES", "RATING_TOTAL_POSITIVE_VOTES", "RATING_TOTAL_NEGATIVE_VOTES", "RATING_USER_VOTE_VALUE", "SOURCE_TYPE");
         if (!isset($arParams["USE_FAVORITES"]) || $arParams["USE_FAVORITES"] != "N") {
             $arSelectFields[] = "FAVORITES_USER_ID";
         }
     }
     static $arFields1 = array("ID" => array("FIELD" => "L.ID", "TYPE" => "int"), "TMP_ID" => array("FIELD" => "L.TMP_ID", "TYPE" => "int"), "SOURCE_ID" => array("FIELD" => "L.SOURCE_ID", "TYPE" => "int"), "ENTITY_TYPE" => array("FIELD" => "L.ENTITY_TYPE", "TYPE" => "string"), "ENTITY_ID" => array("FIELD" => "L.ENTITY_ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "L.USER_ID", "TYPE" => "int"), "EVENT_ID" => array("FIELD" => "L.EVENT_ID", "TYPE" => "string"), "LOG_DATE" => array("FIELD" => "L.LOG_DATE", "TYPE" => "datetime"), "LOG_DATE_TS" => array("FIELD" => "UNIX_TIMESTAMP(L.LOG_DATE)", "TYPE" => "int"), "LOG_UPDATE" => array("FIELD" => "L.LOG_UPDATE", "TYPE" => "datetime"), "TITLE_TEMPLATE" => array("FIELD" => "L.TITLE_TEMPLATE", "TYPE" => "string"), "TITLE" => array("FIELD" => "L.TITLE", "TYPE" => "string"), "MESSAGE" => array("FIELD" => "L.MESSAGE", "TYPE" => "string"), "TEXT_MESSAGE" => array("FIELD" => "L.TEXT_MESSAGE", "TYPE" => "string"), "URL" => array("FIELD" => "L.URL", "TYPE" => "string"), "MODULE_ID" => array("FIELD" => "L.MODULE_ID", "TYPE" => "string"), "CALLBACK_FUNC" => array("FIELD" => "L.CALLBACK_FUNC", "TYPE" => "string"), "EXTERNAL_ID" => array("FIELD" => "L.EXTERNAL_ID", "TYPE" => "string"), "PARAMS" => array("FIELD" => "L.PARAMS", "TYPE" => "string"), "COMMENTS_COUNT" => array("FIELD" => "L.COMMENTS_COUNT", "TYPE" => "int"), "ENABLE_COMMENTS" => array("FIELD" => "L.ENABLE_COMMENTS", "TYPE" => "string"), "SOURCE_TYPE" => array("FIELD" => "L.SOURCE_TYPE", "TYPE" => "string"), "GROUP_NAME" => array("FIELD" => "G.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_OWNER_ID" => array("FIELD" => "G.OWNER_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_INITIATE_PERMS" => array("FIELD" => "G.INITIATE_PERMS", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_VISIBLE" => array("FIELD" => "G.VISIBLE", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_OPENED" => array("FIELD" => "G.OPENED", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "GROUP_IMAGE_ID" => array("FIELD" => "G.IMAGE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sonet_group G ON (L.ENTITY_TYPE = 'G' AND L.ENTITY_ID = G.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_PERSONAL_PHOTO" => array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "USER_PERSONAL_GENDER" => array("FIELD" => "U.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (L.ENTITY_TYPE = 'U' AND L.ENTITY_ID = U.ID)"), "CREATED_BY_NAME" => array("FIELD" => "U1.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_LAST_NAME" => array("FIELD" => "U1.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_SECOND_NAME" => array("FIELD" => "U1.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_LOGIN" => array("FIELD" => "U1.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_PERSONAL_PHOTO" => array("FIELD" => "U1.PERSONAL_PHOTO", "TYPE" => "int", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "CREATED_BY_PERSONAL_GENDER" => array("FIELD" => "U1.PERSONAL_GENDER", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U1 ON L.USER_ID = U1.ID"), "USER_ID|COMMENT_USER_ID" => array("FIELD" => "L.USER_ID|LC.USER_ID", "WHERE" => array("CSocNetLog", "GetSimpleOrQuery"), "FROM" => "LEFT JOIN b_sonet_log_comment LC ON LC.LOG_ID = L.ID"));
     $arFields = array("RATING_TYPE_ID" => array("FIELD" => "L.RATING_TYPE_ID", "TYPE" => "string"), "RATING_ENTITY_ID" => array("FIELD" => "L.RATING_ENTITY_ID", "TYPE" => "int"), "RATING_TOTAL_VALUE" => array("FIELD" => $DB->IsNull('RG.TOTAL_VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_VOTES', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_POSITIVE_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_POSITIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"), "RATING_TOTAL_NEGATIVE_VOTES" => array("FIELD" => $DB->IsNull('RG.TOTAL_NEGATIVE_VOTES', '0'), "TYPE" => "int", "FROM" => "LEFT JOIN b_rating_voting RG ON L.RATING_TYPE_ID = RG.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RG.ENTITY_ID"));
     if (isset($USER) && is_object($USER)) {
         $arFields["RATING_USER_VOTE_VALUE"] = array("FIELD" => $DB->IsNull('RV.VALUE', '0'), "TYPE" => "double", "FROM" => "LEFT JOIN b_rating_vote RV ON L.RATING_TYPE_ID = RV.ENTITY_TYPE_ID AND L.RATING_ENTITY_ID = RV.ENTITY_ID AND RV.USER_ID = " . intval($USER->GetID()));
         if (!isset($arParams["USE_FAVORITES"]) || $arParams["USE_FAVORITES"] != "N") {
             $join_type = "LEFT";
             $field_value = $DB->IsNull("SLF.USER_ID", "0");
             foreach ($arFilter as $key => $value) {
                 if (strpos($key, "FAVORITES_USER_ID") !== false) {
                     $join_type = "INNER";
                     $field_value = "SLF.USER_ID";
                     break;
                 }
             }
             $arFields["FAVORITES_USER_ID"] = array("FIELD" => $field_value, "TYPE" => "double", "FROM" => $join_type . " JOIN b_sonet_log_favorites SLF ON L.ID = SLF.LOG_ID AND SLF.USER_ID = " . intval($USER->GetID()));
         }
     }
     if (isset($USER) && is_object($USER) && $USER->IsAuthorized() && $arParams["USE_FOLLOW"] == "Y") {
         $default_follow = CSocNetLogFollow::GetDefaultValue($USER->GetID());
         $default_field = $default_follow == "Y" ? "LOG_UPDATE" : "LOG_DATE";
         $arFields["DATE_FOLLOW"] = array("FIELD" => "CASE\n\t\t\t\t\tWHEN LFW.USER_ID IS NULL\n\t\t\t\t\t\tTHEN L." . $default_field . "\n\t\t\t\t\tWHEN LFW.FOLLOW_DATE IS NOT NULL\n\t\t\t\t\t\tTHEN LFW.FOLLOW_DATE\n\t\t\t\t\tWHEN LFW.TYPE = 'Y'\n\t\t\t\t\t\tTHEN L.LOG_UPDATE\n\t\t\t\t\tELSE L.LOG_DATE\n\t\t\t\tEND", "TYPE" => "datetime", "FROM" => "LEFT JOIN b_sonet_log_follow LFW ON LFW.USER_ID = " . $USER->GetID() . " AND LFW.REF_ID = L.ID AND LFW.CODE = " . $DB->Concat("'L'", "L.ID"));
         $arFields["FOLLOW"] = array("FIELD" => "CASE\n\t\t\t\t\tWHEN LFW.USER_ID IS NULL\n\t\t\t\t\t\tTHEN '" . $default_follow . "'\n\t\t\t\t\tELSE LFW.TYPE\n\t\t\t\tEND", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_follow LFW ON LFW.USER_ID = " . $USER->GetID() . " AND LFW.REF_ID = L.ID AND LFW.CODE = " . $DB->Concat("'L'", "L.ID"));
         if (!in_array("FOLLOW", $arSelectFields)) {
             $arSelectFields[] = "FOLLOW";
         }
     }
     if (array_key_exists("SITE_ID", $arFilter)) {
         $arFields["SITE_ID"] = array("FIELD" => "SLS.SITE_ID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sonet_log_site SLS ON L.ID = SLS.LOG_ID");
         if (is_array($arFilter["SITE_ID"])) {
             $site_cnt = 0;
             foreach ($arFilter["SITE_ID"] as $site_id_tmp) {
                 if ($site_id_tmp) {
                     $site_cnt++;
                 }
             }
             $strDistinct = $site_cnt > 1 ? " DISTINCT " : " ";
         } else {
             $strDistinct = " ";
         }
         foreach ($arSelectFields as $i => $strFieldTmp) {
             if ($strFieldTmp == "SITE_ID") {
                 unset($arSelectFields[$i]);
             }
         }
         foreach ($arOrder as $by => $order) {
             if (!in_array($by, $arSelectFields)) {
                 $arSelectFields[] = $by;
             }
         }
     } else {
         $arFields["SITE_ID"] = array("FIELD" => "L.SITE_ID", "TYPE" => "string");
         $strDistinct = " ";
     }
     if (array_key_exists("USER_ID", $arFilter) && !array_key_exists("ENTITY_TYPE", $arFilter)) {
         $arCBFilterEntityType = array();
         foreach ($arSocNetAllowedSubscribeEntityTypesDesc as $entity_type_tmp => $arEntityTypeTmp) {
             if (array_key_exists("USE_CB_FILTER", $arEntityTypeTmp) && $arEntityTypeTmp["USE_CB_FILTER"] == "Y") {
                 $arCBFilterEntityType[] = $entity_type_tmp;
             }
         }
         if (is_array($arCBFilterEntityType) && count($arCBFilterEntityType) > 0) {
             $arFilter["ENTITY_TYPE"] = $arCBFilterEntityType;
         }
     }
     if (array_key_exists("LOG_RIGHTS", $arFilter)) {
         $Rights = array();
         if (is_array($arFilter["LOG_RIGHTS"])) {
             foreach ($arFilter["LOG_RIGHTS"] as $str) {
                 if (trim($str)) {
                     $Rights[] = trim($str);
                 }
             }
         } elseif (trim($arFilter["LOG_RIGHTS"])) {
             $Rights = trim($arFilter["LOG_RIGHTS"]);
         }
         unset($arFilter["LOG_RIGHTS"]);
         if (is_array($Rights) && !empty($Rights) || !is_array($Rights)) {
             $arFilter["LOG_RIGHTS"] = $Rights;
             $arFields["LOG_RIGHTS"] = array("FIELD" => "SLR0.GROUP_CODE", "TYPE" => "string", "FROM" => "INNER JOIN b_sonet_log_right SLR0 ON L.ID = SLR0.LOG_ID");
         }
         if (is_array($Rights) && count($Rights) > 1) {
             $strDistinct = " DISTINCT ";
         }
     }
     if (array_key_exists("USER_ID|COMMENT_USER_ID", $arFilter)) {
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:log.php

示例8: getList

 /**
  * Get list of existing learning groups
  * 
  * @param array $arOrder
  * @param array $arFilter
  * @param array $arSelect
  * @param array $arNavParams
  * 
  * @return CDBResult
  */
 public static function getList($arOrder, $arFilter, $arSelect = array(), $arNavParams = array())
 {
     global $DB, $USER, $USER_FIELD_MANAGER;
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("LEARNING_LGROUPS", "LG.ID");
     $obUserFieldsSql->SetSelect($arSelect);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     $arFields = array('ID' => 'LG.ID', 'TITLE' => 'LG.TITLE', 'ACTIVE' => 'LG.ACTIVE', 'CODE' => 'LG.CODE', 'SORT' => 'LG.SORT', 'ACTIVE_FROM' => $DB->DateToCharFunction('LG.ACTIVE_FROM', 'FULL'), 'ACTIVE_TO' => $DB->DateToCharFunction('LG.ACTIVE_TO', 'FULL'), 'COURSE_LESSON_ID' => 'LG.COURSE_LESSON_ID', 'COURSE_TITLE' => 'LL.NAME', 'MEMBER_ID' => 'LGM.USER_ID');
     $arFieldsSort = $arFields;
     $arFieldsSort["ACTIVE_FROM"] = "LG.ACTIVE_FROM";
     $arFieldsSort["ACTIVE_TO"] = "LG.ACTIVE_TO";
     if (count($arSelect) <= 0 || in_array("*", $arSelect)) {
         $arSelect = array_diff(array_keys($arFields), array('MEMBER_ID'));
     } elseif (!in_array("ID", $arSelect)) {
         $arSelect[] = "ID";
     }
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     foreach ($arOrder as $by => $order) {
         $by = (string) $by;
         $byUppercase = strtoupper($by);
         $needle = null;
         $order = strtolower($order);
         if ($order != "asc") {
             $order = "desc";
         }
         if (array_key_exists($byUppercase, $arFieldsSort)) {
             $arSqlOrder[] = ' ' . $arFieldsSort[$byUppercase] . ' ' . $order . ' ';
             $needle = $byUppercase;
         } elseif ($s = $obUserFieldsSql->getOrder(strtolower($by))) {
             $arSqlOrder[] = ' ' . $s . ' ' . $order . ' ';
         }
         if ($needle !== null && !in_array($needle, $arSelect, true)) {
             $arSelect[] = $needle;
         }
     }
     if (isset($arFilter['MEMBER_ID']) && !in_array('MEMBER_ID', $arSelect, true)) {
         $arSelect[] = 'MEMBER_ID';
     }
     $arSqlSelect = array();
     foreach ($arSelect as $field) {
         $field = strtoupper($field);
         if (array_key_exists($field, $arFields)) {
             $arSqlSelect[$field] = $arFields[$field] . ' AS ' . $field;
         }
     }
     if (!sizeof($arSqlSelect)) {
         $arSqlSelect = 'LG.ID AS ID';
     }
     $arSqlSearch = self::getFilter($arFilter);
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $arSqlSearch[] = "(" . $r . ")";
     }
     $strSql = "\n\t\t\tSELECT\n\t\t\t\t" . implode(",\n", $arSqlSelect) . "\n\t\t\t\t" . $obUserFieldsSql->GetSelect();
     $strFrom = "\n\t\t\tFROM\n\t\t\t\tb_learn_groups LG\n\t\t\t\t";
     if (in_array('COURSE_TITLE', $arSelect, true)) {
         $strFrom .= "LEFT OUTER JOIN b_learn_lesson LL ON LL.ID = LG.COURSE_LESSON_ID \n";
     }
     if (in_array('MEMBER_ID', $arSelect, true)) {
         $strFrom .= "LEFT JOIN b_learn_groups_member LGM ON LGM.LEARNING_GROUP_ID = LG.ID \n";
     }
     $strFrom .= $obUserFieldsSql->GetJoin("LG.ID") . " " . (sizeof($arSqlSearch) ? " WHERE " . implode(" AND ", $arSqlSearch) : "") . " ";
     $strSql .= $strFrom;
     $strSqlOrder = "";
     DelDuplicateSort($arSqlOrder);
     for ($i = 0, $arSqlOrderCnt = count($arSqlOrder); $i < $arSqlOrderCnt; $i++) {
         if ($i == 0) {
             $strSqlOrder = " ORDER BY ";
         } else {
             $strSqlOrder .= ",";
         }
         $strSqlOrder .= $arSqlOrder[$i];
     }
     $strSql .= $strSqlOrder;
     if (count($arNavParams)) {
         if (isset($arNavParams['nTopCount'])) {
             $strSql = $DB->TopSql($strSql, (int) $arNavParams['nTopCount']);
             $res = $DB->Query($strSql, $bIgnoreErrors = false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("LEARNING_LGROUPS"));
         } else {
             $res_cnt = $DB->Query("SELECT COUNT(LG.ID) as C " . $strFrom);
             $res_cnt = $res_cnt->Fetch();
             $res = new CDBResult();
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("LEARNING_LGROUPS"));
             $rc = $res->NavQuery($strSql, $res_cnt["C"], $arNavParams, $bIgnoreErrors = false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
     } else {
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:group.php

示例9: GetList


//.........这里部分代码省略.........
  *         Array("SCORE" =&gt; "DESC"), 
  *         Array("CHECK_PERMISSIONS" =&gt; "N", "TEST_ID" =&gt; $TEST_ID, "STUDENT_ID" =&gt; $STUDENT_ID)
  *     );
  * 
  *     while ($arAttempt = $res-&gt;GetNext())
  *     {
  *         echo "Attempt ID:".$arAttempt["ID"]."; Date start: ".$arAttempt["DATE_START"]."; Test name: ".$arAttempt["TEST_NAME"]."&lt;br&gt;";
  *     }
  * }
  * 
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/index.php">CDBResult</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/ctestattempt/index.php">CTestAttempt</a>::<a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/ctestattempt/getbyid.php">GetByID</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/fields.php#attempt">Поля попытки</a> </li> </ul> <a
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/learning/classes/ctestattempt/getlist.php
  * @author Bitrix
  */
 public static function GetList($arOrder = array(), $arFilter = array(), $arSelect = array(), $arNavParams = array())
 {
     global $DB, $USER, $USER_FIELD_MANAGER;
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("LEARN_ATTEMPT", "A.ID");
     $obUserFieldsSql->SetSelect($arSelect);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     $arFields = array("ID" => "A.ID", "TEST_ID" => "A.TEST_ID", "OBY_DATE_END" => "A.DATE_END", "STUDENT_ID" => "A.STUDENT_ID", "DATE_START" => $DB->DateToCharFunction("A.DATE_START", "FULL"), "DATE_END" => $DB->DateToCharFunction("A.DATE_END", "FULL"), "STATUS" => "A.STATUS", "COMPLETED" => "A.COMPLETED", "SCORE" => "A.SCORE", "MAX_SCORE" => "A.MAX_SCORE", "QUESTIONS" => "A.QUESTIONS", "TEST_NAME" => "T.NAME", "USER_NAME" => $DB->Concat("'('", 'U.LOGIN', "') '", "CASE WHEN U.NAME IS NULL THEN '' ELSE U.NAME END", "' '", "CASE WHEN U.LAST_NAME IS NULL THEN '' ELSE U.LAST_NAME END"), "USER_ID" => "U.ID", "MARK" => "TM.MARK", "MESSAGE" => "TM.DESCRIPTION", "LINKED_LESSON_ID" => "C.LINKED_LESSON_ID", "COURSE_ID" => "C.ID", "SPEED" => self::getSpeedFieldSql());
     if (count($arSelect) <= 0 || in_array("*", $arSelect)) {
         $arSelect = array_keys($arFields);
     }
     $arSqlSelect = array();
     foreach ($arSelect as $field) {
         $field = strtoupper($field);
         if (array_key_exists($field, $arFields)) {
             $arSqlSelect[$field] = $arFields[$field] . " AS " . $field;
         }
     }
     $sSelect = implode(",\n", $arSqlSelect);
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = CTestAttempt::GetFilter($arFilter);
     $strSqlSearch = "";
     $arSqlSearchCnt = count($arSqlSearch);
     for ($i = 0; $i < $arSqlSearchCnt; $i++) {
         if (strlen($arSqlSearch[$i]) > 0) {
             $strSqlSearch .= " AND " . $arSqlSearch[$i] . " ";
         }
     }
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $strSqlSearch .= " AND (" . $r . ") ";
     }
     $bCheckPerm = 'ORPHANED VAR';
     $strSqlFrom = '';
     $strSql = static::_GetListSQLFormer($sSelect, $obUserFieldsSql, $bCheckPerm, $USER, $arFilter, $strSqlSearch, $strSqlFrom);
     if (!is_array($arOrder)) {
         $arOrder = array();
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:67,代码来源:attempt.php

示例10: GetList

 public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB, $USER_FIELD_MANAGER;
     $TABLE = 'b_timeman_report_daily R';
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("USER", "R.USER_ID");
     $obUserFieldsSql->SetSelect($arSelectFields);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     $join_user = "LEFT JOIN b_user U ON (R.USER_ID = U.ID)";
     $arFields = array("ID" => array("FIELD" => "R.ID", "TYPE" => "int"), "TIMESTAMP_X" => array("FIELD" => "R.TIMESTAMP_X", "TYPE" => "datetime"), "ACTIVE" => array("FIELD" => "R.ACTIVE", "TYPE" => "string"), "USER_ID" => array("FIELD" => "R.USER_ID", "TYPE" => "int"), "ENTRY_ID" => array("FIELD" => "R.ENTRY_ID", "TYPE" => "int"), "REPORT_DATE" => array("FIELD" => "R.REPORT_DATE", "TYPE" => "date"), "TASKS" => array("FIELD" => "R.TASKS", "TYPE" => "string"), "EVENTS" => array("FIELD" => "R.EVENTS", "TYPE" => "string"), "REPORT" => array("FIELD" => "R.REPORT", "TYPE" => "string"), "MARK" => array("FIELD" => "R.MARK", "TYPE" => "int"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => $join_user), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => $join_user), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => $join_user), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => $join_user), "USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => $join_user), "USER_ACTIVE" => array("FIELD" => "U.ACTIVE", "TYPE" => "char", "FROM" => $join_user));
     if (in_array("*", $arSelectFields)) {
         $arSelectFields = array_keys($arFields);
     } elseif (count($arSelectFields) <= 0) {
         foreach ($arFields as $key => $fld) {
             if (!$fld['FROM']) {
                 $arSelectFields[] = $key;
             }
         }
     }
     $arSqls = CTimeManReportDaily::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql);
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $strSqlUFFilter = " (" . $r . ") ";
     }
     if ($obUserFieldsSql->GetDistinct()) {
         $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", " DISTINCT ", $arSqls["SELECT"]);
     } else {
         $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     }
     $strSql = "\nSELECT\n\t" . $arSqls["SELECT"] . " " . "\n\t" . $obUserFieldsSql->GetSelect() . " " . "\nFROM\n\t" . $TABLE . "\n\t" . $arSqls["FROM"] . " " . "\n\t" . $obUserFieldsSql->GetJoin("E.USER_ID") . " " . "\n";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($strSqlUFFilter) > 0) {
         $strSql .= strlen($arSqls["WHERE"]) > 0 ? ' AND ' : ' WHERE ';
         $strSql .= $strSqlUFFilter;
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $arRes = $dbRes->Fetch();
         if ($arRes) {
             return $arRes["CNT"];
         } else {
             return false;
         }
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "\nSELECT COUNT('x') as CNT\nFROM\n\t" . $TABLE . "\n\t" . $arSqls["FROM"] . "\n\t" . $obUserFieldsSql->GetJoin("E.USER_ID") . "\n";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($strSqlUFFilter) > 0) {
             $strSql_tmp .= strlen($arSqls["WHERE"]) > 0 ? ' AND ' : ' WHERE ';
             $strSql_tmp .= $strSqlUFFilter;
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             $arRes = $dbRes->Fetch();
             if ($arRes) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("USER"));
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . $arNavStartParams["nTopCount"];
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("USER"));
     }
     return $dbRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:87,代码来源:timeman_report_daily.php

示例11: GetList

 public static function GetList($arOrder = array(), $arFilter = array(), $arSelect = array())
 {
     global $DB, $USER_FIELD_MANAGER;
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("CONTROLLER_GROUP", "G.ID");
     $obUserFieldsSql->SetSelect($arSelect);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     static $arFields = array("ID" => array("FIELD_NAME" => "G.ID", "FIELD_TYPE" => "int"), "NAME" => array("FIELD_NAME" => "G.NAME", "FIELD_TYPE" => "string"), "TIMESTAMP_X" => array("FIELD_NAME" => "G.TIMESTAMP_X", "FIELD_TYPE" => "datetime"), "MODIFIED_BY" => array("FIELD_NAME" => "G.MODIFIED_BY", "FIELD_TYPE" => "int"), "UPDATE_PERIOD" => array("FIELD_NAME" => "G.UPDATE_PERIOD", "FIELD_TYPE" => "int"), "MODIFIED_BY_USER" => array("FIELD_TYPE" => "string"), "DATE_CREATE" => array("FIELD_NAME" => "G.DATE_CREATE", "FIELD_TYPE" => "datetime"), "CREATED_BY" => array("FIELD_NAME" => "G.CREATED_BY", "FIELD_TYPE" => "int"), "CREATED_BY_USER" => array("FIELD_TYPE" => "string"), "TRIAL_PERIOD" => array("FIELD_NAME" => "G.TRIAL_PERIOD", "FIELD_TYPE" => "int"), "COUNTER_UPDATE_PERIOD" => array("FIELD_NAME" => "G.COUNTER_UPDATE_PERIOD", "FIELD_TYPE" => "int"), "CHECK_COUNTER_FREE_SPACE" => array("FIELD_NAME" => "G.CHECK_COUNTER_FREE_SPACE", "FIELD_TYPE" => "string"), "CHECK_COUNTER_SITES" => array("FIELD_NAME" => "G.CHECK_COUNTER_SITES", "FIELD_TYPE" => "string"), "CHECK_COUNTER_USERS" => array("FIELD_NAME" => "G.CHECK_COUNTER_USERS", "FIELD_TYPE" => "string"), "CHECK_COUNTER_LAST_AUTH" => array("FIELD_NAME" => "G.CHECK_COUNTER_LAST_AUTH", "FIELD_TYPE" => "string"));
     $arFields["MODIFIED_BY_USER"]["FIELD_NAME"] = $DB->Concat("UM.LOGIN", "UM.NAME", "UM.LAST_NAME");
     $arFields["CREATED_BY_USER"]["FIELD_NAME"] = $DB->Concat("UC.LOGIN", "UC.NAME", "UC.LAST_NAME");
     $obWhere = new CSQLWhere();
     $obWhere->SetFields($arFields);
     $arFilterNew = array();
     foreach ($arFilter as $k => $value) {
         if (strlen($value) > 0 || $value === false) {
             $arFilterNew[$k] = $value;
         }
     }
     $strWhere = "1 = 1";
     $r = $obWhere->GetQuery($arFilterNew);
     if (strlen($r) > 0) {
         $strWhere .= " AND (" . $r . ") ";
     }
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $strWhere .= " AND (" . $r . ") ";
     }
     $strSql = "\n\t\t\tSELECT " . ($obUserFieldsSql->GetDistinct() ? "DISTINCT" : "") . " G.*\n\t\t\t\t,UC.LOGIN as CREATED_BY_LOGIN\n\t\t\t\t,UC.NAME as CREATED_BY_NAME\n\t\t\t\t,UC.LAST_NAME as CREATED_BY_LAST_NAME\n\t\t\t\t,UM.LOGIN as MODIFIED_BY_LOGIN\n\t\t\t\t,UM.NAME as MODIFIED_BY_NAME\n\t\t\t\t,UM.LAST_NAME as MODIFIED_BY_LAST_NAME\n\t\t\t\t," . $DB->DateToCharFunction("G.TIMESTAMP_X") . " as TIMESTAMP_X\n\t\t\t\t," . $DB->DateToCharFunction("G.DATE_CREATE") . " as DATE_CREATE\n\t\t\t\t" . $obUserFieldsSql->GetSelect() . "\n\t\t\tFROM b_controller_group G\n\t\t\t\tLEFT JOIN b_user UC ON UC.ID=G.CREATED_BY\n\t\t\t\tLEFT JOIN b_user UM ON UM.ID=G.MODIFIED_BY\n\t\t\t\t" . $obWhere->GetJoins() . "\n\t\t\t\t" . $obUserFieldsSql->GetJoin("G.ID") . "\n\t\t\tWHERE " . $strWhere . "\n\t\t\t" . CControllerAgent::_OrderBy($arOrder, $arFields, $obUserFieldsSql) . "\n\t\t";
     $dbr = $DB->Query($strSql);
     $dbr->is_filtered = strlen($strWhere) > 0;
     return $dbr;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:33,代码来源:controllergroup.php

示例12: GetList

 public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB, $USER_FIELD_MANAGER;
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("USER", "E.USER_ID");
     $obUserFieldsSql->SetSelect($arSelectFields);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     $join_user = "LEFT JOIN b_user U ON (E.USER_ID = U.ID)";
     $arFields = array("ID" => array("FIELD" => "E.ID", "TYPE" => "int"), "TIMESTAMP_X" => array("FIELD" => "E.TIMESTAMP_X", "TYPE" => "datetime"), "USER_ID" => array("FIELD" => "E.USER_ID", "TYPE" => "int"), "MODIFIED_BY" => array("FIELD" => "E.MODIFIED_BY", "TYPE" => "int"), "ACTIVE" => array("FIELD" => "E.ACTIVE", "TYPE" => "char"), "PAUSED" => array("FIELD" => "E.PAUSED", "TYPE" => "char"), "DATE_START" => array("FIELD" => "E.DATE_START", "TYPE" => "datetime"), "DATE_FINISH" => array("FIELD" => "E.DATE_FINISH", "TYPE" => "datetime"), "TIME_START" => array("FIELD" => "E.TIME_START", "TYPE" => "int"), "TIME_FINISH" => array("FIELD" => "E.TIME_FINISH", "TYPE" => "int"), "DURATION" => array("FIELD" => "E.DURATION", "TYPE" => "int"), "TIME_LEAKS" => array("FIELD" => "E.TIME_LEAKS", "TYPE" => "int"), "TASKS" => array("FIELD" => "E.TASKS", "TYPE" => "string"), "IP_OPEN" => array("FIELD" => "E.IP_OPEN", "TYPE" => "string"), "IP_CLOSE" => array("FIELD" => "E.IP_CLOSE", "TYPE" => "string"), "FORUM_TOPIC_ID" => array("FIELD" => "E.FORUM_TOPIC_ID", "TYPE" => "int"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => $join_user), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => $join_user), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => $join_user), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => $join_user), "USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => $join_user), "USER_GENDER" => array("FIELD" => "U.PERSONAL_GENDER", "TYPE" => "string", "FROM" => $join_user), "USER_ACTIVE" => array("FIELD" => "U.ACTIVE", "TYPE" => "char", "FROM" => $join_user), "ACTIVATED" => array("FIELD" => "CASE WHEN E.ACTIVE='Y' AND EXISTS(\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t'x'\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_timeman_reports TR\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tTR.ENTRY_ID = E.ID\n\t\t\t\t\t\tAND TR.ACTIVE = 'N'\n\t\t\t\t) THEN 'Y' ELSE 'N' END", "TYPE" => "string"), "INACTIVE_OR_ACTIVATED" => array("FIELD" => "CASE WHEN E.ACTIVE='N' OR EXISTS(\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t'x'\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_timeman_reports TR\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tTR.ENTRY_ID = E.ID\n\t\t\t\t\t\tAND TR.ACTIVE = 'N'\n\t\t\t\t) THEN 'Y' ELSE 'N' END", "TYPE" => "string"));
     if (count($arSelectFields) <= 0) {
         foreach ($arFields as $k => $v) {
             if (!isset($v['FROM']) && $k != 'ACTIVATED' && $k != 'INACTIVE_OR_ACTIVATED') {
                 $arSelectFields[] = $k;
             }
         }
     } elseif (in_array("*", $arSelectFields)) {
         $arf = $arFields;
         if (!in_array('ACTIVATED', $arSelectFields)) {
             unset($arf['ACTIVATED']);
         }
         if (!in_array('INACTIVE_OR_ACTIVATED', $arSelectFields)) {
             unset($arf['INACTIVE_OR_ACTIVATED']);
         }
         $arSelectFields = array_keys($arf);
     }
     $arSqls = CTimeManEntry::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql);
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $strSqlUFFilter = " (" . $r . ") ";
     }
     if ($obUserFieldsSql->GetDistinct()) {
         $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", " DISTINCT ", $arSqls["SELECT"]);
     } else {
         $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     }
     $strSql = "\nSELECT\n\t" . $arSqls["SELECT"] . " " . "\n\t" . $obUserFieldsSql->GetSelect() . " " . "\nFROM\n\tb_timeman_entries E\n\t" . $arSqls["FROM"] . " " . "\n\t" . $obUserFieldsSql->GetJoin("E.USER_ID") . " " . "\n";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($strSqlUFFilter) > 0) {
         $strSql .= strlen($arSqls["WHERE"]) > 0 ? ' AND ' : ' WHERE ';
         $strSql .= $strSqlUFFilter;
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return false;
         }
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "\nSELECT COUNT('x') as CNT\nFROM\n\tb_timeman_entries E\n\t" . $arSqls["FROM"] . "\n\t" . $obUserFieldsSql->GetJoin("E.USER_ID") . "\n";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($strSqlUFFilter) > 0) {
             $strSql_tmp .= strlen($arSqls["WHERE"]) > 0 ? ' AND ' : ' WHERE ';
             $strSql_tmp .= $strSqlUFFilter;
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             if ($arRes = $dbRes->Fetch()) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("USER"));
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . $arNavStartParams["nTopCount"];
         }
         //echo '<pre>',$strSql,'</pre>'; die();
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("USER"));
     }
     return $dbRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:92,代码来源:timeman_entry.php

示例13: GetList

 static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (empty($arSelectFields)) {
         $arSelectFields = array("ID", "ACTIVE", "TITLE", "PHONE", "SCHEDULE", "ADDRESS", "DESCRIPTION", "GPS_N", "GPS_S", "IMAGE_ID", "DATE_CREATE", "DATE_MODIFY", "USER_ID", "XML_ID", "SORT", "EMAIL", "ISSUING_CENTER", "SHIPPING_CENTER", "SITE_ID");
     }
     $keyForDelete = array_search("PRODUCT_AMOUNT", $arSelectFields);
     if (!isset($arFilter["PRODUCT_ID"]) && $keyForDelete !== false) {
         unset($arSelectFields[$keyForDelete]);
     }
     if ($keyForDelete == false) {
         $keyForDelete = array_search("ELEMENT_ID", $arSelectFields);
         if ($keyForDelete !== false) {
             unset($arSelectFields[$keyForDelete]);
         }
     }
     $productID = '(';
     if (is_array($arFilter["PRODUCT_ID"])) {
         foreach ($arFilter["PRODUCT_ID"] as $id) {
             $productID .= intval($id) . ',';
         }
         $productID = rtrim($productID, ',') . ')';
     } else {
         $productID .= intval($arFilter["PRODUCT_ID"]) . ')';
     }
     $arFields = array("ID" => array("FIELD" => "CS.ID", "TYPE" => "int"), "ACTIVE" => array("FIELD" => "CS.ACTIVE", "TYPE" => "string"), "TITLE" => array("FIELD" => "CS.TITLE", "TYPE" => "string"), "PHONE" => array("FIELD" => "CS.PHONE", "TYPE" => "string"), "SCHEDULE" => array("FIELD" => "CS.SCHEDULE", "TYPE" => "string"), "ADDRESS" => array("FIELD" => "CS.ADDRESS", "TYPE" => "string"), "DESCRIPTION" => array("FIELD" => "CS.DESCRIPTION", "TYPE" => "string"), "GPS_N" => array("FIELD" => "CS.GPS_N", "TYPE" => "string"), "GPS_S" => array("FIELD" => "CS.GPS_S", "TYPE" => "string"), "IMAGE_ID" => array("FIELD" => "CS.IMAGE_ID", "TYPE" => "int"), "LOCATION_ID" => array("FIELD" => "CS.LOCATION_ID", "TYPE" => "int"), "DATE_CREATE" => array("FIELD" => "CS.DATE_CREATE", "TYPE" => "datetime"), "DATE_MODIFY" => array("FIELD" => "CS.DATE_MODIFY", "TYPE" => "datetime"), "USER_ID" => array("FIELD" => "CS.USER_ID", "TYPE" => "int"), "MODIFIED_BY" => array("FIELD" => "CS.MODIFIED_BY", "TYPE" => "int"), "XML_ID" => array("FIELD" => "CS.XML_ID", "TYPE" => "string"), "SORT" => array("FIELD" => "CS.SORT", "TYPE" => "int"), "EMAIL" => array("FIELD" => "CS.EMAIL", "TYPE" => "string"), "ISSUING_CENTER" => array("FIELD" => "CS.ISSUING_CENTER", "TYPE" => "char"), "SHIPPING_CENTER" => array("FIELD" => "CS.SHIPPING_CENTER", "TYPE" => "char"), "SITE_ID" => array("FIELD" => "CS.SITE_ID", "TYPE" => "string"), "PRODUCT_AMOUNT" => array("FIELD" => "CP.AMOUNT", "TYPE" => "double", "FROM" => "LEFT JOIN b_catalog_store_product CP ON (CS.ID = CP.STORE_ID AND CP.PRODUCT_ID IN " . $productID . ")"), "ELEMENT_ID" => array("FIELD" => "CP.PRODUCT_ID", "TYPE" => "int"));
     $userField = new CUserTypeSQL();
     $userField->SetEntity("CAT_STORE", "CS.ID");
     $userField->SetSelect($arSelectFields);
     $userField->SetFilter($arFilter);
     $userField->SetOrder($arOrder);
     $strUfFilter = $userField->GetFilter();
     $strSqlUfFilter = strlen($strUfFilter) > 0 ? " (" . $strUfFilter . ") " : "";
     $strSqlUfOrder = "";
     foreach ($arOrder as $field => $by) {
         $field = $userField->GetOrder($field);
         if (empty($field)) {
             continue;
         }
         if (strlen($strSqlUfOrder) > 0) {
             $strSqlUfOrder .= ', ';
         }
         $strSqlUfOrder .= $field . " " . $by;
     }
     $arSqls = CCatalog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (empty($arGroupBy) && is_array($arGroupBy)) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . $userField->GetSelect() . " FROM b_catalog_store CS " . $arSqls["FROM"] . " " . $userField->GetJoin("CS.ID");
         if (!empty($arSqls["WHERE"])) {
             $strSql .= " WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUfFilter) > 0) {
             $strSql .= " AND " . $strSqlUfFilter . " ";
         } elseif (strlen($arSqls["WHERE"]) == 0 && strlen($strSqlUfFilter) > 0) {
             $strSql .= " WHERE " . $strSqlUfFilter . " ";
         }
         if (!empty($arSqls["GROUPBY"])) {
             $strSql .= " GROUP BY " . $arSqls["GROUPBY"];
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return false;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . $userField->GetSelect() . " FROM b_catalog_store CS " . $arSqls["FROM"] . " " . $userField->GetJoin("CS.ID");
     if (!empty($arSqls["WHERE"])) {
         $strSql .= " WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUfFilter) > 0) {
         $strSql .= " AND " . $strSqlUfFilter . " ";
     } elseif (strlen($arSqls["WHERE"]) <= 0 && strlen($strSqlUfFilter) > 0) {
         $strSql .= " WHERE " . $strSqlUfFilter . " ";
     }
     if (!empty($arSqls["GROUPBY"])) {
         $strSql .= " GROUP BY " . $arSqls["GROUPBY"];
     }
     if (!empty($arSqls["ORDERBY"])) {
         $strSql .= " ORDER BY " . $arSqls["ORDERBY"];
     } elseif (strlen($arSqls["ORDERBY"]) <= 0 && strlen($strSqlUfOrder) > 0) {
         $strSql .= " ORDER BY " . $strSqlUfOrder;
     }
     $intTopCount = 0;
     $boolNavStartParams = !empty($arNavStartParams) && is_array($arNavStartParams);
     if ($boolNavStartParams && array_key_exists('nTopCount', $arNavStartParams)) {
         $intTopCount = intval($arNavStartParams["nTopCount"]);
     }
     if ($boolNavStartParams && 0 >= $intTopCount) {
         $strSql_tmp = "SELECT COUNT('x') as CNT FROM b_catalog_store CS " . $arSqls["FROM"] . " " . $userField->GetJoin("CS.ID");
         if (!empty($arSqls["WHERE"])) {
             $strSql_tmp .= " WHERE " . $arSqls["WHERE"];
         }
         if (strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUfFilter) > 0) {
             $strSql_tmp .= " AND " . $strSqlUfFilter . " ";
         } elseif (strlen($arSqls["WHERE"]) <= 0 && strlen($strSqlUfFilter) > 0) {
             $strSql_tmp .= " WHERE " . $strSqlUfFilter . " ";
         }
         if (!empty($arSqls["GROUPBY"])) {
             $strSql_tmp .= " GROUP BY " . $arSqls["GROUPBY"];
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:store.php

示例14: GetList

 /**
  * @param $arOrder
  * @param $arFilter
  * @param array $arNavParams
  * @param array $arParams
  * @param array $arSelect
  * @return bool|CDBResult
  *
  * @global $DB CDatabase
  * @global $DBType string
  */
 public static function GetList($arOrder, $arFilter, $arNavParams = array(), $arParams = array(), $arSelect = array())
 {
     global $DB, $DBType, $USER_FIELD_MANAGER;
     $arSqlSearch = CTaskTemplates::GetFilter($arFilter, $arParams);
     // check permissions
     if (isset($arParams['USER_ID'])) {
         $executiveUserId = (int) $arParams['USER_ID'];
         $isAdmin = CTasksTools::IsAdmin($executiveUserId) || CTasksTools::IsPortalB24Admin($executiveUserId);
         if (!$isAdmin) {
             $sql = 'TT.CREATED_BY = ' . (int) $executiveUserId;
             if ($executiveUserId && ($arDepsIDs = CTasks::GetSubordinateDeps($executiveUserId))) {
                 if (!is_array($arDepsIDs)) {
                     $arDepsIDs = array(intval($arDepsIDs));
                 }
                 /** @noinspection PhpDynamicAsStaticMethodCallInspection */
                 $rsDepartmentField = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => "USER", "FIELD_NAME" => "UF_DEPARTMENT"));
                 $cntOfDepartments = count($arDepsIDs);
                 if ($cntOfDepartments && ($arDepartmentField = $rsDepartmentField->Fetch())) {
                     if (strtolower($DBType) === 'oracle' && ($valuesLimit = 1000) && $cntOfDepartments > $valuesLimit) {
                         $arConstraints = array();
                         $sliceIndex = 0;
                         while ($sliceIndex < $cntOfDepartments) {
                             $arConstraints[] = 'BUF1.VALUE_INT IN (' . implode(',', array_slice($arDepsIDs, $sliceIndex, $valuesLimit)) . ')';
                             $sliceIndex += $valuesLimit;
                         }
                         $strConstraint = '(' . implode(' OR ', $arConstraints) . ')';
                     } else {
                         $strConstraint = "BUF1.VALUE_INT IN (" . implode(",", $arDepsIDs) . ")";
                     }
                     $sql .= "\n\t\t\t\t\t\t\tOR EXISTS (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t'x'\n\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tb_utm_user BUF1\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tBUF1.FIELD_ID = " . $arDepartmentField["ID"] . "\n\t\t\t\t\t\t\t\tAND BUF1.VALUE_ID = TT.CREATED_BY\n\t\t\t\t\t\t\t\tAND " . $strConstraint . "\n\t\t\t\t\t\t\t) ";
                 }
             }
             $arSqlSearch[] = ' (' . $sql . ') ';
         }
     }
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("TASKS_TASK_TEMPLATE", "TT.ID");
     $obUserFieldsSql->SetSelect($arSelect);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $arSqlSearch[] = "(" . $r . ")";
     }
     $arFields = array('ID' => array('FIELD' => 'TT.ID', 'DEFAULT' => true), 'TITLE' => array('FIELD' => 'TT.TITLE', 'DEFAULT' => true), 'DESCRIPTION' => array('FIELD' => 'TT.DESCRIPTION', 'DEFAULT' => true), 'DESCRIPTION_IN_BBCODE' => array('FIELD' => 'TT.DESCRIPTION_IN_BBCODE', 'DEFAULT' => true), 'PRIORITY' => array('FIELD' => 'TT.PRIORITY', 'DEFAULT' => true), 'STATUS' => array('FIELD' => 'TT.STATUS', 'DEFAULT' => true), 'RESPONSIBLE_ID' => array('FIELD' => 'TT.RESPONSIBLE_ID', 'DEFAULT' => true), 'DEADLINE_AFTER' => array('FIELD' => 'TT.DEADLINE_AFTER', 'DEFAULT' => true), 'REPLICATE' => array('FIELD' => 'TT.REPLICATE', 'DEFAULT' => true), 'REPLICATE_PARAMS' => array('FIELD' => 'TT.REPLICATE_PARAMS', 'DEFAULT' => true), 'CREATED_BY' => array('FIELD' => 'TT.CREATED_BY', 'DEFAULT' => true), 'XML_ID' => array('FIELD' => 'TT.XML_ID', 'DEFAULT' => true), 'ALLOW_CHANGE_DEADLINE' => array('FIELD' => 'TT.ALLOW_CHANGE_DEADLINE', 'DEFAULT' => true), 'ALLOW_TIME_TRACKING' => array('FIELD' => 'TT.ALLOW_TIME_TRACKING', 'DEFAULT' => true), 'TASK_CONTROL' => array('FIELD' => 'TT.TASK_CONTROL', 'DEFAULT' => true), 'ADD_IN_REPORT' => array('FIELD' => 'TT.ADD_IN_REPORT', 'DEFAULT' => true), 'GROUP_ID' => array('FIELD' => 'TT.GROUP_ID', 'DEFAULT' => true), 'PARENT_ID' => array('FIELD' => 'TT.PARENT_ID', 'DEFAULT' => true), 'MULTITASK' => array('FIELD' => 'TT.MULTITASK', 'DEFAULT' => true), 'SITE_ID' => array('FIELD' => 'TT.SITE_ID', 'DEFAULT' => true), 'ACCOMPLICES' => array('FIELD' => 'TT.ACCOMPLICES', 'DEFAULT' => true), 'AUDITORS' => array('FIELD' => 'TT.AUDITORS', 'DEFAULT' => true), 'RESPONSIBLES' => array('FIELD' => 'TT.RESPONSIBLES', 'DEFAULT' => true), 'FILES' => array('FIELD' => 'TT.FILES', 'DEFAULT' => true), 'TAGS' => array('FIELD' => 'TT.TAGS', 'DEFAULT' => true), 'DEPENDS_ON' => array('FIELD' => 'TT.DEPENDS_ON', 'DEFAULT' => true), 'TASK_ID' => array('FIELD' => 'TT.TASK_ID', 'DEFAULT' => true), 'TPARAM_TYPE' => array('FIELD' => 'TT.TPARAM_TYPE', 'DEFAULT' => true), 'BASE_TEMPLATE_ID' => array('FIELD' => 'CASE WHEN TDD.' . Template\DependencyTable::getPARENTIDColumnName() . ' IS NULL THEN 0 ELSE TDD.' . Template\DependencyTable::getPARENTIDColumnName() . ' END', 'DEFAULT' => false), 'TEMPLATE_CHILDREN_COUNT' => array('FIELD' => 'CASE WHEN TEMPLATE_CHILDREN_COUNT IS NULL THEN 0 ELSE TEMPLATE_CHILDREN_COUNT END', 'DEFAULT' => false), 'CREATED_BY_NAME' => array('FIELD' => 'CU.NAME', 'DEFAULT' => true, 'ALWAYS' => true), 'CREATED_BY_LAST_NAME' => array('FIELD' => 'CU.LAST_NAME ', 'DEFAULT' => true, 'ALWAYS' => true), 'CREATED_BY_SECOND_NAME' => array('FIELD' => 'CU.SECOND_NAME', 'DEFAULT' => true, 'ALWAYS' => true), 'CREATED_BY_LOGIN' => array('FIELD' => 'CU.LOGIN', 'DEFAULT' => true, 'ALWAYS' => true), 'CREATED_BY_WORK_POSITION' => array('FIELD' => 'CU.WORK_POSITION', 'DEFAULT' => true, 'ALWAYS' => true), 'CREATED_BY_PHOTO' => array('FIELD' => 'CU.PERSONAL_PHOTO', 'DEFAULT' => true, 'ALWAYS' => true), 'RESPONSIBLE_NAME' => array('FIELD' => 'RU.NAME', 'DEFAULT' => true, 'ALWAYS' => true), 'RESPONSIBLE_LAST_NAME' => array('FIELD' => 'RU.LAST_NAME', 'DEFAULT' => true, 'ALWAYS' => true), 'RESPONSIBLE_SECOND_NAME' => array('FIELD' => 'RU.SECOND_NAME', 'DEFAULT' => true, 'ALWAYS' => true), 'RESPONSIBLE_LOGIN' => array('FIELD' => 'RU.LOGIN', 'DEFAULT' => true, 'ALWAYS' => true), 'RESPONSIBLE_WORK_POSITION' => array('FIELD' => 'RU.WORK_POSITION', 'DEFAULT' => true, 'ALWAYS' => true), 'RESPONSIBLE_PHOTO' => array('FIELD' => 'RU.PERSONAL_PHOTO', 'DEFAULT' => true, 'ALWAYS' => true));
     $filterByBaseTemplate = false;
     $selectBaseTemplateId = false;
     $useChildrenCount = false;
     if (!is_array($arSelect)) {
         $arSelect = array();
     }
     $defaultSelect = array();
     $alwaysSelect = array();
     foreach ($arFields as $field => $rule) {
         if ($rule['DEFAULT']) {
             $defaultSelect[] = $field;
         }
         if ($rule['ALWAYS']) {
             $alwaysSelect[] = $field;
         }
     }
     if (count($arSelect) <= 0) {
         $arSelect = $defaultSelect;
     } elseif (in_array("*", $arSelect)) {
         $arSelect = array_diff(array_merge($defaultSelect, $arSelect), array("*"));
     }
     $arSelect = array_merge($arSelect, $alwaysSelect);
     $selectBaseTemplateId = in_array('BASE_TEMPLATE_ID', $arSelect);
     $useChildrenCount = in_array('TEMPLATE_CHILDREN_COUNT', $arSelect);
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     foreach ($arOrder as $field => $direction) {
         if ($field == 'BASE_TEMPLATE_ID') {
             $selectBaseTemplateId = true;
         }
         if ($field == 'TEMPLATE_CHILDREN_COUNT') {
             $useChildrenCount = true;
         }
     }
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     if (!is_array($arParams)) {
         $arParams = array();
     }
     foreach ($arFilter as $key => $value) {
         $keyParsed = CTasks::MkOperationFilter($key);
         if ($keyParsed['FIELD'] == 'BASE_TEMPLATE_ID') {
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:tasktemplates.php

示例15: GetList


//.........这里部分代码省略.........
  *         Array("NAME" =&gt; "ASC", "SORT"=&gt;"ASC"), 
  *         Array("COURSE_ID" =&gt; $COURSE_ID, "!SELF" =&gt; "Y")
  *     );
  * 
  *     while ($arQuestion = $res-&gt;GetNext())
  *     {
  *         echo "Question name: ".$arQuestion["NAME"]."&lt;br&gt;";
  *     }
  * }
  * 
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/index.php">CDBResult</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/index.php">CLQuestion</a>::<a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/getbyid.php">GetByID</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/fields.php#question">Поля вопроса</a> </li> </ul> <a
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/getlist.php
  * @author Bitrix
  */
 public static function GetList($arOrder = array(), $arFilter = array(), $bHz = false, $arNavParams = array(), $arSelect = array())
 {
     global $DB, $USER, $USER_FIELD_MANAGER;
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity('LEARNING_QUESTIONS', "CQ.ID");
     $obUserFieldsSql->SetSelect($arSelect);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     $arSqlSearch = array_filter(CLQuestion::GetFilter($arFilter));
     $strSqlFrom = "FROM b_learn_question CQ " . "INNER JOIN b_learn_lesson CL ON CQ.LESSON_ID = CL.ID " . $obUserFieldsSql->GetJoin("CQ.ID") . " WHERE ";
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $arSqlSearch[] = "(" . $r . ")";
     }
     if (!empty($arSqlSearch)) {
         $strSqlFrom .= implode(' AND ', $arSqlSearch);
     } else {
         $strSqlFrom .= ' 1=1 ';
     }
     $strSql = "SELECT CQ.ID, CQ.ACTIVE, CQ.LESSON_ID, CQ.QUESTION_TYPE,\n\t\t\t\tCQ.NAME, CQ.SORT, CQ.DESCRIPTION, CQ.DESCRIPTION_TYPE,\n\t\t\t\tCQ.COMMENT_TEXT, CQ.FILE_ID, CQ.SELF, CQ.POINT, CQ.DIRECTION,\n\t\t\t\tCQ.CORRECT_REQUIRED, CQ.EMAIL_ANSWER, CQ.INCORRECT_MESSAGE," . $DB->DateToCharFunction("CQ.TIMESTAMP_X") . " as TIMESTAMP_X " . $obUserFieldsSql->GetSelect() . " " . $strSqlFrom;
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     foreach ($arOrder as $by => $order) {
         $by = strtolower($by);
         $order = strtolower($order);
         if ($order != "asc") {
             $order = "desc";
         }
         if ($by == "id") {
             $arSqlOrder[] = " CQ.ID " . $order . " ";
         } elseif ($by == "name") {
             $arSqlOrder[] = " CQ.NAME " . $order . " ";
         } elseif ($by == "sort") {
             $arSqlOrder[] = " CQ.SORT " . $order . " ";
         } elseif ($by == "point") {
             $arSqlOrder[] = " CQ.POINT " . $order . " ";
         } elseif ($by == "type") {
             $arSqlOrder[] = " CQ.QUESTION_TYPE " . $order . " ";
         } elseif ($by == "self") {
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:67,代码来源:question.php


注:本文中的CUserTypeSQL::SetOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。