[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/view/admin/adminpostslistview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/view/admin/admineditpostview.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 8 9 /** 10 * \ingroup Action 11 * @private 12 * 13 * Action that shows a form to update a post 14 */ 15 class AdminEditPostAction extends AdminAction 16 { 17 18 var $_postId; 19 20 /** 21 * Constructor. If nothing else, it also has to call the constructor of the parent 22 * class, BlogAction with the same parameters 23 */ 24 function AdminEditPostAction( $actionInfo, $request ) 25 { 26 $this->AdminAction( $actionInfo, $request ); 27 28 // data validation 29 $this->registerFieldValidator( "postId", new IntegerValidator()); 30 // if we don't register the fields below, the view will complain that they are 31 // not valid! 32 $this->registerField( "postTopic" ); 33 $this->registerField( "postText" ); 34 $this->registerField( "postCategories" ); 35 $view = new AdminPostsListView( $this->_blogInfo ); 36 $view->setErrorMessage( $this->_locale->tr("error_incorrect_article_id")); 37 $this->setValidationErrorView( $view ); 38 39 $this->requirePermission( "update_post" ); 40 } 41 42 /** 43 * Carries out the specified action 44 */ 45 function perform() 46 { 47 // fetch the post id that has already been validated 48 $this->_postId = $this->_request->getValue( "postId" ); 49 50 // fetch the post from the database 51 $posts = new Articles(); 52 $post = $posts->getBlogArticle( $this->_postId, $this->_blogInfo->getId(), false ); 53 54 // if the article does not exist, quit 55 if( !$post ) { 56 $this->_view = new AdminPostsListView( $this->_blogInfo ); 57 $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_article" )); 58 $this->setCommonData(); 59 60 return false; 61 } 62 63 // if the user does not have the 'view_all_user_articles' permission, then 64 // we have to check whether the original poster of the article and the current 65 // user match 66 if( !$this->userHasPermission( "view_all_user_articles" )) { 67 if( $post->getUserId() != $this->_userInfo->getId()) { 68 $this->_view = new AdminPostsListView( $this->_blogInfo ); 69 $this->_view->setErrorMessage( $this->_locale->tr("error_can_only_view_own_articles" )); 70 $this->setCommonData(); 71 72 return false; 73 } 74 } 75 76 77 78 // throw the event 79 $this->notifyEvent( EVENT_POST_LOADED, Array( "article" => &$post, "from" => "editPost" )); 80 81 // and create the view where we will edit the post 82 $this->_view = new AdminEditPostView( $this->_blogInfo ); 83 $this->_view->setArticle( $post ); 84 $this->_view->setUserInfo( $this->_userInfo ); 85 $this->setCommonData(); 86 87 return true; 88 } 89 } 90 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |