示例#1
0
 /**
  *
  * Moves the source task before/after the target task;
  * @param array $data
  * @return false|array
  */
 public function move($data)
 {
     global $USER;
     if (!$USER->isAuthorized()) {
         $this->errors->add("AUTH_REQUIRED", Loc::getMessage("TASKS_SORTING_AUTH_REQUIRED"));
         return false;
     }
     $sourceId = isset($data["sourceId"]) ? intval($data["sourceId"]) : 0;
     $targetId = isset($data["targetId"]) ? intval($data["targetId"]) : 0;
     $before = isset($data["before"]) && ($data["before"] === true || $data["before"] === "true") ? true : false;
     $newGroupId = isset($data["newGroupId"]) ? intval($data["newGroupId"]) : null;
     $newParentId = isset($data["newParentId"]) ? intval($data["newParentId"]) : null;
     $currentGroupId = isset($data["currentGroupId"]) ? intval($data["currentGroupId"]) : 0;
     $userId = $USER->getId();
     if ($sourceId === $targetId || $sourceId < 1) {
         return array();
     }
     $sourceTask = new \CTaskItem($sourceId, $userId);
     if (!$sourceTask->checkCanRead()) {
         $this->errors->add("SOURCE_TASK_NOT_FOUND", Loc::getMessage("TASKS_SORTING_WRONG_SOURCE_TASK"));
         return false;
     }
     if ($currentGroupId) {
         $group = \CSocNetGroup::getByID($currentGroupId);
         $canEdit = \CSocNetFeaturesPerms::currentUserCanPerformOperation(SONET_ENTITY_GROUP, $currentGroupId, "tasks", "edit_tasks");
         if (!$group || !$canEdit) {
             $this->errors->add("GROUP_PERMS_NOT_FOUND", Loc::getMessage("TASKS_SORTING_WRONG_GROUP_PERMISSIONS"));
             return false;
         }
     }
     /*
     GROUP_ID and PARENT_ID could be changed after drag&drop manipulations.
     Target task is not required. Example: We want to move Task 1 after Project. In this case a target task is undefined.
     	Task 1
     	Project (without tasks)
     */
     $newTaskData = array();
     if ($newGroupId !== null) {
         $newTaskData["GROUP_ID"] = $newGroupId;
     }
     if ($newParentId !== null) {
         $newTaskData["PARENT_ID"] = $newParentId;
     }
     if (count($newTaskData)) {
         $sourceTask->update($newTaskData);
     }
     //But it's required for sorting
     if ($targetId < 1) {
         return array();
     }
     $targetTask = new \CTaskItem($targetId, $userId);
     if (!$targetTask->checkCanRead()) {
         $this->errors->add("TARGET_TASK_NOT_FOUND", Loc::getMessage("TASKS_SORTING_WRONG_TARGET_TASK"));
         return false;
     }
     SortingTable::setSorting($userId, $currentGroupId, $sourceId, $targetId, $before);
     return array();
 }
示例#2
0
 /**
  * Remove a task from users own favorite list
  */
 public function delete($taskId)
 {
     global $USER;
     $result = array();
     if ($taskId = $this->checkTaskId($taskId)) {
         // user can add a task ONLY to his OWN favorite-list
         $task = new \CTaskItem($taskId, $USER->GetId());
         $task->deleteFromFavorite();
     }
     return $result;
 }
示例#3
0
 /**
  * Delete an existing dependence between two tasks
  */
 public function delete($taskIdFrom, $taskIdTo)
 {
     global $USER;
     try {
         $task = new \CTaskItem($taskIdTo, $USER->GetId());
         $task->deleteDependOn($taskIdFrom, $linkType);
     } catch (Tree\Exception $e) {
         $this->errors->add('ILLEGAL_LINK', \Bitrix\Tasks\Dispatcher::proxyExceptionMessage($e));
     }
     return array();
 }
示例#4
0
 protected function loadTaskData($userId)
 {
     if ($this->taskPostData === null) {
         try {
             $task = new \CTaskItem($this->entityId, $userId);
             $this->taskPostData = $task->getData(false);
         } catch (\TasksException $e) {
             return array();
         }
     }
     return $this->taskPostData;
 }
示例#5
0
 /**
  * See CSocNetLogFavorites::Add() and CSocNetLogFavorites::Change()
  */
 public static function OnSonetLogFavorites(array $params)
 {
     $params['USER_ID'] = intval($params['USER_ID']);
     $params['LOG_ID'] = intval($params['LOG_ID']);
     if ($params['USER_ID'] && $params['LOG_ID'] && static::includeModule()) {
         $res = \CSocNetLog::GetById($params['LOG_ID']);
         if (!empty($res)) {
             $taskId = intval($res['SOURCE_ID']);
             try {
                 $task = new \CTaskItem($taskId, $params['USER_ID']);
                 // ensure task exists
                 if ($params['OPERATION'] == 'ADD') {
                     $task->addToFavorite(array('TELL_SOCNET' => false));
                 } else {
                     $task->deleteFromFavorite(array('TELL_SOCNET' => false));
                 }
             } catch (\TasksException $e) {
                 return;
             }
         }
     }
 }
示例#6
0
 /**
  * Delete an elapsed time record
  */
 public function delete($id)
 {
     global $USER;
     $result = array();
     if ($id = $this->checkId($id)) {
         // get task id
         $taskId = $this->getOwnerTaskId($id);
         if ($taskId) {
             $task = \CTaskItem::getInstanceFromPool($taskId, $USER->GetId());
             // or directly, new \CTaskItem($taskId, $USER->GetId());
             $item = new \CTaskElapsedItem($task, $id);
             $item->delete();
         }
     }
     return $result;
 }
示例#7
0
 public static function runRestMethod($executiveUserId, $methodName, $args, $navigation)
 {
     static $arManifest = null;
     static $arMethodsMetaInfo = null;
     if ($arManifest === null) {
         $arManifest = self::getManifest();
         $arMethodsMetaInfo = $arManifest['REST: available methods'];
     }
     // Check and parse params
     CTaskAssert::assert(isset($arMethodsMetaInfo[$methodName]));
     $arMethodMetaInfo = $arMethodsMetaInfo[$methodName];
     $argsParsed = CTaskRestService::_parseRestParams('ctasklogitem', $methodName, $args);
     $returnValue = null;
     if (isset($arMethodMetaInfo['staticMethod']) && $arMethodMetaInfo['staticMethod']) {
         if ($methodName === 'list') {
             $taskId = $argsParsed[0];
             $order = $argsParsed[1];
             $filter = $argsParsed[2];
             $oTaskItem = CTaskItem::getInstance($taskId, $executiveUserId);
             list($items, $rsData) = self::fetchList($oTaskItem, $order, $filter);
             $returnValue = array();
             foreach ($items as $item) {
                 $returnValue[] = $item->getData(false);
             }
         } else {
             $returnValue = call_user_func_array(array('self', $methodName), $argsParsed);
         }
     } else {
         $taskId = array_shift($argsParsed);
         $itemId = array_shift($argsParsed);
         $oTaskItem = CTaskItem::getInstance($taskId, $executiveUserId);
         $item = new self($oTaskItem, $itemId);
         $returnValue = call_user_func_array(array($item, $methodName), $argsParsed);
     }
     return array($returnValue, null);
 }
