Пример #1
0
 function GetFilter($arFilter)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case "ID":
             case "SORT":
             case "QUESTION_ID":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("CA." . $key, $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "ANSWER":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("CA." . $key, $val, "string", $bFullJoin, $cOperationType);
                 break;
             case "CORRECT":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("CA." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                 break;
         }
     }
     return $arSqlSearch;
 }
Пример #2
0
 /**
  * @access protected
  * @throws LearnException with error bit set EXC_ERR_ALL_PARAMS 
  */
 protected static function GetFilter($arFilter = array(), $mode)
 {
     global $DB;
     if (!is_array($arFilter)) {
         throw new LearnException('EA_PARAMS', LearnException::EXC_ERR_ALL_PARAMS);
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             // for courses only
             case 'COURSE_ID':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TC.ID', $val, 'number', $bFullJoin, $cOperationType);
                 break;
             case 'COURSE_SORT':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TC.SORT', $val, 'number', $bFullJoin, $cOperationType);
                 break;
             case 'EDGE_SORT':
                 // edges table (TLE) available only if requested immediate childs of some parent lesson
                 if ($mode & self::GET_LIST_IMMEDIATE_CHILDS_OF) {
                     $arSqlSearch[] = CLearnHelper::FilterCreate('TLE.SORT', $val, 'number', $bFullJoin, $cOperationType);
                 } else {
                     throw new LearnException('EA_PARAMS: unknown field ' . $key, LearnException::EXC_ERR_ALL_PARAMS);
                 }
                 break;
             case 'SORT':
                 if ($mode & self::GET_LIST_IMMEDIATE_CHILDS_OF) {
                     // edges table (TLE) available only if requested immediate childs of some parent lesson
                     $arSqlSearch[] = CLearnHelper::FilterCreate('TLE.SORT', $val, 'number', $bFullJoin, $cOperationType);
                 } else {
                     // so, by default sort by b_learn_course.SORT (for partially backward compatibility)
                     $arSqlSearch[] = CLearnHelper::FilterCreate('TC.SORT', $val, 'number', $bFullJoin, $cOperationType);
                 }
                 break;
             case 'LINKED_LESSON_ID':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TC.' . $key, $val, 'number', $bFullJoin, $cOperationType, false);
                 break;
             case 'CHILDS_CNT':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('(SELECT COUNT(*) FROM b_learn_lesson_edges TLES WHERE TLES.SOURCE_NODE = TL.ID)', $val, 'number', $bFullJoin, $cOperationType);
                 break;
             case 'ACTIVE_FROM':
             case 'ACTIVE_TO':
                 if (strlen($val) > 0) {
                     $arSqlSearch[] = "(TC." . $key . " " . ($cOperationType == "N" ? "<" : ">=") . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ($cOperationType == "N" ? "" : " OR TC.ACTIVE_FROM IS NULL") . ")";
                 }
                 break;
             case "ACTIVE_DATE":
                 if (strlen($val) > 0) {
                     $arSqlSearch[] = ($cOperationType == "N" ? " NOT" : "") . "((TC.ACTIVE_TO >= " . $DB->GetNowFunction() . " OR TC.ACTIVE_TO IS NULL) AND (TC.ACTIVE_FROM <= " . $DB->GetNowFunction() . " OR TC.ACTIVE_FROM IS NULL))";
                 }
                 break;
             case "DATE_ACTIVE_TO":
             case "DATE_ACTIVE_FROM":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("TC." . $key, $val, 'date', $bFullJoin, $cOperationType);
                 break;
             case 'RATING_TYPE':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TC.' . $key, $val, 'string', $bFullJoin, $cOperationType);
                 break;
             case 'RATING':
             case 'SCORM':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TC.' . $key, $val, 'string_equal', $bFullJoin, $cOperationType);
                 break;
                 // for all lessons
             // for all lessons
             case 'WAS_CHAPTER_ID':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TL.WAS_CHAPTER_ID', $val, 'number', $bFullJoin, $cOperationType);
                 break;
             case 'LESSON_ID':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TL.ID', $val, 'number', $bFullJoin, $cOperationType);
                 break;
             case 'CREATED_BY':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TL.' . $key, $val, 'number', $bFullJoin, $cOperationType);
                 break;
             case 'NAME':
             case 'CODE':
             case 'LAUNCH':
             case 'DETAIL_TEXT':
             case 'DETAIL_TEXT_TYPE':
             case 'PREVIEW_TEXT':
             case 'PREVIEW_TEXT_TYPE':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TL.' . $key, $val, 'string', $bFullJoin, $cOperationType);
                 break;
             case 'CREATED_USER_NAME':
                 $arSqlSearch[] = CLearnHelper::FilterCreate($DB->Concat("'('", 'TU.LOGIN', "') '", 'TU.NAME', "' '", 'TU.LAST_NAME'), $val, 'string', $bFullJoin, $cOperationType);
                 break;
             case 'KEYWORDS':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TL.' . $key, $val, 'string', $bFullJoin, $cOperationType);
                 break;
             case 'ACTIVE':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TL.' . $key, $val, 'string_equal', $bFullJoin, $cOperationType);
                 break;
             case 'TIMESTAMP_X':
             case 'DATE_CREATE':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('TL.' . $key, $val, 'date', $bFullJoin, $cOperationType);
                 break;
             case 'SITE_ID':
                 break;
             case 'CHECK_PERMISSIONS':
             case 'CHECK_PERMISSIONS_FOR_USER_ID':
             case 'ACCESS_OPERATIONS':
                 // this is meta-fields, nothing to do with them here
                 break;
             default:
                 if (substr($key, 0, 3) !== 'UF_') {
                     throw new LearnException('EA_PARAMS: unknown field ' . $key, LearnException::EXC_ERR_ALL_PARAMS);
                 }
                 break;
         }
     }
     return $arSqlSearch;
 }
