Beispiel #1
0
 function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "SITE_ID", "PATH", "TYPE");
     }
     // FIELDS -->
     $arFields = array("ID" => array("FIELD" => "P.ID", "TYPE" => "int"), "SITE_ID" => array("FIELD" => "P.SITE_ID", "TYPE" => "string"), "PATH" => array("FIELD" => "P.PATH", "TYPE" => "string"), "TYPE" => array("FIELD" => "P.TYPE", "TYPE" => "string"));
     // <-- FIELDS
     $arSqls = CSitePath::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_learn_site_path P " . "\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;
         }
     }
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_learn_site_path P " . "\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_learn_site_path P " . "\t" . $arSqls["FROM"] . " ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $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 only
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         //echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
             $strSql .= "LIMIT " . (int) $arNavStartParams["nTopCount"];
         }
         //echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
Beispiel #2
0
 /**
  * <p>Метод изменяет параметры курса с идентификатором ID.</p>
  *
  *
  *
  *
  * @param int $ID  Идентификатор изменяемого курса.
  *
  *
  *
  * @param array $arFields  Массив Array("поле"=&gt;"значение", ...). Содержит значения <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/fields.php#course">всех полей</a> курса.
  * Обязательные поля должны быть заполнены. <br>Дополнительно в поле
  * SITE_ID должен находиться массив идентификаторов сайтов, к которым
  * привязан добавляемый курс. <br>Кроме того, с помощью поля "GROUP_ID",
  * значением которого должен быть массив соответствий кодов групп
  * правам доступа, можно установить права для разных групп на доступ
  * к курсу (см. <a href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/index.php">CCourse</a>::<a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/setpermission.php">SetPermission</a>).
  *
  *
  *
  * @return bool <p>Метод возвращает <i>true</i>, если изменение прошло успешно, при
  * возникновении ошибки функция вернет <i>false</i>. При возникновении
  * ошибки в исключениях будет содержаться текст ошибки.</p>
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * if (CModule::IncludeModule("learning"))
  * {
  *     $arFields = Array(
  *         "ACTIVE" =&gt; "Y",
  *         "NAME" =&gt; "New name",
  *         "SITE_ID" =&gt; Array("en"), //Sites
  *     );
  * 
  *     $ID = 1;//Course ID
  * 
  *     $course = new CCourse;
  *     $success = $course-&gt;Update($ID, $arFields);
  * 
  *     if($success)
  *     {
  *         echo "Ok!";
  *         
  *     }
  *     else
  *     {
  *         if($e = $APPLICATION-&gt;GetException())
  *             echo "Error: ".$e-&gt;GetString();
  *     }
  * 
  * }
  * ?&gt;
  * </pre>
  *
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/learning/fields.php#course">Поля курса</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/index.php">CCourse</a>::<a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/add.php">Add</a> </li> </ul> <a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/update.php
  * @author Bitrix
  */
 public function Update($ID, $arFields)
 {
     global $DB;
     $ID = intval($ID);
     if ($ID < 1) {
         return false;
     }
     if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
         $arFields["ACTIVE"] = "N";
     }
     if (is_set($arFields, "DESCRIPTION_TYPE") && $arFields["DESCRIPTION_TYPE"] != "html") {
         $arFields["DESCRIPTION_TYPE"] = "text";
     }
     if (is_set($arFields, "DETAIL_TEXT_TYPE") && $arFields["DETAIL_TEXT_TYPE"] != "html") {
         $arFields["DETAIL_TEXT_TYPE"] = "text";
     }
     if (is_set($arFields, "PREVIEW_TEXT_TYPE") && $arFields["PREVIEW_TEXT_TYPE"] != "html") {
         $arFields["PREVIEW_TEXT_TYPE"] = "text";
     }
     if (is_set($arFields, "RATING") && !in_array($arFields["RATING"], array("Y", "N"))) {
         $arFields["RATING"] = NULL;
     }
     if (is_set($arFields, "RATING_TYPE") && !in_array($arFields["RATING_TYPE"], array("like", "standart_text", "like_graphic", "standart"))) {
         $arFields["RATING_TYPE"] = NULL;
     }
     $lessonId = self::CourseGetLinkedLesson($ID);
     if ($this->CheckFields($arFields, $ID) && $lessonId !== false) {
         if (array_key_exists('ID', $arFields)) {
             unset($arFields["ID"]);
         }
         $arFieldsLesson = $arFields;
         $arFieldsToUnset = array('GROUP_ID', 'SITE_ID');
         foreach ($arFieldsToUnset as $key => $value) {
             if (array_key_exists($value, $arFieldsLesson)) {
                 unset($arFieldsLesson[$value]);
             }
         }
         //Sites
         if (is_set($arFields, "SITE_ID")) {
             $str_LID = "''";
             foreach ($arFields["SITE_ID"] as $lang) {
                 $str_LID .= ", '" . $DB->ForSql($lang) . "'";
             }
             $strSql = "DELETE FROM b_learn_course_site WHERE COURSE_ID=" . $ID;
             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             $strSql = "INSERT INTO b_learn_course_site(COURSE_ID, SITE_ID) " . "SELECT " . $ID . ", LID " . "FROM b_lang " . "WHERE LID IN (" . $str_LID . ") ";
             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
         CLearnLesson::Update($lessonId, $arFieldsLesson);
         if ($ID && (is_set($arFields, "NAME") || is_set($arFields, "DESCRIPTION") || is_set($arFields, 'DETAIL_TEXT'))) {
             if (CModule::IncludeModule("search")) {
                 $rsCourse = CCourse::GetByID($ID);
                 if ($arCourse = $rsCourse->Fetch()) {
                     $arGroupPermissions = CCourse::GetGroupPermissions($arCourse["ID"]);
                     if (is_set($arFields, "SITE_ID")) {
                         $arSiteIds = array();
                         foreach ($arFields["SITE_ID"] as $lang) {
                             $rsSitePaths = CSitePath::GetList(array(), array("SITE_ID" => $lang, "TYPE" => "C"));
                             if ($arSitePaths = $rsSitePaths->Fetch()) {
                                 $strPath = $arSitePaths["PATH"];
                             } else {
                                 $strPath = "";
                             }
                             $arSiteIds[$lang] = str_replace("#COURSE_ID#", $ID, $strPath);
                         }
                         $detailText = '';
                         if ($arCourse["DETAIL_TEXT_TYPE"] !== 'text') {
                             $detailText = CSearch::KillTags($arCourse['DETAIL_TEXT']);
                         } else {
                             $detailText = strip_tags($arCourse['DETAIL_TEXT']);
                         }
                         $dataBody = '';
                         if (strlen($detailText) > 0) {
                             $dataBody = $detailText;
                         } else {
                             $dataBody = $arCourse['NAME'];
                         }
                         $arSearchIndex = array("LAST_MODIFIED" => $arCourse["TIMESTAMP_X"], "TITLE" => $arCourse["NAME"], "BODY" => $dataBody, "SITE_ID" => $arSiteIds, "PERMISSIONS" => $arGroupPermissions);
                         CSearch::Index("learning", "C" . $ID, $arSearchIndex);
                     }
                     CSearch::ChangePermission("learning", $arGroupPermissions, false, "C" . $arCourse["ID"]);
                 }
             }
         }
         global $CACHE_MANAGER;
         $CACHE_MANAGER->ClearByTag('LEARN_COURSE_' . $ID);
         return true;
     }
     return false;
 }