示例#8
0
 private function getTaskPosition($taskId, array $order = array(), array $filter = array(), array $navigation = array(), array $select = array())
 {
     global $USER;
     //Navigation Restrictions
     if (isset($navigation["NAV_PARAMS"])) {
         $navigation["NAV_PARAMS"]["NavShowAll"] = false;
         $navigation["NAV_PARAMS"]["bShowAll"] = false;
     }
     $maxPageSize = \Bitrix\Tasks\Manager\Task::LIMIT_PAGE_SIZE;
     if (isset($navigation["NAV_PARAMS"]["nPageTop"])) {
         $navigation["NAV_PARAMS"]["nPageTop"] = min(intval($navigation["NAV_PARAMS"]["nPageTop"]), $maxPageSize);
     }
     if (isset($navigation["NAV_PARAMS"]["nPageSize"])) {
         $navigation["NAV_PARAMS"]["nPageSize"] = min(intval($navigation["NAV_PARAMS"]["nPageSize"]), $maxPageSize);
     }
     list($items) = \CTaskItem::fetchList($USER->GetId(), $order, $filter, $navigation, $select);
     $result = array("found" => false, "prevTaskId" => 0, "nextTaskId" => 0);
     for ($i = 0, $l = count($items); $i < $l; $i++) {
         $id = $items[$i]->getId();
         if ($id == $taskId) {
             $result["found"] = true;
             if (isset($items[$i + 1])) {
                 $result["nextTaskId"] = $items[$i + 1]->getId();
             }
             break;
         }
         $result["prevTaskId"] = $id;
     }
     return $result;
 }
