Exemple #1
0
 public static function retrieveByUserIdSlug($user_id, $slug)
 {
     $c = new Criteria();
     $c->add(ToDoPeer::OWNER_ID, $user_id);
     $c->add(ToDoPeer::SLUG, $slug);
     $c->addAscendingOrderByColumn(ToDoPeer::FINISH);
     /*
     if ($all != true) {
       //$c->add(ToDoPeer::STATUS, sfConfig::get('app_task_status_open'));
     }
     */
     return ToDoPeer::doSelectOne($c);
 }
Exemple #2
0
 /**
  * Executes updateTodo action
  *
  */
 public function executeUpdateTodo()
 {
     $this->forward404Unless($this->getUser()->isAuthenticated() && ($this->profile = $this->getUser()->getProfile()));
     $this->forward404Unless($todo = ToDoPeer::retrieveByUserIdSlug($this->profile->getUserId(), $this->getRequestParameter('todo'), true), 'Todo not found by user_id:slug, [' . $this->profile->getUserId() . ']:[' . $this->getRequestParameter('todo') . ']');
     $this->forward404Unless($todo->getOwnerId() == $this->getUser()->getId(), 'Owner doesn\'t match current user');
     $todo->setName($this->getRequestParameter('name'));
     $todo->setDescription($this->getRequestParameter('description'));
     $todo->setStatus($this->getRequestParameter('status'));
     if ($this->getRequestParameter('begin')) {
         list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('begin'), $this->getUser()->getCulture());
         $todo->setBegin("{$y}-{$m}-{$d}");
     }
     if ($this->getRequestParameter('finish')) {
         list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('finish'), $this->getUser()->getCulture());
         $todo->setFinish("{$y}-{$m}-{$d}");
     }
     $todo->save();
     $this->todo = $todo;
     $this->setTemplate('showTodo');
 }
Exemple #3
0
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ToDoPeer::ID, $pks, Criteria::IN);
         $objs = ToDoPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemple #4
0
 public function countToDos($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseToDoPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(ToDoPeer::OWNER_ID, $this->getId());
     return ToDoPeer::doCount($criteria, $distinct, $con);
 }