Ejemplo n.º 1
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->user = $this->getUser()->getTemposUser();
     $this->forward404Unless($this->user, 'Only users can access this page.');
     $this->step = sfConfig::get('app_max_messages_on_messagelist');
     $this->getUser()->syncParameters($this, 'message', 'index', array('offset', 'limit', 'sort_column', 'sort_direction'), $request);
     if (is_null($this->sort_column)) {
         $this->sort_column = 'created_at';
         $this->sort_direction = 'down';
     }
     if (is_null($this->offset)) {
         $this->offset = 0;
     }
     if (is_null($this->limit) || $this->limit <= 0) {
         $this->limit = $this->step;
     }
     $c = MessagePeer::getUserCriteria($this->user->getId());
     $cb = clone $c;
     SortCriteria::addSortCriteria($c, $this->sort_column, MessagePeer::getSortAliases(), $this->sort_direction);
     $c->setOffset($this->offset);
     if ($this->limit >= 0) {
         $c->setLimit($this->limit);
     }
     $this->message_list = MessagePeer::doSelect($c);
     $this->count = MessagePeer::doCount($cb);
     $this->unread_count = MessagePeer::doCountUserUnreadMessages($this->user->getId());
     if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) {
         $this->forward404('Invalid offset/count values.');
     }
 }
Ejemplo n.º 2
0
 /**
  * function getNbNewMessages
  * retrieves number of new messages in a user's mailbox folder
  *
  * @return int
  * @author Sean Grove
  **/
 public static function getNbNewMessages($folder = 'inbox')
 {
     $user_id = sfContext::getInstance()->getUser()->getProfile()->getUserId();
     $c = new Criteria();
     $c->add(self::RECIPIENT_ID, $user_id);
     $c->add(self::OWNER_ID, $user_id);
     $c->add(self::FOLDER, $folder);
     $c->add(self::READ_AT, null);
     $messages = MessagePeer::doSelect($c);
     return count($messages);
 }
Ejemplo n.º 3
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(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(MessagePeer::DATABASE_NAME);
         $criteria->add(MessagePeer::ID, $pks, Criteria::IN);
         $objs = MessagePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Ejemplo n.º 4
0
 public function executeList()
 {
     $this->messages = MessagePeer::doSelect(new Criteria());
 }
Ejemplo n.º 5
0
 /**
  * Gets an array of Message 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 User has previously been saved, it will retrieve
  * related MessagesRelatedByOwnerId from storage. If this User 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 Message[]
  * @throws     PropelException
  */
 public function getMessagesRelatedByOwnerId($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(UserPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collMessagesRelatedByOwnerId === null) {
         if ($this->isNew()) {
             $this->collMessagesRelatedByOwnerId = array();
         } else {
             $criteria->add(MessagePeer::OWNER_ID, $this->id);
             MessagePeer::addSelectColumns($criteria);
             $this->collMessagesRelatedByOwnerId = MessagePeer::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(MessagePeer::OWNER_ID, $this->id);
             MessagePeer::addSelectColumns($criteria);
             if (!isset($this->lastMessageRelatedByOwnerIdCriteria) || !$this->lastMessageRelatedByOwnerIdCriteria->equals($criteria)) {
                 $this->collMessagesRelatedByOwnerId = MessagePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastMessageRelatedByOwnerIdCriteria = $criteria;
     return $this->collMessagesRelatedByOwnerId;
 }
Ejemplo n.º 6
0
 public function getMessagesRelatedByRecipientId($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseMessagePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collMessagesRelatedByRecipientId === null) {
         if ($this->isNew()) {
             $this->collMessagesRelatedByRecipientId = array();
         } else {
             $criteria->add(MessagePeer::RECIPIENT_ID, $this->getId());
             MessagePeer::addSelectColumns($criteria);
             $this->collMessagesRelatedByRecipientId = MessagePeer::doSelect($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(MessagePeer::RECIPIENT_ID, $this->getId());
             MessagePeer::addSelectColumns($criteria);
             if (!isset($this->lastMessageRelatedByRecipientIdCriteria) || !$this->lastMessageRelatedByRecipientIdCriteria->equals($criteria)) {
                 $this->collMessagesRelatedByRecipientId = MessagePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastMessageRelatedByRecipientIdCriteria = $criteria;
     return $this->collMessagesRelatedByRecipientId;
 }
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Production has previously
  * been saved, it will retrieve related Messages from storage.
  * If this Production is new, it will return
  * an empty collection or the current collection, the criteria
  * is ignored on a new object.
  *
  * @param      Connection $con
  * @param      Criteria $criteria
  * @throws     PropelException
  */
 public function getMessages($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'src/model/whiteboard/om/BaseMessagePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collMessages === null) {
         if ($this->isNew()) {
             $this->collMessages = array();
         } else {
             $criteria->add(MessagePeer::PRODUCTION_ID, $this->getProductionId());
             MessagePeer::addSelectColumns($criteria);
             $this->collMessages = MessagePeer::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(MessagePeer::PRODUCTION_ID, $this->getProductionId());
             MessagePeer::addSelectColumns($criteria);
             if (!isset($this->lastMessageCriteria) || !$this->lastMessageCriteria->equals($criteria)) {
                 $this->collMessages = MessagePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastMessageCriteria = $criteria;
     return $this->collMessages;
 }