Пример #3
0
	public static function GetFilter($arFilter)
	{

		if (!is_array($arFilter))
			$arFilter = Array();

		$arSqlSearch = Array();

		foreach ($arFilter as $key => $val)
		{
			$res = CLearnHelper::MkOperationFilter($key);
			$key = $res["FIELD"];
			$cOperationType = $res["OPERATION"];

			$key = strtoupper($key);

			switch ($key)
			{
				case "ID":
				case "STUDENT_ID":
				case "TEST_ID":
				case "RESULT":
				case "MAX_RESULT":
					$arSqlSearch[] = CLearnHelper::FilterCreate("G.".$key, $val, "number", $bFullJoin, $cOperationType);
					break;
				case "COMPLETED":
					$arSqlSearch[] = CLearnHelper::FilterCreate("G.".$key, $val, "string_equal", $bFullJoin, $cOperationType);
					break;
				case "USER":
					$arSqlSearch[] = GetFilterQuery("U.ID, U.LOGIN, U.NAME, U.LAST_NAME",$val);
					break;
			}

		}

		return $arSqlSearch;

	}
Пример #4
0
	public static function GetFilter($arFilter)
	{
		if (!is_array($arFilter))
			$arFilter = Array();

		$arSqlSearch = Array();

		foreach ($arFilter as $key => $val)
		{
			$res = CLearnHelper::MkOperationFilter($key);
			$key = $res["FIELD"];
			$cOperationType = $res["OPERATION"];

			$key = strtoupper($key);

			switch ($key)
			{
				case "ID":
				case "ATTEMPT_ID":
				case "QUESTION_ID":
				case "POINT":
					$arSqlSearch[] = CLearnHelper::FilterCreate("TR.".$key, $val, "number", $bFullJoin, $cOperationType);
					break;

				case "RESPONSE":
					$arSqlSearch[] = CLearnHelper::FilterCreate("TR.".$key, $val, "string", $bFullJoin, $cOperationType);
					break;

				case "QUESTION_NAME":
					$arSqlSearch[] = CLearnHelper::FilterCreate("Q.NAME", $val, "string", $bFullJoin, $cOperationType);
					break;

				case "ANSWERED":
				case "CORRECT":
					$arSqlSearch[] = CLearnHelper::FilterCreate("TR.".$key, $val, "string_equal", $bFullJoin, $cOperationType);
					break;
			}
		}

		return $arSqlSearch;
	}
