Documentation

GetList

CDBResult
CTasks::GetList(
 array arOrder = array(),
 array arFilter = array(),
 array arSelect = array(),
 array arParams = array()
);

Returns list of tasks by arFilter filter, sorted in the arOrder direction.

Note: This method accepts an array of configuration parameters and generates scripts, necessary to show file dialog. Static method.

Method parameters

Parameter Description Available from version
arOrder Array for sorting of result. Array of array("sorting field"=>"sorting direction" [, ...]) type.
Field for sorting can have the following values:
  • TITLE - task name;
  • DATE_START - start date;
  • DEADLINE - deadline;
  • STATUS - status;
  • PRIORITY - priority;
  • MARK - evaluation;
  • CREATED_BY - task creator; 
  • RESPONSIBLE_ID - responsible user; 
  • GROUP_ID - workgroup. 
Sorting direction can have the following values:
  • asc - by ascension;
  • desc - by descension;
  Optional. By default, it is filtered by descending task ID.

Note. Sorting by user fields is available.

arFilter Array of array("filtered field"=>"filter value" [, ...]) type. Filtered field can have the following values:
  • ID - task ID;
  • PARENT_ID - parent task ID;
  • GROUP_ID - workgroup ID;
  • CREATED_BY - task creator;
  • STATUS_CHANGED_BY - user who modified task status last;
  • PRIORITY - priority;
  • FORUM_TOPIC_ID - forum topic ID;
  • RESPONSIBLE_ID - responsible user;
  • TITLE - task name (can be searched by the template [%_]) ;
  • TAG -  tag;
  • REAL_STATUS - task status. Constants that show task statuses:
    • CTasks::STATE_NEW = 1;
    • CTasks::STATE_PENDING = 2;
    • CTasks::STATE_IN_PROGRESS = 3;
    • CTasks::STATE_SUPPOSEDLY_COMPLETED = 4;
    • CTasks::STATE_COMPLETED = 5;
    • CTasks::STATE_DEFERRED = 6;
    • CTasks::STATE_DECLINED = 7;
  • STATUS - status for sorting. Similar to REAL_STATUS, but additionally has two meta statuses:
    • -2 - task not viewed;
    • -1 - overdue task.
  • MARK - evaluation;
  • XML_ID - external code;
  • SITE_ID - site ID;
  • ADD_IN_REPORT - task in the report (Y|N);
  • DATE_START - completion start date;
  • DEADLINE - deadline;
  • CREATED_DATE - creation date;
  • CLOSED_DATE - completion date;
  • CHANGED_DATE - last modification date;
  • ACCOMPLICE - task participant ID;
  • AUDITOR - auditor ID;
  • DEPENDS_ON - previous task ID; 
  • ONLY_ROOT_TASKS -  only root tasks (Y|N); 
  • SUBORDINATE_TASKS -  tasks of the current user or his/her subordinates (Y|N); 
  • OVERDUED -  task time limit was exceeded (Y|N); 
  • DEPARTMENT_ID - department ID.
Type of filtration can be specified in forms of filtered field name:
  • "!" - not equal
  • "<" - less
  • "<=" - less or equal
  • ">" - more
  • ">=" - more or equal

"filter values" - single value or an array.

Optional. By default, records are not filtered.
arSelect Array of returned task fields.
arParams Array of additional parameters. Optional.

Returned value

CDBResult object is returned. 

Examples of use

<?

// Select all task of the user with ID = 2
if (CModule::IncludeModule("tasks"))
{
$res = CTasks::GetList(
Array("TITLE" => "ASC"),
Array("RESPONSIBLE_ID" => "2")
);

while ($arTask = $res->GetNext())
{
echo "Task name: ".$arTask["TITLE"]."<br>";
}
}

?>

<?
// Selected tasks for which the user is responsible or a participant

$arFilter = array(
            '::LOGIC' => 'AND',
            'CHECK_PERMISSIONS' => 'Y',
            'ONLY_ROOT_TASKS' => 'Y',
            'SAME_GROUP_PARENT' => 'Y',
            '::SUBFILTER-1' => array(
               '::LOGIC' => 'OR',
               '::SUBFILTER-1' => array(
                  'ACCOMPLICE' => $USER->GetID(),
                  'REAL_STATUS' => array(CTasks::STATE_NEW, CTasks::STATE_PENDING, CTasks::STATE_IN_PROGRESS),
               ),
               '::SUBFILTER-2' => array(
                  'RESPONSIBLE_ID' => $USER->GetID(),
                  'REAL_STATUS' => array(CTasks::STATE_NEW, CTasks::STATE_PENDING, CTasks::STATE_IN_PROGRESS),
               ),
            ),
         );
?>

© «Bitrix24», 2001-2024