示例#9
0
function tasksRenderJSON($arTask, $childrenCount, $arPaths, $bParent = false, $bGant = false, $top = false, $nameTemplate = "", $arAdditionalFields = array(), $bSkipJsMenu = false)
{
    global $USER;
    $arAllowedTaskActions = array();
    if (isset($arTask['META:ALLOWED_ACTIONS'])) {
        $arAllowedTaskActions = $arTask['META:ALLOWED_ACTIONS'];
    } elseif ($arTask['ID']) {
        $oTask = CTaskItem::getInstanceFromPool($arTask['ID'], $USER->getId());
        $arAllowedTaskActions = $oTask->getAllowedTaskActionsAsStrings();
        $arTask['META:ALLOWED_ACTIONS'] = $arAllowedTaskActions;
    }
    $runningTaskId = $runningTaskTimer = null;
    if ($arTask['ALLOW_TIME_TRACKING'] === 'Y') {
        $oTimer = CTaskTimerManager::getInstance($USER->getId());
        $runningTaskData = $oTimer->getRunningTask(false);
        $runningTaskId = $runningTaskData['TASK_ID'];
        $runningTaskTimer = time() - $runningTaskData['TIMER_STARTED_AT'];
    }
    ?>
	{
		id : <?php 
    echo $arTask["ID"];
    ?>
,
		name : "<?php 
    echo CUtil::JSEscape($arTask["TITLE"]);
    ?>
",
		<?php 
    if ($arTask["GROUP_ID"]) {
        ?>
			projectId : <?php 
        echo $arTask["GROUP_ID"];
        ?>
,
			projectName : '<?php 
        echo CUtil::JSEscape($arTask['GROUP_NAME']);
        ?>
',
		<?php 
    }
    ?>
		status : "<?php 
    echo tasksStatus2String($arTask["STATUS"]);
    ?>
",
		realStatus : "<?php 
    echo $arTask["REAL_STATUS"];
    ?>
",
		url: '<?php 
    echo CUtil::JSEscape(CComponentEngine::MakePathFromTemplate($arPaths["PATH_TO_TASKS_TASK"], array("task_id" => $arTask["ID"], "action" => "view")));
    ?>
',
		details: window.top.onDetails,
		priority : <?php 
    echo $arTask["PRIORITY"];
    ?>
,
		mark : <?php 
    echo !$arTask["MARK"] ? "null" : "'" . $arTask["MARK"] . "'";
    ?>
,
		responsible: '<?php 
    echo CUtil::JSEscape(tasksFormatNameShort($arTask["RESPONSIBLE_NAME"], $arTask["RESPONSIBLE_LAST_NAME"], $arTask["RESPONSIBLE_LOGIN"], $arTask["RESPONSIBLE_SECOND_NAME"], $nameTemplate));
    ?>
',
		director: '<?php 
    echo CUtil::JSEscape(tasksFormatNameShort($arTask["CREATED_BY_NAME"], $arTask["CREATED_BY_LAST_NAME"], $arTask["CREATED_BY_LOGIN"], $arTask["CREATED_BY_SECOND_NAME"], $nameTemplate));
    ?>
',
		responsibleId : <?php 
    echo $arTask["RESPONSIBLE_ID"];
    ?>
,
		directorId : <?php 
    echo $arTask["CREATED_BY"];
    ?>
,
		responsible_name: '<?php 
    echo CUtil::JSEscape($arTask["RESPONSIBLE_NAME"]);
    ?>
',
		responsible_second_name: '<?php 
    echo CUtil::JSEscape($arTask["RESPONSIBLE_SECOND_NAME"]);
    ?>
',
		responsible_last_name: '<?php 
    echo CUtil::JSEscape($arTask["RESPONSIBLE_LAST_NAME"]);
    ?>
',
		responsible_login: '******',
		director_name: '<?php 
    echo CUtil::JSEscape($arTask["CREATED_BY_NAME"]);
    ?>
',
		director_second_name: '<?php 
    echo CUtil::JSEscape($arTask["CREATED_BY_SECOND_NAME"]);
    ?>
',
		director_last_name: '<?php 
    echo CUtil::JSEscape($arTask["CREATED_BY_LAST_NAME"]);
    ?>
',
		director_login: '******',
		dateCreated : <?php 
    tasksJSDateObject($arTask["CREATED_DATE"], $top);
    ?>
,

		<?php 
    if ($arTask["START_DATE_PLAN"]) {
        ?>
dateStart : <?php 
        tasksJSDateObject($arTask["START_DATE_PLAN"], $top);
        ?>
,<?php 
    } else {
        ?>
dateStart: null,<?php 
    }
    ?>

		<?php 
    if ($arTask["END_DATE_PLAN"]) {
        ?>
dateEnd : <?php 
        tasksJSDateObject($arTask["END_DATE_PLAN"], $top);
        ?>
,<?php 
    } else {
        ?>
dateEnd: null,<?php 
    }
    ?>

		<?php 
    if ($arTask["DATE_START"]) {
        ?>
dateStarted: <?php 
        tasksJSDateObject($arTask["DATE_START"], $top);
        ?>
,<?php 
    }
    ?>

		dateCompleted : <?php 
    if ($arTask["CLOSED_DATE"]) {
        tasksJSDateObject($arTask["CLOSED_DATE"], $top);
    } else {
        ?>
null<?php 
    }
    ?>
,

		<?php 
    if ($arTask["DEADLINE"]) {
        ?>
dateDeadline : <?php 
        tasksJSDateObject($arTask["DEADLINE"], $top);
        ?>
,<?php 
    } else {
        ?>
dateDeadline: null,<?php 
    }
    ?>

		canEditPlanDates : <?php 
    if ($arAllowedTaskActions['ACTION_EDIT']) {
        ?>
true<?php 
    } else {
        ?>
false<?php 
    }
    ?>
,

		<?php 
    if ($arTask["PARENT_ID"] && $bParent) {
        ?>
			parentTaskId : <?php 
        echo $arTask["PARENT_ID"];
        ?>
,
		<?php 
    }
    ?>

		<?php 
    if (sizeof($arTask["FILES"])) {
        $i = 0;
        ?>
			files: [
				<?php 
        foreach ($arTask["FILES"] as $file) {
            $i++;
            ?>
				{ name : '<?php 
            echo CUtil::JSEscape($file["ORIGINAL_NAME"]);
            ?>
', url : '/bitrix/components/bitrix/tasks.task.detail/show_file.php?fid=<?php 
            echo $file["ID"];
            ?>
', size : '<?php 
            echo CUtil::JSEscape(CFile::FormatSize($file["FILE_SIZE"]));
            ?>
' }<?php 
            if ($i != sizeof($arTask["FILES"])) {
                ?>
,<?php 
            }
            ?>
				<?php 
        }
        ?>
			],
		<?php 
    }
    ?>

		<?php 
    if (count($arTask['ACCOMPLICES']) > 0) {
        $i = 0;
        echo 'accomplices: [';
        foreach ($arTask['ACCOMPLICES'] as $ACCOMPLICE_ID) {
            if ($i++) {
                echo ',';
            }
            echo '{ id: ' . (int) $ACCOMPLICE_ID . ' }';
        }
        echo '], ';
    }
    ?>

		<?php 
    if (count($arTask['AUDITORS']) > 0) {
        $i = 0;
        echo 'auditors: [';
        foreach ($arTask['AUDITORS'] as $AUDITOR_ID) {
            if ($i++) {
                echo ',';
            }
            echo '{ id: ' . (int) $AUDITOR_ID . ' }';
        }
        echo '], ';
    }
    ?>

		isSubordinate: <?php 
    echo $arTask["SUBORDINATE"] == "Y" ? "true" : "false";
    ?>
,
		isInReport: <?php 
    echo $arTask["ADD_IN_REPORT"] == "Y" ? "true" : "false";
    ?>
,
		hasChildren : <?php 
    if ((int) $childrenCount > 0) {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
,
		childrenCount : <?php 
    echo (int) $childrenCount;
    ?>
,
		canEditDealine : <?php 
    if ($arAllowedTaskActions['ACTION_EDIT'] || $arAllowedTaskActions['ACTION_CHANGE_DEADLINE']) {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
,
		canStartTimeTracking : <?php 
    if ($arAllowedTaskActions['ACTION_START_TIME_TRACKING']) {
        ?>
true<?php 
    } else {
        ?>
false<?php 
    }
    ?>
,
		ALLOW_TIME_TRACKING : <?php 
    if (isset($arTask['ALLOW_TIME_TRACKING']) && $arTask['ALLOW_TIME_TRACKING'] === 'Y') {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
,
		TIMER_RUN_TIME : <?php 
    if ($runningTaskId == $arTask['ID']) {
        echo (int) $runningTaskTimer;
    } else {
        echo 'false';
    }
    ?>
,
		TIME_SPENT_IN_LOGS : <?php 
    echo (int) $arTask['TIME_SPENT_IN_LOGS'];
    ?>
,
		TIME_ESTIMATE : <?php 
    echo (int) $arTask['TIME_ESTIMATE'];
    ?>
,
		IS_TASK_TRACKING_NOW : <?php 
    if ($runningTaskId == $arTask['ID']) {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
,
		menuItems: [<?php 
    tasksGetItemMenu($arTask, $arPaths, SITE_ID, $bGant, $top, $bSkipJsMenu);
    ?>
]

		<?php 
    foreach ($arAdditionalFields as $key => $value) {
        echo ', ' . $key . ' : ' . $value . "\n";
    }
    ?>
	}
<?php 
}
示例#10
0
 public function getAllowedActions($bReturnAsStrings = false)
 {
     if ($bReturnAsStrings) {
         return $this->getAllowedActionsAsStrings();
     }
     // Lazy load and cache allowed actions list
     if ($this->arTaskAllowedActions === null) {
         $arTaskData = $this->getData($bSpecialChars = false);
         $bmUserRoles = $this->getUserRoles();
         $arBaseAllowedActions = self::getBaseAllowedActions();
         $arActualBaseAllowedActions = $arBaseAllowedActions[$arTaskData['REAL_STATUS']];
         $arAllowedActions = array();
         $mergesCount = 0;
         if (is_array($arActualBaseAllowedActions)) {
             foreach ($arActualBaseAllowedActions as $userRole => $arActions) {
                 if ($userRole & $bmUserRoles) {
                     $arAllowedActions = array_merge($arAllowedActions, $arActions);
                     ++$mergesCount;
                 }
             }
         }
         if ($mergesCount > 1) {
             $arAllowedActions = array_unique($arAllowedActions);
         }
         $isAdmin = CTasksTools::IsAdmin($this->executiveUserId) || CTasksTools::IsPortalB24Admin($this->executiveUserId);
         if (self::$bSocialNetworkModuleIncluded === null) {
             self::$bSocialNetworkModuleIncluded = CModule::IncludeModule('socialnetwork');
         }
         // Admin always can edit and remove, also implement rights from task group
         if (!in_array(self::ACTION_REMOVE, $arAllowedActions, true)) {
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             if ($isAdmin || $arTaskData['GROUP_ID'] > 0 && self::$bSocialNetworkModuleIncluded && CSocNetFeaturesPerms::CanPerformOperation($this->executiveUserId, SONET_ENTITY_GROUP, $arTaskData['GROUP_ID'], 'tasks', 'delete_tasks')) {
                 $arAllowedActions[] = self::ACTION_REMOVE;
             }
         }
         if (!in_array(self::ACTION_EDIT, $arAllowedActions, true)) {
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             if ($isAdmin || $arTaskData['GROUP_ID'] > 0 && self::$bSocialNetworkModuleIncluded && CSocNetFeaturesPerms::CanPerformOperation($this->executiveUserId, SONET_ENTITY_GROUP, $arTaskData['GROUP_ID'], 'tasks', 'edit_tasks')) {
                 $arAllowedActions[] = self::ACTION_EDIT;
             }
         }
         // Precache result of slow 'in_array' function
         $bCanEdit = in_array(self::ACTION_EDIT, $arAllowedActions, true);
         // User can change deadline, if ...
         if ($isAdmin || $bCanEdit || $arTaskData['ALLOW_CHANGE_DEADLINE'] === 'Y' && self::ROLE_RESPONSIBLE & $bmUserRoles) {
             $arAllowedActions[] = self::ACTION_CHANGE_DEADLINE;
         }
         // If user can edit task, he can also add elapsed time and checklist items
         if ($isAdmin || $bCanEdit) {
             $arAllowedActions[] = self::ACTION_ELAPSED_TIME_ADD;
             $arAllowedActions[] = self::ACTION_CHECKLIST_ADD_ITEMS;
         }
         // Director can change director, and user who can edit can
         if ($isAdmin || $bCanEdit || self::ROLE_DIRECTOR & $bmUserRoles) {
             $arAllowedActions[] = self::ACTION_CHANGE_DIRECTOR;
         }
         if ($arTaskData['ALLOW_TIME_TRACKING'] === 'Y') {
             // User can do time tracking, if he is participant in the task
             if ($this->executiveUserId == $arTaskData['RESPONSIBLE_ID'] || !empty($arTaskData['ACCOMPLICES']) && in_array($this->executiveUserId, $arTaskData['ACCOMPLICES'])) {
                 $arAllowedActions[] = self::ACTION_START_TIME_TRACKING;
             }
         }
         $this->arTaskAllowedActions = array_values(array_unique($arAllowedActions));
     }
     return $this->arTaskAllowedActions;
 }
示例#11
0
} else {
    $arResult['SYSTEM_COLUMN_IDS'] = array(CTaskColumnList::SYS_COLUMN_CHECKBOX, CTaskColumnList::SYS_COLUMN_COMPLETE);
    // checkbox & complete columns
}
$oTimer = $arTimer = null;
// we will load timer data on demand, only once
$index = 0;
$arResult['ITEMS'] = array();
foreach ($arParams['~DATA_COLLECTION'] as &$dataItem) {
    $arResult['ITEMS'][$index] = array('TASK' => $dataItem['TASK'], 'CHILDREN_COUNT' => $dataItem['CHILDREN_COUNT'], 'DEPTH' => isset($dataItem['DEPTH']) ? $dataItem['DEPTH'] : 0, 'UPDATES_COUNT' => isset($dataItem['UPDATES_COUNT']) ? $dataItem['UPDATES_COUNT'] : 0, 'PROJECT_EXPANDED' => isset($dataItem['PROJECT_EXPANDED']) ? $dataItem['PROJECT_EXPANDED'] : true, 'ALLOWED_ACTIONS' => null);
    if (isset($dataItem['ALLOWED_ACTIONS'])) {
        $arResult['ITEMS'][$index]['ALLOWED_ACTIONS'] = $dataItem['ALLOWED_ACTIONS'];
    } elseif (isset($dataItem['TASK']['META:ALLOWED_ACTIONS'])) {
        $arResult['ITEMS'][$index]['ALLOWED_ACTIONS'] = $dataItem['TASK']['META:ALLOWED_ACTIONS'];
    } elseif ($dataItem['TASK']['ID']) {
        $oTask = CTaskItem::getInstanceFromPool($dataItem['TASK']['ID'], $loggedInUser);
        $arResult['ITEMS'][$index]['ALLOWED_ACTIONS'] = $oTask->getAllowedTaskActionsAsStrings();
    }
    if ($dataItem["TASK"]['ALLOW_TIME_TRACKING'] === 'Y') {
        if ($dataItem['TASK']['TIME_ESTIMATE'] > 0 && $arResult['ITEMS'][$index]['CURRENT_TASK_SPENT_TIME'] > $dataItem['TASK']['TIME_ESTIMATE']) {
            $arResult['ITEMS'][$index]['TASK_TIMER_OVERDUE'] = 'Y';
        } else {
            $arResult['ITEMS'][$index]['TASK_TIMER_OVERDUE'] = 'N';
        }
        // Lazy load timer data only once
        if ($oTimer === null) {
            $oTimer = CTaskTimerManager::getInstance($loggedInUser);
            $arTimer = $oTimer->getRunningTask(false);
            // false => allow use static cache
            $arResult['TIMER'] = $arTimer;
        }
示例#12
0
 public 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, array(CTasks::STATE_PENDING, CTasks::STATE_IN_PROGRESS, CTasks::STATE_SUPPOSEDLY_COMPLETED, CTasks::STATE_COMPLETED, CTasks::STATE_DEFERRED), true)) {
             throw new TasksException('Invalid status given', TasksException::TE_WRONG_ARGUMENTS);
         }
         $oTask = CTaskItem::getInstance($taskId, 1);
         // 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);
         } 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();
     }
 }
示例#13
0
     if (in_array($arEventsID["EVENT_ID"], array("blog_post", "blog_post_important", "idea")) && intval($arEventsID["SOURCE_ID"]) > 0) {
         $arDiskUFEntity["BLOG_POST"][] = $arEventsID["SOURCE_ID"];
     } elseif (!in_array($arEventsID["EVENT_ID"], array("data", "photo", "photo_photo", "bitrix24_new_user", "intranet_new_user", "news"))) {
         $arDiskUFEntity["SONET_LOG"][] = $arEventsID["ID"];
     }
 }
 if (isset($arDiskUFEntity) && (!empty($arDiskUFEntity["SONET_LOG"]) || !empty($arDiskUFEntity["BLOG_POST"]))) {
     $events = GetModuleEvents("socialnetwork", "OnAfterFetchDiskUfEntity");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($arDiskUFEntity));
     }
 }
 if (!empty($arActivity2Log) && CModule::IncludeModule('crm') && CModule::IncludeModule('tasks')) {
     $rsActivity = CCrmActivity::GetList(array(), array("@ID" => array_keys($arActivity2Log), "TYPE_ID" => CCrmActivityType::Task, "CHECK_PERMISSIONS" => "N"), false, false, array("ID", "ASSOCIATED_ENTITY_ID"));
     while (($arActivity = $rsActivity->Fetch()) && intval($arActivity["ASSOCIATED_ENTITY_ID"]) > 0) {
         $taskItem = new CTaskItem(intval($arActivity["ASSOCIATED_ENTITY_ID"]), $GLOBALS["USER"]->GetId());
         if (!$taskItem->CheckCanRead()) {
             unset($arActivity2Log[$arActivity["ID"]]);
         }
     }
 }
 if ($bFirstPage) {
     $last_date = $arTmpEventsNew[count($arTmpEventsNew) - 1][$arParams["USE_FOLLOW"] == "Y" ? "DATE_FOLLOW" : "LOG_UPDATE"];
 } elseif ($dbEventsID && $dbEventsID->NavContinue() && ($arEvents = $dbEventsID->GetNext())) {
     $next_page_date = $arParams["USE_FOLLOW"] == "Y" ? $arEvents["DATE_FOLLOW"] : $arEvents["LOG_UPDATE"];
     if ($GLOBALS["USER"]->IsAuthorized() && $arResult["LAST_LOG_TS"] < MakeTimeStamp($next_page_date)) {
         $next_page_date = $arResult["LAST_LOG_TS"];
     }
 }
 if ($cnt == 0 && isset($dateLastPageStart) && $GLOBALS["USER"]->IsAuthorized() && $arParams["SET_LOG_PAGE_CACHE"] == "Y") {
     CSocNetLogPages::DeleteEx($user_id, SITE_ID, $arParams["PAGE_SIZE"], strlen($arResult["COUNTER_TYPE"]) > 0 ? $arResult["COUNTER_TYPE"] : "**");
示例#14
0
 protected static function SaveTask(&$arFields)
 {
     $responsibleID = isset($arFields['RESPONSIBLE_ID']) ? intval($arFields['RESPONSIBLE_ID']) : 0;
     $typeID = isset($arFields['TYPE_ID']) ? intval($arFields['TYPE_ID']) : CCrmActivityType::Undefined;
     if (!($responsibleID > 0 && $typeID === CCrmActivityType::Task)) {
         return false;
     }
     if (!(IsModuleInstalled('tasks') && CModule::IncludeModule('tasks'))) {
         return false;
     }
     $associatedEntityID = isset($arFields['ASSOCIATED_ENTITY_ID']) ? intval($arFields['ASSOCIATED_ENTITY_ID']) : 0;
     if ($associatedEntityID <= 0) {
         return false;
     }
     $arTaskFields = array();
     if (isset($arFields['SUBJECT'])) {
         $arTaskFields['TITLE'] = $arFields['SUBJECT'];
     }
     if (isset($arFields['END_TIME'])) {
         $arTaskFields['DEADLINE'] = $arFields['END_TIME'];
     }
     if (isset($arFields['COMPLETED']) && $arFields['COMPLETED'] !== 'Y') {
         $arTaskFields['STATUS'] = CTasks::STATE_PENDING;
     }
     $result = true;
     if (!empty($arTaskFields)) {
         $task = new CTasks();
         self::$TASK_OPERATIONS[$associatedEntityID] = 'U';
         $result = $task->Update($associatedEntityID, $arTaskFields);
         unset(self::$TASK_OPERATIONS[$associatedEntityID]);
     }
     if (isset($arFields['COMPLETED']) && $arFields['COMPLETED'] === 'Y') {
         self::$TASK_OPERATIONS[$associatedEntityID] = 'U';
         try {
             $currentUser = CCrmSecurityHelper::GetCurrentUserID();
             $taskItem = CTaskItem::getInstance($associatedEntityID, $currentUser > 0 ? $currentUser : 1);
             $taskItem->complete();
             $result = true;
         } catch (TasksException $e) {
             $result = false;
         }
         unset(self::$TASK_OPERATIONS[$associatedEntityID]);
     }
     return $result;
 }
示例#15
0
 /**
  * Move a specified check list item after another check list item
  */
 public function moveAfter($id, $afterId)
 {
     // you can move check list items ONLY when you have write access to the task
     global $USER;
     $result = array();
     if (($id = $this->checkId($id)) && ($afterId = $this->checkId($afterId))) {
         if ($id != $afterId) {
             // get task id
             $taskId = $this->getOwnerTaskId($id);
             if ($taskId) {
                 $task = \CTaskItem::getInstanceFromPool($taskId, $USER->GetId());
                 // or directly, new \CTaskItem($taskId, $USER->GetId());
                 if (!$task->isActionAllowed(\CTaskItem::ACTION_EDIT)) {
                     throw new Tasks\ActionNotAllowedException('Checklist move after', array('AUX' => array('ERROR' => array('TASK_ID' => $taskId, 'ITEM' => $id, 'AFTER_ITEM' => $afterId))));
                 }
                 $item = new \CTaskCheckListItem($task, $id);
                 $item->moveAfterItem($afterId);
             }
         }
     }
     return $result;
 }
示例#16
0
 private function loadTaskData()
 {
     if ($this->taskPostData === null) {
         try {
             if (Loader::includeModule("tasks")) {
                 $task = new \CTaskItem($this->getId(), $this->getUser()->getId());
                 $this->taskPostData = $task->getData(false);
             } else {
                 return array();
             }
         } catch (\TasksException $e) {
             return array();
         }
     }
     return $this->taskPostData;
 }
示例#17
0
    $arSelect = array('ID', 'TITLE', 'PRIORITY', 'STATUS', 'REAL_STATUS', 'MULTITASK', 'DATE_START', 'GROUP_ID', 'DEADLINE', 'ALLOW_TIME_TRACKING', 'TIME_ESTIMATE', 'TIME_SPENT_IN_LOGS', 'COMMENTS_COUNT', 'FILES', 'MARK', 'ADD_IN_REPORT', 'SUBORDINATE', 'CREATED_DATE', 'VIEWED_DATE', 'FORUM_TOPIC_ID', 'END_DATE_PLAN', 'START_DATE_PLAN', 'CLOSED_DATE', 'PARENT_ID', 'ALLOW_CHANGE_DEADLINE', 'ALLOW_TIME_TRACKING', 'CHANGED_DATE', 'CREATED_BY', 'CREATED_BY_NAME', 'CREATED_BY_LAST_NAME', 'CREATED_BY_SECOND_NAME', 'CREATED_BY_LOGIN', 'CREATED_BY_WORK_POSITION', 'CREATED_BY_PHOTO', 'RESPONSIBLE_ID', 'RESPONSIBLE_NAME', 'RESPONSIBLE_LAST_NAME', 'RESPONSIBLE_SECOND_NAME', 'RESPONSIBLE_LOGIN', 'RESPONSIBLE_WORK_POSITION', 'RESPONSIBLE_PHOTO', 'UF_CRM_TASK');
    try {
        list($arTaskItems, $rsItems) = CTaskItem::fetchList($loggedInUserId, $arOrder, $arFilter, $arGetListParams, $arSelect);
    } catch (TasksException $e) {
        // Got SQL error for extended filter? Rollback to default filter preset.
        if ($arParams['USE_FILTER_V2'] && $e->getCode() & TasksException::TE_SQL_ERROR) {
            $bGroupMode = $taskType === 'group';
            $oFilter = CTaskFilterCtrl::GetInstance($arParams['USER_ID'], $bGroupMode);
            // Not default preset? Switch to it.
            if ($oFilter->GetSelectedFilterPresetId() != CTaskFilterCtrl::STD_PRESET_ALIAS_TO_DEFAULT) {
                $oFilter->SwitchFilterPreset(CTaskFilterCtrl::STD_PRESET_ALIAS_TO_DEFAULT);
                $arFilter = $oFilter->GetSelectedFilterPresetCondition();
                $arResult['SELECTED_PRESET_NAME'] = $oFilter->GetSelectedFilterPresetName();
                $arResult['SELECTED_PRESET_ID'] = $oFilter->GetSelectedFilterPresetId();
                // Try again to load data
                list($arTaskItems, $rsItems) = CTaskItem::fetchList($loggedInUserId, $arOrder, $arFilter, $arGetListParams, $arSelect);
            } else {
                throw new TasksException();
            }
        } else {
            throw new TasksException();
        }
    }
} catch (Exception $e) {
    ShowError(GetMessage('TASKS_UNEXPECTED_ERROR'));
    return;
}
$arResult["NAV_STRING"] = $rsItems->GetPageNavString(GetMessage("TASKS_TITLE_TASKS"), $arParams['NAV_TEMPLATE']);
$arResult["NAV_PARAMS"] = $rsItems->getNavParams();
$arResult["TASKS"] = array();
$arTasksIDs = array();
示例#18
0
 /**
  * This is experimental code, don't rely on it.
  * It can be removed or changed in future without any notifications.
  * 
  * Use CTaskItem::getAllowedTaskActions() and CTaskItem::getAllowedTaskActionsAsStrings() instead.
  * 
  * @deprecated
  */
 public static function GetAllowedActions($arTask, $userId = null)
 {
     $arAllowedActions = array();
     if ($userId === null) {
         global $USER;
         $curUserId = (int) $USER->GetID();
     } else {
         $curUserId = (int) $userId;
     }
     // we cannot use cached object here (CTaskItem::getInstanceFromPool($arTask['ID'], $curUserId);)
     // because of backward compatibility (CTasks::Update() don't mark cache as dirty in pooled CTaskItem objects)
     $oTask = new CTaskItem($arTask['ID'], $curUserId);
     if ($oTask->isUserRole(CTaskItem::ROLE_RESPONSIBLE)) {
         if ($arTask['REAL_STATUS'] == CTasks::STATE_NEW) {
             $arAllowedActions[] = array('public_name' => 'accept', 'system_name' => 'accept', 'id' => CTaskItem::ACTION_ACCEPT);
             $arAllowedActions[] = array('public_name' => 'decline', 'system_name' => 'decline', 'id' => CTaskItem::ACTION_DECLINE);
         }
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_COMPLETE)) {
         $arAllowedActions[] = array('public_name' => 'close', 'system_name' => 'close', 'id' => CTaskItem::ACTION_COMPLETE);
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_START)) {
         $arAllowedActions[] = array('public_name' => 'start', 'system_name' => 'start', 'id' => CTaskItem::ACTION_START);
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_DELEGATE)) {
         $arAllowedActions[] = array('public_name' => 'delegate', 'system_name' => 'delegate', 'id' => CTaskItem::ACTION_DELEGATE);
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_APPROVE)) {
         $arAllowedActions[] = array('public_name' => 'approve', 'system_name' => 'close', 'id' => CTaskItem::ACTION_APPROVE);
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_DISAPPROVE)) {
         $arAllowedActions[] = array('public_name' => 'redo', 'system_name' => 'accept', 'id' => CTaskItem::ACTION_DISAPPROVE);
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_REMOVE)) {
         $arAllowedActions[] = array('public_name' => 'remove', 'system_name' => 'remove', 'id' => CTaskItem::ACTION_REMOVE);
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_EDIT)) {
         $arAllowedActions[] = array('public_name' => 'edit', 'system_name' => 'edit', 'id' => CTaskItem::ACTION_EDIT);
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_DEFER)) {
         $arAllowedActions[] = array('public_name' => 'pause', 'system_name' => 'defer', 'id' => CTaskItem::ACTION_DEFER);
     }
     if ($oTask->isActionAllowed(CTaskItem::ACTION_START)) {
         $arAllowedActions[] = array('public_name' => 'renew', 'system_name' => 'start', 'id' => CTaskItem::ACTION_START);
     } elseif ($oTask->isActionAllowed(CTaskItem::ACTION_RENEW)) {
         $arAllowedActions[] = array('public_name' => 'renew', 'system_name' => 'accept', 'id' => CTaskItem::ACTION_RENEW);
     }
     return $arAllowedActions;
 }
