本文整理汇总了PHP中CUserTypeSQL类的典型用法代码示例。如果您正苦于以下问题:PHP CUserTypeSQL类的具体用法?PHP CUserTypeSQL怎么用?PHP CUserTypeSQL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CUserTypeSQL类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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->Se
|
请发表评论