This function builds subquery (for oracle) or comma-separated list of lessons IDs (for mysql/mssql) for SQL WHERE clause, which selects/contains all child lessons (only childs, without parent lesson). This functions prevents cycling.
on oracle SQLClauseForAllSubLessons(13) returns subquery: SELECT b_learn_lesson_edges.TARGET_NODE FROM b_learn_lesson_edges START WITH b_learn_lesson_edges.SOURCE_NODE=13 CONNECT BY NOCYCLE PRIOR b_learn_lesson_edges.TARGET_NODE = b_learn_lesson_edges.SOURCE_NODE
on mysql/mssql SQLClauseForAllSubLessons(13) returns list of child lessons: 14, 16, 120, 875, 476
Any of this strings can be used in WHERE IN(...our string...) clause.
<?php
{
const OPTION_ID =
'~CLearnHelper::isUpdatedToGraph();';
{
static $arCourseLinksPatterns =
array(
'{SELF}'
);
$argsCheck = is_string($strContent)
&& ($contextCourseId !== false)
&& ($contextCourseId > 0);
if ( ! $argsCheck )
return ($strContent);
$arCourseResolvedLinks = str_replace(
'{SELF}',
(string) ((int) $contextCourseId),
$arCourseLinksPatterns
);
$rc = str_replace(
$arCourseLinksPatterns,
$arCourseResolvedLinks,
$strContent
);
return ($rc);
}
public static function FireEvent ($eventName, $eventParams)
{
while ($arEvent = $events->Fetch())
}
{
if ( ! (
is_numeric($parentLessonId)
&& is_int($parentLessonId + 0)
)
)
{
'$parentLessonId must be strictly castable to integer',
}
$arChildLessonsIds = $oTree->GetLessonsIdListInTree();
$arChildLessonsIdsEscaped = array_map('intval', $arChildLessonsIds);
$sqlChildLessonsIdsList = implode (', ', $arChildLessonsIdsEscaped);
if ($sqlChildLessonsIdsList == '')
$sqlChildLessonsIdsList = 'NULL';
return ($sqlChildLessonsIdsList);
}
{
if(mb_substr(
$key, 0, 1) ==
"=")
{
$cOperationType = "I";
}
{
$cOperationType = "NI";
}
{
$cOperationType = "S";
}
{
$cOperationType = "NS";
}
{
$cOperationType = "?";
}
{
$cOperationType = "B";
}
{
$cOperationType = "NB";
}
{
$cOperationType = "GE";
}
{
$cOperationType = "G";
}
{
$cOperationType = "LE";
}
{
$cOperationType = "L";
}
{
$cOperationType = "N";
}
else
$cOperationType = "E";
return Array(
"FIELD"=>
$key,
"OPERATION"=>$cOperationType);
}
public static function FilterCreate($fname, $vals,
$type, &$bFullJoin, $cOperationType=
false, $bSkipEmpty =
true)
{
if(!is_array($vals))
$vals=Array($vals);
return "";
if(is_bool($cOperationType))
{
if($cOperationType===true)
$cOperationType = "N";
else
$cOperationType = "E";
}
if($cOperationType=="G")
$strOperation = ">";
$strOperation = ">=";
$strOperation = "<=";
$strOperation = "<";
else
$strOperation = "=";
$bFullJoin = false;
$bWasLeftJoin = false;
{
{
{
case "string_equal":
($cOperationType=="N"?"NOT":"").
"(".
$fname.
" IS NULL OR ".
$DB->Length($fname).
"<=0)";
else
"(".
($cOperationType=="N"?" ".$fname." IS NULL OR NOT (":"").
($cOperationType=="N"?")":"").
")";
break;
case "string":
if($cOperationType=="?")
{
}
{
$res[] = ($cOperationType==
"N"?
"NOT":
"").
"(".$fname.
" IS NULL OR ".
$DB->Length($fname).
"<=0)";
}
else
{
if($strOperation=="=")
"(".
($cOperationType=="N"?" ".$fname." IS NULL OR NOT (":"").
($cOperationType=="N"?")":"").
")";
else
"(".
($cOperationType=="N"?" ".$fname." IS NULL OR NOT (":"").
($cOperationType=="N"?")":"").
")";
}
break;
case "date":
$res[] = ($cOperationType==
"N"?
"NOT":
"").
"(".$fname.
" IS NULL)";
else
"(".
($cOperationType=="N"?" ".$fname." IS NULL OR NOT (":"").
$fname.
" ".$strOperation.
" ".
$DB->CharToDateFunction(
$DB->ForSql(
$val),
"FULL").
($cOperationType=="N"?")":"").
")";
break;
case "number":
$res[] = ($cOperationType==
"N"?
"NOT":
"").
"(".$fname.
" IS NULL)";
else
"(".
($cOperationType=="N"?" ".$fname." IS NULL OR NOT (":"").
$fname.
" ".$strOperation.
" '".DoubleVal(
$val).
($cOperationType=="N"?"')":"'").
")";
break;
}
if((
string)
$val <> '' && $cOperationType!=
"N")
$bFullJoin = true;
else
$bWasLeftJoin = true;
}
}
$strResult = "";
{
$strResult .= ($cOperationType=="N"?" AND ":" OR ");
}
$strResult = "(".$strResult.")";
if($bFullJoin && $bWasLeftJoin && $cOperationType!="N")
$bFullJoin = false;
return $strResult;
}
{
if (self::getUpdatedToGraphStatus() === self::GRAPH_STATUS_UPDATED_TO_GRAPH)
return true;
else
return false;
}
{
$isSaved = COption::SetOptionString(self::MODULE_ID, self::OPTION_ID,
return ($isSaved);
}
{
$rc = COption::GetOptionString(self::MODULE_ID, self::OPTION_ID, self::DEFAULT_VALUE, self::SITE_ID);
if ($rc === self::DEFAULT_VALUE)
{
}
$allowed_statuses =
array (
self::GRAPH_STATUS_LEGACY,
self::GRAPH_STATUS_UPDATED_TO_GRAPH,
self::GRAPH_STATUS_UNDEFINED
);
if ( ! in_array($rc, $allowed_statuses, true) )
{
AddMessage2Log(
'Invalid COption ~CLearnHelper::isUpdatedToGraph();: `'
. $rc . '`;', 'learning');
$rc = self::GRAPH_STATUS_UNDEFINED;
}
return ($rc);
}
{
|| ( ! (preg_match(
"#^[^\\\/:*?\"\'~%<>|]+$#is",
$filename) > 0) );
return ( ! $isUnSafe );
}
public static function CopyDirFiles($path_from, $path_to, $ReWrite = True, $Recursive = False)
{
if (mb_strpos($path_to."/", $path_from."/") === 0 || realpath($path_to) === realpath($path_from))
return false;
if (is_dir($path_from))
{
}
{
$path_to_dir = mb_substr($path_to, 0,
$p);
if (file_exists($path_to) && !$ReWrite)
return False;
@copy($path_from, $path_to);
if(is_file($path_to))
@chmod($path_to, BX_FILE_PERMISSIONS);
return True;
}
else
{
return True;
}
if (
$handle = @opendir($path_from))
{
while (($file = readdir(
$handle)) !==
false)
{
if ($file == "." || $file == "..")
continue;
continue;
if (is_dir($path_from."/".$file) && $Recursive)
{
}
elseif (is_file($path_from.
"/".$file))
{
if (file_exists($path_to."/".$file) && !$ReWrite)
continue;
@copy($path_from."/".$file, $path_to."/".$file);
@chmod($path_to."/".$file, BX_FILE_PERMISSIONS);
}
}
return true;
}
return false;
}
}
static isUpdatedToGraph()
const GRAPH_STATUS_UPDATED_TO_GRAPH
static PatchLessonContentLinks($strContent, $contextCourseId=false)
static CopyDirFiles($path_from, $path_to, $ReWrite=True, $Recursive=False)
static FilterCreate($fname, $vals, $type, &$bFullJoin, $cOperationType=false, $bSkipEmpty=true)
static IsBaseFilenameSafe($filename)
const GRAPH_STATUS_NOT_SET
const GRAPH_STATUS_UNDEFINED
static SQLClauseForAllSubLessons($parentLessonId)
static MkOperationFilter($key)
static getUpdatedToGraphStatus()
const GRAPH_STATUS_LEGACY
static FireEvent($eventName, $eventParams)
static setUpdatedToGraphStatus($status)
static GetTree( $lessonId, $arOrder=array('EDGE_SORT'=> 'asc'), $arFilter=array(), $publishProhibitionMode=true, $arSelectFields=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
ExecuteModuleEventEx($arEvent, $arParams=[])
AddMessage2Log($text, $module='', $traceDepth=6, $showArgs=false)
bxstrrpos($haystack, $needle)
HasScriptExtension($check_name)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"