示例#19
0
 public static function checkUserReadAccess(array $params)
 {
     $task = new \CTaskItem($params['taskId'], static::getUser()->GetID());
     $access = $task->checkCanRead();
     return !!$access;
 }
示例#20
0
 /**
  * @deprecated
  */
 private static function getTaskMembersByTaskId($taskId, $excludeUser = 0)
 {
     $oTask = CTaskItem::getInstance((int) $taskId, CTasksTools::GetCommanderInChief());
     $arTask = $oTask->getData(false);
     $arUsersIds = CTaskNotifications::getRecipientsIDs($arTask, $bExcludeLoggedUser = false);
     $excludeUser = (int) $excludeUser;
     if ($excludeUser >= 1) {
         $currentUserPos = array_search($excludeUser, $arUsersIds);
         if ($currentUserPos !== false) {
             unset($arUsersIds[$currentUserPos]);
         }
     } else {
         if ($excludeUser < 0) {
             CTaskAssert::logWarning('[0x3c2a31fe] invalid user id (' . $excludeUser . ')');
         }
     }
     return $arUsersIds;
 }
示例#21
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("tasks")) {
    ShowError(GetMessage("TASKS_MODULE_NOT_FOUND"));
    return;
}
$arResult['LOGGED_IN_USER'] = $USER->getId();
if (isset($arParams['~ALLOWED_ACTIONS'])) {
    $arResult['ALLOWED_ACTIONS'] = $arParams['~ALLOWED_ACTIONS'];
} elseif (isset($arParams['~TASK']['META:ALLOWED_ACTIONS'])) {
    $arResult['ALLOWED_ACTIONS'] = $arParams['~TASK']['META:ALLOWED_ACTIONS'];
} elseif ($arParams['~TASK']['ID']) {
    $oTask = CTaskItem::getInstanceFromPool($arParams['~TASK']['ID'], $arResult['LOGGED_IN_USER']);
    $arResult['ALLOWED_ACTIONS'] = $oTask->getAllowedTaskActionsAsStrings();
    $arParams['~TASK']['META:ALLOWED_ACTIONS'] = $arResult['ALLOWED_ACTIONS'];
}
$arResult['IFRAME'] = null;
if (isset($arParams['IFRAME'])) {
    $arResult['IFRAME'] = $arParams['IFRAME'];
}
if ($arParams["~TASK"]['ALLOW_TIME_TRACKING'] === 'Y') {
    if ($arParams['~TASK']['TIME_ESTIMATE'] > 0 && $arResult['CURRENT_TASK_SPENT_TIME'] > $arParams['~TASK']['TIME_ESTIMATE']) {
        $arResult['TASK_TIMER_OVERDUE'] = 'Y';
    } else {
        $arResult['TASK_TIMER_OVERDUE'] = 'N';
    }
    $oTimer = CTaskTimerManager::getInstance($arResult['LOGGED_IN_USER']);
    $arTimer = $oTimer->getRunningTask(false);
示例#22
0
 public function deleteDependOn($parentId)
 {
     $exceptionInfo = array('AUX' => array('MESSAGE' => array('FROM_TASK_ID' => $parentId, 'TASK_ID' => $this->getId(), 'LINK_TYPE' => $linkType)));
     if ($this->isActionAllowed(self::ACTION_CHANGE_DEADLINE)) {
         $parentTask = CTaskItem::getInstanceFromPool($parentId, $this->executiveUserId);
         if ($parentTask->isActionAllowed(self::ACTION_CHANGE_DEADLINE)) {
             $result = DependenceTable::deleteLink($this->getId(), $parentId);
             if (!$result->isSuccess()) {
                 $exceptionInfo['ERROR'] = $result->getErrorMessages();
                 throw new ActionFailedException(Loc::getMessage('TASK_CANT_DELETE_LINK'), $exceptionInfo);
             }
             return;
         }
     }
     throw new ActionNotAllowedException(Loc::getMessage('TASK_CANT_DELETE_LINK'), $exceptionInfo);
 }
示例#23
0
 /**
  * Stop an execution timer for a specified task
  */
 public function stopWatch($id)
 {
     global $USER;
     $result = array();
     if ($id = $this->checkTaskId($id)) {
         $task = new \CTaskItem($id, $USER->GetId());
         $task->stopWatch();
     }
     return $result;
 }
示例#24
0
                     foreach ($arChecklistItemsInDb as $oChecklistItem) {
                         if (in_array($oChecklistItem->getId(), $arItemsToRemove)) {
                             $oChecklistItem->delete();
                         }
                     }
                 }
             }
         }
     }
     return $arChecklistItems;
 } else {
     throw new \Bitrix\Main\SystemException();
 }
 $arResult['BLOCKS'] = array_intersect($arWhiteList, $arParams['BLOCKS']);
 if (isset($arParams['TASK_ID']) && isset($arParams['LOAD_TASK_DATA']) && $arParams['LOAD_TASK_DATA'] === 'Y') {
     $oTask = CTaskItem::getInstance($arParams['TASK_ID'], $arResult['LOGGED_IN_USER']);
     $arResult['ALLOWED_ACTIONS'] = $oTask->getAllowedActions($asStrings = true);
     $arResult['TASK'] = $oTask->getData();
     $arResult['TASK']['META:ALLOWED_ACTIONS_CODES'] = $oTask->getAllowedTaskActions();
     $arResult['TASK']['META:ALLOWED_ACTIONS'] = $arResult['ALLOWED_ACTIONS'];
     $arResult['TASK']['META:IN_DAY_PLAN'] = 'N';
     $arResult['TASK']['META:CAN_ADD_TO_DAY_PLAN'] = 'N';
     // Was task created from template?
     if ($arResult['TASK']['FORKED_BY_TEMPLATE_ID']) {
         $rsTemplate = CTaskTemplates::GetByID($arResult['TASK']['FORKED_BY_TEMPLATE_ID']);
         if ($arTemplate = $rsTemplate->Fetch()) {
             $arTemplate['REPLICATE_PARAMS'] = unserialize($arTemplate['REPLICATE_PARAMS']);
             $arResult['TASK']['FORKED_BY_TEMPLATE'] = $arTemplate;
         }
     }
     if (($arResult['TASK']["RESPONSIBLE_ID"] == $arResult['LOGGED_IN_USER'] || in_array($arResult['LOGGED_IN_USER'], $arResult['TASK']['ACCOMPLICES'])) && CModule::IncludeModule("timeman") && (!CModule::IncludeModule('extranet') || !CExtranet::IsExtranetSite())) {
示例#25
0
             if ($i < $iMax) {
                 echo ", ";
             }
         } else {
             $params = array("PATHS" => $arPaths, "PLAIN" => false, "DEFER" => true, "SITE_ID" => $SITE_ID, "TASK_ADDED" => false, 'IFRAME' => 'N', "NAME_TEMPLATE" => $nameTemplate, 'DATA_COLLECTION' => array(array("CHILDREN_COUNT" => $arChildrenCount["PARENT_" . $task["ID"]], "DEPTH" => $depth, "UPDATES_COUNT" => $arUpdatesCount[$task["ID"]], "PROJECT_EXPANDED" => true, 'ALLOWED_ACTIONS' => null, "TASK" => $task)));
             if ($columnsOrder !== null) {
                 $params['COLUMNS_IDS'] = $columnsOrder;
             }
             $APPLICATION->IncludeComponent('bitrix:tasks.list.items', '.default', $params, null, array("HIDE_ICONS" => "Y"));
         }
     }
     if ($bIsJSON) {
         echo "]";
     }
 } else {
     $oTask = CTaskItem::getInstanceFromPool($_POST['id'], $USER->getId());
     $arTask = $oTask->getData($bEscape = false);
     if ($_POST["mode"] == "delete" && $oTask->isActionAllowed(CTaskItem::ACTION_REMOVE)) {
         $APPLICATION->RestartBuffer();
         $task = new CTasks();
         $rc = $task->Delete(intval($_POST["id"]));
         if ($rc === false) {
             $strError = 'Error';
             if ($ex = $APPLICATION->GetException()) {
                 $strError = $ex->GetString();
             }
             if ($_POST["type"] == "json") {
                 echo "['strError' : '" . CUtil::JSEscape(htmlspecialcharsbx($strError)) . "']";
             } else {
                 echo htmlspecialcharsbx($strError);
             }
示例#26
0
 public static function OnGetRatingContentOwner($params)
 {
     if (intval($params['ENTITY_ID']) && $params['ENTITY_TYPE_ID'] == 'TASK') {
         list($oTaskItems, $rsData) = CTaskItem::fetchList(CTasksTools::GetCommanderInChief(), array(), array('=ID' => $params['ENTITY_ID']), array(), array('ID', 'CREATED_BY'));
         unset($rsData);
         if ($oTaskItems[0] instanceof CTaskItem) {
             $data = $oTaskItems[0]->getData(false);
             if (intval($data['CREATED_BY'])) {
                 return intval($data['CREATED_BY']);
             }
         }
     }
     return false;
 }
示例#27
0
 protected static function getTask($userId, $taskId)
 {
     // on the same $userId and $taskId this will return the same task instance from cache
     return \CTaskItem::getInstance($taskId, $userId);
 }
示例#28
0
         $breakExecution = true;
     }
     break;
 case 'CTaskCheckListItem::complete()':
 case 'CTaskCheckListItem::renew()':
 case 'CTaskCheckListItem::delete()':
 case 'CTaskCheckListItem::isComplete()':
 case 'CTaskCheckListItem::update()':
 case 'CTaskCheckListItem::moveAfterItem()':
     CTaskAssert::assert(isset($arAction['taskId'], $arAction['itemId']));
     // Is task id the result of previous operation in batch?
     $taskId = BXTasksResolveDynaParamValue($arAction['taskId'], array('$arOperationsResults' => $arOperationsResults));
     // Is item id the result of previous operation in batch?
     $itemId = BXTasksResolveDynaParamValue($arAction['itemId'], array('$arOperationsResults' => $arOperationsResults));
     CTaskAssert::assertLaxIntegers($taskId, $itemId);
     $oTask = CTaskItem::getInstanceFromPool($taskId, $loggedInUserId);
     $oCheckListItem = new CTaskCheckListItem($oTask, $itemId);
     $returnValue = null;
     switch ($arAction['operation']) {
         case 'CTaskCheckListItem::moveAfterItem()':
             $insertAfterItemId = BXTasksResolveDynaParamValue($arAction['insertAfterItemId'], array('$arOperationsResults' => $arOperationsResults));
             CTaskAssert::assertLaxIntegers($insertAfterItemId);
             $oCheckListItem->moveAfterItem($insertAfterItemId);
             break;
         case 'CTaskCheckListItem::complete()':
             $oCheckListItem->complete();
             break;
         case 'CTaskCheckListItem::renew()':
             $oCheckListItem->renew();
             break;
         case 'CTaskCheckListItem::delete()':
示例#29
0
 public function stop()
 {
     global $CACHE_MANAGER;
     $arTimer = CTaskTimerCore::stop($this->userId);
     $this->cachedLastTimer = null;
     if ($arTimer !== false && $arTimer['TIMER_ACCUMULATOR'] > 0) {
         /** @noinspection PhpDeprecationInspection */
         $o = new CTaskElapsedTime();
         $o->add(array('USER_ID' => $this->userId, 'TASK_ID' => $arTimer['TASK_ID'], 'SECONDS' => $arTimer['TIMER_ACCUMULATOR'], 'COMMENT_TEXT' => ''), array('SOURCE_SYSTEM' => 'Y'));
         $oTaskItem = CTaskItem::getInstance($arTimer['TASK_ID'], $this->userId);
         $arTask = $oTaskItem->getData(false);
         $arAffectedUsers = array_unique(array_merge(array($this->userId, $arTask['RESPONSIBLE_ID']), (array) $arTask['ACCOMPLICES']));
         foreach ($arAffectedUsers as $userId) {
             $CACHE_MANAGER->ClearByTag('tasks_user_' . $userId);
         }
     }
 }
示例#30
0
             // Don't format time, if it's 00:00
             if (date('H:i', $arData['TO_VALUE']) == '00:00') {
                 $strDateTo = FormatDate(CDatabase::DateFormatToPHP(FORMAT_DATE), $arData['TO_VALUE']);
             } else {
                 $strDateTo = FormatDate(CDatabase::DateFormatToPHP(FORMAT_DATETIME), $arData['TO_VALUE']);
             }
         }
         $arResult = array('td1' => '<span class="task-log-date">' . FormatDateFromDB($arData['CREATED_DATE']) . '</span>', 'td2' => '<a class="task-log-author" target="_top" href="' . CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_USER_PROFILE'], array('user_id' => $authorUserId)) . '">' . htmlspecialcharsbx(tasksFormatNameShort($arCurUserData["NAME"], $arCurUserData["LAST_NAME"], $arCurUserData["LOGIN"], $arCurUserData["SECOND_NAME"], $arParams["NAME_TEMPLATE"])) . '</a>', 'td3' => '<span class="task-log-where">' . GetMessage("TASKS_LOG_DEADLINE") . '</span>', 'td4' => '<span class="task-log-what">' . $strDateFrom . '<span class="task-log-arrow">&rarr;</span>' . $strDateTo . '</span>');
         header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
         echo CUtil::PhpToJsObject($arResult);
     }
 } elseif ($action === 'remove_file') {
     try {
         CTaskAssert::log('remove_file: fileId=' . $_POST['fileId'] . ', taskId=' . $_POST['taskId'] . ', userId=' . $loggedInUserId, CTaskAssert::ELL_INFO);
         CTaskAssert::assert(isset($_POST['fileId'], $_POST['taskId']));
         $oTaskItem = new CTaskItem($_POST['taskId'], $loggedInUserId);
         $oTaskItem->removeAttachedFile($_POST['fileId']);
         echo 'Success';
     } catch (Exception $e) {
         echo 'Error occured';
         CTaskAssert::logWarning('Unable to remove_file: fileId=' . $_POST['fileId'] . ', taskId=' . $_POST['taskId'] . ', userId=' . $loggedInUserId);
     }
 } elseif ($action === 'render_task_detail_part') {
     if (isset($_POST['BLOCK'])) {
         switch ($_POST['BLOCK']) {
             case 'buttons':
             case 'right_sidebar':
                 if ($_POST['IS_IFRAME'] === 'true' || $_POST['IS_IFRAME'] === true || $_POST['IS_IFRAME'] === 'Y') {
                     $isIframe = true;
                 } else {
                     $isIframe = false;