public function setsubtitleAction() { // Get, check and setup the parameters $story_id = $this->getRequest()->getParam("story"); // TODO We should also filter and strip tags here $title = substr($this->getRequest()->getParam("value"), 0, 50); //Verify if the requested story exist $stories = new Stories(); if (!($story = $stories->getStory($story_id))) { return $this->_helper->json->sendJson(false); } // Check if we are the owner if ($this->_application->user->id != $story->user_id) { return $this->_helper->json->sendJson(false); } // Ok, we can set the title $stories->setSubTitle($story_id, $title); // Die with the string if (!$title) { $title = '[Edit Subtitle]'; } die($title); }