Пример #5
0
 function GetFilter($arFilter)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case "ID":
             case "STUDENT_ID":
             case "COURSE_ID":
             case "SORT":
             case "SUMMARY":
             case "MAX_SUMMARY":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("CER." . $key, $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "ACTIVE":
             case "PUBLIC_PROFILE":
             case "FROM_ONLINE":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("CER." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                 break;
             case "TIMESTAMP_X":
             case "DATE_CREATE":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("CER." . $key, $val, "date", $bFullJoin, $cOperationType);
                 break;
             case "USER":
                 $arSqlSearch[] = GetFilterQuery("U.ID, U.LOGIN, U.NAME, U.LAST_NAME", $val);
                 break;
         }
     }
     return $arSqlSearch;
 }
Пример #6
0
 private static function getFilter($arFilter)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case 'LESSON_ID':
             case 'LEARNING_GROUP_ID':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('LGL.' . $key, $val, 'number', $bFullJoin, $cOperationType);
                 break;
         }
     }
     return array_filter($arSqlSearch);
 }
Пример #7
0
 public static function GetFilter($arFilter)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case "USER_ID":
             case "TRANSCRIPT":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("S." . $key, $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "PUBLIC_PROFILE":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("S." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                 break;
             case "RESUME":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("S." . $key, $val, "string", $bFullJoin, $cOperationType);
                 break;
         }
     }
     return $arSqlSearch;
 }
Пример #8
0
    public static function GetFilter($arFilter)
    {
        global $DBType;
        if (!is_array($arFilter)) {
            $arFilter = array();
        }
        $arSqlSearch = array();
        foreach ($arFilter as $key => $val) {
            $res = CLearnHelper::MkOperationFilter($key);
            $key = $res["FIELD"];
            $cOperationType = $res["OPERATION"];
            $key = strtoupper($key);
            switch ($key) {
                case "ID":
                case "SORT":
                case "LESSON_ID":
                case "POINT":
                    $arSqlSearch[] = CLearnHelper::FilterCreate("CQ." . $key, $val, "number", $bFullJoin, $cOperationType);
                    break;
                case "COURSE_ID":
                    // was:	$arSqlSearch[] = CLearnHelper::FilterCreate("C.".$key, $val, "number", $bFullJoin, $cOperationType);
                    $courseLessonId = CCourse::CourseGetLinkedLesson($val);
                    if ($courseLessonId === false) {
                        break;
                    }
                    // it is not a course, so skipping
                    if ($DBType === 'oracle') {
                        // This subquery gets ids of all childs lesson for given $courseLessonId
                        $subQuery = "\n\t\t\t\t\t\t\tSELECT TLE.TARGET_NODE\n\t\t\t\t\t\t\tFROM b_learn_lesson_edges TLE\n\t\t\t\t\t\t\tSTART WITH TLE.SOURCE_NODE=" . ($courseLessonId + 0) . "\n\t\t\t\t\t\t\tCONNECT BY NOCYCLE PRIOR TLE.TARGET_NODE = TLE.SOURCE_NODE";
                        // But we need also $courseLessonId itself, so final clause will be:
                        $arSqlSearch[] = '(CQ.LESSON_ID IN (' . $subQuery . ')
							OR CQ.LESSON_ID = ' . ($courseLessonId + 0) . ')';
                    } elseif ($DBType === 'mysql' || $DBType === 'mssql') {
                        // MySQL & MSSQL supports "WHERE IN(...)" clause for more than 10 000 elements
                        // add to sql "WHERE" constraint: lessons id only from given array
                        $sqlCourseLessonsIdsList = '';
                        $oTree = CLearnLesson::GetTree($courseLessonId);
                        $arChildLessonForCourse = $oTree->GetLessonsIdListInTree();
                        // root lesson not in tree, so add it
                        $arChildLessonForCourse[] = $courseLessonId;
                        // We need escape data for SQL
                        $arChildLessonForCourseEscaped = array_map('intval', $arChildLessonForCourse);
                        $sqlCourseLessonsIdsList = implode(', ', $arChildLessonForCourseEscaped);
                        if (strlen($sqlCourseLessonsIdsList) > 0) {
                            $arSqlSearch[] = 'CQ.LESSON_ID IN (' . $sqlCourseLessonsIdsList . ')';
                        }
                    } else {
                        throw new LearnException('Unsupported DB engine: ' . $DBType, LearnException::EXC_ERR_ALL_GIVEUP);
                    }
                    break;
                case "NAME":
                    $arSqlSearch[] = CLearnHelper::FilterCreate("CQ." . $key, $val, "string", $bFullJoin, $cOperationType);
                    break;
                case "QUESTION_TYPE":
                case "ACTIVE":
                case "SELF":
                case "CORRECT_REQUIRED":
                    $arSqlSearch[] = CLearnHelper::FilterCreate("CQ." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                    break;
            }
        }
        return $arSqlSearch;
    }
Пример #9
0
 function GetFilter($arFilter)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case "ID":
             case "TEST_ID":
             case "STUDENT_ID":
             case "SCORE":
             case "MAX_SCORE":
             case "QUESTIONS":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("A." . $key, $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "STATUS":
             case "COMPLETED":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("A." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                 break;
             case "DATE_START":
             case "DATE_END":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("A." . $key, $val, "date", $bFullJoin, $cOperationType);
                 break;
             case "USER":
                 $arSqlSearch[] = GetFilterQuery("U.ID, U.LOGIN, U.NAME, U.LAST_NAME", $val);
                 break;
         }
     }
     return $arSqlSearch;
 }
Пример #10
0
 public static function MkOperationFilter($key)
 {
     // refactored: body of function moved to CLearnHelper class
     return CLearnHelper::MkOperationFilter($key);
 }
Пример #11
0
 private static function getFilter($arFilter)
 {
     global $DB;
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case 'ID':
             case 'SORT':
             case 'COURSE_LESSON_ID':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('LG.' . $key, $val, 'number', $bFullJoin, $cOperationType);
                 break;
             case 'ACTIVE':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('LG.' . $key, $val, 'string_equal', $bFullJoin, $cOperationType);
                 break;
             case 'ACTIVE_FROM':
             case 'ACTIVE_TO':
                 if ($val !== null) {
                     $arSqlSearch[] = CLearnHelper::FilterCreate('LG.' . $key, $val, 'date', $bFullJoin, $cOperationType);
                 }
                 break;
             case 'TITLE':
             case 'CODE':
                 $arSqlSearch[] = CLearnHelper::FilterCreate("LG." . $key, $val, "string", $bFullJoin, $cOperationType);
                 break;
             case 'COURSE_TITLE':
                 $arSqlSearch[] = CLearnHelper::FilterCreate("LL.NAME", $val, "string", $bFullJoin, $cOperationType);
                 break;
             case 'MEMBER_ID':
                 $arSqlSearch[] = CLearnHelper::FilterCreate('LGM.USER_ID', $val, 'number', $bFullJoin, $cOperationType);
                 break;
             default:
                 if (substr($key, 0, 3) !== 'UF_') {
                     throw new LearnException('Unknown field: ' . $key, LearnException::EXC_ERR_ALL_PARAMS);
                 }
                 break;
         }
     }
     return array_filter($arSqlSearch);
 }
Пример #12
0
 function GetFilter($arFilter)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case "ID":
             case "SCORE":
             case "TEST_ID":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("TM." . $key, $val, "number", $bFullJoin, $cOperationType);
                 break;
         }
     }
     return $arSqlSearch;
 }
Пример #13
0
 function GetFilter($arFilter)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CLearnHelper::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case "ID":
             case "SORT":
             case "COURSE_ID":
             case "ATTEMPT_LIMIT":
             case "TIME_LIMIT":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("LT." . $key, $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "NAME":
             case "DESCRIPTION":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("LT." . $key, $val, "string", $bFullJoin, $cOperationType);
                 break;
             case "ACTIVE":
             case "APPROVED":
             case "INCLUDE_SELF_TEST":
             case "RANDOM_ANSWERS":
             case "RANDOM_QUESTIONS":
             case "QUESTIONS_FROM":
             case "QUESTIONS_FROM_ID":
             case "PASSAGE_TYPE":
                 $arSqlSearch[] = CLearnHelper::FilterCreate("LT." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                 break;
         }
     }
     return $arSqlSearch;
 }