00001 <?php
00002
00009 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
00010 lt_include( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
00011 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
00012 lt_include( PLOG_CLASS_PATH."class/view/admin/adminglobalarticlecategorieslistview.class.php" );
00013
00020 class AdminAddGlobalArticleCategoryAction extends AdminAction
00021 {
00022
00023 var $_categoryName;
00024 var $_categoryDescription;
00025
00030 function AdminAddGlobalArticleCategoryAction( $actionInfo, $request )
00031 {
00032 $this->AdminAction( $actionInfo, $request );
00033
00034
00035 $this->registerFieldValidator( "categoryName", new StringValidator());
00036 $this->registerFieldValidator( "categoryDescription", new StringValidator(), true );
00037
00038 $errorView = new AdminTemplatedView( $this->_blogInfo, "newglobalarticlecategory" );
00039 $errorView->setErrorMessage( $this->_locale->tr("error_adding_global_article_category" ));
00040 $this->setValidationErrorView( $errorView );
00041
00042 $this->requireAdminPermission( "add_global_category" );
00043 }
00044
00048 function perform()
00049 {
00050
00051 $this->_categoryName = $this->_request->getValue( "categoryName" );
00052 $this->_categoryDescription = $this->_request->getValue( "categoryDescription" );
00053
00054
00055 $categories = new GlobalArticleCategories();
00056 $category = new GlobalArticleCategory( $this->_categoryName,
00057 $this->_categoryDescription );
00058
00059
00060 $this->notifyEvent( EVENT_PRE_ADD_GLOBAL_CATEGORY, Array( "category" => &$category ));
00061
00062
00063 if( $categories->addGlobalArticleCategory( $category )) {
00064
00065
00066
00067
00068 if( $this->userHasPermission( "view_global_categories", ADMIN_PERMISSION ))
00069 $this->_view = new AdminGlobalArticleCategoriesListView( $this->_blogInfo );
00070 else
00071 $this->_view = new AdminTemplatedView( $this->_blogInfo, "newglobalarticlecategory" );
00072 $this->_view->setSuccess( true );
00073 $this->_view->setSuccessMessage( $this->_locale->pr("global_category_added_ok", $category->getName()));
00074
00075
00076 $this->notifyEvent( EVENT_POST_ADD_GLOBAL_CATEGORY, Array( "category" => &$category ));
00077
00078 $this->setCommonData();
00079 }
00080 else {
00081
00082
00083 $this->_view->setError( true );
00084 $this->_view->setErrorMessage( $this->_locale->tr("error_adding_global_article_category" ));
00085 $this->setCommonData( true );
00086 }
00087
00088
00089 return true;
00090 }
00091 }
00092 ?>