/** * 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'); }