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


PHP CDBResult::SetUserFields方法代码示例

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


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

示例1: Prepare


//.........这里部分代码省略.........
     if (count($this->afterPrepareSqlCallback) > 0) {
         $arUserSql = call_user_func_array($this->afterPrepareSqlCallback, array($this, $arOrder, $arFilter, $arGroupBy, $arSelectFields));
         if (is_array($arUserSql)) {
             if (isset($arUserSql['FROM'])) {
                 $this->Add2SqlData($arUserSql['FROM'], 'FROM');
             }
             if (isset($arUserSql['WHERE'])) {
                 $this->Add2SqlData($arUserSql['WHERE'], 'WHERE');
             }
         }
     }
     if ($ufSelectSql) {
         // Adding user fields to SELECT
         $this->Add2SqlData($ufSelectSql->GetSelect(), 'SELECT');
         // Adding user fields to ORDER BY
         if (is_array($arOrder)) {
             foreach ($arOrder as $orderKey => $order) {
                 $orderSql = $ufSelectSql->GetOrder($orderKey);
                 if (!is_string($orderSql) || $orderSql === '') {
                     continue;
                 }
                 $order = strtoupper($order);
                 if ($order !== 'ASC' && $order !== 'DESC') {
                     $order = 'ASC';
                 }
                 $this->Add2SqlData("{$orderSql} {$order}", 'ORDERBY');
             }
         }
         // Adding user fields to joins
         $this->Add2SqlData($ufSelectSql->GetJoin($this->tableAlias . '.ID'), 'FROM');
     }
     if ($ufFilterSql) {
         // Adding user fields to WHERE
         $ufWhere = $ufFilterSql->GetFilter();
         if ($ufWhere !== '') {
             $ufSql = $this->tableAlias . '.ID IN (SELECT ' . $this->tableAlias . '.ID FROM ' . $this->tableName . ' ' . $this->tableAlias . ' ' . $ufFilterSql->GetJoin($this->tableAlias . '.ID') . ' WHERE ' . $ufWhere . ')';
             // Adding user fields to joins
             $this->Add2SqlData($ufSql, 'WHERE');
         }
     }
     //Get count only
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         return $this->GetRowCount(RestrictionManager::getSqlRestriction()->getRowCountThreshold());
     }
     $sql = 'SELECT ' . $this->sqlData['SELECT'] . ' FROM ' . $this->tableName . ' ' . $this->tableAlias;
     if (isset($this->sqlData['FROM'][0])) {
         $sql .= ' ' . $this->sqlData['FROM'];
     }
     if (isset($this->sqlData['WHERE'][0])) {
         $sql .= ' WHERE ' . $this->sqlData['WHERE'];
     }
     if (isset($this->sqlData['GROUPBY'][0])) {
         $sql .= ' GROUP BY ' . $this->sqlData['GROUPBY'];
     }
     if (isset($this->sqlData['ORDERBY'][0])) {
         $sql .= ' ORDER BY ' . $this->sqlData['ORDERBY'];
     }
     $enableNavigation = is_array($arNavStartParams);
     $top = $enableNavigation && isset($arNavStartParams['nTopCount']) ? intval($arNavStartParams['nTopCount']) : 0;
     if ($enableNavigation && $top <= 0) {
         $dbRes = new CDBResult();
         if ($this->ufEntityID !== '') {
             $dbRes->SetUserFields($GLOBALS['USER_FIELD_MANAGER']->GetUserFields($this->ufEntityID));
         } elseif (!empty($this->userFields)) {
             $dbRes->SetUserFields($this->userFields);
         }
         //Trace('CCrmEntityListBuilder::Prepare, SQL', $sql, 1);
         $cnt = $this->GetRowCount(RestrictionManager::getSqlRestriction()->getRowCountThreshold());
         $dbRes->NavQuery($sql, $cnt, $arNavStartParams);
     } else {
         $limit = $top;
         $offset = 0;
         if (isset($arOptions['QUERY_OPTIONS']) && is_array($arOptions['QUERY_OPTIONS'])) {
             $queryOptions = $arOptions['QUERY_OPTIONS'];
             $limit = isset($queryOptions['LIMIT']) ? (int) $queryOptions['LIMIT'] : 0;
             $offset = isset($queryOptions['OFFSET']) ? (int) $queryOptions['OFFSET'] : 0;
         }
         $threshold = RestrictionManager::getSqlRestriction()->getRowCountThreshold();
         if ($threshold > 0 && $threshold < $limit + $offset) {
             $delta = $threshold - $offset;
             if ($delta <= 0) {
                 $obRes = new CDBResult();
                 $obRes->InitFromArray(array());
                 return $obRes;
             }
             $limit = $delta;
         }
         if ($limit > 0) {
             $sql = Main\Application::getConnection()->getSqlHelper()->getTopSql($sql, $limit, $offset);
         }
         //Trace('CCrmEntityListBuilder::Prepare, SQL', $sql, 1);
         $dbRes = $DB->Query($sql, false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__);
         if ($this->ufEntityID !== '') {
             $dbRes->SetUserFields($GLOBALS['USER_FIELD_MANAGER']->GetUserFields($this->ufEntityID));
         } elseif (!empty($this->userFields)) {
             $dbRes->SetUserFields($this->userFields);
         }
     }
     return $dbRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:crm_entity_list_builder.php

示例2: GetList


//.........这里部分代码省略.........
		else
			$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
		
		$r = $obUserFieldsSql->GetFilter();
		if(strlen($r)>0)
			$strSqlUFFilter = " (".$r.") ";

		if (is_array($arGroupBy) && count($arGroupBy)==0)
		{
			$strSql =
				"SELECT ".$arSqls["SELECT"]." ".
					$obUserFieldsSql->GetSelect()." ".
				"FROM b_blog_comment C ".
				"	".$arSqls["FROM"]." ".
					$obUserFieldsSql->GetJoin("C.ID")." ";
			if (strlen($arSqls["WHERE"]) > 0)
				$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 (strlen($arSqls["GROUPBY"]) > 0)
				$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			if ($arRes = $dbRes->Fetch())
				return $arRes["CNT"];
			else
				return False;
		}
		
		$strSql =
			"SELECT ".$arSqls["SELECT"]." ".
				$obUserFieldsSql->GetSelect()." ".
			"FROM b_blog_comment C ".
			"	".$arSqls["FROM"]." ".
				$obUserFieldsSql->GetJoin("C.ID")." ";
		if (strlen($arSqls["WHERE"]) > 0)
			$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 (strlen($arSqls["GROUPBY"]) > 0)
			$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
		if (strlen($arSqls["ORDERBY"]) > 0)
			$strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";

		if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"])<=0)
		{
			$strSql_tmp =
				"SELECT COUNT('x') as CNT ".
					$obUserFieldsSql->GetSelect()." ".
				"FROM b_blog_comment C ".
				"	".$arSqls["FROM"]." ".
				$obUserFieldsSql->GetJoin("C.ID")." ";
			if (strlen($arSqls["WHERE"]) > 0)
				$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 (strlen($arSqls["GROUPBY"]) > 0)
				$strSql_tmp .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";

			$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();

			//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
			$dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_POST"));
			$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
		}
		else
		{
			if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0)
				$strSql .= "LIMIT ".IntVal($arNavStartParams["nTopCount"]);

			//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_POST"));
		}
		return $dbRes;
	}
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:blog_comment.php

示例3: GetList


//.........这里部分代码省略.........

		$r = $obUserFieldsSql->GetFilter();
		if(strlen($r)>0)
			$strSqlUFFilter = " (".$r.") ";

		if (is_array($arGroupBy) && count($arGroupBy)==0)
		{
			$strSql =
				"SELECT ".$arSqls["SELECT"]." ".
					$obUserFieldsSql->GetSelect()." ".
				"FROM b_blog_post P ".
				"	".$arSqls["FROM"]." ".
					$obUserFieldsSql->GetJoin("P.ID")." ";
			if (strlen($arSqls["WHERE"]) > 0)
				$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 (strlen($arSqls["GROUPBY"]) > 0)
				$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			if ($arRes = $dbRes->Fetch())
				return $arRes["CNT"];
			else
				return False;
		}

		$strSql =
			"SELECT ".$arSqls["SELECT"]." ".
				$obUserFieldsSql->GetSelect()." ".
			"FROM b_blog_post P ".
			"	".$arSqls["FROM"]." ".
				$obUserFieldsSql->GetJoin("P.ID")." ";
		if (strlen($arSqls["WHERE"]) > 0)
			$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 (strlen($arSqls["GROUPBY"]) > 0)
			$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
		if (strlen($arSqls["ORDERBY"]) > 0)
			$strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";
		if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"])<=0)
		{
			$strSql_tmp =
				"SELECT COUNT(DISTINCT P.ID) as CNT ".
				"FROM b_blog_post P ".
				"	".$arSqls["FROM"]." ".
					$obUserFieldsSql->GetJoin("P.ID")." ";
			if (strlen($arSqls["WHERE"]) > 0)
				$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 (strlen($arSqls["GROUPBY"]) > 0)
				$strSql_tmp .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";

			$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();

			//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_POST"));
			$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
		}
		else
		{
			if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0)
				$strSql .= "LIMIT ".IntVal($arNavStartParams["nTopCount"]);

			//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_POST"));
		}
		//echo "!4!=".htmlspecialcharsbx($strSql)."<br>";
		return $dbRes;
	}
开发者ID:akniyev,项目名称:arteva.ru,代码行数:101,代码来源:blog_post.php

示例4: GetList


//.........这里部分代码省略.........
		if (strlen($strSqlUFFilter) > 0)
		{
			$strSql .= ($bWhereStarted ? " AND " : " WHERE ").$strSqlUFFilter." ";
			$bWhereStarted = true;
		}

		if (strlen($arSqls["RIGHTS"]) > 0)
		{
			$strSql .= ($bWhereStarted ? " AND " : " WHERE ").$arSqls["RIGHTS"]." ";
			$bWhereStarted = true;
		}

		if (strlen($arSqls["CRM_RIGHTS"]) > 0)
		{
			$strSql .= ($bWhereStarted ? " AND " : " WHERE ").$arSqls["CRM_RIGHTS"]." ";
			$bWhereStarted = true;
		}

		if (strlen($arSqls["GROUPBY"]) > 0)
			$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
		if (strlen($arSqls["ORDERBY"]) > 0)
			$strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";

		if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0)
		{
			$strSql_tmp =
				"SELECT COUNT('x') as CNT ".
				$obUserFieldsSql->GetSelect()." ".
				"FROM b_sonet_log_comment LC ".
				"	".$arSqls["FROM"]." ".
				$obUserFieldsSql->GetJoin("LC.ID")." ";

			$bWhereStarted = false;

			if (strlen($arSqls["WHERE"]) > 0)
			{
				$strSql_tmp .= "WHERE ".$arSqls["WHERE"]." ".(strlen($arSqls["SUBSCRIBE"]) > 0 ? "AND (".$arSqls["SUBSCRIBE"].") " : "");
				$bWhereStarted = true;
			}
			elseif (strlen($arSqls["SUBSCRIBE"]) > 0)
			{
				$strSql_tmp .= "WHERE (".$arSqls["SUBSCRIBE"].") ";
				$bWhereStarted = true;
			}

			if (strlen($strSqlUFFilter) > 0)
			{
				$strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ").$strSqlUFFilter." ";
				$bWhereStarted = true;
			}

			if (strlen($arSqls["RIGHTS"]) > 0)
			{
				$strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ").$arSqls["RIGHTS"]." ";
				$bWhereStarted = true;
			}

			if (strlen($arSqls["CRM_RIGHTS"]) > 0)
			{
				$strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ").$arSqls["CRM_RIGHTS"]." ";
				$bWhereStarted = true;
			}

			if (strlen($arSqls["GROUPBY"]) > 0)
				$strSql_tmp .= "GROUP BY ".$arSqls["GROUPBY"]." ";

			//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";

			$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
			{
				// рнкэйн дкъ MYSQL!!! дкъ ORACLE дпсцни йнд
				$cnt = $dbRes->SelectedRowsCount();
			}

			$dbRes = new CDBResult();

			//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";

			$dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_COMMENT"));
			$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
		}
		else
		{
			if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0)
				$strSql .= "LIMIT ".intval($arNavStartParams["nTopCount"]);

			//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
			$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			$dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_COMMENT"));
		}

		return $dbRes;
	}
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:101,代码来源:log_comments.php

示例5: GetList


//.........这里部分代码省略.........
             $bWhereStarted = true;
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_sonet_log L " . $strMinIDJoin . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("L.ID") . " ";
     $bWhereStarted = false;
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         $bWhereStarted = true;
     }
     if (strlen($strSqlUFFilter) > 0) {
         $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $strSqlUFFilter . " ";
         $bWhereStarted = true;
     }
     if (strlen($arSqls["RIGHTS"]) > 0) {
         $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["RIGHTS"] . " ";
         $bWhereStarted = true;
     }
     if (strlen($arSqls["CRM_RIGHTS"]) > 0) {
         $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["CRM_RIGHTS"] . " ";
         $bWhereStarted = true;
     }
     if (strlen($arSqls["SUBSCRIBE"]) > 0) {
         $strSql .= ($bWhereStarted ? " AND " : " WHERE ") . "(" . $arSqls["SUBSCRIBE"] . ") ";
         $bWhereStarted = true;
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         if (isset($arNavStartParams["nRecordCount"]) && intval($arNavStartParams["nRecordCount"]) > 0) {
             $cnt = intval($arNavStartParams["nRecordCount"]);
         } else {
             $strSql_tmp = "SELECT COUNT('x') as CNT " . $obUserFieldsSql->GetSelect() . " " . "FROM b_sonet_log L " . $strMinIDJoin . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("L.ID") . " ";
             $bWhereStarted = false;
             if (strlen($arSqls["WHERE"]) > 0) {
                 $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
                 $bWhereStarted = true;
             }
             if (strlen($strSqlUFFilter) > 0) {
                 $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $strSqlUFFilter . " ";
                 $bWhereStarted = true;
             }
             if (strlen($arSqls["RIGHTS"]) > 0) {
                 $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["RIGHTS"] . " ";
                 $bWhereStarted = true;
             }
             if (strlen($arSqls["CRM_RIGHTS"]) > 0) {
                 $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . $arSqls["CRM_RIGHTS"] . " ";
                 $bWhereStarted = true;
             }
             if (strlen($arSqls["SUBSCRIBE"]) > 0) {
                 $strSql_tmp .= ($bWhereStarted ? " AND " : " WHERE ") . "(" . $arSqls["SUBSCRIBE"] . ") ";
                 $bWhereStarted = true;
             }
             if (strlen($arSqls["GROUPBY"]) > 0) {
                 $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
             }
             //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
             $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 {
                 // рнкэйн дкъ MYSQL!!! дкъ ORACLE дпсцни йнд
                 $cnt = $dbRes->SelectedRowsCount();
             }
             // for empty 2nd page show
             if ($arNavStartParams["bSkipPageReset"] && $arNavStartParams["nPageSize"] >= $cnt) {
                 $cnt = $arNavStartParams["nPageSize"] + $cnt;
             }
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_LOG"));
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . intval($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_LOG"));
     }
     return $dbRes;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:log.php

示例6: GetList


//.........这里部分代码省略.........
                 $needle = 'ALLOW_TIME_TRACKING';
                 break;
             default:
                 if (substr($by, 0, 3) === 'uf_') {
                     if ($s = $obUserFieldsSql->GetOrder($by)) {
                         $arSqlOrder[$by] = " " . $s . " " . $order . " ";
                     }
                 } else {
                     CTaskAssert::logWarning('[0x9a92cf7d] invalid sort by field requested: ' . $by);
                 }
                 break;
         }
         if ($needle !== null && !in_array($needle, $arSelect)) {
             $arSelect[] = $needle;
         }
     }
     $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 = "T.ID AS ID";
     }
     // First level logic MUST be 'AND', because of backward compatibility
     // and some requests for checking rights, attached at first level of filter.
     // Situtation when there is OR-logic at first level cannot be resolved
     // in general case.
     // So if there is OR-logic, it is FATAL error caused by programmer.
     // But, if you want to use OR-logic at the first level of filter, you
     // can do this by putting all your filter conditions to the ::SUBFILTER-xxx,
     // except CHECK_PERMISSIONS, SUBORDINATE_TASKS (if you don't know exactly,
     // what are consequences of this fields in OR-logic of subfilters).
     if (isset($arFilter['::LOGIC'])) {
         CTaskAssert::assert($arFilter['::LOGIC'] === 'AND');
     }
     $arSqlSearch = CTasks::GetFilter($arFilter, '', $arParams);
     if (!$bGetZombie) {
         $arSqlSearch[] = " T.ZOMBIE = 'N' ";
     }
     $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();
     if (in_array('COMMENTS_COUNT', $arSelect, true) || in_array('FORUM_ID', $arSelect, true)) {
         $bNeedJoinForumsTable = true;
     } else {
         $bNeedJoinForumsTable = false;
     }
     $strFrom = "\n\t\t\tFROM\n\t\t\t\tb_tasks T\n\t\t\tINNER JOIN b_user CU ON CU.ID = T.CREATED_BY \n\t\t\tINNER JOIN b_user RU ON RU.ID = T.RESPONSIBLE_ID \n\t\t\tLEFT JOIN b_tasks_viewed TV ON TV.TASK_ID = T.ID \n\t\t\t\tAND TV.USER_ID = " . $userID . " " . ($bNeedJoinForumsTable ? " LEFT JOIN b_forum_topic FT ON FT.ID = T.FORUM_TOPIC_ID " : "") . $obUserFieldsSql->GetJoin("T.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 ($nPageTop !== false && is_numeric($nPageTop)) {
         $strSql = $DB->TopSql($strSql, intval($nPageTop));
     }
     if (is_array($arParams) && array_key_exists("NAV_PARAMS", $arParams) && is_array($arParams["NAV_PARAMS"])) {
         $nTopCount = intval($arParams['NAV_PARAMS']['nTopCount']);
         if ($nTopCount > 0) {
             $strSql = $DB->TopSql($strSql, $nTopCount);
             $res = $DB->Query($strSql, $bIgnoreErrors, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             if ($res === false) {
                 throw new TasksException('', TasksException::TE_SQL_ERROR);
             }
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("TASKS_TASK"));
         } else {
             $res_cnt = $DB->Query("SELECT COUNT(T.ID) as C " . $strFrom);
             $res_cnt = $res_cnt->Fetch();
             $totalTasksCount = (int) $res_cnt["C"];
             // unknown by default
             // Sync counters in case of mistiming
             CTaskCountersProcessorHomeostasis::onTaskGetList($arFilter, $totalTasksCount);
             $res = new CDBResult();
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("TASKS_TASK"));
             $rc = $res->NavQuery($strSql, $totalTasksCount, $arParams["NAV_PARAMS"], $bIgnoreErrors);
             if ($bIgnoreErrors && $rc === false) {
                 throw new TasksException('', TasksException::TE_SQL_ERROR);
             }
         }
     } else {
         $res = $DB->Query($strSql, $bIgnoreErrors, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($res === false) {
             throw new TasksException('', TasksException::TE_SQL_ERROR);
         }
         $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("TASKS_TASK"));
     }
     return $res;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:task.php

