public static function getList($userId, $taskId, array $parameters = array()) { $data = array(); $res = \CTaskReminders::GetList(array("date" => "asc"), array("USER_ID" => $userId, "TASK_ID" => $taskId)); while ($item = $res->Fetch()) { $data[] = $item; } return array('DATA' => $data, 'CAN' => array()); }
/** * Duplicate task and return an instance of the clone. * * @param mixed[] $overrideTaskData Task data needs to be overrided externally. * @param mixed[] $parameters Various set of parameters. * * <li> CLONE_CHILD_TASKS boolean clone subtasks or not * <li> CLONE_CHECKLIST_ITEMS boolean clone check list items or not * <li> CLONE_TAGS boolean clone tags or not * <li> CLONE_REMINDERS boolean clone reminders or not * <li> CLONE_TASK_DEPENDENCY boolean clone previous tasks or not * <li> CLONE_FILES boolean clone files or not * * @throws TasksException - on access denied, task not found. * @throws CTaskAssertException. * @throws Exception - on unexpected error. * * @return CTaskItem[] */ public function duplicate($overrideTaskData = array(), $parameters = array('CLONE_CHILD_TASKS' => true, 'CLONE_CHECKLIST_ITEMS' => true, 'CLONE_TAGS' => true, 'CLONE_REMINDERS' => true, 'CLONE_TASK_DEPENDENCY' => true, 'CLONE_FILES' => true)) { if (!is_array($overrideTaskData)) { $overrideTaskData = array(); } if (!is_array($parameters)) { $parameters = array(); } if (!isset($parameters['CLONE_CHILD_TASKS'])) { $parameters['CLONE_CHILD_TASKS'] = true; } if (!isset($parameters['CLONE_CHECKLIST_ITEMS'])) { $parameters['CLONE_CHECKLIST_ITEMS'] = true; } if (!isset($parameters['CLONE_TAGS'])) { $parameters['CLONE_TAGS'] = true; } if (!isset($parameters['CLONE_REMINDERS'])) { $parameters['CLONE_REMINDERS'] = true; } if (!isset($parameters['CLONE_TASK_DEPENDENCY'])) { $parameters['CLONE_TASK_DEPENDENCY'] = true; } if (!isset($parameters['CLONE_FILES'])) { $parameters['CLONE_FILES'] = true; } $result = array(); $data = $this->getData(false); // ensure we have access to the task if (is_array($data)) { $data = array_merge($data, $overrideTaskData); // drop unwanted unset($data['ID']); unset($data['GUID']); unset($data['STATUS']); // detach forum, if any unset($data['FORUM_TOPIC_ID']); unset($data['COMMENTS_COUNT']); // clean dates unset($data['CREATED_DATE']); unset($data['CHANGED_DATE']); unset($data['VIEWED_DATE']); unset($data['STATUS_CHANGED_DATE']); unset($data['CHANGED_BY']); $files = array(); if (is_array($data['UF_TASK_WEBDAV_FILES']) && !empty($data['UF_TASK_WEBDAV_FILES'])) { $files = $data['UF_TASK_WEBDAV_FILES']; } unset($data['UF_TASK_WEBDAV_FILES']); $clone = static::add($data, $this->getExecutiveUserId()); $taskDupId = $clone->getId(); if (intval($taskDupId)) { $result[$clone->getId()] = $clone; if ($parameters['CLONE_CHECKLIST_ITEMS']) { list($arChecklistItems, $arMetaData) = CTaskCheckListItem::fetchList($this, array('SORT_INDEX' => 'ASC')); unset($arMetaData); foreach ($arChecklistItems as $oChecklistItem) { $cliData = $oChecklistItem->getData(); $cliCloneData = array('TITLE' => $cliData['TITLE'], 'IS_COMPLETE' => $cliData['IS_COMPLETE'], 'SORT_INDEX' => $cliData['SORT_INDEX']); CTaskCheckListItem::add($clone, $cliCloneData); } } if ($parameters['CLONE_TAGS']) { $tags = $this->getTags(); if (is_array($tags)) { foreach ($tags as $tag) { if ((string) $tag != '') { $oTag = new CTaskTags(); $oTag->Add(array('TASK_ID' => $taskDupId, 'NAME' => $tag), $this->getExecutiveUserId()); } } } } if ($parameters['CLONE_REMINDERS']) { $res = CTaskReminders::GetList(false, array('TASK_ID' => $this->getId())); while ($item = $res->fetch()) { $item['TASK_ID'] = $taskDupId; $item['USER_ID'] = $this->getExecutiveUserId(); $oReminder = new CTaskReminders(); $oReminder->Add($item); } } if ($parameters['CLONE_TASK_DEPENDENCY']) { $res = CTaskDependence::GetList(array(), array('TASK_ID' => $this->getId())); while ($item = $res->fetch()) { $depInstance = new CTaskDependence(); if (is_array($item)) { $depInstance->Add(array('TASK_ID' => $taskDupId, 'DEPENDS_ON_ID' => $item['DEPENDS_ON_ID'])); } } } if ($parameters['CLONE_FILES'] && !empty($files) && \Bitrix\Main\Loader::includeModule('disk')) { // find which files are new and which are old $old = array(); $new = array(); foreach ($files as $fileId) { if ((string) $fileId) { if (strpos($fileId, 'n') === 0) { $new[] = $fileId; } else { $old[] = $fileId; } } } if (!empty($old)) { $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager(); $old = $userFieldManager->cloneUfValuesFromAttachedObject($old, $this->getExecutiveUserId()); if (is_array($old) && !empty($old)) { $new = array_merge($new, $old); } } if (!empty($new)) { $clone->update(array('UF_TASK_WEBDAV_FILES' => $new)); } } if ($parameters['CLONE_CHILD_TASKS']) { $notifADWasDisabled = CTaskNotifications::disableAutoDeliver(); $clones = $this->duplicateChildTasks($clone); if (is_array($clones)) { foreach ($clones as $cId => $cInst) { $result[$cId] = $cInst; } } if ($notifADWasDisabled) { CTaskNotifications::enableAutoDeliver(); } } } } return $result; }
$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); } } } elseif ($_POST["mode"] == "reminders") { CTaskReminders::Delete(array("TASK_ID" => intval($_POST["id"]), "USER_ID" => $USER->GetID())); if (isset($_POST["reminders"])) { $obReminder = new CTaskReminders(); foreach ($_POST["reminders"] as $reminder) { $arFields = array("TASK_ID" => intval($_POST["id"]), "USER_ID" => $USER->GetID(), "REMIND_DATE" => $reminder["r_date"], "TYPE" => $reminder["type"], "TRANSPORT" => $reminder["transport"]); $obReminder->Add($arFields); } } } else { $arActionsMap = array('close' => 'complete', 'start' => 'startExecution', 'accept' => 'accept', 'renew' => 'renew', 'defer' => 'defer', 'decline' => 'decline', 'approve' => 'approve', 'disapprove' => 'disapprove', 'pause' => 'pauseExecution'); $arFields = array(); if ($_POST["mode"] == "mark" && in_array($_POST["mark"], array("NULL", "P", "N"))) { if ($_POST["mark"] == "NULL") { $arFields["MARK"] = false; } else { $arFields["MARK"] = $_POST["mark"]; } if ($arTask["SUBORDINATE"] == "Y" && $arTask["RESPONSIBLE_ID"] != $USER->GetID() && isset($_POST["report"])) {
function SendAgent() { global $DB; /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $arFilter = array("<=REMIND_DATE" => (string) new \Bitrix\Main\Type\DateTime()); $rsReminders = CTaskReminders::GetList(array("date" => "asc"), $arFilter); while ($arReminder = $rsReminders->Fetch()) { $rsTask = CTasks::GetByID($arReminder["TASK_ID"], false); if ($arTask = $rsTask->Fetch()) { // remind about not closed tasks only if ($arTask['CLOSED_DATE'] === NULL) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $rsUser = CUser::GetByID($arReminder["USER_ID"]); if ($arUser = $rsUser->Fetch()) { $arTask["PATH_TO_TASK"] = CTaskNotifications::GetNotificationPath($arUser, $arTask["ID"]); $arFilterForSendedRemind = array_merge($arFilter, array('TASK_ID' => $arReminder['TASK_ID'], 'USER_ID' => $arReminder['USER_ID'], 'TRANSPORT' => $arReminder['TRANSPORT'], 'TYPE' => $arReminder['TYPE'])); CTaskReminders::Delete($arFilterForSendedRemind); if ($arReminder["TRANSPORT"] == self::REMINDER_TRANSPORT_EMAIL || !CModule::IncludeModule("socialnetwork") || !CTaskReminders::__SendJabberReminder($arUser["ID"], $arTask)) { CTaskReminders::__SendEmailReminder($arUser["EMAIL"], $arTask); } } } } } // Some older items can still exists (for removed users, etc.) CTaskReminders::Delete($arFilter); return "CTaskReminders::SendAgent();"; }
/** * Delete all reminders for the current user */ public function deleteByCurrentUser() { global $USER; \CTaskReminders::DeleteByUserID($USER->GetId()); return array(); }
public static function sendReminder() { \CTaskReminders::SendAgent(); return '\\' . __CLASS__ . "::sendReminder();"; }
$arElapsedData['META:CAN_REMOVE'] = $oElapsedItem->isActionAllowed(CTaskElapsedItem::ACTION_ELAPSED_TIME_REMOVE); $arResult["ELAPSED_TIME"][] = $arElapsedData; $arResult["FULL_ELAPSED_TIME"] += $arElapsedData['MINUTES']; } // user fields $arResult["USER_FIELDS"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("TASKS_TASK", $arParams["TASK_ID"], LANGUAGE_ID); $arResult["SHOW_USER_FIELDS"] = false; foreach ($arResult["USER_FIELDS"] as $arUserField) { if ($arUserField["VALUE"] !== false) { $arResult["SHOW_USER_FIELDS"] = true; break; } } // reminders $arResult["REMINDERS"] = array(); $rsReminders = CTaskReminders::GetList(array("date" => "asc"), array("USER_ID" => $loggedInUserId, "TASK_ID" => $arParams["TASK_ID"])); while ($arReminder = $rsReminders->Fetch()) { $arResult["REMINDERS"][] = array("date" => $arReminder["REMIND_DATE"], "type" => $arReminder["TYPE"], "transport" => $arReminder["TRANSPORT"]); } } else { if ($arResult["IS_IFRAME"]) { ShowInFrame($this, true, GetMessage("TASKS_TASK_NOT_FOUND")); } else { ShowError(GetMessage("TASKS_TASK_NOT_FOUND")); } return; } $arResult['ALLOWED_ACTIONS'] = $arResult['TASK']['META:ALLOWED_ACTIONS']; $sTitle = $arResult["TASK"]['TITLE'] . ' (' . toLower(str_replace("#TASK_NUM#", $arResult["TASK"]["ID"], GetMessage("TASKS_TASK_NUM"))) . ')'; if ($arParams["SET_TITLE"] == "Y") { $APPLICATION->SetTitle($sTitle);