コード例 #1
0
 private function deleteReferenceInTasks()
 {
     $contextId = $this->getId();
     $tasks = PcTaskPeer::getTasksByContextId($contextId);
     foreach ($tasks as $task) {
         $contextIdsString = $task->getContexts();
         $contextIds = PcUtils::explodeWithEmptyInputDetection(',', $contextIdsString);
         $contextIds = array_diff($contextIds, array($contextId));
         $task->setContexts(implode(',', $contextIds))->save();
     }
 }
コード例 #2
0
 /**
  * @return string (XML format)
  */
 public function getXmlString()
 {
     $dump = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
     $dump .= '<backup version="1" title="Plancake backup" link="http://www.plancake.com">' . "\n";
     $dump .= "\t<plancake_tasks>\n";
     // This Ids are to make the dump more portable:
     // tasks will be related to tags and lists via these "virtual" ids
     $tagLocalIds = array();
     $listLocalIds = array();
     $c = new Criteria();
     $c->add(PcUsersContextsPeer::USER_ID, $this->user->getId(), Criteria::EQUAL);
     $c->addDescendingOrderByColumn(PcUsersContextsPeer::SORT_ORDER);
     $c->addDescendingOrderByColumn(PcUsersContextsPeer::ID);
     $tags = PcUsersContextsPeer::doSelect($c);
     $dump .= "\t\t<tags>\n";
     $localId = 1;
     foreach ($tags as $tag) {
         $dump .= "\t\t\t<tag>\n";
         $dump .= "\t\t\t\t<localId>{$localId}</localId>\n";
         $dump .= "\t\t\t\t<id>{$tag->getId()}</id>\n";
         $dump .= "\t\t\t\t<name><![CDATA[{$tag->getContext()}]]></name>\n";
         $dump .= "\t\t\t\t<sortOrder>{$tag->getSortOrder()}</sortOrder>\n";
         $dump .= "\t\t\t\t<updatedAt>{$tag->getUpdatedAt()}</updatedAt>\n";
         $dump .= "\t\t\t\t<createdAt>{$tag->getCreatedAt()}</createdAt>\n";
         $dump .= "\t\t\t</tag>\n";
         $tagLocalIds[$tag->getId()] = $localId;
         $localId++;
     }
     $dump .= "\t\t</tags>\n\n";
     $c = new Criteria();
     $c->add(PcListPeer::CREATOR_ID, $this->user->getId(), Criteria::EQUAL);
     $c->addDescendingOrderByColumn(PcListPeer::SORT_ORDER);
     $c->addDescendingOrderByColumn(PcListPeer::ID);
     $lists = PcListPeer::doSelect($c);
     $dump .= "\t\t<lists>\n";
     $localId = 1;
     foreach ($lists as $list) {
         $listIsInbox = $list->getIsInbox() ? 1 : 0;
         $listIsTodo = $list->getIsTodo() ? 1 : 0;
         $listIsHeader = $list->getIsHeader() ? 1 : 0;
         $dump .= "\t\t\t<list>\n";
         $dump .= "\t\t\t\t<localId>{$localId}</localId>\n";
         $dump .= "\t\t\t\t<id>{$list->getId()}</id>\n";
         $dump .= "\t\t\t\t<name><![CDATA[{$list->getTitle()}]]></name>\n";
         $dump .= "\t\t\t\t<sortOrder>{$list->getSortOrder()}</sortOrder>\n";
         $dump .= "\t\t\t\t<isInbox>{$listIsInbox}</isInbox>\n";
         $dump .= "\t\t\t\t<isTodo>{$listIsTodo}</isTodo>\n";
         $dump .= "\t\t\t\t<isHeader>{$listIsHeader}</isHeader>\n";
         $dump .= "\t\t\t\t<updatedAt>{$list->getUpdatedAt()}</updatedAt>\n";
         $dump .= "\t\t\t\t<createdAt>{$list->getCreatedAt()}</createdAt>\n";
         $dump .= "\t\t\t</list>\n";
         $listLocalIds[$list->getId()] = $localId;
         $localId++;
     }
     $dump .= "\t\t</lists>\n";
     $tasks = $this->user->getTasksByMultipleCriteria();
     $c = new Criteria();
     $c->addJoin(PcTaskPeer::LIST_ID, PcListPeer::ID, Criteria::INNER_JOIN);
     $c->add(PcListPeer::CREATOR_ID, $this->user->getId());
     $c->addDescendingOrderByColumn(PcTaskPeer::LIST_ID);
     $c->addAscendingOrderByColumn(PcTaskPeer::SORT_ORDER);
     $c->addAscendingOrderByColumn(PcTaskPeer::ID);
     $tasks = PcTaskPeer::doSelect($c);
     $dump .= "\t\t<tasks>\n";
     $localId = 1;
     foreach ($tasks as $task) {
         $taskIsStarred = $task->getIsStarred() ? 1 : 0;
         $taskIsCompleted = $task->getIsCompleted() ? 1 : 0;
         $taskIsHeader = $task->getIsHeader() ? 1 : 0;
         $taskIsFromSystem = $task->getIsFromSystem() ? 1 : 0;
         $taskListId = $task->getListId();
         $taskListLocalId = $listLocalIds[$task->getListId()];
         $taskTagIds = $task->getContexts();
         // comma separated list of tagIds
         $taskTagIdsArray = PcUtils::explodeWithEmptyInputDetection(',', $taskTagIds);
         $taskTagLocalIdsArray = array();
         foreach ($taskTagIdsArray as $id) {
             $taskTagLocalIdsArray[] = $tagLocalIds[$id];
         }
         $taskTagLocalIds = implode(',', $taskTagLocalIdsArray);
         $dump .= "\t\t\t<task>\n";
         $dump .= "\t\t\t\t<id>{$task->getId()}</id>\n";
         $dump .= "\t\t\t\t<localId>{$localId}</localId>\n";
         $dump .= "\t\t\t\t<listName><![CDATA[{$task->getList()->getTitle()}]]></listName>\n";
         $dump .= "\t\t\t\t<listLocalId>{$taskListLocalId}</listLocalId>\n";
         $dump .= "\t\t\t\t<description><![CDATA[{$task->getDescription()}]]></description>\n";
         $dump .= "\t\t\t\t<sortOrder>{$list->getSortOrder()}</sortOrder>\n";
         $dump .= "\t\t\t\t<dueDate>{$task->getDueDate()}</dueDate>\n";
         $dump .= "\t\t\t\t<dueTime>{$task->getDueTime()}</dueTime>\n";
         $dump .= "\t\t\t\t<repetitionId>{$task->getRepetitionId()}</repetitionId>\n";
         $dump .= "\t\t\t\t<repetitionParam>{$task->getRepetitionParam()}</repetitionParam>\n";
         $dump .= "\t\t\t\t<isStarred>{$taskIsStarred}</isStarred>\n";
         $dump .= "\t\t\t\t<isCompleted>{$taskIsCompleted}</isCompleted>\n";
         $dump .= "\t\t\t\t<isHeader>{$taskIsHeader}</isHeader>\n";
         $dump .= "\t\t\t\t<isFromSystem>{$taskIsFromSystem}</isFromSystem>\n";
         $dump .= "\t\t\t\t<tagLocalIds>{$taskTagLocalIds}</tagLocalIds>\n";
         $dump .= "\t\t\t\t<note><![CDATA[{$task->getNote()}]]></note>\n";
         $dump .= "\t\t\t\t<completedAt>{$task->getCompletedAt()}</completedAt>\n";
         $dump .= "\t\t\t\t<updatedAt>{$task->getUpdatedAt()}</updatedAt>\n";
         $dump .= "\t\t\t\t<createdAt>{$task->getCreatedAt()}</createdAt>\n";
         $dump .= "\t\t\t</task>\n";
         $localId++;
     }
     $dump .= "\t\t</tasks>\n";
     $dump .= "\t</plancake_tasks>\n";
     $dump .= "\t<plancake_notes>\n";
     $c = new Criteria();
     $c->add(PcNotePeer::CREATOR_ID, $this->user->getId(), Criteria::EQUAL);
     $c->addDescendingOrderByColumn(PcNotePeer::ID);
     $notes = PcNotePeer::doSelect($c);
     $dump .= "\t\t<notes>\n";
     $localId = 1;
     foreach ($notes as $note) {
         $dump .= "\t\t\t<note>\n";
         $dump .= "\t\t\t\t<localId>{$localId}</localId>\n";
         $dump .= "\t\t\t\t<id>{$note->getId()}</id>\n";
         $dump .= "\t\t\t\t<title><![CDATA[{$note->getTitle()}]]></title>\n";
         $dump .= "\t\t\t\t<content><![CDATA[{$note->getContent()}]]></content>\n";
         $dump .= "\t\t\t\t<updatedAt>{$note->getUpdatedAt()}</updatedAt>\n";
         $dump .= "\t\t\t\t<createdAt>{$note->getCreatedAt()}</createdAt>\n";
         $dump .= "\t\t\t</note>\n";
         $localId++;
     }
     $dump .= "\t\t</notes>\n";
     $dump .= "\t</plancake_notes>";
     $dump .= "\n" . '</backup>';
     return $dump;
 }