示例7: GetList


//.........这里部分代码省略.........
         $strSqlOrder = "ORDER BY AUTO_CLOSE_DAYS_LEFT";
     } elseif ($by == 's_coupon') {
         $strSqlOrder = 'ORDER BY T.COUPON';
     } elseif ($by == 's_deadline') {
         $strSqlOrder = 'ORDER BY T.SUPPORT_DEADLINE';
     } elseif ($s = $obUserFieldsSql->GetOrder($by)) {
         $strSqlOrder = "ORDER BY " . strtoupper($s);
     } else {
         $by = "s_default";
         $strSqlOrder = "ORDER BY IS_SUPER_TICKET DESC, T.IS_OVERDUE DESC, T.IS_NOTIFIED DESC, T.LAST_MESSAGE_DATE";
     }
     if ($order != "asc") {
         $strSqlOrder .= " desc ";
         $order = "desc";
     }
     $arSqlSearch[] = $obUserFieldsSql->GetFilter();
     if ($getUserName == "Y") {
         $u_select = "\n\t\t\t\t,\n\t\t\t\tUO.LOGIN\t\t\t\t\t\t\t\t\t\t\t\t\tOWNER_LOGIN,\n\t\t\t\tUO.EMAIL\t\t\t\t\t\t\t\t\t\t\t\t\tOWNER_EMAIL,\n\t\t\t\tconcat(ifnull(UO.NAME,''),' ',ifnull(UO.LAST_NAME,''))\t\tOWNER_NAME,\n\t\t\t\tUR.LOGIN\t\t\t\t\t\t\t\t\t\t\t\t\tRESPONSIBLE_LOGIN,\n\t\t\t\tUR.EMAIL\t\t\t\t\t\t\t\t\t\t\t\t\tRESPONSIBLE_EMAIL,\n\t\t\t\tconcat(ifnull(UR.NAME,''),' ',ifnull(UR.LAST_NAME,''))\t\tRESPONSIBLE_NAME,\n\t\t\t\tUM.LOGIN\t\t\t\t\t\t\t\t\t\t\t\t\tMODIFIED_BY_LOGIN,\n\t\t\t\tUM.EMAIL\t\t\t\t\t\t\t\t\t\t\t\t\tMODIFIED_BY_EMAIL,\n\t\t\t\tconcat(ifnull(UM.NAME,''),' ',ifnull(UM.LAST_NAME,''))\t\tMODIFIED_BY_NAME,\n\t\t\t\tUM.LOGIN\t\t\t\t\t\t\t\t\t\t\t\t\tMODIFIED_LOGIN,\n\t\t\t\tUM.EMAIL\t\t\t\t\t\t\t\t\t\t\t\t\tMODIFIED_EMAIL,\n\t\t\t\tconcat(ifnull(UM.NAME,''),' ',ifnull(UM.LAST_NAME,''))\t\tMODIFIED_NAME,\n\t\t\t\tUL.LOGIN\t\t\t\t\t\t\t\t\t\t\t\t\tLAST_MESSAGE_LOGIN,\n\t\t\t\tUL.EMAIL\t\t\t\t\t\t\t\t\t\t\t\t\tLAST_MESSAGE_EMAIL,\n\t\t\t\tconcat(ifnull(UL.NAME,''),' ',ifnull(UL.LAST_NAME,''))\t\tLAST_MESSAGE_NAME,\n\t\t\t\tUC.LOGIN\t\t\t\t\t\t\t\t\t\t\t\t\tCREATED_LOGIN,\n\t\t\t\tUC.EMAIL\t\t\t\t\t\t\t\t\t\t\t\t\tCREATED_EMAIL,\n\t\t\t\tconcat(ifnull(UC.NAME,''),' ',ifnull(UC.LAST_NAME,''))\t\tCREATED_NAME\n\t\t\t";
         $u_join = "\n\t\t\tLEFT JOIN b_user UO ON (UO.ID = T.OWNER_USER_ID)\n\t\t\tLEFT JOIN b_user UR ON (UR.ID = T.RESPONSIBLE_USER_ID)\n\t\t\tLEFT JOIN b_user UM ON (UM.ID = T.MODIFIED_USER_ID)\n\t\t\tLEFT JOIN b_user UL ON (UL.ID = T.LAST_MESSAGE_USER_ID)\n\t\t\tLEFT JOIN b_user UC ON (UC.ID = T.CREATED_USER_ID)\n\t\t\t";
     }
     if ($getExtraNames == "Y") {
         $d_select = "\n\t\t\t\t,\n\t\t\t\tDC.NAME\t\t\t\t\t\t\t\t\t\t\t\t\t\tCATEGORY_NAME,\n\t\t\t\tDC.DESCR\t\t\t\t\t\t\t\t\t\t\t\t\tCATEGORY_DESC,\n\t\t\t\tDC.SID\t\t\t\t\t\t\t\t\t\t\t\t\t\tCATEGORY_SID,\n\t\t\t\tDK.NAME\t\t\t\t\t\t\t\t\t\t\t\t\t\tCRITICALITY_NAME,\n\t\t\t\tDK.DESCR\t\t\t\t\t\t\t\t\t\t\t\t\tCRITICALITY_DESC,\n\t\t\t\tDK.SID\t\t\t\t\t\t\t\t\t\t\t\t\t\tCRITICALITY_SID,\n\t\t\t\tDS.NAME\t\t\t\t\t\t\t\t\t\t\t\t\t\tSTATUS_NAME,\n\t\t\t\tDS.DESCR\t\t\t\t\t\t\t\t\t\t\t\t\tSTATUS_DESC,\n\t\t\t\tDS.SID\t\t\t\t\t\t\t\t\t\t\t\t\t\tSTATUS_SID,\n\t\t\t\tDM.NAME\t\t\t\t\t\t\t\t\t\t\t\t\tMARK_NAME,\n\t\t\t\tDM.DESCR\t\t\t\t\t\t\t\t\t\t\t\t\tMARK_DESC,\n\t\t\t\tDM.SID\t\t\t\t\t\t\t\t\t\t\t\t\t\tMARK_SID,\n\t\t\t\tDSR.NAME\t\t\t\t\t\t\t\t\t\t\t\t\tSOURCE_NAME,\n\t\t\t\tDSR.DESCR\t\t\t\t\t\t\t\t\t\t\t\t\tSOURCE_DESC,\n\t\t\t\tDSR.SID\t\t\t\t\t\t\t\t\t\t\t\t\t\tSOURCE_SID,\n\t\t\t\tDD.NAME\t\t\t\t\t\t\t\t\t\t\t\t\tDIFFICULTY_NAME,\n\t\t\t\tDD.DESCR\t\t\t\t\t\t\t\t\t\t\t\t\tDIFFICULTY_DESC,\n\t\t\t\tDD.SID\t\t\t\t\t\t\t\t\t\t\t\t\t\tDIFFICULTY_SID,\n\t\t\t\tSLA.NAME\t\t\t\t\t\t\t\t\t\t\t\t\tSLA_NAME\n\t\t\t";
         $d_join = "\n\t\t\tLEFT JOIN b_ticket_dictionary DC ON (DC.ID = T.CATEGORY_ID and DC.C_TYPE = 'C')\n\t\t\tLEFT JOIN b_ticket_dictionary DK ON (DK.ID = T.CRITICALITY_ID and DK.C_TYPE = 'K')\n\t\t\tLEFT JOIN b_ticket_dictionary DS ON (DS.ID = T.STATUS_ID and DS.C_TYPE = 'S')\n\t\t\tLEFT JOIN b_ticket_dictionary DM ON (DM.ID = T.MARK_ID and DM.C_TYPE = 'M')\n\t\t\tLEFT JOIN b_ticket_dictionary DSR ON (DSR.ID = T.SOURCE_ID and DSR.C_TYPE = 'SR')\n\t\t\tLEFT JOIN b_ticket_dictionary DD ON (DD.ID = T.DIFFICULTY_ID and DD.C_TYPE = 'D')\n\t\t\tLEFT JOIN b_ticket_sla SLA ON (SLA.ID = T.SLA_ID)\n\t\t\t";
     }
     if (strlen($siteID) > 0) {
         $dates_select = "\n\t\t\t\t" . $DB->DateToCharFunction("T.DATE_CREATE", "FULL", $siteID, true) . "\tDATE_CREATE,\n\t\t\t\t" . $DB->DateToCharFunction("T.TIMESTAMP_X", "FULL", $siteID, true) . "\tTIMESTAMP_X,\n\t\t\t\t" . $DB->DateToCharFunction("T.LAST_MESSAGE_DATE", "FULL", $siteID, true) . "\tLAST_MESSAGE_DATE,\n\t\t\t\t" . $DB->DateToCharFunction("T.DATE_CLOSE", "FULL", $siteID, true) . "\tDATE_CLOSE,\n\t\t\t\t" . $DB->DateToCharFunction("T.DATE_CREATE", "SHORT", $siteID, true) . "\tDATE_CREATE_SHORT,\n\t\t\t\t" . $DB->DateToCharFunction("T.TIMESTAMP_X", "SHORT", $siteID, true) . "\tTIMESTAMP_X_SHORT,\n\t\t\t\t" . $DB->DateToCharFunction("T.DATE_CLOSE", "SHORT", $siteID, true) . "\tDATE_CLOSE_SHORT,\n\t\t\t\t" . $DB->DateToCharFunction("T.SUPPORT_DEADLINE", "FULL", $siteID, true) . "\tSUPPORT_DEADLINE,\n\t\t\t\tCASE WHEN (UNIX_TIMESTAMP(T.DATE_CLOSE) IS NULL OR UNIX_TIMESTAMP(T.DATE_CLOSE) = 0) AND T.LAST_MESSAGE_BY_SUPPORT_TEAM = 'Y' THEN " . $DB->DateToCharFunction("ADDDATE(T.LAST_MESSAGE_DATE, INTERVAL T.AUTO_CLOSE_DAYS DAY)", "FULL", $siteID, true) . " ELSE NULL END AUTO_CLOSE_DATE\n\t\t\t";
     } else {
         $dates_select = "\n\t\t\t\t" . $DB->DateToCharFunction("T.DATE_CREATE", "FULL") . "\t\tDATE_CREATE,\n\t\t\t\t" . $DB->DateToCharFunction("T.TIMESTAMP_X", "FULL") . "\t\tTIMESTAMP_X,\n\t\t\t\t" . $DB->DateToCharFunction("T.LAST_MESSAGE_DATE", "FULL") . "\tLAST_MESSAGE_DATE,\n\t\t\t\t" . $DB->DateToCharFunction("T.DATE_CLOSE", "FULL") . "\t\tDATE_CLOSE,\n\t\t\t\t" . $DB->DateToCharFunction("T.DATE_CREATE", "SHORT") . "\tDATE_CREATE_SHORT,\n\t\t\t\t" . $DB->DateToCharFunction("T.TIMESTAMP_X", "SHORT") . "\tTIMESTAMP_X_SHORT,\n\t\t\t\t" . $DB->DateToCharFunction("T.DATE_CLOSE", "SHORT") . "\t\tDATE_CLOSE_SHORT,\n\t\t\t\t" . $DB->DateToCharFunction("T.SUPPORT_DEADLINE", "FULL") . "\tSUPPORT_DEADLINE,\n\t\t\t\tCASE WHEN (UNIX_TIMESTAMP(T.DATE_CLOSE) IS NULL OR UNIX_TIMESTAMP(T.DATE_CLOSE) = 0) AND T.LAST_MESSAGE_BY_SUPPORT_TEAM = 'Y' THEN " . $DB->DateToCharFunction("ADDDATE(T.LAST_MESSAGE_DATE, INTERVAL T.AUTO_CLOSE_DAYS DAY)", "FULL") . " ELSE NULL END AUTO_CLOSE_DATE\n\t\t\t";
     }
     $ugroupJoin = '';
     if ($bJoinSupportTeamTbl) {
         $ugroupJoin .= "\n\t\t\tLEFT JOIN b_ticket_user_ugroup UGS ON (UGS.USER_ID = T.RESPONSIBLE_USER_ID) ";
         $need_group = true;
     }
     if ($bJoinClientTbl) {
         $ugroupJoin .= "\n\t\t\tLEFT JOIN b_ticket_user_ugroup UGC ON (UGC.USER_ID = T.OWNER_USER_ID) ";
         $need_group = true;
     }
     // add permissions check
     if (!($bAdmin == 'Y' || $bDemo == 'Y')) {
         // a list of users who own or are responsible for tickets, which we can show to our current user
         $ticketUsers = array($uid);
         // check if user has groups
         $result = $DB->Query('SELECT GROUP_ID FROM b_ticket_user_ugroup WHERE USER_ID = ' . $uid . ' AND CAN_VIEW_GROUP_MESSAGES = \'Y\'');
         if ($result) {
             // collect members of these groups
             $uGroups = array();
             while ($row = $result->Fetch()) {
                 $uGroups[] = $row['GROUP_ID'];
             }
             if (!empty($uGroups)) {
                 $result = $DB->Query('SELECT USER_ID FROM b_ticket_user_ugroup WHERE GROUP_ID IN (' . join(',', $uGroups) . ')');
                 if ($result) {
                     while ($row = $result->Fetch()) {
                         $ticketUsers[] = $row['USER_ID'];
                     }
                 }
             }
         }
         // build sql
         $strSqlSearchUser = "";
         if ($bSupportTeam == 'Y') {
             $strSqlSearchUser = 'T.RESPONSIBLE_USER_ID IN (' . join(',', $ticketUsers) . ')';
         } elseif ($bSupportClient == 'Y') {
             $strSqlSearchUser = 'T.OWNER_USER_ID IN (' . join(',', $ticketUsers) . ')';
         }
         $arSqlSearch[] = $strSqlSearchUser;
     }
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $onlineInterval = intval(COption::GetOptionString("support", "ONLINE_INTERVAL"));
     $strSqlSelect = "\n\t\t\tSELECT\n\t\t\t\tT.*,\n\t\t\t\tT.SITE_ID,\n\t\t\t\tT.SITE_ID\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLID,\n\t\t\t\t{$dates_select},\n\t\t\t\tUNIX_TIMESTAMP(T.DATE_CLOSE)-UNIX_TIMESTAMP(T.DATE_CREATE)\t\t\t\t\t\t\tTICKET_TIME,\n\t\t\t\tCASE WHEN (UNIX_TIMESTAMP(T.DATE_CLOSE) IS NULL OR UNIX_TIMESTAMP(T.DATE_CLOSE) = 0) AND T.LAST_MESSAGE_BY_SUPPORT_TEAM = 'Y' THEN\n\t\t\t\t\tTO_DAYS(\n\t\t\t\t\t\tADDDATE(\n\t\t\t\t\t\t\tT.LAST_MESSAGE_DATE, INTERVAL T.AUTO_CLOSE_DAYS DAY\n\t\t\t\t\t\t)\n\t\t\t\t\t) - TO_DAYS(now())\n\t\t\t\tELSE -1 END AUTO_CLOSE_DAYS_LEFT,\n\t\t\t\t(SELECT COUNT(DISTINCT USER_ID) FROM b_ticket_online WHERE TICKET_ID = T.ID AND TIMESTAMP_X >= DATE_ADD(now(), INTERVAL - " . $onlineInterval . " SECOND)) USERS_ONLINE,\n\t\t\t\tif(T.COUPON IS NOT NULL, 1, 0)\t\t\t\t\t\t\t\t\t\t\t\t\t\tIS_SUPER_TICKET,\n\t\t\t\t{$lamp}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLAMP\n\t\t\t\t{$d_select}\n\t\t\t\t{$u_select}\n\t\t\t\t" . $obUserFieldsSql->GetSelect();
     $strSqlFrom = "\n\t\t\tFROM\n\t\t\t\tb_ticket T\n\t\t\t{$u_join}\n\t\t\t{$d_join}\n\t\t\t{$messJoin}\n\t\t\t{$searchJoin}\n\t\t\t{$ugroupJoin}\n\t\t\t\t" . $obUserFieldsSql->GetJoin("T.ID");
     $strSqlWhere = "\n\t\t\tWHERE\n\t\t\t{$strSqlSearch}\n\t\t";
     $strSqlGroup = $need_group ? ' GROUP BY T.ID  ' : '';
     $strSqlHaving = $arSqlHaving ? ' HAVING ' . join(' AND ', $arSqlHaving) . ' ' : '';
     $strSql = $strSqlSelect . $strSqlFrom . $strSqlWhere . $strSqlGroup . $strSqlHaving . $strSqlOrder;
     if (is_array($arParams) && isset($arParams["NAV_PARAMS"]) && is_array($arParams["NAV_PARAMS"])) {
         $nTopCount = isset($arParams['NAV_PARAMS']['nTopCount']) ? intval($arParams['NAV_PARAMS']['nTopCount']) : 0;
         if ($nTopCount > 0) {
             $strSql = $DB->TopSql($strSql, $nTopCount);
             $res = $DB->Query($strSql, false, $err_mess . __LINE__);
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SUPPORT"));
         } else {
             $cntSql = "SELECT COUNT(T.ID) as C " . $strSqlFrom . $strSqlWhere . $strSqlGroup . $strSqlHaving;
             if (!empty($strSqlGroup)) {
                 $cntSql = 'SELECT COUNT(1) AS C FROM (' . $cntSql . ') tt';
             }
             $res_cnt = $DB->Query($cntSql);
             $res_cnt = $res_cnt->Fetch();
             $res = new CDBResult();
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SUPPORT"));
             $res->NavQuery($strSql, $res_cnt["C"], $arParams["NAV_PARAMS"]);
         }
     } else {
         $res = $DB->Query($strSql, false, $err_mess . __LINE__);
         $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SUPPORT"));
     }
     $isFiltered = IsFiltered($strSqlSearch);
     return $res;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:support.php

