Example #1
0
 /**
  * Prepares "parameters" argument for self::getList() according to the purposes of a REST interface
  * 
  * @param mixed[] Initial parameters
  * @param mixed[] Behaviour flags
  * 
  * 	<li> USER_ID integer Current user id, mandatory.
  * 	<li> ROW_LIMIT integer Row limit on each rest query, optional
  * 
  * @return mixed[]
  */
 public static function getList(array $parameters = array(), $behaviour = array())
 {
     if (!is_array($behaviour)) {
         $behaviour = array();
     }
     $behaviour['USER_ID'] = Assert::expectIntegerPositive($behaviour['USER_ID'], '$behaviour[USER_ID]');
     if (!isset($behaviour['ROW_LIMIT'])) {
         $behaviour['ROW_LIMIT'] = false;
     }
     $runtime = array();
     if (is_array($parameters['order']) && !empty($parameters['order'])) {
         static::parseOutSimpleAggregations(array_keys($parameters['order']), $runtime);
     }
     $parameters['filter']['=TASK.ZOMBIE'] = 'N';
     if (is_array($parameters['select']) && !empty($parameters['select'])) {
         static::parseOutSimpleAggregations($parameters['select'], $runtime);
     }
     $rights = TaskTable::getRuntimeFieldMixins(array('CHECK_RIGHTS'), array('USER_ID' => $behaviour['USER_ID'], 'REF_FIELD' => 'TASK_ID'));
     if (!empty($rights)) {
         $runtime['CHECK_RIGHTS'] = $rights['CHECK_RIGHTS'];
     }
     if (!empty($runtime)) {
         $parameters['runtime'] = $runtime;
     }
     $behaviour['ROW_LIMIT'] = intval($behaviour['ROW_LIMIT']);
     if ($behaviour['ROW_LIMIT'] && (!isset($parameters['limit']) || (int) $parameters['limit'] > $behaviour['ROW_LIMIT'])) {
         $parameters['limit'] = $behaviour['ROW_LIMIT'];
     }
     return parent::getList($parameters);
 }
Example #2
0
 /**
  * Returns a list of direct links according to the old-style (sutable for CTask::GetList()) filter
  */
 public static function getListByLegacyTaskFilter(array $filter = array(), array $parameters = array())
 {
     $mixins = TaskTable::getRuntimeMixins(array(array('CODE' => 'LEGACY_FILTER', 'FILTER' => $filter, 'REF_FIELD' => 'TASK_ID')));
     if (!empty($mixins)) {
         if (!is_array($parameters['runtime'])) {
             $parameters['runtime'] = array();
         }
         $parameters['runtime'] = array_merge($parameters['runtime'], $mixins);
     }
     $parameters['filter']['=DIRECT'] = '1';
     return self::getList($parameters);
 }
Example #3
0
 /**
  * Removes a task from favorites for a particular (or current) user. This function DOES NOT check permissions.
  * 
  * @param mixed[] Primary key for \Bitrix\Tasks\Task\FavoriteTable entity
  * @param mixed[] Behaviour flags
  * 
  *  <li> AFFECT_CHILDREN boolean if true, all child tasks also will be added to favorite. (default false)
  * 
  * @return \Bitrix\Main\Entity\DeleteResult
  */
 public static function delete($primary, $behaviour = array('AFFECT_CHILDREN' => false))
 {
     if (!is_array($behaviour)) {
         $behaviour = array();
     }
     if (!isset($behaviour['AFFECT_CHILDREN'])) {
         $behaviour['AFFECT_CHILDREN'] = false;
     }
     $primary = static::processPrimary($primary);
     $result = parent::delete($primary);
     if ($result->isSuccess() && $behaviour['AFFECT_CHILDREN']) {
         // add also all children...
         $res = TaskTable::getChildrenTasksData($primary['TASK_ID'], array('runtime' => TaskTable::getRuntimeFieldMixins(array('IN_FAVORITE'), array('USER_ID' => $primary['USER_ID'])), 'select' => array('IN_FAVORITE')));
         while ($item = $res->fetch()) {
             if ($item['IN_FAVORITE']) {
                 // our client
                 static::delete(array('TASK_ID' => $item['ID']), array('AFFECT_CHILDREN' => false));
             }
         }
     }
     return $result;
 }
Example #4
0
 protected function initializeTaskFromData(array $taskData = array())
 {
     if (empty($taskData)) {
         $select = array('ID', 'MATCH_WORK_TIME', 'ALLOW_CHANGE_DEADLINE', 'START_DATE_PLAN', 'END_DATE_PLAN', 'CREATED_DATE', 'RESPONSIBLE_ID', 'CREATED_BY', 'GROUP_ID', 'STATUS' => 'REAL_STATUS');
         $taskData = TaskTable::getList(array('filter' => array('=ID' => $this->taskId), 'select' => $select))->fetch();
     } else {
         if (!isset($taskData['MATCH_WORK_TIME'])) {
             $taskData['MATCH_WORK_TIME'] = 'N';
             // assume no
         }
     }
     if (!isset($taskData['ID'])) {
         if ($this->taskId) {
             $taskData['ID'] = $this->taskId;
         } else {
             $taskData['ID'] = PHP_INT_MAX;
         }
     }
     $this->taskPool[$this->taskId] = \CTaskItem::constructWithPreloadedData($this->userId, $taskData);
     $this->taskPool[$this->taskId]->setCalendar($this->calendar);
     if ($this->taskId > 0) {
         static::checkAccessThrowException($this->taskPool[$this->taskId]);
     }
 }