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


PHP CDatabase::ForSql方法代码示例

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


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

示例1: removeRecord

 /**
  * @param $versionName
  * @return bool|\CDBResult
  */
 public function removeRecord($versionName)
 {
     $versionName = $this->bitrixDb->ForSql($versionName);
     if ($this->isMssql) {
         return $this->query('DELETE FROM #TABLE1# WHERE version = \'%s\'', $versionName);
     } else {
         return $this->query('DELETE FROM `#TABLE1#` WHERE `version` = "%s"', $versionName);
     }
 }
开发者ID:andreyryabin,项目名称:sprint.migration,代码行数:13,代码来源:VersionTable.php

示例2: InviteAttendees

 public static function InviteAttendees($ID, $arFields = array(), $arAttendees = array(), $arStatuses = array(), $bSendInvitations = true, $userId = 0)
 {
     global $DB, $CACHE_MANAGER;
     $ID = intVal($ID);
     if (!$ID) {
         return;
     }
     // It's new event
     $bNew = !isset($arFields['ID']) || $arFields['ID'] <= 0;
     $curAttendeesIndex = array();
     $deletedAttendees = array();
     $arAffectedSections = array();
     if (!$bNew) {
         $curAttendees = self::GetAttendees($ID);
         $curAttendees = $curAttendees[$ID];
         if (is_array($curAttendees)) {
             foreach ($curAttendees as $user) {
                 $curAttendeesIndex[$user['USER_KEY']] = $user;
                 $deletedAttendees[$user['USER_KEY']] = $user['USER_KEY'];
                 $arAffectedSections[] = CCalendar::GetMeetingSection($user['USER_KEY']);
             }
         }
     }
     $dbAttendees = array();
     $bReinvite = $arFields['~MEETING']['REINVITE'] !== false;
     $userId = $userId > 0 ? $userId : $arFields['MEETING_HOST'];
     $CACHE_MANAGER->ClearByTag('calendar_user_' . $userId);
     $delIdStr = "";
     // List of all attendees for event
     foreach ($arAttendees as $userKey) {
         $bExternal = false;
         $key = false;
         if (substr($userKey, 0, strlen('BXEXT:')) == 'BXEXT:') {
             $email = substr($userKey, strlen('BXEXT:'));
             if (!check_email($email, true)) {
                 continue;
             }
             $key = $email;
             $bExternal = true;
         }
         if (!$bExternal && intVal($userKey) > 0) {
             // User by ID
             $key = intVal($userKey);
         }
         if (!$key) {
             // Incorrect user
             continue;
         }
         unset($deletedAttendees[$key]);
         // Unset item from deleted list
         if (!$curAttendeesIndex[$key]) {
             $arAffectedSections[] = CCalendar::GetMeetingSection($key);
         }
         if ($curAttendeesIndex[$key] && !$bReinvite) {
             if (!$bNew && $key != $userId && $bSendInvitations) {
                 if (!$bExternal && $curAttendeesIndex[$key]['STATUS'] == 'Y') {
                     // Just send changing event notification
                     CCalendar::SendMessage(array('mode' => 'change_notify', 'name' => $arFields['NAME'], "from" => $arFields["DT_FROM"], "to" => $arFields["DT_TO"], "location" => CCalendar::GetTextLocation($arFields["LOCATION"]), "meetingText" => $arFields["~MEETING"]["TEXT"], "guestId" => $key, "eventId" => $ID, "userId" => $userId));
                 }
             }
             continue;
         }
         if ($bExternal || $arFields['MEETING_HOST'] == $key) {
             $status = 'Y';
         } else {
             $status = 'Q';
         }
         $dbAttendees[$key] = array("bExternal" => $bExternal, "bReinvite" => isset($curAttendeesIndex[$key]) && $curAttendeesIndex[$key], "USER_KEY" => $key, "USER_ID" => $bExternal ? 0 : $key, "USER_EMAIL" => $bExternal ? $key : '', "USER_NAME" => "", "STATUS" => $status, "ACCESSIBILITY" => $arFields["ACCESSIBILITY"], "REMIND" => $arFields["REMIND"]);
         if (!$dbAttendees[$key]['bReinvite']) {
             $delIdStr .= ',' . (intVal($key) == $key ? intVal($key) : "'" . CDatabase::ForSql($key) . "'");
         }
     }
     $delIdStr = trim($delIdStr, ', ');
     // Delete users from attendees list
     if (count($deletedAttendees) > 0) {
         foreach ($deletedAttendees as $key) {
             $att = $curAttendeesIndex[$key];
             if (!$att['EVENT_ID']) {
                 //Send email DELETE
                 //echo "Send EMAIL DELETE \n";
             } elseif ($bSendInvitations) {
                 $CACHE_MANAGER->ClearByTag('calendar_user_' . $att["USER_ID"]);
                 CCalendar::SendMessage(array('mode' => 'cancel', 'name' => $arFields['NAME'], "from" => $arFields["DT_FROM"], "to" => $arFields["DT_TO"], "location" => CCalendar::GetTextLocation($arFields["LOCATION"]), "guestId" => $att["USER_ID"], "eventId" => $ID, "userId" => $arFields['MEETING_HOST']));
             }
             $curAttendeesIndex[$user['USER_KEY']] = $user;
             $delIdStr .= ',' . (intVal($key) == $key ? intVal($key) : "'" . CDatabase::ForSql($key) . "'");
         }
     }
     $delIdStr = trim($delIdStr, ', ');
     if ($delIdStr != '') {
         $strSql = "DELETE from b_calendar_attendees WHERE EVENT_ID=" . $ID . " AND USER_KEY in(" . $delIdStr . ")";
         $res = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     }
     if (CModule::IncludeModule("im")) {
         CIMNotify::DeleteBySubTag("CALENDAR|INVITE|" . $ID);
     }
     // Add new attendees
     foreach ($dbAttendees as $att) {
         if ($att['bReinvite']) {
             $status = 'Q';
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:calendar_event.php

示例3: FormatDate

 function FormatDate($strDate, $format = "DD.MM.YYYY HH:MI:SS", $new_format = "DD.MM.YYYY HH:MI:SS")
 {
     $strDate = trim($strDate);
     $new_format = str_replace("MI", "I", $new_format);
     $new_format = preg_replace("/([DMYIHS])\\1+/is" . BX_UTF_PCRE_MODIFIER, "\\1", $new_format);
     $arFormat = preg_split("/[^0-9a-z]/is", strtoupper($format));
     $arDate = preg_split("/[^0-9]/", $strDate);
     $arParsedDate = array();
     $bound = min(count($arFormat), count($arDate));
     for ($i = 0; $i < $bound; $i++) {
         //if ($intval) $r = IntVal($arDate[$i]); else
         if (preg_match("/^[0-9]/", $arDate[$i])) {
             $r = CDatabase::ForSql($arDate[$i], 4);
         } else {
             $r = IntVal($arDate[$i]);
         }
         $arParsedDate[substr($arFormat[$i], 0, 2)] = $r;
     }
     if (intval($arParsedDate["DD"]) <= 0 || intval($arParsedDate["MM"]) <= 0 || intval($arParsedDate["YY"]) <= 0) {
         return false;
     }
     $strResult = "";
     if (intval($arParsedDate["YY"]) > 1970 && intval($arParsedDate["YY"]) < 2038) {
         $ux_time = mktime(intval($arParsedDate["HH"]), intval($arParsedDate["MI"]), intval($arParsedDate["SS"]), intval($arParsedDate["MM"]), intval($arParsedDate["DD"]), intval($arParsedDate["YY"]));
         for ($i = 0; $i < strlen($new_format); $i++) {
             $simbol = substr($new_format, $i, 1);
             switch ($simbol) {
                 case "F":
                     $match = GetMessage("FORUM_MONTH_" . date("n", $ux_time));
                     break;
                 case "M":
                     $match = GetMessage("FORUM_MON_" . date("n", $ux_time));
                     break;
                 case "l":
                     $match = GetMessage("FORUM_DAY_OF_WEEK_" . date("w", $ux_time));
                     break;
                 case "D":
                     $match = GetMessage("FORUM_DOW_" . date("w", $ux_time));
                     break;
                 default:
                     $match = date(substr($new_format, $i, 1), $ux_time);
                     break;
             }
             $strResult .= $match;
         }
     } else {
         if ($arParsedDate["MM"] < 1 || $arParsedDate["MM"] > 12) {
             $arParsedDate["MM"] = 1;
         }
         for ($i = 0; $i < strLen($new_format); $i++) {
             $simbol = substr($new_format, $i, 1);
             switch ($simbol) {
                 case "F":
                     $match = str_pad($arParsedDate["MM"], 2, "0", STR_PAD_LEFT);
                     if (intVal($arParsedDate["MM"]) > 0) {
                         $match = GetMessage("FORUM_MONTH_" . intVal($arParsedDate["MM"]));
                     }
                     break;
                 case "M":
                     $match = str_pad($arParsedDate["MM"], 2, "0", STR_PAD_LEFT);
                     if (intVal($arParsedDate["MM"]) > 0) {
                         $match = GetMessage("FORUM_MON_" . intVal($arParsedDate["MM"]));
                     }
                     break;
                 case "l":
                     $match = str_pad($arParsedDate["DD"], 2, "0", STR_PAD_LEFT);
                     if (intVal($arParsedDate["DD"]) > 0) {
                         $match = GetMessage("FORUM_DAY_OF_WEEK_" . intVal($arParsedDate["DD"]));
                     }
                     break;
                 case "D":
                     $match = str_pad($arParsedDate["DD"], 2, "0", STR_PAD_LEFT);
                     if (intVal($arParsedDate["DD"]) > 0) {
                         $match = GetMessage("FORUM_DOW_" . intVal($arParsedDate["DD"]));
                     }
                     break;
                 case "d":
                     $match = str_pad($arParsedDate["DD"], 2, "0", STR_PAD_LEFT);
                     break;
                 case "m":
                     $match = str_pad($arParsedDate["MM"], 2, "0", STR_PAD_LEFT);
                     break;
                 case "j":
                     $match = intVal($arParsedDate["MM"]);
                     break;
                 case "Y":
                     $match = str_pad($arParsedDate["YY"], 4, "0", STR_PAD_LEFT);
                     break;
                 case "y":
                     $match = substr($arParsedDate["YY"], 2);
                     break;
                 case "H":
                     $match = str_pad($arParsedDate["HH"], 2, "0", STR_PAD_LEFT);
                     break;
                 case "i":
                     $match = str_pad($arParsedDate["MI"], 2, "0", STR_PAD_LEFT);
                     break;
                 case "S":
                     $match = str_pad($arParsedDate["SS"], 2, "0", STR_PAD_LEFT);
                     break;
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:components_lib.php

示例4: FormatDate

 function FormatDate($strDate, $format = "DD.MM.YYYY HH:MI:SS", $new_format = "DD.MM.YYYY HH:MI:SS")
 {
     $strDate = trim($strDate);
     $new_format = str_replace("MI", "I", strtoupper($new_format));
     $new_format = preg_replace("/([DMYIHGST])\\1+/is", "\\1", $new_format);
     $arParsedDate = ParseDateTime($strDate, $format);
     if (!$arParsedDate) {
         return false;
     }
     foreach ($arParsedDate as $k => $v) {
         if (preg_match("/[^0-9]/", $v)) {
             $arParsedDate[$k] = CDatabase::ForSql($v, 10);
         } else {
             $arParsedDate[$k] = intval($v);
         }
     }
     /*time hacks*/
     if (isset($arParsedDate["H"])) {
         $arParsedDate['HH'] = intval($arParsedDate["H"]);
         unset($arParsedDate["H"]);
     } elseif (isset($arParsedDate["GG"])) {
         $arParsedDate['HH'] = intval($arParsedDate["GG"]);
         unset($arParsedDate["GG"]);
     } elseif (isset($arParsedDate["G"])) {
         $arParsedDate['HH'] = intval($arParsedDate["G"]);
         unset($arParsedDate["G"]);
     }
     if (isset($arParsedDate['TT']) || isset($arParsedDate['T'])) {
         $middletime = $arParsedDate['TT'] ? $arParsedDate['TT'] : $arParsedDate['T'];
         if (strcasecmp($middletime, 'pm') === 0) {
             if ($arParsedDate['HH'] < 12) {
                 $arParsedDate['HH'] += 12;
             }
         } else {
             if ($arParsedDate['HH'] == 12) {
                 $arParsedDate['HH'] = 0;
             }
         }
         if (isset($arParsedDate['TT'])) {
             unset($arParsedDate['TT']);
         } else {
             unset($arParsedDate['T']);
         }
     }
     if (isset($arParsedDate["MMMM"])) {
         if (is_numeric($arParsedDate["MMMM"])) {
             $arParsedDate['MM'] = intval($arParsedDate["MMMM"]);
         } else {
             $arParsedDate['MM'] = GetNumMonth($arParsedDate["MMMM"]);
             if (!$arParsedDate['MM']) {
                 $arParsedDate['MM'] = intval(date('m', strtotime($arParsedDate["MMMM"])));
             }
         }
     } elseif (isset($arParsedDate["MM"])) {
         $arParsedDate['MM'] = intval($arParsedDate["MM"]);
     } elseif (isset($arParsedDate["M"])) {
         if (is_numeric($arParsedDate["M"])) {
             $arParsedDate['MM'] = intval($arParsedDate["M"]);
         } else {
             $arParsedDate['MM'] = GetNumMonth($arParsedDate["M"], true);
             if (!$arParsedDate['MM']) {
                 $arParsedDate['MM'] = intval(date('m', strtotime($arParsedDate["M"])));
             }
         }
     }
     if (isset($arParsedDate["YYYY"])) {
         $arParsedDate["YY"] = $arParsedDate["YYYY"];
     }
     if (intval($arParsedDate["DD"]) <= 0 || intval($arParsedDate["MM"]) <= 0 || intval($arParsedDate["YY"]) <= 0) {
         return false;
     }
     $strResult = "";
     if (intval($arParsedDate["YY"]) > 1970 && intval($arParsedDate["YY"]) < 2038) {
         $ux_time = mktime(isset($arParsedDate["HH"]) ? intval($arParsedDate["HH"]) : 0, isset($arParsedDate["MI"]) ? intval($arParsedDate["MI"]) : 0, isset($arParsedDate["SS"]) ? intval($arParsedDate["SS"]) : 0, intval($arParsedDate["MM"]), intval($arParsedDate["DD"]), intval($arParsedDate["YY"]));
         $new_format_len = strlen($new_format);
         for ($i = 0; $i < $new_format_len; $i++) {
             $ch = substr($new_format, $i, 1);
             if ($ch == "D") {
                 $strResult .= date("d", $ux_time);
             } elseif ($ch == "M") {
                 $strResult .= date("m", $ux_time);
             } elseif ($ch == "Y") {
                 $strResult .= date("Y", $ux_time);
             } elseif ($ch == "H") {
                 $strResult .= date("H", $ux_time);
             } elseif ($ch == "G") {
                 $strResult .= date("h", $ux_time);
             } elseif ($ch == "I") {
                 $strResult .= date("i", $ux_time);
             } elseif ($ch == "S") {
                 $strResult .= date("s", $ux_time);
             } elseif ($ch == "T") {
                 $strResult .= date("a", $ux_time);
             } else {
                 $strResult .= $ch;
             }
         }
     } else {
         if ($arParsedDate["MM"] < 1 || $arParsedDate["MM"] > 12) {
             $arParsedDate["MM"] = 1;
//.........这里部分代码省略.........
开发者ID:spas-viktor,项目名称:books,代码行数:101,代码来源:database.php

示例5: GetSuperposedList

 public static function GetSuperposedList($Params = array())
 {
     global $DB;
     $checkPermissions = $Params['checkPermissions'] !== false;
     $checkSocnetPermissions = $Params['checkSocnetPermissions'] !== false;
     $userId = isset($Params['userId']) ? intVal($Params['userId']) : self::$userId;
     $arResult = array();
     $arSectionIds = array();
     $sqlSearch = "";
     // Common types
     $strTypes = "";
     if (isset($Params['TYPES']) && is_array($Params['TYPES'])) {
         foreach ($Params['TYPES'] as $type) {
             $strTypes .= ",'" . CDatabase::ForSql($type) . "'";
         }
         $strTypes = trim($strTypes, ", ");
         if ($strTypes != "") {
             $sqlSearch .= "(CS.CAL_TYPE in (" . $strTypes . "))";
         }
     }
     // Group's calendars
     $strGroups = "0";
     if (is_array($Params['GROUPS']) && count($Params['GROUPS']) > 0) {
         foreach ($Params['GROUPS'] as $ownerId) {
             if (IntVal($ownerId) > 0) {
                 $strGroups .= "," . IntVal($ownerId);
             }
         }
         if ($strGroups != "0") {
             if ($sqlSearch != "") {
                 $sqlSearch .= " OR ";
             }
             $sqlSearch .= "(CS.OWNER_ID in (" . $strGroups . ") AND CS.CAL_TYPE='group')";
         }
     }
     if ($sqlSearch != "") {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCS.*,\n\t\t\t\t\tCT.NAME AS TYPE_NAME, CT.DESCRIPTION AS TYPE_DESC\n\t\t\t\tFROM\n\t\t\t\t\tb_calendar_section CS\n\t\t\t\t\tLEFT JOIN b_calendar_type CT ON (CS.CAL_TYPE=CT.XML_ID)\n\t\t\t\tWHERE\n\t\t\t\t\t(\n\t\t\t\t\t\tCT.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t(\n\t\t\t\t\t\t{$sqlSearch}\n\t\t\t\t\t))";
         $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($arRes = $res->Fetch()) {
             $arSectionIds[] = $arRes['ID'];
             $arResult[] = $arRes;
         }
     }
     // User's calendars
     $strUsers = "0";
     if (is_array($Params['USERS']) && count($Params['USERS']) > 0) {
         foreach ($Params['USERS'] as $ownerId) {
             if (IntVal($ownerId) > 0) {
                 $strUsers .= "," . IntVal($ownerId);
             }
         }
         if ($strUsers != "0") {
             $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCS.*,\n\t\t\t\t\tU.LOGIN AS USER_LOGIN, U.NAME AS USER_NAME, U.LAST_NAME AS USER_LAST_NAME, U.SECOND_NAME AS USER_SECOND_NAME\n\t\t\t\tFROM\n\t\t\t\t\tb_calendar_section CS\n\t\t\t\t\tLEFT JOIN b_user U ON (CS.OWNER_ID=U.ID)\n\t\t\t\tWHERE\n\t\t\t\t\t(\n\t\t\t\t\t\tCS.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.OWNER_ID in (" . $strUsers . ")\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.CAL_TYPE='user'\n\t\t\t\t\t)";
             $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
         while ($arRes = $res->Fetch()) {
             $arSectionIds[] = $arRes['ID'];
             $arResult[] = $arRes;
         }
     }
     if ($checkPermissions && count($arSectionIds) > 0) {
         if ($checkSocnetPermissions) {
             if (isset($Params['USERS']) && count($Params['USERS']) > 0) {
                 $arFeaturesU = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $Params['USERS'], "calendar");
                 $arViewU = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $Params['USERS'], "calendar", 'view');
                 $arWriteU = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['USERS'], "calendar", 'write');
             }
             if (isset($Params['GROUPS']) && count($Params['GROUPS']) > 0) {
                 $arFeaturesG = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar");
                 $arViewG = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar", 'view');
                 $arWriteG = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar", 'write');
             }
         }
         CCalendarSect::GetArrayPermissions($arSectionIds);
         $res = array();
         $sectIds = array();
         foreach ($arResult as $sect) {
             $sectId = $sect['ID'];
             $ownerId = $sect['OWNER_ID'];
             if (self::CanDo('calendar_view_time', $sectId) && !in_array($sectId, $sectIds)) {
                 if ($checkSocnetPermissions) {
                     // Disabled in socialnetwork
                     if ($sect['CAL_TYPE'] == 'group' && (!$arFeaturesG[$ownerId] || !$arViewG[$ownerId]) || $sect['CAL_TYPE'] == 'user' && (!$arFeaturesU[$ownerId] || !$arViewU[$ownerId])) {
                         continue;
                     }
                 }
                 $sect['PERM'] = array('view_time' => self::CanDo('calendar_view_time', $sectId), 'view_title' => self::CanDo('calendar_view_title', $sectId), 'view_full' => self::CanDo('calendar_view_full', $sectId), 'add' => self::CanDo('calendar_add', $sectId), 'edit' => self::CanDo('calendar_edit', $sectId), 'edit_section' => self::CanDo('calendar_edit_section', $sectId), 'access' => self::CanDo('calendar_edit_access', $sectId));
                 if ($checkSocnetPermissions) {
                     if ($sect['CAL_TYPE'] == 'group' && !$arWriteG[$ownerId] || $sect['CAL_TYPE'] == 'user' && !$arWriteU[$ownerId]) {
                         $sect['PERM']['add'] = false;
                         $sect['PERM']['edit'] = false;
                         $sect['PERM']['edit_section'] = false;
                         $sect['PERM']['access'] = false;
                     }
                 }
                 if ($sect['CAL_TYPE'] == 'user') {
                     if (isset($sect['USER_NAME'], $sect['USER_LAST_NAME'])) {
                         $sect['OWNER_NAME'] = CCalendar::GetUserName(array("NAME" => $sect['USER_NAME'], "LAST_NAME" => $sect['USER_LAST_NAME'], "LOGIN" => $sect['USER_LOGIN'], "ID" => $ownerId, "SECOND_NAME" => $sect['USER_SECOND_NAME']));
                         unset($sect['USER_LOGIN']);
                         unset($sect['USER_LAST_NAME']);
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:calendar_sect.php

示例6: GetList

 public static function GetList($Params = array())
 {
     global $DB;
     $access = new CAccess();
     $access->UpdateCodes();
     $arFilter = $Params['arFilter'];
     $arOrder = isset($Params['arOrder']) ? $Params['arOrder'] : array('XML_ID' => 'asc');
     $checkPermissions = $Params['checkPermissions'] !== false;
     $bCache = CCalendar::CacheTime() > 0;
     if ($bCache) {
         $cache = new CPHPCache();
         $cacheId = serialize(array('type_list', $arFilter, $arOrder));
         $cachePath = CCalendar::CachePath() . 'type_list';
         if ($cache->InitCache(CCalendar::CacheTime(), $cacheId, $cachePath)) {
             $res = $cache->GetVars();
             $arResult = $res["arResult"];
             $arTypeXmlIds = $res["arTypeXmlIds"];
         }
     }
     if (!$bCache || !isset($arTypeXmlIds)) {
         static $arFields = array("XML_ID" => array("FIELD_NAME" => "CT.XML_ID", "FIELD_TYPE" => "string"), "NAME" => array("FIELD_NAME" => "CT.NAME", "FIELD_TYPE" => "string"), "ACTIVE" => array("FIELD_NAME" => "CT.ACTIVE", "FIELD_TYPE" => "string"), "DESCRIPTION" => array("FIELD_NAME" => "CT.DESCRIPTION", "FIELD_TYPE" => "string"), "EXTERNAL_ID" => array("FIELD_NAME" => "CT.EXTERNAL_ID", "FIELD_TYPE" => "string"));
         $err_mess = "Function: CCalendarType::GetList<br>Line: ";
         $arSqlSearch = array();
         $strSqlSearch = "";
         if (is_array($arFilter)) {
             $filter_keys = array_keys($arFilter);
             for ($i = 0, $l = count($filter_keys); $i < $l; $i++) {
                 $n = strtoupper($filter_keys[$i]);
                 $val = $arFilter[$filter_keys[$i]];
                 if (is_string($val) && strlen($val) <= 0) {
                     continue;
                 }
                 if ($n == 'XML_ID') {
                     if (is_array($val)) {
                         $strXml = "";
                         foreach ($val as $xmlId) {
                             $strXml .= ",'" . CDatabase::ForSql($xmlId) . "'";
                         }
                         $arSqlSearch[] = "CT.XML_ID in (" . trim($strXml, ", ") . ")";
                     } else {
                         $arSqlSearch[] = GetFilterQuery("CT.XML_ID", $val, 'N');
                     }
                 }
                 if ($n == 'EXTERNAL_ID') {
                     $arSqlSearch[] = GetFilterQuery("CT.EXTERNAL_ID", $val, 'N');
                 } elseif (isset($arFields[$n])) {
                     $arSqlSearch[] = GetFilterQuery($arFields[$n]["FIELD_NAME"], $val);
                 }
             }
         }
         $strOrderBy = '';
         foreach ($arOrder as $by => $order) {
             if (isset($arFields[strtoupper($by)])) {
                 $strOrderBy .= $arFields[strtoupper($by)]["FIELD_NAME"] . ' ' . (strtolower($order) == 'desc' ? 'desc' . (strtoupper($DB->type) == "ORACLE" ? " NULLS LAST" : "") : 'asc' . (strtoupper($DB->type) == "ORACLE" ? " NULLS FIRST" : "")) . ',';
             }
         }
         if (strlen($strOrderBy) > 0) {
             $strOrderBy = "ORDER BY " . rtrim($strOrderBy, ",");
         }
         $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCT.*\n\t\t\t\tFROM\n\t\t\t\t\tb_calendar_type CT\n\t\t\t\tWHERE\n\t\t\t\t\t{$strSqlSearch}\n\t\t\t\t{$strOrderBy}";
         $res = $DB->Query($strSql, false, $err_mess . __LINE__);
         $arResult = array();
         $arTypeXmlIds = array();
         while ($arRes = $res->Fetch()) {
             $arResult[] = $arRes;
             $arTypeXmlIds[] = $arRes['XML_ID'];
         }
         if ($bCache) {
             $cache->StartDataCache(CCalendar::CacheTime(), $cacheId, $cachePath);
             $cache->EndDataCache(array("arResult" => $arResult, "arTypeXmlIds" => $arTypeXmlIds));
         }
     }
     if ($checkPermissions && count($arTypeXmlIds) > 0) {
         $arPerm = self::GetArrayPermissions($arTypeXmlIds);
         $res = array();
         $arAccessCodes = array();
         foreach ($arResult as $type) {
             $typeXmlId = $type['XML_ID'];
             if (self::CanDo('calendar_type_view', $typeXmlId)) {
                 $type['PERM'] = array('view' => self::CanDo('calendar_type_view', $typeXmlId), 'add' => self::CanDo('calendar_type_add', $typeXmlId), 'edit' => self::CanDo('calendar_type_edit', $typeXmlId), 'edit_section' => self::CanDo('calendar_type_edit_section', $typeXmlId), 'access' => self::CanDo('calendar_type_access', $typeXmlId));
                 if (self::CanDo('calendar_type_access', $typeXmlId)) {
                     $type['ACCESS'] = array();
                     if (count($arPerm[$typeXmlId]) > 0) {
                         // Add codes to get they full names for interface
                         $arAccessCodes = array_merge($arAccessCodes, array_keys($arPerm[$typeXmlId]));
                         $type['ACCESS'] = $arPerm[$typeXmlId];
                     }
                 }
                 $res[] = $type;
             }
         }
         CCalendar::PushAccessNames($arAccessCodes);
         $arResult = $res;
     }
     return $arResult;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:97,代码来源:calendar_type.php

示例7: GetList

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


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