示例8: GetList


//.........这里部分代码省略.........
     $arFields = array_merge($arFields1, $arFields);
     $arSqls = CSocNetGroup::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, array("ENTITY_ID" => "SONET_GROUP"));
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", $strDistinct, $arSqls["SELECT"]);
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sonet_group G " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $checkPermissions = Array_Key_Exists("CHECK_PERMISSIONS", $arFilter);
     if ($checkPermissions) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sonet_group G " . "\t" . $arSqls["FROM"] . " " . "WHERE G.VISIBLE = 'Y' ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "AND " . $arSqls["WHERE"] . " ";
         }
         $strSql .= "UNION " . "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sonet_group G " . "\tINNER JOIN b_sonet_user2group UG ON (G.ID = UG.GROUP_ID AND UG.USER_ID = " . IntVal($arFilter["CHECK_PERMISSIONS"]) . " AND UG.ROLE <= '" . $DB->ForSql(SONET_ROLES_USER, 1) . "') " . "\t" . $arSqls["FROM"] . " " . "WHERE G.VISIBLE = 'N' ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "AND " . $arSqls["WHERE"] . " ";
         }
         $strSql .= " ";
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         if (strlen($arSqls["ORDERBY"]) > 0) {
             $strSql .= "ORDER BY " . Str_Replace(array(" G.", " UG.", " S."), array(" ", " ", " "), " " . $arSqls["ORDERBY"]) . " ";
         }
     } else {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sonet_group G " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         if (strlen($arSqls["ORDERBY"]) > 0) {
             $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
         }
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sonet_group G " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0 || $checkPermissions) {
             $strSql_tmp .= "WHERE " . ($checkPermissions ? "G.VISIBLE = 'Y'" : "1 = 1") . (strlen($arSqls["WHERE"]) > 0 ? " AND " : "") . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
         $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 {
             // ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
             $cnt = $dbRes->SelectedRowsCount();
         }
         if ($checkPermissions) {
             $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sonet_group G " . "\tINNER JOIN b_sonet_user2group UG ON (G.ID = UG.GROUP_ID AND UG.USER_ID = " . IntVal($arFilter["CHECK_PERMISSIONS"]) . " AND UG.ROLE <= '" . $DB->ForSql(SONET_ROLES_USER, 1) . "') " . "\t" . $arSqls["FROM"] . " " . "WHERE G.VISIBLE = 'N' ";
             if (strlen($arSqls["WHERE"]) > 0) {
                 $strSql_tmp .= "AND " . $arSqls["WHERE"] . " ";
             }
             if (strlen($arSqls["GROUPBY"]) > 0) {
                 $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
             }
             //echo "!2.2!=".htmlspecialcharsbx($strSql_tmp)."<br>";
             $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             if (strlen($arSqls["GROUPBY"]) <= 0) {
                 if ($arRes = $dbRes->Fetch()) {
                     $cnt += $arRes["CNT"];
                 }
             } else {
                 // ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
                 $cnt += $dbRes->SelectedRowsCount();
             }
         }
         $dbRes = new CDBResult();
         //echo "!2.3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_GROUP"));
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("SONET_GROUP"));
     }
     return $dbRes;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:group.php

