コード例 #1
0
ファイル: PcUser.php プロジェクト: ntemple/intelli-plancake
 /**
  *
  * @return array of PcNote
  */
 public function getNotes()
 {
     $c = new Criteria();
     $c->add(PcNotePeer::CREATOR_ID, $this->getId());
     $c->addDescendingOrderByColumn(PcNotePeer::UPDATED_AT);
     return PcNotePeer::doSelect($c);
 }
コード例 #2
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(PcNotePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(PcNotePeer::DATABASE_NAME);
         $criteria->add(PcNotePeer::ID, $pks, Criteria::IN);
         $objs = PcNotePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
コード例 #3
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;
 }
コード例 #4
0
 /**
  * Gets an array of PcNote objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this PcUser has previously been saved, it will retrieve
  * related PcNotes from storage. If this PcUser is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array PcNote[]
  * @throws     PropelException
  */
 public function getPcNotes($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PcUserPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collPcNotes === null) {
         if ($this->isNew()) {
             $this->collPcNotes = array();
         } else {
             $criteria->add(PcNotePeer::CREATOR_ID, $this->id);
             PcNotePeer::addSelectColumns($criteria);
             $this->collPcNotes = PcNotePeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(PcNotePeer::CREATOR_ID, $this->id);
             PcNotePeer::addSelectColumns($criteria);
             if (!isset($this->lastPcNoteCriteria) || !$this->lastPcNoteCriteria->equals($criteria)) {
                 $this->collPcNotes = PcNotePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastPcNoteCriteria = $criteria;
     return $this->collPcNotes;
 }