コード例 #3
0
 public function import($xml)
 {
     $originalMaxExecutionTime = ini_get('max_execution_time');
     ini_set('max_execution_time', 120);
     proc_nice(1);
     $tagLocalIds = array();
     $listLocalIds = array();
     $newTagIds = array();
     $newListIds = array();
     $newTaskIds = array();
     $newNoteIds = array();
     $tags = $xml->plancake_tasks->tags->tag;
     foreach ($tags as $tag) {
         $isNewTag = false;
         $tagId = (int) $tag->id > 0 ? $tag->id : null;
         $tagLocalId = (int) $tag->localId;
         $tagName = (string) $tag->name;
         $tagSortOrder = (int) $tag->sortOrder;
         $tagObj = null;
         if ($tagId && !in_array($tagId, $newTagIds)) {
             $tagObj = PcUsersContextsPeer::retrieveByPK($tagId);
         }
         if ($tagObj) {
             if ($tagObj->getUserId() != $this->user->getId()) {
                 die("Hacking attempt.");
             }
         } else {
             // tags are unique by name, thus
             // we check whether the tag is already in the instance
             // we are importing the dump to.
             $c = new Criteria();
             $c->add(PcUsersContextsPeer::CONTEXT, $tagName);
             $tagObj = PcUsersContextsPeer::doSelectOne($c);
             if (!is_object($tagObj)) {
                 $tagObj = new PcUsersContexts();
                 $isNewTag = true;
             }
         }
         $tagObj->setUserId($this->user->getId())->setContext($tagName)->setSortOrder($tagSortOrder)->save();
         $tagLocalIds[$tagLocalId] = $tagObj->getId();
         if ($isNewTag) {
             $newTagIds[] = $tagObj->getId();
         }
     }
     $lists = $xml->plancake_tasks->lists->list;
     foreach ($lists as $list) {
         $isNewList = false;
         $listId = (int) $list->id > 0 ? $list->id : null;
         $listLocalId = (int) $list->localId;
         $listName = (string) $list->name;
         $listSortOrder = (int) $list->sortOrder;
         $listIsInbox = (int) $list->isInbox == 1 ? true : false;
         $listIsTodo = (int) $list->isTodo == 1 ? true : false;
         $listIsHeader = (int) $list->isHeader == 1 ? true : false;
         $listObj = null;
         if ($listId && !in_array($listId, $newListIds)) {
             $listObj = PcListPeer::retrieveByPK($listId);
         }
         if ($listObj) {
             if ($listObj->getCreatorId() != $this->user->getId()) {
                 die("Hacking attempt.");
             }
         } else {
             if ($listIsInbox) {
                 $listObj = $this->user->getInbox();
             } else {
                 if ($listIsTodo) {
                     $listObj = $this->user->getTodo();
                 } else {
                     $listObj = new PcList();
                     $isNewList = true;
                 }
             }
         }
         $listObj->setCreatorId($this->user->getId())->setTitle($listName)->setSortOrder($listSortOrder)->setIsInbox($listIsInbox)->setIsTodo($listIsTodo)->setIsHeader($listIsHeader)->save();
         $listLocalIds[$listLocalId] = $listObj->getId();
         if ($isNewList) {
             $newListIds[] = $listObj->getId();
         }
     }
     $tasks = $xml->plancake_tasks->tasks->task;
     foreach ($tasks as $task) {
         $isNewTask = false;
         $taskId = (int) $task->id > 0 ? $task->id : 0;
         $taskListLocalId = (int) $task->listLocalId;
         $taskDescription = (string) $task->description;
         $taskSortOrder = (int) $task->sortOrder;
         $taskDueDate = (string) $task->dueDate;
         $taskDueTime = strlen($task->dueTime) > 0 ? (int) $task->dueTime : '';
         $taskRepetitionId = (int) $task->repetitionId;
         $taskRepetitionParam = (int) $task->repetitionParam;
         $taskIsStarred = (int) $task->isStarred == 1 ? true : false;
         $taskIsCompleted = (int) $task->isCompleted == 1 ? true : false;
         $taskIsHeader = (int) $task->isHeader == 1 ? true : false;
         $taskIsFromSystem = (int) $task->isFromSystem == 1 ? true : false;
         $taskTagLocalIds = (string) $task->tagLocalIds;
         $taskNote = (string) $task->note;
         $taskListId = $listLocalIds[$taskListLocalId];
         $taskTagIdsArray = array();
         $taskTagLocalIdsArray = PcUtils::explodeWithEmptyInputDetection(',', $taskTagLocalIds);
         foreach ($taskTagLocalIdsArray as $id) {
             $taskTagIdsArray[] = $tagLocalIds[$id];
         }
         $taskTagIds = '';
         if (count($taskTagIdsArray)) {
             $taskTagIds = implode(',', $taskTagIdsArray);
         }
         $taskFromDb = null;
         if ($taskId && !in_array($taskId, $newTaskIds)) {
             $taskFromDb = PcTaskPeer::retrieveByPK($taskId);
         }
         if (!is_object($taskFromDb)) {
             // if the task doesn't exist (even if the dump contains a taskId)
             // we want to add it.
             $taskId = 0;
             $isNewTask = true;
         }
         $newTask = PcTaskPeer::createOrEdit($taskDescription, $taskListId, $taskId, $taskTagIds, $taskIsHeader, $taskNote, $taskDueDate, $taskDueTime, $taskIsStarred, $taskRepetitionId, $taskRepetitionParam, 0, '', 'd-m-Y', false);
         if ($taskIsCompleted) {
             $newTask->setIsCompleted(1);
             $newTask->setCompletedAt($task->completedAt);
             $newTask->save();
         }
         if ($isNewTask) {
             $newTaskIds[] = $newTask->getId();
         }
         if (!$taskId) {
             $newTask->deleteDirtyEntry();
         }
     }
     $notes = $xml->plancake_notes->notes->note;
     foreach ($notes as $note) {
         $isNewNote = false;
         $noteId = (int) $note->id > 0 ? $note->id : null;
         $noteTitle = (string) $note->title;
         $noteContent = (string) $note->content;
         $noteObj = null;
         if ($noteId && !in_array($noteId, $newNoteIds)) {
             $noteObj = PcNotePeer::retrieveByPK($noteId);
         }
         if ($noteObj) {
             if ($noteObj->getCreatorId() != $this->user->getId()) {
                 die("Hacking attempt.");
             }
         } else {
             $noteObj = new PcNote();
             $isNewNote = true;
         }
         $noteObj->setCreatorId($this->user->getId())->setTitle($noteTitle)->setContent($noteContent)->save();
         if ($isNewNote) {
             $newNoteIds[] = $noteObj->getId();
         }
     }
     ini_set('max_execution_time', $originalMaxExecutionTime);
 }
