Esempio n. 1
0
 protected function show_all()
 {
     $this->params['deadline_to'] = null;
     $this->params['fulltext'] = "";
     $this->params['importance'] = "0";
     $note_query = NoteQuery::create()->filterByUser($this->params['user'])->leftJoinWith('Note.Category');
     if (isset($_GET['deadline_to']) && !empty($_GET['deadline_to'])) {
         $note_query = $note_query->filterByDeadline(array('max' => $_GET['deadline_to']));
         $this->params['deadline_to'] = $_GET['deadline_to'];
     }
     if (isset($_GET['category']) && is_array($_GET['category'])) {
         $note_query = $note_query->useCategoryQuery()->filterByName($_GET['category'])->endUse();
     }
     if (isset($_GET['state']) && is_array($_GET['state'])) {
         $note_query = $note_query->filterByState($_GET['state']);
     }
     if (isset($_GET['importance_from']) && $_GET['importance_from'] > 0) {
         $note_query = $note_query->filterByImportance(array('min' => $_GET['importance_from']));
         $this->params['importance'] = $_GET['importance_from'];
     }
     if (isset($_GET['fulltext']) && !empty($_GET['fulltext'])) {
         $note_query = $note_query->filterByText($_GET['fulltext']);
         $this->params['fulltext'] = $_GET['fulltext'];
     }
     if (isset($_GET['sort_by'])) {
         switch ($_GET['sort_by']) {
             case 'deadline':
                 $note_query = $note_query->addAscendingOrderByColumn("deadline");
                 break;
             case 'relevance':
                 $note_query = $note_query->orderByRelevance();
                 break;
             case 'importance':
                 $note_query = $note_query->addDescendingOrderByColumn("importance");
                 break;
             case 'category':
                 $note_query = $note_query->addAscendingOrderByColumn("category.name");
                 break;
         }
     }
     $note_query = $note_query->addAscendingOrderByColumn("note.created_at");
     $page = 1;
     if (isset($_GET['page']) && $_GET['page'] > 0) {
         $page = $_GET['page'];
     }
     $per_page = 32;
     $this->params['notes'] = $note_query->paginate($page = $page, $maxPerPage = $per_page);
     $this->params['notifications'] = NotificationQuery::create()->filterByUser($this->params['user'])->find();
     $categories = CategoryQuery::create()->select('name')->filterByUser($this->params['user'])->find();
     $selected = isset($_GET['category']) ? $_GET['category'] : null;
     $this->params['categories'] = options_for_select($categories, $selected);
     $selected = isset($_GET['state']) ? $_GET['state'] : null;
     $this->params['states'] = options_for_select(array('opened', 'done', 'wip', 'closed'), $selected);
     $selected = isset($_GET['sort_by']) ? $_GET['sort_by'] : 'relevance';
     $this->params['sort_by'] = options_for_select(array('created_at', 'deadline', 'relevance', 'importance', 'category'), $selected);
     if (strpos($_SERVER['HTTP_ACCEPT'], 'text/javascript') !== FALSE) {
         $this->renderType('js.phtml');
     }
 }
Esempio n. 2
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Note is new, it will return
  * an empty collection; or if this Note has previously
  * been saved, it will retrieve related Notifications from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Note.
  *
  * @param      Criteria $criteria optional Criteria object to narrow the query
  * @param      ConnectionInterface $con optional connection object
  * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return ObjectCollection|ChildNotification[] List of ChildNotification objects
  */
 public function getNotificationsJoinOriginUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
 {
     $query = ChildNotificationQuery::create(null, $criteria);
     $query->joinWith('OriginUser', $joinBehavior);
     return $this->getNotifications($query, $con);
 }
Esempio n. 3
0
 /**
  * Returns a new ChildNotificationQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildNotificationQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildNotificationQuery) {
         return $criteria;
     }
     $query = new ChildNotificationQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Esempio n. 4
0
 /**
  * Performs an INSERT on the database, given a Notification or Criteria object.
  *
  * @param mixed               $criteria Criteria or Notification object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(NotificationTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Notification object
     }
     if ($criteria->containsKey(NotificationTableMap::COL_ID) && $criteria->keyContainsValue(NotificationTableMap::COL_ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . NotificationTableMap::COL_ID . ')');
     }
     // Set the correct dbName
     $query = NotificationQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
Esempio n. 5
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @throws LogicException if no primary key is defined
  *
  * @return Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = ChildNotificationQuery::create();
     $criteria->add(NotificationTableMap::COL_ID, $this->id);
     return $criteria;
 }
Esempio n. 6
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this User is new, it will return
  * an empty collection; or if this User has previously
  * been saved, it will retrieve related NotificationsRelatedByOriginTypeOriginId from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in User.
  *
  * @param      Criteria $criteria optional Criteria object to narrow the query
  * @param      ConnectionInterface $con optional connection object
  * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return ObjectCollection|ChildNotification[] List of ChildNotification objects
  */
 public function getNotificationsRelatedByOriginTypeOriginIdJoinNote(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
 {
     $query = ChildNotificationQuery::create(null, $criteria);
     $query->joinWith('Note', $joinBehavior);
     return $this->getNotificationsRelatedByOriginTypeOriginId($query, $con);
 }