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


PHP CUserTypeSQL::SetSelect方法代码示例

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


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

示例1: 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

示例2: GetList


//.........这里部分代码省略.........
                     break;
                 case 'SUPPORTTEAM_GROUP_ID':
                 case 'CLIENT_GROUP_ID':
                     if ($key == 'SUPPORTTEAM_GROUP_ID') {
                         $table = 'UGS';
                         $bJoinSupportTeamTbl = true;
                     } else {
                         $table = 'UGC';
                         $bJoinClientTbl = true;
                     }
                     if (is_array($val)) {
                         $val = array_map('intval', $val);
                         $val = array_unique($val);
                         $val = array_filter($val);
                         if (count($val) > 0) {
                             $arSqlSearch[] = '(' . $table . '.GROUP_ID IS NOT NULL AND ' . $table . '.GROUP_ID IN (' . implode(',', $val) . '))';
                         }
                     } else {
                         $val = intval($val);
                         if ($val > 0) {
                             $arSqlSearch[] = '(' . $table . '.GROUP_ID IS NOT NULL AND ' . $table . '.GROUP_ID=\'' . $val . '\')';
                         }
                     }
                     break;
                 case 'COUPON':
                     $match = $matchValueSet && $arFilter[$key . "_EXACT_MATCH"] != "Y" ? "Y" : "N";
                     $arSqlSearch[] = GetFilterQuery("T." . $key, $val, $match);
                     break;
             }
         }
     }
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("SUPPORT", "T.ID");
     $obUserFieldsSql->SetSelect($arParams["SELECT"]);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder(array($by => $order));
     if ($by == "s_id") {
         $strSqlOrder = "ORDER BY T.ID";
     } elseif ($by == "s_last_message_date") {
         $strSqlOrder = "ORDER BY T.LAST_MESSAGE_DATE";
     } elseif ($by == "s_site_id" || $by == "s_lid") {
         $strSqlOrder = "ORDER BY T.SITE_ID";
     } elseif ($by == "s_lamp") {
         $strSqlOrder = "ORDER BY LAMP";
     } elseif ($by == "s_is_overdue") {
         $strSqlOrder = "ORDER BY T.IS_OVERDUE";
     } elseif ($by == "s_is_notified") {
         $strSqlOrder = "ORDER BY T.IS_NOTIFIED";
     } elseif ($by == "s_date_create") {
         $strSqlOrder = "ORDER BY T.DATE_CREATE";
     } elseif ($by == "s_timestamp") {
         $strSqlOrder = "ORDER BY T.TIMESTAMP_X";
     } elseif ($by == "s_date_close") {
         $strSqlOrder = "ORDER BY T.DATE_CLOSE";
     } elseif ($by == "s_owner") {
         $strSqlOrder = "ORDER BY T.OWNER_USER_ID";
     } elseif ($by == "s_modified_by") {
         $strSqlOrder = "ORDER BY T.MODIFIED_USER_ID";
     } elseif ($by == "s_title") {
         $strSqlOrder = "ORDER BY T.TITLE ";
     } elseif ($by == "s_responsible") {
         $strSqlOrder = "ORDER BY T.RESPONSIBLE_USER_ID";
     } elseif ($by == "s_messages") {
         $strSqlOrder = "ORDER BY T.MESSAGES";
     } elseif ($by == "s_category") {
         $strSqlOrder = "ORDER BY T.CATEGORY_ID";
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:67,代码来源:support.php

示例3: GetList

 function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array(), $arOptions = array())
 {
     global $DB, $USER_FIELD_MANAGER;
     if (!is_array($arOrder)) {
         $arOrder = array('ID' => 'DESC');
     }
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     if (!is_array($arSelectFields)) {
         $arSelectFields = array();
     }
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("ORDER", "O.ID");
     $obUserFieldsSql->SetSelect($arSelectFields);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     if (array_key_exists("DATE_FROM", $arFilter)) {
         $val = $arFilter["DATE_FROM"];
         unset($arFilter["DATE_FROM"]);
         $arFilter[">=DATE_INSERT"] = $val;
     }
     if (array_key_exists("DATE_TO", $arFilter)) {
         $val = $arFilter["DATE_TO"];
         unset($arFilter["DATE_TO"]);
         $arFilter["<=DATE_INSERT"] = $val;
     }
     if (array_key_exists("DATE_INSERT_FROM", $arFilter)) {
         $val = $arFilter["DATE_INSERT_FROM"];
         unset($arFilter["DATE_INSERT_FROM"]);
         $arFilter[">=DATE_INSERT"] = $val;
     }
     if (array_key_exists("DATE_INSERT_TO", $arFilter)) {
         $val = $arFilter["DATE_INSERT_TO"];
         unset($arFilter["DATE_INSERT_TO"]);
         $arFilter["<=DATE_INSERT"] = $val;
     }
     if (array_key_exists("DATE_UPDATE_FROM", $arFilter)) {
         $val = $arFilter["DATE_UPDATE_FROM"];
         unset($arFilter["DATE_UPDATE_FROM"]);
         $arFilter[">=DATE_UPDATE"] = $val;
     }
     if (array_key_exists("DATE_UPDATE_TO", $arFilter)) {
         $val = $arFilter["DATE_UPDATE_TO"];
         unset($arFilter["DATE_UPDATE_TO"]);
         $arFilter["<=DATE_UPDATE"] = $val;
     }
     if (array_key_exists("DATE_STATUS_FROM", $arFilter)) {
         $val = $arFilter["DATE_STATUS_FROM"];
         unset($arFilter["DATE_STATUS_FROM"]);
         $arFilter[">=DATE_STATUS"] = $val;
     }
     if (array_key_exists("DATE_STATUS_TO", $arFilter)) {
         $val = $arFilter["DATE_STATUS_TO"];
         unset($arFilter["DATE_STATUS_TO"]);
         $arFilter["<=DATE_STATUS"] = $val;
     }
     if (array_key_exists("DATE_PAYED_FROM", $arFilter)) {
         $val = $arFilter["DATE_PAYED_FROM"];
         unset($arFilter["DATE_PAYED_FROM"]);
         $arFilter[">=DATE_PAYED"] = $val;
     }
     if (array_key_exists("DATE_PAYED_TO", $arFilter)) {
         $val = $arFilter["DATE_PAYED_TO"];
         unset($arFilter["DATE_PAYED_TO"]);
         $arFilter["<=DATE_PAYED"] = $val;
     }
     if (array_key_exists("DATE_ALLOW_DELIVERY_FROM", $arFilter)) {
         $val = $arFilter["DATE_ALLOW_DELIVERY_FROM"];
         unset($arFilter["DATE_ALLOW_DELIVERY_FROM"]);
         $arFilter[">=DATE_ALLOW_DELIVERY"] = $val;
     }
     if (array_key_exists("DATE_ALLOW_DELIVERY_TO", $arFilter)) {
         $val = $arFilter["DATE_ALLOW_DELIVERY_TO"];
         unset($arFilter["DATE_ALLOW_DELIVERY_TO"]);
         $arFilter["<=DATE_ALLOW_DELIVERY"] = $val;
     }
     if (array_key_exists("DATE_CANCELED_FROM", $arFilter)) {
         $val = $arFilter["DATE_CANCELED_FROM"];
         unset($arFilter["DATE_CANCELED_FROM"]);
         $arFilter[">=DATE_CANCELED"] = $val;
     }
     if (array_key_exists("DATE_CANCELED_TO", $arFilter)) {
         $val = $arFilter["DATE_CANCELED_TO"];
         unset($arFilter["DATE_CANCELED_TO"]);
         $arFilter["<=DATE_CANCELED"] = $val;
     }
     if (array_key_exists("DATE_DEDUCTED_FROM", $arFilter)) {
         $val = $arFilter["DATE_DEDUCTED_FROM"];
         unset($arFilter["DATE_DEDUCTED_FROM"]);
         $arFilter[">=DATE_DEDUCTED"] = $val;
     }
     if (array_key_exists("DATE_DEDUCTED_TO", $arFilter)) {
         $val = $arFilter["DATE_DEDUCTED_TO"];
         unset($arFilter["DATE_DEDUCTED_TO"]);
         $arFilter["<=DATE_DEDUCTED"] = $val;
     }
     if (array_key_exists("DATE_MARKED_FROM", $arFilter)) {
         $val = $arFilter["DATE_MARKED_FROM"];
         unset($arFilter["DATE_MARKED_FROM"]);
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:order.php

示例4: GetList

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

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

		if (count($arSelectFields) <= 0)
			$arSelectFields = array("ID", "BLOG_ID", "POST_ID", "PARENT_ID", "AUTHOR_ID", "AUTHOR_NAME", "AUTHOR_EMAIL", "AUTHOR_IP", "AUTHOR_IP1", "TITLE", "POST_TEXT");
		if(in_array("*", $arSelectFields))
			$arSelectFields = array("ID", "BLOG_ID", "POST_ID", "PARENT_ID", "AUTHOR_ID", "AUTHOR_NAME", "AUTHOR_EMAIL", "AUTHOR_IP", "AUTHOR_IP1", "TITLE", "POST_TEXT", "DATE_CREATE", "USER_LOGIN", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_EMAIL", "USER", "BLOG_USER_ALIAS", "BLOG_USER_AVATAR", "BLOG_URL", "BLOG_OWNER_ID", "BLOG_SOCNET_GROUP_ID", "BLOG_ACTIVE", "BLOG_GROUP_ID", "BLOG_GROUP_SITE_ID", "BLOG_USE_SOCNET", "PERMS", "PUBLISH_STATUS");
		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" => "C.ID", "TYPE" => "int"),
				"BLOG_ID" => array("FIELD" => "C.BLOG_ID", "TYPE" => "int"),
				"POST_ID" => array("FIELD" => "C.POST_ID", "TYPE" => "int"),
				"PARENT_ID" => array("FIELD" => "C.PARENT_ID", "TYPE" => "int"),
				"AUTHOR_ID" => array("FIELD" => "C.AUTHOR_ID", "TYPE" => "int"),
				"AUTHOR_NAME" => array("FIELD" => "C.AUTHOR_NAME", "TYPE" => "string"),
				"AUTHOR_EMAIL" => array("FIELD" => "C.AUTHOR_EMAIL", "TYPE" => "string"),
				"AUTHOR_IP" => array("FIELD" => "C.AUTHOR_IP", "TYPE" => "string"),
				"AUTHOR_IP1" => array("FIELD" => "C.AUTHOR_IP1", "TYPE" => "string"),
				"TITLE" => array("FIELD" => "C.TITLE", "TYPE" => "string"),
				"POST_TEXT" => array("FIELD" => "C.POST_TEXT", "TYPE" => "string"),
				"DATE_CREATE" => array("FIELD" => "C.DATE_CREATE", "TYPE" => "datetime"),
				"DATE_CREATE_TS" => array("FIELD" => "UNIX_TIMESTAMP(C.DATE_CREATE)", "TYPE" => "int"),
				"PATH" => array("FIELD" => "C.PATH", "TYPE" => "string"),
				"PUBLISH_STATUS" => array("FIELD" => "C.PUBLISH_STATUS", "TYPE" => "string"),
				"HAS_PROPS" => array("FIELD" => "C.HAS_PROPS", "TYPE" => "string"),
				"SHARE_DEST" => array("FIELD" => "C.SHARE_DEST", "TYPE" => "string"),

				"USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (C.AUTHOR_ID = U.ID)"),
				"USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (C.AUTHOR_ID = U.ID)"),
				"USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (C.AUTHOR_ID = U.ID)"),
				"USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (C.AUTHOR_ID = U.ID)"),
				"USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (C.AUTHOR_ID = U.ID)"),
				"USER" => 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 (C.AUTHOR_ID = U.ID)"),
				
				"BLOG_USER_ALIAS" => array("FIELD" => "BU.ALIAS", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_user BU ON (C.AUTHOR_ID = BU.USER_ID)"),
				"BLOG_USER_AVATAR" => array("FIELD" => "BU.AVATAR", "TYPE" => "int", "FROM" => "LEFT JOIN b_blog_user BU ON (C.AUTHOR_ID = BU.USER_ID)"),
				
				"BLOG_URL" => array("FIELD" => "B.URL", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (C.BLOG_ID = B.ID)"),
				"BLOG_OWNER_ID" => array("FIELD" => "B.OWNER_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (C.BLOG_ID = B.ID)"),
				"BLOG_SOCNET_GROUP_ID" => array("FIELD" => "B.SOCNET_GROUP_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (C.BLOG_ID = B.ID)"),
				"BLOG_ACTIVE" => array("FIELD" => "B.ACTIVE", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (C.BLOG_ID = B.ID)"),
				"BLOG_GROUP_ID" => array("FIELD" => "B.GROUP_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog B ON (C.BLOG_ID = B.ID)"),
				"BLOG_USE_SOCNET" => array("FIELD" => "B.USE_SOCNET", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (C.BLOG_ID = B.ID)"),
				"BLOG_NAME" => array("FIELD" => "B.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_blog B ON (C.BLOG_ID = B.ID)"),
				
				"BLOG_GROUP_SITE_ID" => array("FIELD" => "BG.SITE_ID", "TYPE" => "string", "FROM" => "
						INNER JOIN b_blog BGS ON (C.BLOG_ID = BGS.ID)
						INNER JOIN b_blog_group BG ON (BGS.GROUP_ID = BG.ID)"),
				"PERMS" => Array(),
				
				"SOCNET_BLOG_READ" => array("FIELD" => "BSR.BLOG_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_socnet BSR ON (C.BLOG_ID = BSR.BLOG_ID)"),
				
				"POST_CODE" => array("FIELD" => "BP.CODE", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_post BP ON (C.POST_ID = BP.ID)"),
				"POST_TITLE" => array("FIELD" => "BP.TITLE", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_post BP ON (C.POST_ID = BP.ID)"),
				"BLOG_POST_PUBLISH_STATUS" => array("FIELD" => "BP.PUBLISH_STATUS", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_post BP ON (C.POST_ID = BP.ID)"),
				"BLOG_POST_MICRO" => array("FIELD" => "BP.MICRO", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_post BP ON (C.POST_ID = BP.ID)"),
			);
				
		if(isset($arFilter["GROUP_CHECK_PERMS"]))
		{
			if(is_array($arFilter["GROUP_CHECK_PERMS"]))
			{
				foreach($arFilter["GROUP_CHECK_PERMS"] as $val)
				{
					if(IntVal($val)>0)
					{
						$arFields["POST_PERM_".$val] = Array(
								"FIELD" => "BUGP".$val.".PERMS", 
								"TYPE" => "string", 
								"FROM" => "LEFT JOIN b_blog_user_group_perms BUGP".$val." 
											ON (C.BLOG_ID = BUGP".$val.".BLOG_ID 
												AND C.POST_ID = BUGP".$val.".POST_ID 
												AND BUGP".$val.".USER_GROUP_ID = ".$val." 
												AND BUGP".$val.".PERMS_TYPE = '".BLOG_PERMS_COMMENT."')"
							);
						$arSelectFields[] = "POST_PERM_".$val;
					}
				}
			}
			else
			{
				if(IntVal($arFilter["GROUP_CHECK_PERMS"])>0)
				{
					$arFields["POST_PERM_".$arFilter["GROUP_CHECK_PERMS"]] = Array(
							"FIELD" => "BUGP.PERMS", 
							"TYPE" => "string", 
							"FROM" => "LEFT JOIN b_blog_user_group_perms BUGP 
										ON (C.BLOG_ID = BUGP.BLOG_ID 
											AND C.POST_ID = BUGP.POST_ID 
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:blog_comment.php

示例5: GetListUni

 protected static function GetListUni($arOrder = array(), $arFilter = array(), $arSelectFields = array(), $mode = self::GET_LIST_ALL, $lessonId = -1, $arNavParams = array())
 {
     global $DB, $USER_FIELD_MANAGER;
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity('LEARNING_LESSONS', 'TL.ID');
     $obUserFieldsSql->SetSelect($arSelectFields);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     $bReplaceCourseId = false;
     if (isset($arFilter['#REPLACE_COURSE_ID_TO_ID'])) {
         $bReplaceCourseId = true;
         unset($arFilter['#REPLACE_COURSE_ID_TO_ID']);
     }
     $oPermParser = new CLearnParsePermissionsFromFilter($arFilter);
     // For ordering
     $arMap = array('lesson_id' => 'TL.ID', 'site_id' => 'TL.ID', 'name' => 'TL.NAME', 'code' => 'TL.CODE', 'active' => 'TL.ACTIVE', 'created' => 'TL.DATE_CREATE', 'date_create' => 'TL.DATE_CREATE', 'created_by' => 'TL.CREATED_BY', 'timestamp_x' => 'TL.TIMESTAMP_X', 'course_id' => 'TC.ID', 'course_sort' => 'TC.SORT', 'active_from' => 'TC.ACTIVE_FROM', 'sort' => 'TC.SORT', 'linked_lesson_id' => 'TC.LINKED_LESSON_ID');
     $allowedModes = array(self::GET_LIST_ALL, self::GET_LIST_IMMEDIATE_CHILDS_OF, self::GET_LIST_IMMEDIATE_PARENTS_OF, self::GET_LIST_IMMEDIATE_CHILDS_OF | self::GET_LIST_IMMEDIATE_PARENTS_OF);
     $argsCheck = is_array($arOrder) && is_array($arSelectFields) && in_array($mode, $allowedModes, true) && self::_EnsureArgsStrictlyCastableToIntegers($lessonId);
     if (!$argsCheck) {
         throw new LearnException('EA_PARAMS', LearnException::EXC_ERR_ALL_PARAMS);
     }
     $arFieldsMap = array('LESSON_ID' => 'TL.ID', 'SITE_ID' => 'CASE WHEN (1 > 0) THEN \'no site\' ELSE \'0\' END', 'WAS_CHAPTER_ID' => 'TL.WAS_CHAPTER_ID', 'KEYWORDS' => 'TL.KEYWORDS', 'CHILDS_CNT' => '(SELECT COUNT(*) FROM b_learn_lesson_edges TLES WHERE TLES.SOURCE_NODE = TL.ID)', 'IS_CHILDS' => 'CASE WHEN (SELECT COUNT(*) FROM b_learn_lesson_edges TLES WHERE TLES.SOURCE_NODE = TL.ID) > 0 THEN \'1\' ELSE \'0\' END', 'SORT' => 'TC.SORT', 'TIMESTAMP_X' => $DB->DateToCharFunction('TL.TIMESTAMP_X'), 'DATE_CREATE' => $DB->DateToCharFunction('TL.DATE_CREATE'), 'CREATED_USER_NAME' => $DB->Concat("'('", 'TU.LOGIN', "') '", 'TU.NAME', "' '", 'TU.LAST_NAME'), 'CREATED_BY' => 'TL.CREATED_BY', 'ACTIVE' => 'TL.ACTIVE', 'NAME' => 'TL.NAME', 'PREVIEW_PICTURE' => 'TL.PREVIEW_PICTURE', 'PREVIEW_TEXT' => 'TL.PREVIEW_TEXT', 'PREVIEW_TEXT_TYPE' => 'TL.PREVIEW_TEXT_TYPE', 'DETAIL_TEXT' => 'TL.DETAIL_TEXT', 'DETAIL_PICTURE' => 'TL.DETAIL_PICTURE', 'DETAIL_TEXT_TYPE' => 'TL.DETAIL_TEXT_TYPE', 'LAUNCH' => 'TL.LAUNCH', 'CODE' => 'TL.CODE', 'ACTIVE_FROM' => $DB->DateToCharFunction('TC.ACTIVE_FROM'), 'ACTIVE_TO' => $DB->DateToCharFunction('TC.ACTIVE_TO'), 'RATING' => 'TC.RATING', 'RATING_TYPE' => 'TC.RATING_TYPE', 'SCORM' => 'TC.SCORM', 'LINKED_LESSON_ID' => 'TC.LINKED_LESSON_ID', 'COURSE_ID' => 'TC.ID', 'COURSE_SORT' => 'TC.SORT');
     // filter by TIMESTAMP_X by default
     if (count($arOrder) == 0) {
         $arOrder['TIMESTAMP_X'] = 'DESC';
     }
     $arSqlSearch = self::GetFilter($arFilter, $mode);
     if (isset($arFilter['SITE_ID'])) {
         $arLID = array();
         if (is_array($arFilter['SITE_ID'])) {
             $arLID = $arFilter['SITE_ID'];
         } else {
             if (strlen($arFilter['SITE_ID']) > 0) {
                 $arLID[] = $arFilter['SITE_ID'];
             }
         }
         $SqlSearchLang = "''";
         foreach ($arLID as $v) {
             $SqlSearchLang .= ", '" . $DB->ForSql($v) . "'";
         }
     }
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $arSqlSearch[] = "(" . $r . ")";
     }
     $sqlSearch = '';
     foreach ($arSqlSearch as $value) {
         if (strlen($value) > 0) {
             $sqlSearch .= ' AND ' . $value;
         }
     }
     $modeSQL_join = $modeSQL_where = '';
     $modeSQL_defaultSortField = "TC.SORT";
     // as SORT
     // Prepare SQL's joins, if $mode need it
     if ($mode & self::GET_LIST_IMMEDIATE_PARENTS_OF) {
         $modeSQL_join .= "\nINNER JOIN b_learn_lesson_edges TLE \n\t\t\t\tON TLE.SOURCE_NODE = TL.ID\n";
         $modeSQL_where .= "\nAND TLE.TARGET_NODE = " . ($lessonId + 0) . "\n";
         $arFieldsMap['EDGE_SORT'] = 'TLE.SORT';
         $arFieldsMap['SORT'] = 'TLE.SORT';
     }
     if ($mode & self::GET_LIST_IMMEDIATE_CHILDS_OF) {
         /**
          * GROUP BY works for MySQL, MSSQL, Oracle
          * select a.id, a.NAME, count(b.USER_ID) as C 
          * from b_group a, b_user_group b
          * where a.id = b.GROUP_ID
          * group by a.id, a.NAME
          * order by C
          */
         $modeSQL_join .= "\nINNER JOIN b_learn_lesson_edges TLE \n\t\t\t\tON TLE.TARGET_NODE = TL.ID\n";
         $modeSQL_where .= "\nAND TLE.SOURCE_NODE = " . ($lessonId + 0) . "\n";
         $arMap['childs_cnt'] = 'CHILDS_CNT';
         $arMap['is_childs'] = 'IS_CHILDS';
         $arMap['edge_sort'] = 'TLE.SORT';
         // Override default sort
         $arMap['sort'] = $arMap['edge_sort'];
         $modeSQL_defaultSortField = "TLE.SORT";
         // as SORT
         $arFieldsMap['EDGE_SORT'] = 'TLE.SORT';
         $arFieldsMap['SORT'] = 'TLE.SORT';
     }
     if ($bReplaceCourseId) {
         $arFieldsMap['ID'] = $arFieldsMap['COURSE_ID'];
     }
     // Select all fields by default
     if (count($arSelectFields) == 0) {
         $arSelectFields = array_keys($arFieldsMap);
     }
     // Ensure that all order fields will be selected
     foreach ($arOrder as $by => $order) {
         $fieldName = strtoupper($by);
         if (!in_array($fieldName, $arSelectFields)) {
             $arSelectFields[] = $fieldName;
         }
     }
     // Build list of fields to be selected
     $strSqlSelect = '';
     $bFirstPass = true;
     $bDefaultSortFieldSelected = false;
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:clearnlesson.php

示例6: GetList


//.........这里部分代码省略.........
                     break;
                 case 'SUPPORTTEAM_GROUP_ID':
                 case 'CLIENT_GROUP_ID':
                     if ($key == 'SUPPORTTEAM_GROUP_ID') {
                         $table = 'UGS';
                         $bJoinSupportTeamTbl = true;
                     } else {
                         $table = 'UGC';
                         $bJoinClientTbl = true;
                     }
                     if (is_array($val)) {
                         $val = array_map('intval', $val);
                         $val = array_unique($val);
                         $val = array_filter($val);
                         if (count($val) > 0) {
                             $arSqlSearch[] = '(' . $table . '.GROUP_ID IS NOT NULL AND ' . $table . '.GROUP_ID IN (' . implode(',', $val) . '))';
                         }
                     } else {
                         $val = intval($val);
                         if ($val > 0) {
                             $arSqlSearch[] = '(' . $table . '.GROUP_ID IS NOT NULL AND ' . $table . '.GROUP_ID=\'' . $val . '\')';
                         }
                     }
                     break;
                 case 'COUPON':
                     $match = $matchValueSet && $arFilter[$key . "_EXACT_MATCH"] != "Y" ? "Y" : "N";
                     $arSqlSearch[] = GetFilterQuery("T." . $key, $val, $match);
                     break;
             }
         }
     }
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("SUPPORT", "T.ID");
     $obUserFieldsSql->SetSelect($arParams["SELECT"]);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder(array($by => $order));
     if ($by == "s_id") {
         $strSqlOrder = "ORDER BY T.ID";
     } elseif ($by == "s_last_message_date") {
         $strSqlOrder = "ORDER BY T.LAST_MESSAGE_DATE";
     } elseif ($by == "s_site_id" || $by == "s_lid") {
         $strSqlOrder = "ORDER BY T.SITE_ID";
     } elseif ($by == "s_lamp") {
         $strSqlOrder = "ORDER BY LAMP";
     } elseif ($by == "s_is_overdue") {
         $strSqlOrder = "ORDER BY T.IS_OVERDUE";
     } elseif ($by == "s_is_notified") {
         $strSqlOrder = "ORDER BY T.IS_NOTIFIED";
     } elseif ($by == "s_date_create") {
         $strSqlOrder = "ORDER BY T.DATE_CREATE";
     } elseif ($by == "s_timestamp" || $by == "s_timestamp_x") {
         $strSqlOrder = "ORDER BY T.TIMESTAMP_X";
     } elseif ($by == "s_date_close") {
         $strSqlOrder = "ORDER BY T.DATE_CLOSE";
     } elseif ($by == "s_owner") {
         $strSqlOrder = "ORDER BY T.OWNER_USER_ID";
     } elseif ($by == "s_modified_by") {
         $strSqlOrder = "ORDER BY T.MODIFIED_USER_ID";
     } elseif ($by == "s_title") {
         $strSqlOrder = "ORDER BY T.TITLE ";
     } elseif ($by == "s_responsible") {
         $strSqlOrder = "ORDER BY T.RESPONSIBLE_USER_ID";
     } elseif ($by == "s_messages") {
         $strSqlOrder = "ORDER BY T.MESSAGES";
     } elseif ($by == "s_category") {
         $strSqlOrder = "ORDER BY T.CATEGORY_ID";
开发者ID:rasuldev,项目名称:torino,代码行数:67,代码来源:support.php

示例7: PrepareSql

 function PrepareSql(&$arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $arUF = array())
 {
     global $DB;
     $obUserFieldsSql = false;
     if (is_array($arUF) && array_key_exists("ENTITY_ID", $arUF)) {
         $obUserFieldsSql = new CUserTypeSQL();
         $obUserFieldsSql->SetEntity($arUF["ENTITY_ID"], $arFields["ID"]["FIELD"]);
         $obUserFieldsSql->SetSelect($arSelectFields);
         $obUserFieldsSql->SetFilter($arFilter);
         $obUserFieldsSql->SetOrder($arOrder);
     }
     $strSqlSelect = "";
     $strSqlFrom = "";
     $strSqlWhere = "";
     $strSqlGroupBy = "";
     $strSqlOrderBy = "";
     $arGroupByFunct = array("COUNT", "AVG", "MIN", "MAX", "SUM");
     $arAlreadyJoined = array();
     // GROUP BY -->
     if (is_array($arGroupBy) && count($arGroupBy) > 0) {
         $arSelectFields = $arGroupBy;
         foreach ($arGroupBy as $key => $val) {
             $val = strtoupper($val);
             $key = strtoupper($key);
             if (array_key_exists($val, $arFields) && !in_array($key, $arGroupByFunct)) {
                 if (strlen($strSqlGroupBy) > 0) {
                     $strSqlGroupBy .= ", ";
                 }
                 $strSqlGroupBy .= $arFields[$val]["FIELD"];
                 if (isset($arFields[$val]["FROM"]) && strlen($arFields[$val]["FROM"]) > 0 && !in_array($arFields[$val]["FROM"], $arAlreadyJoined)) {
                     if (strlen($strSqlFrom) > 0) {
                         $strSqlFrom .= " ";
                     }
                     $strSqlFrom .= $arFields[$val]["FROM"];
                     $arAlreadyJoined[] = $arFields[$val]["FROM"];
                 }
             }
         }
     }
     // <-- GROUP BY
     // WHERE -->
     $arAlreadyJoinedOld = $arAlreadyJoined;
     $strSqlWhere .= CSqlUtil::PrepareWhere($arFields, $arFilter, $arAlreadyJoined);
     $arAlreadyJoinedDiff = array_diff($arAlreadyJoined, $arAlreadyJoinedOld);
     foreach ($arAlreadyJoinedDiff as $from_tmp) {
         if (strlen($strSqlFrom) > 0) {
             $strSqlFrom .= " ";
         }
         $strSqlFrom .= $from_tmp;
     }
     if ($obUserFieldsSql) {
         $r = $obUserFieldsSql->GetFilter();
         if (strlen($r) > 0) {
             $strSqlWhere .= (strlen($strSqlWhere) > 0 ? " AND" : "") . " (" . $r . ") ";
         }
     }
     // <-- WHERE
     // ORDER BY -->
     $arSqlOrder = array();
     foreach ($arOrder as $by => $order) {
         $by = strtoupper($by);
         $order = strtoupper($order);
         if ($order != "ASC") {
             $order = "DESC";
         } else {
             $order = "ASC";
         }
         if (array_key_exists($by, $arFields)) {
             if ($arFields[$by]["TYPE"] == "datetime" || $arFields[$by]["TYPE"] == "date") {
                 $arSqlOrder[] = " " . $by . "_X1 " . $order . " ";
                 if (!is_array($arSelectFields) || !in_array($by, $arSelectFields)) {
                     $arSelectFields[] = $by;
                 }
             } else {
                 $arSqlOrder[] = " " . $arFields[$by]["FIELD"] . " " . $order . " ";
             }
             if (isset($arFields[$by]["FROM"]) && strlen($arFields[$by]["FROM"]) > 0 && !in_array($arFields[$by]["FROM"], $arAlreadyJoined)) {
                 if (strlen($strSqlFrom) > 0) {
                     $strSqlFrom .= " ";
                 }
                 $strSqlFrom .= $arFields[$by]["FROM"];
                 $arAlreadyJoined[] = $arFields[$by]["FROM"];
             }
         } elseif ($obUserFieldsSql && ($s = $obUserFieldsSql->GetOrder($by))) {
             $arSqlOrder[$by] = " " . $s . " " . $order . " ";
         }
     }
     $strSqlOrderBy = "";
     DelDuplicateSort($arSqlOrder);
     $tmp_count = count($arSqlOrder);
     for ($i = 0; $i < $tmp_count; $i++) {
         if (strlen($strSqlOrderBy) > 0) {
             $strSqlOrderBy .= ", ";
         }
         if (strtoupper($DB->type) == "ORACLE") {
             if (substr($arSqlOrder[$i], -3) == "ASC") {
                 $strSqlOrderBy .= $arSqlOrder[$i] . " NULLS FIRST";
             } else {
                 $strSqlOrderBy .= $arSqlOrder[$i] . " NULLS LAST";
             }
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:group.php

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: GetList

 public static function GetList($Params = array())
 {
     global $DB, $USER_FIELD_MANAGER;
     $getUF = $Params['getUserfields'] !== false;
     $checkPermissions = $Params['checkPermissions'] !== false;
     $bCache = CCalendar::CacheTime() > 0;
     $Params['setDefaultLimit'] = $Params['setDefaultLimit'] === true;
     $userId = isset($Params['userId']) ? intVal($Params['userId']) : CCalendar::GetCurUserId();
     CTimeZone::Disable();
     if ($bCache) {
         $cache = new CPHPCache();
         $cacheId = 'event_list_' . md5(serialize($Params));
         if ($checkPermissions) {
             $cacheId .= 'chper' . CCalendar::GetCurUserId() . '|';
         }
         if (CCalendar::IsSocNet() && CCalendar::IsSocnetAdmin()) {
             $cacheId .= 'socnetAdmin|';
         }
         $cacheId .= CCalendar::GetOffset();
         $cachePath = CCalendar::CachePath() . 'event_list';
         if ($cache->InitCache(CCalendar::CacheTime(), $cacheId, $cachePath)) {
             $res = $cache->GetVars();
             $arResult = $res["arResult"];
             $arAttendees = $res["arAttendees"];
         }
     }
     if (!$bCache || !isset($arResult)) {
         $arFilter = $Params['arFilter'];
         if ($getUF) {
             $obUserFieldsSql = new CUserTypeSQL();
             $obUserFieldsSql->SetEntity("CALENDAR_EVENT", "CE.ID");
             $obUserFieldsSql->SetSelect(array("UF_*"));
             $obUserFieldsSql->SetFilter($arFilter);
         }
         $fetchMeetings = $Params['fetchMeetings'];
         $Params['fetchAttendees'] = $Params['fetchAttendees'] !== false;
         $skipDeclined = $Params['skipDeclined'] === true;
         if ($Params['setDefaultLimit'] !== false) {
             if (!isset($arFilter["FROM_LIMIT"])) {
                 // default 3 month back
                 $arFilter["FROM_LIMIT"] = CCalendar::Date(time() - 31 * 3 * 24 * 3600, false);
             }
             if (!isset($arFilter["TO_LIMIT"])) {
                 // default one year into the future
                 $arFilter["TO_LIMIT"] = CCalendar::Date(time() + 365 * 24 * 3600, false);
             }
         }
         $arOrder = isset($Params['arOrder']) ? $Params['arOrder'] : array('SORT' => 'asc');
         $arFields = self::GetFields();
         if ($arFilter["DELETED"] === false) {
             unset($arFilter["DELETED"]);
         } elseif (!isset($arFilter["DELETED"])) {
             $arFilter["DELETED"] = "N";
         }
         $ownerId = isset($arFilter['OWNER_ID']) ? $arFilter['OWNER_ID'] : CCalendar::GetOwnerId();
         $arSqlSearch = array();
         if (is_array($arFilter)) {
             $filter_keys = array_keys($arFilter);
             for ($i = 0, $l = count($filter_keys); $i < $l; $i++) {
                 $n = strtoupper($filter_keys[$i]);
                 $val = $arFilter[$filter_keys[$i]];
                 if (is_string($val) && strlen($val) <= 0 || strval($val) == "NOT_REF") {
                     continue;
                 }
                 if ($n == 'FROM_LIMIT') {
                     $ts = CCalendar::Timestamp($val, false);
                     if ($ts > 0) {
                         $arSqlSearch[] = "CE.DATE_TO_TS_UTC>=" . $ts;
                     }
                 } elseif ($n == 'TO_LIMIT') {
                     $ts = CCalendar::Timestamp($val, false);
                     if ($ts > 0) {
                         $arSqlSearch[] = "CE.DATE_FROM_TS_UTC<=" . ($ts + 86399);
                     }
                 } elseif ($n == 'OWNER_ID' && intVal($val) > 0) {
                     $arSqlSearch[] = "CE.OWNER_ID=" . intVal($val);
                 }
                 if ($n == 'NAME') {
                     $arSqlSearch[] = "CE.NAME='" . CDatabase::ForSql($val) . "'";
                 } elseif ($n == 'CREATED_BY') {
                     if (is_array($val)) {
                         $val = array_map(intVal, $val);
                         $arSqlSearch[] = 'CE.CREATED_BY IN (\'' . implode('\',\'', $val) . '\')';
                     } else {
                         if (intVal($val) > 0) {
                             $arSqlSearch[] = "CE.CREATED_BY=" . intVal($val);
                         }
                     }
                 } elseif ($n == 'SECTION') {
                     if (!is_array($val)) {
                         $val = array($val);
                     }
                     $q = "";
                     if (is_array($val)) {
                         $sval = '';
                         foreach ($val as $sectid) {
                             if (intVal($sectid) > 0) {
                                 $sval .= intVal($sectid) . ',';
                             }
                         }
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:calendar_event.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

 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


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