示例9: GetList

 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_BLOG", "B.ID");
     $obUserFieldsSql->SetSelect($arSelectFields);
     $obUserFieldsSql->SetFilter($arFilter);
     $obUserFieldsSql->SetOrder($arOrder);
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "NAME", "DESCRIPTION", "DATE_CREATE", "DATE_UPDATE", "ACTIVE", "OWNER_ID", "URL", "REAL_URL", "GROUP_ID", "ENABLE_COMMENTS", "ENABLE_IMG_VERIF", "EMAIL_NOTIFY", "ENABLE_RSS", "LAST_POST_ID", "LAST_POST_DATE", "AUTO_GROUPS", "ALLOW_HTML", "SOCNET_GROUP_ID");
     }
     if (in_array("*", $arSelectFields)) {
         $arSelectFields = array("ID", "NAME", "DESCRIPTION", "DATE_CREATE", "DATE_UPDATE", "ACTIVE", "OWNER_ID", "SOCNET_GROUP_ID", "URL", "REAL_URL", "GROUP_ID", "ENABLE_COMMENTS", "ENABLE_IMG_VERIF", "EMAIL_NOTIFY", "ENABLE_RSS", "ALLOW_HTML", "LAST_POST_ID", "LAST_POST_DATE", "AUTO_GROUPS", "SEARCH_INDEX", "USE_SOCNET", "OWNER_LOGIN", "OWNER_NAME", "OWNER_LAST_NAME", "OWNER_EMAIL", "OWNER", "GROUP_NAME", "GROUP_SITE_ID", "BLOG_USER_ALIAS", "BLOG_USER_AVATAR");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "B.ID", "TYPE" => "int"), "NAME" => array("FIELD" => "B.NAME", "TYPE" => "string"), "DESCRIPTION" => array("FIELD" => "B.DESCRIPTION", "TYPE" => "string"), "DATE_CREATE" => array("FIELD" => "B.DATE_CREATE", "TYPE" => "datetime"), "DATE_UPDATE" => array("FIELD" => "B.DATE_UPDATE", "TYPE" => "datetime"), "ACTIVE" => array("FIELD" => "B.ACTIVE", "TYPE" => "char"), "OWNER_ID" => array("FIELD" => "B.OWNER_ID", "TYPE" => "int"), "SOCNET_GROUP_ID" => array("FIELD" => "B.SOCNET_GROUP_ID", "TYPE" => "int"), "URL" => array("FIELD" => "B.URL", "TYPE" => "string"), "REAL_URL" => array("FIELD" => "B.REAL_URL", "TYPE" => "string"), "GROUP_ID" => array("FIELD" => "B.GROUP_ID", "TYPE" => "int"), "ENABLE_COMMENTS" => array("FIELD" => "B.ENABLE_COMMENTS", "TYPE" => "char"), "ENABLE_IMG_VERIF" => array("FIELD" => "B.ENABLE_IMG_VERIF", "TYPE" => "char"), "EMAIL_NOTIFY" => array("FIELD" => "B.EMAIL_NOTIFY", "TYPE" => "char"), "ENABLE_RSS" => array("FIELD" => "B.ENABLE_RSS", "TYPE" => "char"), "ALLOW_HTML" => array("FIELD" => "B.ALLOW_HTML", "TYPE" => "char"), "LAST_POST_ID" => array("FIELD" => "B.LAST_POST_ID", "TYPE" => "int"), "LAST_POST_DATE" => array("FIELD" => "B.LAST_POST_DATE", "TYPE" => "datetime"), "AUTO_GROUPS" => array("FIELD" => "B.AUTO_GROUPS", "TYPE" => "string"), "SEARCH_INDEX" => array("FIELD" => "B.SEARCH_INDEX", "TYPE" => "char"), "USE_SOCNET" => array("FIELD" => "B.USE_SOCNET", "TYPE" => "char"), "OWNER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "LEFT JOIN b_user U ON (B.OWNER_ID = U.ID)"), "OWNER" => 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 (B.OWNER_ID = U.ID)"), "GROUP_NAME" => array("FIELD" => "G.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_group G ON (B.GROUP_ID = G.ID)"), "GROUP_SITE_ID" => array("FIELD" => "G.SITE_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_blog_group G ON (B.GROUP_ID = G.ID)"), "BLOG_USER_ALIAS" => array("FIELD" => "BU.ALIAS", "TYPE" => "string", "FROM" => "LEFT JOIN b_blog_user BU ON (B.OWNER_ID = BU.USER_ID)"), "BLOG_USER_AVATAR" => array("FIELD" => "BU.AVATAR", "TYPE" => "int", "FROM" => "LEFT JOIN b_blog_user BU ON (B.OWNER_ID = BU.USER_ID)"), "SOCNET_BLOG_READ" => array("FIELD" => "BS.BLOG_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_socnet BS ON (B.ID = BS.BLOG_ID)"), "PERMS" => array());
     // <-- FIELDS
     if ($GLOBALS["USER"]->IsAuthorized()) {
         $arFields["PERMS"] = array("FIELD" => "bugp.PERMS", "TYPE" => "char", "FROM" => "INNER JOIN b_blog_user_group_perms bugp ON (B.ID = bugp.BLOG_ID)\n\t\t\t\t\t\t\tINNER JOIN b_blog_user2user_group bug ON (B.ID = bug.BLOG_ID AND bugp.USER_GROUP_ID = bug.USER_GROUP_ID)");
         $arFields["PERMS_TYPE"] = array("FIELD" => "bugp.PERMS_TYPE", "TYPE" => "char", "FROM" => "INNER JOIN b_blog_user_group_perms bugp ON (B.ID = bugp.BLOG_ID)\n\t\t\t\t\t\t\tINNER JOIN b_blog_user2user_group bug ON (B.ID = bug.BLOG_ID AND bugp.USER_GROUP_ID = bug.USER_GROUP_ID)");
         $arFields["PERMS_USER_ID"] = array("FIELD" => "bug.USER_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_user_group_perms bugp ON (B.ID = bugp.BLOG_ID)\n\t\t\t\t\t\t\tINNER JOIN b_blog_user2user_group bug ON (B.ID = bug.BLOG_ID AND bugp.USER_GROUP_ID = bug.USER_GROUP_ID)");
         $arFields["PERMS_POST_ID"] = array("FIELD" => "bugp.POST_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_blog_user_group_perms bugp ON (B.ID = bugp.BLOG_ID)\n\t\t\t\t\t\t\tINNER JOIN b_blog_user2user_group bug ON (B.ID = bug.BLOG_ID AND bugp.USER_GROUP_ID = bug.USER_GROUP_ID)");
     }
     $arSqls = CBlog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $strSqlUFFilter = " (" . $r . ") ";
     }
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_blog B " . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("B.ID") . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $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 (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return False;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . $obUserFieldsSql->GetSelect() . " " . "FROM b_blog B " . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("B.ID") . " ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $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 (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_blog B " . "\t" . $arSqls["FROM"] . " " . $obUserFieldsSql->GetJoin("B.ID") . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $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 (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         //echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
         $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();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_BLOG"));
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_BLOG"));
     }
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:blog.php

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