Beispiel #3
0
 public static function PrepareSql(&$arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields, $obUserFieldsSql = false)
 {
     global $DB;
     $strSqlSelect = "";
     $strSqlFrom = "";
     $strSqlWhere = "";
     $strSqlGroupBy = "";
     $strSqlOrderBy = "";
     $arGroupByFunct = array("COUNT", "AVG", "MIN", "MAX", "SUM");
     $arAlreadyJoined = array();
     // GROUP BY -->
     if (is_array($arGroupBy) && count($arGroupBy) > 0) {
         $arSelectFields = $arGroupBy;
         foreach ($arGroupBy as $key => $val) {
             $val = strtoupper($val);
             $key = strtoupper($key);
             if (array_key_exists($val, $arFields) && !in_array($key, $arGroupByFunct)) {
                 if (strlen($strSqlGroupBy) > 0) {
                     $strSqlGroupBy .= ", ";
                 }
                 $strSqlGroupBy .= $arFields[$val]["FIELD"];
                 if (isset($arFields[$val]["FROM"]) && strlen($arFields[$val]["FROM"]) > 0 && !in_array($arFields[$val]["FROM"], $arAlreadyJoined)) {
                     if (strlen($strSqlFrom) > 0) {
                         $strSqlFrom .= " ";
                     }
                     $strSqlFrom .= $arFields[$val]["FROM"];
                     $arAlreadyJoined[] = $arFields[$val]["FROM"];
                 }
             }
         }
     }
     // <-- GROUP BY
     // SELECT -->
     $arFieldsKeys = array_keys($arFields);
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $strSqlSelect = "COUNT(%%_DISTINCT_%% " . $arFields[$arFieldsKeys[0]]["FIELD"] . ") as CNT ";
     } else {
         if (isset($arSelectFields) && !is_array($arSelectFields) && is_string($arSelectFields) && strlen($arSelectFields) > 0 && array_key_exists($arSelectFields, $arFields)) {
             $arSelectFields = array($arSelectFields);
         }
         if (!isset($arSelectFields) || !is_array($arSelectFields) || count($arSelectFields) <= 0 || in_array("*", $arSelectFields)) {
             foreach ($arFieldsKeys as $i => $value) {
                 if (isset($arFields[$arFieldsKeys[$i]]["WHERE_ONLY"]) && $arFields[$arFieldsKeys[$i]]["WHERE_ONLY"] == "Y") {
                     continue;
                 }
                 if (strlen($strSqlSelect) > 0) {
                     $strSqlSelect .= ", ";
                 }
                 if ($arFields[$arFieldsKeys[$i]]["TYPE"] == "datetime") {
                     if ((strtoupper($DB->type) == "ORACLE" || strtoupper($DB->type) == "MSSQL") && array_key_exists($arFieldsKeys[$i], $arOrder)) {
                         $strSqlSelect .= $arFields[$arFieldsKeys[$i]]["FIELD"] . " as " . $arFieldsKeys[$i] . "_X1, ";
                     }
                     $strSqlSelect .= $DB->DateToCharFunction($arFields[$arFieldsKeys[$i]]["FIELD"], "FULL") . " as " . $arFieldsKeys[$i];
                 } elseif ($arFields[$arFieldsKeys[$i]]["TYPE"] == "date") {
                     if ((strtoupper($DB->type) == "ORACLE" || strtoupper($DB->type) == "MSSQL") && array_key_exists($arFieldsKeys[$i], $arOrder)) {
                         $strSqlSelect .= $arFields[$arFieldsKeys[$i]]["FIELD"] . " as " . $arFieldsKeys[$i] . "_X1, ";
                     }
                     $strSqlSelect .= $DB->DateToCharFunction($arFields[$arFieldsKeys[$i]]["FIELD"], "SHORT") . " as " . $arFieldsKeys[$i];
                 } else {
                     $strSqlSelect .= $arFields[$arFieldsKeys[$i]]["FIELD"] . " as " . $arFieldsKeys[$i];
                 }
                 if (isset($arFields[$arFieldsKeys[$i]]["FROM"]) && strlen($arFields[$arFieldsKeys[$i]]["FROM"]) > 0 && !in_array($arFields[$arFieldsKeys[$i]]["FROM"], $arAlreadyJoined)) {
                     if (strlen($strSqlFrom) > 0) {
                         $strSqlFrom .= " ";
                     }
                     $strSqlFrom .= $arFields[$arFieldsKeys[$i]]["FROM"];
                     $arAlreadyJoined[] = $arFields[$arFieldsKeys[$i]]["FROM"];
                 }
             }
         } else {
             foreach ($arSelectFields as $key => $val) {
                 $val = strtoupper($val);
                 $key = strtoupper($key);
                 if (array_key_exists($val, $arFields)) {
                     if (strlen($strSqlSelect) > 0) {
                         $strSqlSelect .= ", ";
                     }
                     if (in_array($key, $arGroupByFunct)) {
                         $strSqlSelect .= $key . "(" . $arFields[$val]["FIELD"] . ") as " . $val;
                     } else {
                         if ($arFields[$val]["TYPE"] == "datetime") {
                             if ((strtoupper($DB->type) == "ORACLE" || strtoupper($DB->type) == "MSSQL") && array_key_exists($val, $arOrder)) {
                                 $strSqlSelect .= $arFields[$val]["FIELD"] . " as " . $val . "_X1, ";
                             }
                             $strSqlSelect .= $DB->DateToCharFunction($arFields[$val]["FIELD"], "FULL") . " as " . $val;
                         } elseif ($arFields[$val]["TYPE"] == "date") {
                             if ((strtoupper($DB->type) == "ORACLE" || strtoupper($DB->type) == "MSSQL") && array_key_exists($val, $arOrder)) {
                                 $strSqlSelect .= $arFields[$val]["FIELD"] . " as " . $val . "_X1, ";
                             }
                             $strSqlSelect .= $DB->DateToCharFunction($arFields[$val]["FIELD"], "SHORT") . " as " . $val;
                         } else {
                             $strSqlSelect .= $arFields[$val]["FIELD"] . " as " . $val;
                         }
                     }
                     if (isset($arFields[$val]["FROM"]) && strlen($arFields[$val]["FROM"]) > 0 && !in_array($arFields[$val]["FROM"], $arAlreadyJoined)) {
                         if (strlen($strSqlFrom) > 0) {
                             $strSqlFrom .= " ";
                         }
                         $strSqlFrom .= $arFields[$val]["FROM"];
                         $arAlreadyJoined[] = $arFields[$val]["FROM"];
                     }
                 }
             }
         }
         if (strlen($strSqlGroupBy) > 0) {
             if (strlen($strSqlSelect) > 0) {
                 $strSqlSelect .= ", ";
             }
             $strSqlSelect .= "COUNT(%%_DISTINCT_%% " . $arFields[$arFieldsKeys[0]]["FIELD"] . ") as CNT";
         } else {
             $strSqlSelect = "%%_DISTINCT_%% " . $strSqlSelect;
         }
     }
     // <-- SELECT
     // WHERE -->
     $arSqlSearch = array();
     if (!is_array($arFilter)) {
         $filter_keys = array();
     } else {
         $filter_keys = array_keys($arFilter);
     }
     for ($i = 0; $i < count($filter_keys); $i++) {
         $vals = $arFilter[$filter_keys[$i]];
         if (!is_array($vals)) {
             $vals = array($vals);
         }
         $key = $filter_keys[$i];
         $key_res = CSitePath::GetFilterOperation($key);
         $key = $key_res["FIELD"];
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         $strOrNull = $key_res["OR_NULL"];
         if (array_key_exists($key, $arFields)) {
             $arSqlSearch_tmp = array();
             for ($j = 0; $j < count($vals); $j++) {
                 $val = $vals[$j];
                 if (isset($arFields[$key]["WHERE"])) {
                     $arSqlSearch_tmp1 = call_user_func_array($arFields[$key]["WHERE"], array($val, $key, $strOperation, $strNegative, $arFields[$key]["FIELD"], $arFields, $arFilter));
                     if ($arSqlSearch_tmp1 !== false) {
                         $arSqlSearch_tmp[] = $arSqlSearch_tmp1;
                     }
                 } else {
                     if ($arFields[$key]["TYPE"] == "int") {
                         if (IntVal($val) == 0 && strpos($strOperation, "=") !== False) {
                             $arSqlSearch_tmp[] = "(" . $arFields[$key]["FIELD"] . " IS " . ($strNegative == "Y" ? "NOT " : "") . "NULL) " . ($strNegative == "Y" ? "AND" : "OR") . " " . ($strNegative == "Y" ? "NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " 0)";
                         } else {
                             $arSqlSearch_tmp[] = ($strNegative == "Y" ? " " . $arFields[$key]["FIELD"] . " IS NULL OR NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " " . IntVal($val) . " )";
                         }
                     } elseif ($arFields[$key]["TYPE"] == "double") {
                         $val = str_replace(",", ".", $val);
                         if (DoubleVal($val) == 0 && strpos($strOperation, "=") !== False) {
                             $arSqlSearch_tmp[] = "(" . $arFields[$key]["FIELD"] . " IS " . ($strNegative == "Y" ? "NOT " : "") . "NULL) " . ($strNegative == "Y" ? "AND" : "OR") . " " . ($strNegative == "Y" ? "NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " 0)";
                         } else {
                             $arSqlSearch_tmp[] = ($strNegative == "Y" ? " " . $arFields[$key]["FIELD"] . " IS NULL OR NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " " . DoubleVal($val) . " )";
                         }
                     } elseif ($arFields[$key]["TYPE"] == "string" || $arFields[$key]["TYPE"] == "char") {
                         if ($strOperation == "QUERY") {
                             $arSqlSearch_tmp[] = GetFilterQuery($arFields[$key]["FIELD"], $val, "Y");
                         } else {
                             if (strlen($val) == 0 && strpos($strOperation, "=") !== False) {
                                 $arSqlSearch_tmp[] = "(" . $arFields[$key]["FIELD"] . " IS " . ($strNegative == "Y" ? "NOT " : "") . "NULL) " . ($strNegative == "Y" ? "AND NOT" : "OR") . " (" . $DB->Length($arFields[$key]["FIELD"]) . " <= 0) " . ($strNegative == "Y" ? "AND NOT" : "OR") . " (" . $arFields[$key]["FIELD"] . " " . $strOperation . " '" . $DB->ForSql($val) . "' )";
                             } else {
                                 $arSqlSearch_tmp[] = ($strNegative == "Y" ? " " . $arFields[$key]["FIELD"] . " IS NULL OR NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " '" . $DB->ForSql($val) . "' )";
                             }
                         }
                     } elseif ($arFields[$key]["TYPE"] == "datetime") {
                         if (strlen($val) <= 0) {
                             $arSqlSearch_tmp[] = ($strNegative == "Y" ? "NOT" : "") . "(" . $arFields[$key]["FIELD"] . " IS NULL)";
                         } else {
                             $arSqlSearch_tmp[] = ($strNegative == "Y" ? " " . $arFields[$key]["FIELD"] . " IS NULL OR NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ")";
                         }
                     } elseif ($arFields[$key]["TYPE"] == "date") {
                         if (strlen($val) <= 0) {
                             $arSqlSearch_tmp[] = ($strNegative == "Y" ? "NOT" : "") . "(" . $arFields[$key]["FIELD"] . " IS NULL)";
                         } else {
                             $arSqlSearch_tmp[] = ($strNegative == "Y" ? " " . $arFields[$key]["FIELD"] . " IS NULL OR NOT " : "") . "(" . $arFields[$key]["FIELD"] . " " . $strOperation . " " . $DB->CharToDateFunction($DB->ForSql($val), "SHORT") . ")";
                         }
                     }
                 }
             }
             if (isset($arFields[$key]["FROM"]) && strlen($arFields[$key]["FROM"]) > 0 && !in_array($arFields[$key]["FROM"], $arAlreadyJoined)) {
                 if (strlen($strSqlFrom) > 0) {
                     $strSqlFrom .= " ";
                 }
                 $strSqlFrom .= $arFields[$key]["FROM"];
                 $arAlreadyJoined[] = $arFields[$key]["FROM"];
             }
             $strSqlSearch_tmp = "";
             for ($j = 0; $j < count($arSqlSearch_tmp); $j++) {
                 if ($j > 0) {
                     $strSqlSearch_tmp .= $strNegative == "Y" ? " AND " : " OR ";
                 }
                 $strSqlSearch_tmp .= "(" . $arSqlSearch_tmp[$j] . ")";
             }
             if ($strOrNull == "Y") {
                 if (strlen($strSqlSearch_tmp) > 0) {
                     $strSqlSearch_tmp .= $strNegative == "Y" ? " AND " : " OR ";
                 }
                 $strSqlSearch_tmp .= "(" . $arFields[$key]["FIELD"] . " IS " . ($strNegative == "Y" ? "NOT " : "") . "NULL)";
                 if (strlen($strSqlSearch_tmp) > 0) {
                     $strSqlSearch_tmp .= $strNegative == "Y" ? " AND " : " OR ";
                 }
                 if ($arFields[$key]["TYPE"] == "int" || $arFields[$key]["TYPE"] == "double") {
                     $strSqlSearch_tmp .= "(" . $arFields[$key]["FIELD"] . " " . ($strNegative == "Y" ? "<>" : "=") . " 0)";
                 } elseif ($arFields[$key]["TYPE"] == "string" || $arFields[$key]["TYPE"] == "char") {
                     $strSqlSearch_tmp .= "(" . $arFields[$key]["FIELD"] . " " . ($strNegative == "Y" ? "<>" : "=") . " '')";
                 }
             }
             if ($strSqlSearch_tmp != "") {
                 $arSqlSearch[] = "(" . $strSqlSearch_tmp . ")";
             }
         }
     }
     for ($i = 0; $i < count($arSqlSearch); $i++) {
         if (strlen($strSqlWhere) > 0) {
             $strSqlWhere .= " AND ";
         }
         $strSqlWhere .= "(" . $arSqlSearch[$i] . ")";
     }
     // <-- WHERE
     // ORDER BY -->
     $arSqlOrder = array();
     foreach ($arOrder as $by => $order) {
         $by = strtoupper($by);
         $order = strtoupper($order);
         if ($order != "ASC") {
             $order = "DESC";
         } else {
             $order = "ASC";
         }
         if (array_key_exists($by, $arFields)) {
             $arSqlOrder[] = " " . $arFields[$by]["FIELD"] . " " . $order . " ";
             if (isset($arFields[$by]["FROM"]) && strlen($arFields[$by]["FROM"]) > 0 && !in_array($arFields[$by]["FROM"], $arAlreadyJoined)) {
                 if (strlen($strSqlFrom) > 0) {
                     $strSqlFrom .= " ";
                 }
                 $strSqlFrom .= $arFields[$by]["FROM"];
                 $arAlreadyJoined[] = $arFields[$by]["FROM"];
             }
         } elseif ($obUserFieldsSql) {
             $arSqlOrder[] = " " . $obUserFieldsSql->GetOrder($by) . " " . $order . " ";
         }
     }
     $strSqlOrderBy = "";
     DelDuplicateSort($arSqlOrder);
     for ($i = 0; $i < count($arSqlOrder); $i++) {
         if (strlen($strSqlOrderBy) > 0) {
             $strSqlOrderBy .= ", ";
         }
         if (strtoupper($DB->type) == "ORACLE") {
             if (substr($arSqlOrder[$i], -3) == "ASC") {
                 $strSqlOrderBy .= $arSqlOrder[$i] . " NULLS FIRST";
             } else {
                 $strSqlOrderBy .= $arSqlOrder[$i] . " NULLS LAST";
             }
         } else {
             $strSqlOrderBy .= $arSqlOrder[$i];
         }
     }
     // <-- ORDER BY
     return array("SELECT" => $strSqlSelect, "FROM" => $strSqlFrom, "WHERE" => $strSqlWhere, "GROUPBY" => $strSqlGroupBy, "ORDERBY" => $strSqlOrderBy);
 }