コード例 #4
0
 /**
  * Creates (or edits) a task
  * By default, it sets isFromSystem false. That is because a user may
  * edit a task from the system and make it meaningful to them. The problem
  * is the automatic cleaning up of system tasks would delete it. And this
  * method is used also when editing a task.
  * Repetition expression has got priority on dueDate
  * 
  * @param string $description
  * @param integer $listId (if listId not >0, we will use the user's Inbox)
  * @param integer $taskId (if we are editing an existing task)
  * @param string $contexts (comma separated list of ids)
  * @param boolean $isHeader
  * @param string $note
  * @param string $dueDate (no GMT but user's local date)
  * @param string $dueTime - formatted as an integer, ie: 0753 (no GMT but user's local time)
  * @param integer $repetitionId
  * @param integer $repetitionParam
  * @param integer $taskAboveId - if ($taskAboveId = -100000), that means to put at the end of the list
  * @param string $callerContext - can be either 'ajax' or 'email' or 'gcal'
  * @param string $dueDateFormat - to specify a particular format for parsing the dueDate param
  *               (otherwise the user's date format is used).
  *               Uses the PHP date() format
  * @param boolean $setNextOccurrence (=true)
  * @return     PcTask - the object that has been created
  */
 public static function createOrEdit($description, $listId = 0, $taskId = 0, $contexts = '', $isHeader = false, $note = '', $dueDate = '', $dueTime = '', $isStarred = 0, $repetitionId = 0, $repetitionParam = 0, $taskAboveId = 0, $callerContext = '', $dueDateFormat = '', $setNextOccurrence = true)
 {
     $dueDate = strtolower($dueDate);
     $loggedInUser = PcUserPeer::getLoggedInUser();
     if ($repetitionId < 0) {
         $repetitionId = 0;
     }
     if (!((int) $listId > 0)) {
         // Inserting into the default list: Inbox
         $listId = $loggedInUser->getInbox()->getId();
     }
     $listCreator = PcListPeer::retrieveByPk($listId)->getCreator();
     PcUtils::checkLoggedInUserPermission($listCreator);
     $mode = $taskId ? 'edit' : 'add';
     $task = $mode == 'add' ? new PcTask() : PcTaskPeer::retrieveByPk($taskId);
     if ($mode == 'edit' && !$task->validateOwner($loggedInUser)) {
         throw new sfException('User ' . $loggedInUser->getId() . ' trying to access the task ' . $task->getId() . ' illegitimately');
     }
     list($listIdFromShortcut, $contextIdsFromShortcut, $potentialDueDateExpressionsFromShortcut, $potentialDueTimeExpressionsFromShortcut) = $task->extractInfoFromTaskDescription($description);
     $listId = $listIdFromShortcut > 0 ? $listIdFromShortcut : $listId;
     // if we are here all the contexts (if any) are valid
     if (count($contextIdsFromShortcut)) {
         $task->setContexts(implode(',', $contextIdsFromShortcut));
     } else {
         $userContexts = $loggedInUser->getContextsArray(true);
         $contextIdsFromInput = PcUtils::explodeWithEmptyInputDetection(',', $contexts);
         $validatedContexts = array();
         foreach ($contextIdsFromInput as $cid) {
             $userContext = PcUsersContextsPeer::retrieveByPK($cid);
             if ($userContext) {
                 $validatedContexts[] = array_search(strtolower($userContext->getContext()), $userContexts);
             }
         }
         $task->setContexts(implode(',', $validatedContexts));
     }
     // {{{ START: looking for a contact
     $contactPrefix = 'cid';
     if (strpos($description, $contactPrefix) !== FALSE) {
         if (preg_match('/' . $contactPrefix . '([0-9]+)/', $description, $contactArray)) {
             $description = str_replace($contactArray[0], '', $description);
             // removing the contact bit from the description
             if (is_numeric($contactArray[1])) {
                 $task->setContactId($contactArray[1]);
             }
         }
     }
     // END: looking for a contact }}}
     $task->setDescription($description);
     // it is the actual content of the task
     if ($repetitionId == 34 && !($repetitionParam > 0)) {
         // $repetitionParam should have been > 0!
         $repetitionId = 0;
     }
     $oldRepetitionId = $task->getRepetitionId();
     if ($repetitionId > 0) {
         $task->setRepetitionId($repetitionId);
         $task->setRepetitionParam($repetitionParam);
     } else {
         $task->setRepetitionId(NULL);
         $task->setRepetitionParam(0);
     }
     $changeInRepetitionId = false;
     if ($oldRepetitionId != $task->getRepetitionId()) {
         $changeInRepetitionId = true;
     }
     try {
         $task->setListId($listId);
     } catch (sfException $e) {
         if ($callerContext == 'ajax') {
             die('ERROR: You can\'t insert a task in a header.');
         }
     }
     $task->setIsHeader($isHeader);
     if (!$isHeader) {
         $task->setNote($note);
     } else {
         $task->setDueDate(null);
     }
     $validDueDateExpression = false;
     $unrecognizedShortcuts = array();
     if (count($potentialDueDateExpressionsFromShortcut) && !$isHeader) {
         foreach ($potentialDueDateExpressionsFromShortcut as $potentialDueDateExpressionFromShortcut) {
             $validDueDateExpression = $task->setDueDate($potentialDueDateExpressionFromShortcut);
             if (!$validDueDateExpression) {
                 $unrecognizedShortcuts[] = $potentialDueDateExpressionFromShortcut;
             } else {
                 $validDueDateExpression = true;
                 break;
             }
         }
     }
     if (!$validDueDateExpression && $dueDate && !$isHeader) {
         $validDueDateExpression = $task->setDueDate($dueDate, $dueDateFormat);
     }
     if (!$task->getDueDate()) {
         $task->setDueDate(NULL);
     }
     if ($mode == 'add') {
         $list = $task->getPcList();
         if (!$list) {
             // this should not happen, but just in case...
             $list = $loggedInUser->getInbox();
         }
         if (!$taskAboveId) {
             $maxTasksSortOrder = self::getMaxTasksSortOrder($list);
             $task->setSortOrder($maxTasksSortOrder + 1);
         } else {
             if ($taskAboveId == -100000) {
                 $minTasksSortOrder = self::getMinTasksSortOrder($list);
                 $task->setSortOrder($minTasksSortOrder - 1);
             } else {
                 $maxTasksSortOrder = self::getMaxTasksSortOrder($list);
                 // they are inserting the new task below an old one
                 // I need to insert the new task after the task whose id is beforeListId
                 $allTasks = $list->getIncompletedTasks();
                 // the tasks are returned with sortOrder descending order
                 // and the tasks are displayed with the greatest sortOrder on top
                 $newSortOrder = $maxTasksSortOrder;
                 foreach ($allTasks as $oneOfTheOtherTasks) {
                     $delta = 1;
                     if ($oneOfTheOtherTasks->getId() == $taskAboveId) {
                         $task->setSortOrder($newSortOrder - 1);
                         $delta++;
                     }
                     $oneOfTheOtherTasks->setSortOrder($newSortOrder);
                     $oneOfTheOtherTasks->save();
                     $newSortOrder -= $delta;
                 }
             }
         }
     }
     if (count($unrecognizedShortcuts)) {
         if ($callerContext == 'ajax') {
             die("ERROR: {$unrecognizedShortcuts[0]} is not a tag neither a valid due date/time expression.");
         }
     }
     if ($potentialDueTimeExpressionsFromShortcut && $callerContext == 'ajax') {
         if (!$potentialDueTimeExpressionsFromShortcut->isValid()) {
             die("ERROR: the due time shortcut is not valid.");
         }
     }
     if ($dueTime || $potentialDueTimeExpressionsFromShortcut) {
         // it doesn't make sense to set a time if a date is not specified
         if ($task->getDueDate() || $task->getRepetitionId()) {
             if ($dueTime) {
                 $task->setDueTime($dueTime);
             } else {
                 $task->setDueTime($potentialDueTimeExpressionsFromShortcut->getIntegerValue());
             }
         } else {
             if ($callerContext == 'ajax') {
                 die('ERROR: You can\'t set a due time without a due date.');
             } else {
                 // if the user tried to insert a due time shortcuts but we couldn't take
                 // that value because there is no due date, we put the due time back in
                 // the description
                 if ($potentialDueTimeExpressionsFromShortcut) {
                     $descriptionWithDueTimeEmbedded = $task->getDescription() . ' @' . $potentialDueTimeExpressionsFromShortcut->getHumanFriendlyTime($loggedInUser);
                     $task->setDescription($descriptionWithDueTimeEmbedded);
                 }
             }
         }
     } else {
         $task->setDueTime(null);
     }
     if (!$task->isHeader()) {
         $task->setStarred((bool) $isStarred);
     }
     $task->save();
     if ($task->getRepetitionId() && $setNextOccurrence) {
         $task->setNextOccurrence(true);
         // N.B.: this saves the object!!!!!!!
     }
     // we need to do this operation here because we need the object
     // saved in the db to be able to refer to it via its ID
     $task->alignTasksContextsTable();
     // {{{
     // this is to fix a bug:
     // long task descriptions were cut (because of database schema contraint)
     // without a clear feedback on the user interface (Javascript was
     // inserting the whole string sent via AJAX)
     $task = PcTaskPeer::retrieveByPK($task->getId());
     // }}}
     // This is VERY IMPRTANT because a user may
     // edit a task from the system and make it meaningful to them. The problem
     // is the automatic cleaning up of system tasks would delete it. And this
     // method is used also when editing a task.
     $task->setIsFromSystem(false);
     if ($loggedInUser->hasGoogleCalendarIntegrationActive()) {
         if ($callerContext != 'gcal') {
             $gcal = new GoogleCalendarInterface($loggedInUser);
             $gcal->init();
             $gcal->createOrUpdateEvent($task);
         }
     }
     return $task;
 }
コード例 #5
0
ファイル: PcTask.php プロジェクト: ntemple/intelli-plancake
 /**
  * It is called by the save() method.
  * It populates the pc_tasks_contexts table.
  *
  * @return void
  */
 public function alignTasksContextsTable()
 {
     $contexts = $this->getContexts();
     // first, let's delete all the pre-existing contexts from this task
     $c = new Criteria();
     $c->add(PcTasksContextsPeer::TASK_ID, $this->getId());
     PcTasksContextsPeer::doDelete($c);
     $contexts = $this->getContexts();
     $contextIds = PcUtils::explodeWithEmptyInputDetection(',', $contexts);
     if (count($contextIds)) {
         foreach ($contextIds as $contextId) {
             if (is_numeric($contextId)) {
                 $record = new PcTasksContexts();
                 $record->setTaskId($this->getId())->setUsersContextsId($contextId)->save();
             }
         }
     }
 }