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


PHP CUserTypeSQL类代码示例

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


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

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

示例2: GetList


//.........这里部分代码省略.........
                 case "IS_SPAM_MAYBE":
                     $arSqlSearch[] = $val == "Y" ? "T.IS_SPAM='N'" : "(T.IS_SPAM='Y' or T.IS_SPAM is null)";
                     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";
开发者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

	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: GetDestinationUsers

 public static function GetDestinationUsers($arCodes, $bFetchUsers = false)
 {
     global $DB;
     $arUsers = array();
     $arCodes2 = array();
     if (!$bFetchUsers) {
         foreach ($arCodes as $code) {
             if (substr($code, 0, 1) === 'U' && $code !== 'UA') {
                 $id = intVal(substr($code, 1));
                 if ($id > 0) {
                     $arUsers[] = $id;
                     continue;
                 }
             }
             if (substr($code, 0, 2) === 'SG') {
                 $arCodes2[] = $code . '_K';
             }
             $arCodes2[] = $code;
         }
         $bUnique = count($arCodes2) > 0 && count($arUsers) > 0;
     } else {
         foreach ($arCodes as $code) {
             if (substr($code, 0, 2) === 'SG') {
                 $arCodes2[] = $code . '_K';
             }
             $arCodes2[] = $code;
         }
         $bUnique = false;
     }
     $obUserFieldsSql = new CUserTypeSQL();
     $obUserFieldsSql->SetEntity("USER", "USER_ID");
     $obUserFieldsSql->SetFilter(array("!UF_DEPARTMENT" => false));
     $where = $obUserFieldsSql->GetFilter();
     $join = $obUserFieldsSql->GetJoin("UA.USER_ID");
     if ($where == '') {
         $where = '1=1';
     }
     $strCodes = in_array('UA', $arCodes2) ? "'G2'" : "'" . join("','", $arCodes2) . "'";
     if ($bFetchUsers) {
         $strSql = "SELECT DISTINCT UA.USER_ID, U.LOGIN, U.NAME, U.LAST_NAME, U.SECOND_NAME, U.EMAIL, U.PERSONAL_PHOTO, U.WORK_POSITION " . "FROM b_user_access UA\n\t\t\t\tINNER JOIN b_user U ON (U.ID=UA.USER_ID)" . $join . " WHERE ACCESS_CODE in (" . $strCodes . ") AND " . $where;
     } else {
         $strSql = "SELECT DISTINCT USER_ID " . "FROM b_user_access UA " . $join . " WHERE ACCESS_CODE in (" . $strCodes . ") AND " . $where;
     }
     $res = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     if ($bFetchUsers) {
         while ($ar = $res->Fetch()) {
             if ($ar > 0) {
                 $arUsers[] = $ar;
             }
         }
     } else {
         while ($ar = $res->Fetch()) {
             if ($ar['USER_ID'] > 0) {
                 $arUsers[] = $ar['USER_ID'];
             }
         }
     }
     if ($bUnique) {
         $arUsers = array_unique($arUsers);
     }
     return $arUsers;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:62,代码来源:calendar.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


//.........这里部分代码省略.........
  *     $TEST_ID = 45;
  *     $STUDENT_ID = 3;
  * 
  *     $res = CTestAttempt::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';
开发者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

 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

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

示例15: GetList


//.........这里部分代码省略.........
  * {
  *     $COURSE_ID = 97;
  * 
  *     $res = CLQuestion::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") {
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:67,代码来源:question.php


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