Example #1
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;
 }
Example #2
0
 /**
  * Agent handler for repeating tasks.
  * Create new task based on given template.
  * 
  * @param integer $templateId - id of task template
  * @param integer $flipFlop - this param needs for prevent duplicate names 
  * 		of agent (when adding agent, there is still exists current agent,
  * 		which will be removed later, when our function returns empty string),
  * 		must be 1 or 0.
  * 
  * @return string empty string.
  */
 public static function RepeatTaskByTemplateId($templateId, $flipFlop = 0)
 {
     global $DB;
     $curFlipFlop = (int) $flipFlop;
     if ($curFlipFlop === 0) {
         $newFlipFlop = 1;
     } else {
         $newFlipFlop = 0;
     }
     $templateId = (int) $templateId;
     $arFilter = array('ID' => $templateId);
     $rsTemplate = CTaskTemplates::GetList(array(), $arFilter, false, false, array('*', 'UF_*'));
     $arTemplate = $rsTemplate->Fetch();
     if (!$arTemplate) {
         return '';
     }
     // nothing to do
     if ($arTemplate['REPLICATE'] !== 'Y') {
         return '';
     }
     // nothing to do
     if (intval($arTemplate['CREATED_BY'])) {
         CTasksTools::setOccurAsUserId($arTemplate['CREATED_BY']);
     }
     // not admin in logs, but template creator
     CTaskItem::addByTemplate($templateId, CTasksTools::GetCommanderInChief(), array(), array('TEMPLATE_DATA' => $arTemplate, 'SPAWNED_BY_AGENT' => true));
     $arTemplate['REPLICATE_PARAMS'] = unserialize($arTemplate['REPLICATE_PARAMS']);
     // get next time task will be created, i.e. next Thursday if today is Thursday (and task marked as repeated) and so on
     $nextTime = CTasks::GetNextTime($arTemplate['REPLICATE_PARAMS']);
     if ($nextTime) {
         CTimeZone::Disable();
         $currentAgentCallStr = 'CTasks::RepeatTaskByTemplateId(' . $templateId . ', ' . $curFlipFlop . ');';
         $newAgentCallStr = 'CTasks::RepeatTaskByTemplateId(' . $templateId . ', ' . $newFlipFlop . ');';
         CAgent::RemoveAgent($currentAgentCallStr);
         CAgent::AddAgent($newAgentCallStr, 'tasks', 'N', 86400, $nextTime, 'Y', $nextTime);
         CTimeZone::Enable();
     }
     return '';
 }
 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;
 }
 private function getAdminId()
 {
     static $adminId;
     if ($adminId === null) {
         $adminId = CTasksTools::GetCommanderInChief();
         if (!intval($adminId)) {
             CAdminNotify::Add(array("MESSAGE" => GetMessage('TASKS_COUNTERS_PROCESSOR_ADMIN_IS_NOT_AN_ADMIN'), "TAG" => "TASKS_SYSTEM_NO_ADMIN", "MODULE_ID" => "TASKS", "ENABLE_CLOSE" => "Y"));
         }
     }
     return $adminId;
 }