- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/restservice.php
- Класс: CTaskRestService
- Вызов: CTaskRestService::tasks_extended_meta_setAnyStatus
static function tasks_extended_meta_setAnyStatus($args)
{
$arMessages = array();
$parsedReturnValue = null;
$withoutExceptions = false;
try
{
CTaskAssert::assert(
is_array($args)
&& (count($args) == 2)
);
$statusId = array_pop($args);
$taskId = array_pop($args);
CTaskAssert::assertLaxIntegers($statusId, $taskId);
$taskId = (int) $taskId;
$statusId = (int) $statusId;
if ( ! in_array(
$statusId,
[
Status::PENDING,
Status::IN_PROGRESS,
Status::SUPPOSEDLY_COMPLETED,
Status::COMPLETED,
Status::DEFERRED,
],
true // forbid type casting
))
{
throw new TasksException('Invalid status given', TasksException::TE_WRONG_ARGUMENTS);
}
$oTask = CTaskItem::getInstance($taskId, CTasksTools::getCommanderInChief()); // act as Admin
$oTask->update(array('STATUS' => $statusId));
$parsedReturnValue = null;
$withoutExceptions = true;
}
catch (CTaskAssertException $e)
{
$arMessages[] = array(
'id' => 'TASKS_ERROR_ASSERT_EXCEPTION',
'text' => 'TASKS_ERROR_ASSERT_EXCEPTION'
);
}
catch (TasksException $e)
{
$errCode = $e->getCode();
$errMsg = $e->getMessage();
if ($e->GetCode() & TasksException::TE_FLAG_SERIALIZED_ERRORS_IN_MESSAGE)
$arMessages = unserialize($errMsg, ['allowed_classes' => false]);
else
{
$arMessages[] = array(
'id' => 'TASKS_ERROR_EXCEPTION_#' . $errCode,
'text' => 'TASKS_ERROR_EXCEPTION_#' . $errCode
. '; ' . $errMsg
. '; ' . TasksException::renderErrorCode($e)
);
}
}
catch (Exception $e)
{
$errMsg = $e->getMessage();
if ($errMsg !== '')
$arMessages[] = array('text' => $errMsg, 'id' => 'TASKS_ERROR');
}
if ($withoutExceptions)
return ($parsedReturnValue);
else
{
self::_emitError($arMessages);
throw new Exception();
}
}