示例11: GetList


//.........这里部分代码省略.........
         $arFilter = array();
     }
     $arSqlSearch = CTestAttempt::GetFilter($arFilter);
     $strSqlSearch = "";
     $arSqlSearchCnt = count($arSqlSearch);
     for ($i = 0; $i < $arSqlSearchCnt; $i++) {
         if (strlen($arSqlSearch[$i]) > 0) {
             $strSqlSearch .= " AND " . $arSqlSearch[$i] . " ";
         }
     }
     $r = $obUserFieldsSql->GetFilter();
     if (strlen($r) > 0) {
         $strSqlSearch .= " AND (" . $r . ") ";
     }
     $bCheckPerm = 'ORPHANED VAR';
     $strSqlFrom = '';
     $strSql = static::_GetListSQLFormer($sSelect, $obUserFieldsSql, $bCheckPerm, $USER, $arFilter, $strSqlSearch, $strSqlFrom);
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     foreach ($arOrder as $by => $order) {
         $by = strtolower($by);
         $order = strtolower($order);
         if ($order != "asc") {
             $order = "desc";
         }
         if ($by == "id") {
             $arSqlOrder[] = " A.ID " . $order . " ";
         } elseif ($by == "test_id") {
             $arSqlOrder[] = " A.TEST_ID " . $order . " ";
         } elseif ($by == "student_id") {
             $arSqlOrder[] = " A.STUDENT_ID " . $order . " ";
         } elseif ($by == "date_start") {
             $arSqlOrder[] = " A.DATE_START " . $order . " ";
         } elseif ($by == "date_end") {
             $arSqlOrder[] = " A.DATE_END " . $order . " ";
         } elseif ($by == "status") {
             $arSqlOrder[] = " A.STATUS " . $order . " ";
         } elseif ($by == "score") {
             $arSqlOrder[] = " A.SCORE " . $order . " ";
         } elseif ($by == "max_score") {
             $arSqlOrder[] = " A.MAX_SCORE " . $order . " ";
         } elseif ($by == "completed") {
             $arSqlOrder[] = " A.COMPLETED " . $order . " ";
         } elseif ($by == "questions") {
             $arSqlOrder[] = " A.QUESTIONS " . $order . " ";
         } elseif ($by == "user_name") {
             $arSqlOrder[] = " USER_NAME " . $order . " ";
         } elseif ($by == "test_name") {
             $arSqlOrder[] = " TEST_NAME " . $order . " ";
         } elseif ($by == "speed") {
             $arSqlOrder[] = " SPEED " . $order . " ";
         } elseif ($s = $obUserFieldsSql->GetOrder($by)) {
             $arSqlOrder[$by] = " " . $s . " " . $order . " ";
         } else {
             $arSqlOrder[] = " A.ID " . $order . " ";
         }
     }
     $strSqlOrder = "";
     DelDuplicateSort($arSqlOrder);
     $arSqlOrderCnt = count($arSqlOrder);
     for ($i = 0; $i < $arSqlOrderCnt; $i++) {
         if ($i == 0) {
             $strSqlOrder = " ORDER BY ";
         } else {
             $strSqlOrder .= ",";
         }
         $strSqlOrder .= $arSqlOrder[$i];
     }
     $strSql .= $strSqlOrder;
     if (!empty($arNavParams)) {
         $nTopCount = null;
         if (isset($arNavParams['NAV_PARAMS']['nPageTop']) && $arNavParams['NAV_PARAMS']['nPageTop'] > 0) {
             $nTopCount = (int) $arNavParams['NAV_PARAMS']['nPageTop'];
         } else {
             if (isset($arNavParams['nPageTop'])) {
                 $nTopCount = (int) $arNavParams['nPageTop'];
             } else {
                 if (isset($arNavParams['nTopCount'])) {
                     $nTopCount = (int) $arNavParams['nTopCount'];
                 } else {
                     $res_cnt = $DB->Query("SELECT COUNT(A.ID) as C " . $strSqlFrom);
                     $res_cnt = $res_cnt->fetch();
                     $res = new CDBResult();
                     $res->NavQuery($strSql, $res_cnt['C'], $arNavParams);
                     $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("LEARN_ATTEMPT"));
                 }
             }
         }
         if ($nTopCount !== null) {
             $strSql = $DB->TopSql($strSql, $nTopCount);
             $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("LEARN_ATTEMPT"));
         }
     } else {
         $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("LEARN_ATTEMPT"));
     }
     return $res;
 }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:101,代码来源:attempt.php

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

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

