Documentation

CCourse::GetList

CDBResult
CCourse::GetList(
 array arOrder = Array("TIMESTAMP_X"=>"DESC"),
 array arFilter = Array(),
 bool bIncCnt = false
);

The GetList method returns the list of courses filtered by arFilter and sorted in the arOrder order. The current user access permissions are considered.

Parameters

ParameterDescription
arOrder An array in the format array("filter field"=>"sort order" [, ...]). The sorting field can have the following values:
  • ID - the course ID;
  • NAME - the course name;
  • ACTIVE - active state flag;
  • SORT - sort index;
  • TIMESTAMP_X - the date when the course was modified.
Sort order can be one of the following:
  • asc - ascending;
  • desc - descending;
Optional. The default value is descending.
arFilter An array in the format array("filtered field"=>"filter value" [, ...]). The following values are possible:
  • ID - the course ID;
  • NAME - the course name (wildcards allowed: [%_]);
  • SORT - sort index;
  • CODE - mnemonic name of the course (wildcards allowed: [%_]);
  • DESCRIPTION - the course description  (wildcards allowed: [%_]);
  • ACTIVE - active state flag (Y|N);
  • SITE_ID - the site ID;
  • TIMESTAMP_X - the date when the course was modified;
  • ACTIVE_FROM - the date from which the course is active (regarding the empty value);
  • ACTIVE_TO - the date from which the course is inactive (regarding the empty value);
  • DATE_ACTIVE_FROM - the date from which the course is active (regardless of the empty value);
  • DATE_ACTIVE_TO - the date from which the course is inactive (regardless of the empty value);
  • ACTIVE_DATE - if not empty, activates the active date filter (ACTIVE_FROM и ACTIVE_TO). If set to an empty string, the active date filter is not activated;
  • MIN_PERMISSION - minimum access permission level. "R" by default. See CCourse::SetPermission for available access permissions;
  • CHECK_PERMISSIONS - the level of access permission will be checked. If set to "N", the check is not performed;
  • CNT_ACTIVE - if set bIncCnt to true, only active lessons will be counted.
The following logic can be specified at the beginning of the field name:
  • "!" - not equal;
  • "<" - less than;
  • "<=" - less or equal;
  • ">" - more than;
  • ">=" - more or equal.

"filter values"  is a single value or an array.

Optional. By default, records are not filtered.
bIncCnt Defines whether the number of course lessons is to be returned in ELEMENT_CNT. Optional, false by default.

Return Values

The method returns an instance of the CDBResult object.

See Also

  • CDBResult
  • CCourse::GetByID
  • Course fields

    Example

    
    lt;?
    if (CModule::IncludeModule("learning"))
    {
        $res = CCourse::GetList(
            Array("SORT"=>"ASC"), 
            Array("ACTIVE" => "Y", "CNT_ACTIVE" => "Y"), 
            $bIncCnt = true
        );
    
        while ($arCourse = $res->GetNext())
        {
            echo "Course name: ".$arCourse["NAME"]."<br>";
            echo "Active lessons: ".$arCourse["ELEMENT_CNT"]."<br><br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $res = CCourse::GetList(
            Array("SORT"=>"ASC"), 
            Array("?NAME" => "Site")
        );
    
        while ($arCourse = $res->GetNext())
        {
            echo "Course name: ".$arCourse["NAME"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $res = CCourse::GetList(
            Array("NAME" => "ASC", "SORT"=>"ASC"), 
            Array("CHECK_PERMISSIONS" => "N")
        );
    
        while ($arCourse = $res->GetNext())
        {
            echo "Course name: ".$arCourse["NAME"]."<br>";
        }
    }
    ?>

    
    <?
    if(CModule::IncludeModule("learning")):
    
        $res = CCourse::GetList(Array("SORT" => "DESC"),
                                Array("ACTIVE" => "Y",
                                      "ACTIVE_DATE" => "Y",
                                      "SITE_ID" => LANG));
    
        while ($arElement = $res->GetNext()):?>
    
            <font class="text">
            <?if ($arElement["PREVIEW_PICTURE"]):?>
                <table cellpadding="0" cellspacing="0" border="0" align="left">
    
                    <tr>
                        <td><?echo ShowImage($arElement["PREVIEW_PICTURE"], 
                                             200, 200, 
                                             "hspace='0' vspace='2' align='left' border='0'", 
                                             "", true);?></td>
                        <td valign="top" width="0%">
                            <img src="/bitrix/images/1.gif" width="10" height="1">
                        </td>
    
                    </tr>
                </table>
            <?endif;?>
            <a target="blank_" href="
                <?=$COURSE_URL?>?COURSE_ID=<?=$arElement["ID"]?>"><?=$arElement["NAME"]?></a>
    
            <?=(strlen($arElement["PREVIEW_TEXT"])>0 ? "<br>".$arElement["PREVIEW_TEXT"]: "")?>
            </font><br clear="all"><br>
    
        <?endwhile?>
    <?endif?>
    ?>
  • © «Bitrix24», 2001-2024