Beispiel #4
0
			</td>
		</tr>
	<?php 
}
?>

	<tr class="heading">
		<td colspan="2"><?php 
echo GetMessage("LEARNING_SITE_PATH");
?>
</td>
	</tr>
	<?php 
$arPaths = array();
$dbPaths = CSitePath::GetList();
while ($arPath = $dbPaths->Fetch()) {
    $arPaths[$arPath["SITE_ID"]][$arPath["TYPE"]] = $arPath["PATH"];
}
$dbSites = CSite::GetList($b = "", $o = "", array("ACTIVE" => "Y"));
while ($arSite = $dbSites->Fetch()) {
    ?>
		<tr>
			<td valign="top" colspan="2" align="center"><?php 
    echo str_replace("#SITE#", $arSite["LID"], GetMessage("LEARNING_SITE_PATH_SITE"));
    ?>
:</td>
		</tr>
		<tr>
			<td align="right"><?php 
    echo GetMessage("LEARNING_SITE_PATH_SITE_COURSE");
Beispiel #5
0
    return;
}
// paths templates for correct indexing
$urls = array(array(WIZARD_SITE_DIR . 'services/learning/course.php?COURSE_ID=#COURSE_ID#&INDEX=Y', 'C'), array(WIZARD_SITE_DIR . 'services/learning/course.php?COURSE_ID=#COURSE_ID#&CHAPTER_ID=#CHAPTER_ID#', 'H'), array(WIZARD_SITE_DIR . 'services/learning/course.php?COURSE_ID=#COURSE_ID#&LESSON_ID=#LESSON_ID#', 'L'));
// If method not exists => new data model used
if (!method_exists('CCourse', 'SetPermission')) {
    $urls[] = array(WIZARD_SITE_DIR . 'services/learning/course.php?LESSON_PATH=#LESSON_PATH#', 'U');
}
$dbPath = CSitePath::GetList(array(), array("SITE_ID" => WIZARD_SITE_ID));
while ($arPath = $dbPath->Fetch()) {
    unset($GLOBALS["LEARNING_SITE_PATH"]["LEARNING_SITE_PATH1_CACHE_" . $arPath["SITE_ID"]]);
    unset($GLOBALS["LEARNING_SITE_PATH"]["LEARNING_SITE_PATH_CACHE_" . $arPath["ID"]]);
    $DB->Query("DELETE FROM b_learn_site_path WHERE ID = '" . $arPath["ID"] . "'", true);
}
foreach ($urls as $url) {
    CSitePath::Add(array("SITE_ID" => WIZARD_SITE_ID, "PATH" => $url[0], "TYPE" => $url[1]));
}
$arCourses = array("new_employee", "portal");
$arCoursesSite = array("new_employee_" . WIZARD_SITE_ID, "portal_" . WIZARD_SITE_ID);
if (!WIZARD_NEW_2011 && WIZARD_SITE_ID == 's1') {
    $arCoursesSite = array("new_employee", "portal");
}
foreach ($arCourses as $key => $courseCode) {
    try {
        $dbResult = CCourse::GetList(array(), array("CODE" => $arCoursesSite[$key]));
        $pathToService = WIZARD_SERVICE_ABSOLUTE_PATH;
        if (!($arCourse = $dbResult->Fetch())) {
            $pathToCourse = WIZARD_SERVICE_RELATIVE_PATH . "/" . LANGUAGE_ID . "/" . $courseCode . "/";
            $package = new CCourseImport($pathToCourse, array(WIZARD_SITE_ID));
            if (strlen($package->LAST_ERROR) > 0) {
                return;