示例14: GetList


//.........这里部分代码省略.........
             $filterByBaseTemplate = true;
         }
         if ($keyParsed['FIELD'] == 'TEMPLATE_CHILDREN_COUNT') {
             $useChildrenCount = true;
         }
     }
     $includeSubtree = $arParams['INCLUDE_TEMPLATE_SUBTREE'] === true || $arParams['INCLUDE_TEMPLATE_SUBTREE'] === 'Y';
     $excludeSubtree = $arParams['EXCLUDE_TEMPLATE_SUBTREE'] === true || $arParams['EXCLUDE_TEMPLATE_SUBTREE'] === 'Y';
     $treeJoin = '';
     if ($excludeSubtree) {
         $treeJoin = "";
     } else {
         $treeJoin = "LEFT JOIN " . Template\DependencyTable::getTableName() . " TD on TT.ID = TD.TEMPLATE_ID" . ($includeSubtree ? "" : " AND TD.DIRECT = '1'");
     }
     $temporalTableName = \Bitrix\Tasks\DB\Helper::getTemporaryTableNameSql();
     $strFrom = "FROM\n\t\t\t\tb_tasks_template TT\n\n\t\t\t" . $treeJoin . "\n\n\t\t\t" . ($selectBaseTemplateId ? "\n\t\t\tLEFT JOIN\n\t\t\t\t" . Template\DependencyTable::getTableName() . " TDD ON TT.ID = TDD.TEMPLATE_ID AND TDD.DIRECT = '1'\n\t\t\t" : "\n\t\t\t") . "\n\n\t\t\t" . ($useChildrenCount ? "\n\t\t\t\tLEFT JOIN (\n\t\t\t\t\tSELECT TTI.ID, COUNT(TDDC.TEMPLATE_ID) AS TEMPLATE_CHILDREN_COUNT\n\t\t\t\t\tfrom\n\t\t\t\t\t\tb_tasks_template TTI\n\t\t\t\t\t\tINNER JOIN " . Template\DependencyTable::getTableName() . " TDDC ON TTI.ID = TDDC.PARENT_TEMPLATE_ID AND TDDC.DIRECT = '1'\n\t\t\t\t\tGROUP BY TTI.ID\n\t\t\t\t) " . $temporalTableName . " on " . $temporalTableName . ".ID = TT.ID\n\t\t\t" : "\n\t\t\t") . "\n\n\t\t\tLEFT JOIN\n\t\t\t\tb_user CU ON CU.ID = TT.CREATED_BY\n\t\t\tLEFT JOIN\n\t\t\t\tb_user RU ON RU.ID = TT.RESPONSIBLE_ID\n\t\t\t\n\t\t\t" . $obUserFieldsSql->GetJoin("TT.ID") . "\n\n\t\t\t" . (sizeof($arSqlSearch) ? "WHERE " . implode(" AND ", $arSqlSearch) : "") . " ";
     foreach ($arOrder as $by => $order) {
         $by = strtolower($by);
         $order = strtolower($order);
         if ($order != "asc") {
             $order = "desc";
         }
         if ($by == "task") {
             $arSqlOrder[] = " TT " . $order . " ";
         } elseif ($by == "title") {
             $arSqlOrder[] = " TT.TITLE " . $order . " ";
         } elseif ($by == "depends_on") {
             $arSqlOrder[] = " TT.DEPENDS_ON " . $order . " ";
         } elseif ($by == "rand") {
             $arSqlOrder[] = CTasksTools::getRandFunction();
         } elseif ($by === 'responsible_last_name') {
             $arSqlOrder[] = " RU.LAST_NAME " . $order . " ";
         } elseif ($by === 'tparam_type') {
             $arSqlOrder[] = " TT.TPARAM_TYPE " . $order . " ";
         } elseif ($by === 'template_children_count') {
             $arSqlOrder[] = " TEMPLATE_CHILDREN_COUNT " . $order . " ";
         } elseif ($by === 'base_template_id') {
             $arSqlOrder[] = " BASE_TEMPLATE_ID " . $order . " ";
         } elseif (substr($by, 0, 3) === 'uf_') {
             if ($s = $obUserFieldsSql->GetOrder($by)) {
                 $arSqlOrder[$by] = " " . $s . " " . $order . " ";
             }
         } else {
             $arSqlOrder[] = " TT.ID " . $order . " ";
             $by = "id";
         }
         if ($by !== 'rand' && !in_array(strtoupper($by), $arSelect)) {
             $arSelect[] = strtoupper($by);
         }
     }
     $strSqlOrder = "";
     DelDuplicateSort($arSqlOrder);
     $arSqlOrderCnt = count($arSqlOrder);
     for ($i = 0; $i < $arSqlOrderCnt; $i++) {
         if ($i == 0) {
             $strSqlOrder = " ORDER BY ";
         } else {
             $strSqlOrder .= ",";
         }
         $strSqlOrder .= $arSqlOrder[$i];
     }
     if (!in_array("ID", $arSelect)) {
         $arSelect[] = "ID";
     }
     $arSqlSelect = array();
     foreach ($arSelect as $field) {
         $field = strtoupper($field);
         if (array_key_exists($field, $arFields)) {
             $arSqlSelect[$field] = \Bitrix\Tasks\DB\Helper::wrapColumnWithFunction($arFields[$field]['FIELD'], $arFields[$field]['WRAP']) . " AS " . $field;
         }
     }
     if (!sizeof($arSqlSelect)) {
         $arSqlSelect = "TT.ID AS ID";
     } else {
         $arSqlSelect = implode(",\n", $arSqlSelect);
     }
     $ufSelect = $obUserFieldsSql->GetSelect();
     if (strlen($ufSelect)) {
         $arSqlSelect .= $ufSelect;
     }
     $strSql = "\n\t\t\tSELECT \n\t\t\t\t" . $arSqlSelect . "\n\t\t\t\t" . $strFrom . "\n\t\t\t\t" . $strSqlOrder;
     if (isset($arNavParams["NAV_PARAMS"]) && is_array($arNavParams["NAV_PARAMS"])) {
         $nTopCount = (int) $arNavParams['NAV_PARAMS']['nTopCount'];
         if ($nTopCount > 0) {
             $strSql = $DB->TopSql($strSql, $nTopCount);
             $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("TASKS_TASK_TEMPLATE"));
         } else {
             $res_cnt = $DB->Query("SELECT COUNT(TT.ID) as C " . $strFrom);
             $res_cnt = $res_cnt->Fetch();
             $res = new CDBResult();
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("TASKS_TASK_TEMPLATE"));
             $res->NavQuery($strSql, $res_cnt["C"], $arNavParams["NAV_PARAMS"]);
         }
     } else {
         $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("TASKS_TASK_TEMPLATE"));
     }
     return $res;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:tasktemplates.php

