Prev | Current Page 311 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

..
}
/**
* Changes the articles of a given post
* Optionally, publishes after changing the post
*
* @param string $postid Unique identifier of the post to be changed C
* @param string $username Login for a user who has permission to edit
Licensed to Menshu You
Zend Framework in Action (Ch01) Manning Publications Co. 25
* the given post (either the original creator or an admin of the blog)
* @param string $password Password for said username
* @param struct $struct New content of the post
* @param boolean $publish If true, the blog will be published
* immediately after the post is made
* @return boolean D
*/
public function editPost($postid, $username, $password, $struct, $publish) E
{
$identity = $this->_auth->authenticate($username, $password); F
if(false === $identity) {
throw new Exception('Authentication Failed');
}
// Set up filters
$filterInt = new Zend_Filter_Int; G
$filterStripTags = new Zend_Filter_StripTags;
$id = $filterInt->filter($postid);
$data = array( H
'publish' => $filterInt->filter($struct['publish']),
'title' => $filterStripTags->filter($struct['title']),
'body' => $struct['description']
);
$where = $this->_articleTable->getAdapter()->quoteInto('id = ?', $id);
$rows_affected = $this->_articleTable->update($data, $where); I
if(0 == $rows_affected) {
throw new Exception('Somehow your post failed to be updated');
}
return true; J
}
// Add all the other required methods here.


Pages:
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
bosten.pl Praca dla pielegniarek kasyno szkolenia dla przedsiębiorców House Extension London