示例15: GetList


//.........这里部分代码省略.........
                 default:
                     if (in_array($key, $arFields)) {
                         $arSqlSearch[] = GetFilterQuery('U.' . $key, $val, $arFilter[$key . "_EXACT_MATCH"] == "Y" && $match_value_set ? "N" : "Y");
                     }
             }
         }
     }
     $arSqlOrder = array();
     foreach ($arOrder as $field => $dir) {
         $field = strtoupper($field);
         if (strtolower($dir) != "asc") {
             $dir = "desc";
             if ($bSingleBy) {
                 $order = "desc";
             }
         }
         if ($field == "CURRENT_BIRTHDAY") {
             $cur_year = intval(date('Y'));
             $arSqlOrder[$field] = "IF(ISNULL(PERSONAL_BIRTHDAY), '9999-99-99', IF (\n\t\t\t\t\tDATE_FORMAT(U.PERSONAL_BIRTHDAY, '" . $cur_year . "-%m-%d') < DATE_FORMAT(DATE_ADD(" . $DB->CurrentTimeFunction() . ", INTERVAL " . CTimeZone::GetOffset() . " SECOND), '%Y-%m-%d'),\n\t\t\t\t\tDATE_FORMAT(U.PERSONAL_BIRTHDAY, '" . ($cur_year + 1) . "-%m-%d'),\n\t\t\t\t\tDATE_FORMAT(U.PERSONAL_BIRTHDAY, '" . $cur_year . "-%m-%d')\n\t\t\t\t)) " . $dir;
         } elseif ($field == "IS_ONLINE") {
             $arSelectFields[$field] = "IF(U.LAST_ACTIVITY_DATE > DATE_SUB(NOW(), INTERVAL " . $online_interval . " SECOND), 'Y', 'N') IS_ONLINE";
             $arSqlOrder[$field] = "IS_ONLINE " . $dir;
         } elseif (in_array($field, $arFields_all)) {
             $arSqlOrder[$field] = "U." . $field . " " . $dir;
         } elseif ($s = $obUserFieldsSql->GetOrder($field)) {
             $arSqlOrder[$field] = strtoupper($s) . " " . $dir;
         } elseif (preg_match('/^RATING_(\\d+)$/i', $field, $matches)) {
             $ratingId = intval($matches[1]);
             if ($ratingId > 0) {
                 $arSqlOrder[$field] = $field . "_ISNULL ASC, " . $field . " " . $dir;
                 $arParams['SELECT'][] = $field;
             } else {
                 $field = "TIMESTAMP_X";
                 $arSqlOrder[$field] = "U." . $field . " " . $dir;
                 if ($bSingleBy) {
                     $by = strtolower($field);
                 }
             }
         } else {
             $field = "TIMESTAMP_X";
             $arSqlOrder[$field] = "U." . $field . " " . $dir;
             if ($bSingleBy) {
                 $by = strtolower($field);
             }
         }
     }
     $userFieldsSelect = $obUserFieldsSql->GetSelect();
     $arSqlSearch[] = $obUserFieldsSql->GetFilter();
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $sSelect = ($obUserFieldsSql->GetDistinct() ? "DISTINCT " : "") . implode(', ', $arSelectFields) . "\n\t\t\t" . $userFieldsSelect . "\n\t\t";
     if (is_array($arParams['SELECT'])) {
         $arRatingInSelect = array();
         foreach ($arParams['SELECT'] as $column) {
             if (preg_match('/^RATING_(\\d+)$/i', $column, $matches)) {
                 $ratingId = intval($matches[1]);
                 if ($ratingId > 0 && !in_array($ratingId, $arRatingInSelect)) {
                     $sSelect .= ", RR" . $ratingId . ".CURRENT_POSITION IS NULL as RATING_" . $ratingId . "_ISNULL";
                     $sSelect .= ", RR" . $ratingId . ".CURRENT_VALUE as RATING_" . $ratingId;
                     $sSelect .= ", RR" . $ratingId . ".CURRENT_VALUE as RATING_" . $ratingId . "_CURRENT_VALUE";
                     $sSelect .= ", RR" . $ratingId . ".PREVIOUS_VALUE as RATING_" . $ratingId . "_PREVIOUS_VALUE";
                     $sSelect .= ", RR" . $ratingId . ".CURRENT_POSITION as RATING_" . $ratingId . "_CURRENT_POSITION";
                     $sSelect .= ", RR" . $ratingId . ".PREVIOUS_POSITION as RATING_" . $ratingId . "_PREVIOUS_POSITION";
                     $strJoin .= " LEFT JOIN  b_rating_results RR" . $ratingId . "\n\t\t\t\t\t\t\tON RR" . $ratingId . ".RATING_ID=" . $ratingId . "\n\t\t\t\t\t\t\tand RR" . $ratingId . ".ENTITY_TYPE_ID = 'USER'\n\t\t\t\t\t\t\tand RR" . $ratingId . ".ENTITY_ID = U.ID ";
                     $arRatingInSelect[] = $ratingId;
                 }
             }
         }
     }
     $strFrom = "\n\t\t\tFROM\n\t\t\t\tb_user U\n\t\t\t\t" . $obUserFieldsSql->GetJoin("U.ID") . "\n\t\t\t\t" . $strJoin . "\n\t\t\tWHERE\n\t\t\t\t" . $strSqlSearch . "\n\t\t\t";
     $strSqlOrder = '';
     if (!empty($arSqlOrder)) {
         $strSqlOrder = 'ORDER BY ' . implode(', ', $arSqlOrder);
     }
     $strSql = "SELECT " . $sSelect . $strFrom . $strSqlOrder;
     if (array_key_exists("NAV_PARAMS", $arParams) && is_array($arParams["NAV_PARAMS"])) {
         $nTopCount = intval($arParams['NAV_PARAMS']['nTopCount']);
         if ($nTopCount > 0) {
             $strSql = $DB->TopSql($strSql, $nTopCount);
             $res = $DB->Query($strSql, false, $err_mess . __LINE__);
             if ($userFieldsSelect != '') {
                 $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("USER"));
             }
         } else {
             $res_cnt = $DB->Query("SELECT COUNT(" . ($obUserFieldsSql->GetDistinct() ? "DISTINCT " : "") . "U.ID) as C " . $strFrom);
             $res_cnt = $res_cnt->Fetch();
             $res = new CDBResult();
             if ($userFieldsSelect != '') {
                 $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("USER"));
             }
             $res->NavQuery($strSql, $res_cnt["C"], $arParams["NAV_PARAMS"]);
         }
     } else {
         $res = $DB->Query($strSql, false, $err_mess . __LINE__);
         if ($userFieldsSelect != '') {
             $res->SetUserFields($USER_FIELD_MANAGER->GetUserFields("USER"));
         }
     }
     $res->is_filtered = IsFiltered($strSqlSearch);
     return $res;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:user.php


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