NewsNewsFeaturesDownloadsDevelopmentSupportForumDocumentsAbout Us

adminaction.class.php

查看本檔案說明文件.
00001 <?php
00002 
00003     include_once( PLOG_CLASS_PATH."class/action/action.class.php" );
00004     include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
00005     include_once( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
00006     include_once( PLOG_CLASS_PATH."class/template/templateservice.class.php" );
00007     include_once( PLOG_CLASS_PATH."class/misc/version.class.php" );
00008     include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
00009     include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
00010     include_once( PLOG_CLASS_PATH."class/view/admin/admindefaultview.class.php" );
00011     include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00012 
00028     class AdminAction extends Action 
00029     {
00030 
00031         var $_blogInfo;
00032         var $_userInfo;
00033         var $_session;
00034         var $_config;
00035         var $_locale;
00036         var $_pm;
00037         var $_userBlogs;
00038 
00045         function AdminAction( $actionInfo, $request )
00046         {
00047             $this->Action( $actionInfo, $request );
00048     
00049             // get information about the session
00050             $session = HttpVars::getSession();
00051             $this->_session = $session["SessionInfo"];
00052 
00053             $this->_config  =& Config::getConfig();
00054 
00055             // get the information about the user and quit if we don't have it...
00056             $this->_getUserInfo();
00057             if( $this->_userInfo == "" ) {
00058                 header( "HTTP/1.0 403 Forbidden" );
00059                 print($this->mustAuthenticatePage());
00060                 die();
00061             }
00062 
00063             // do the same with the information about the blog
00064             $this->_getBlogInfo();
00065             if( $this->_blogInfo == "" ) {
00066                 if( $this->_actionInfo->getActionParamValue() != "blogSelect" ) {
00067                     header( "HTTP/1.0 403 Forbidden" );
00068                     print($this->mustAuthenticatePage());
00069                     die();
00070                 }
00071             }
00072             
00073             // prepare the plugin manager in case we'd like to throw events
00074             $this->_pm =& PluginManager::getPluginManager();            
00075             
00076             // fetch the site locale
00077             $this->_locale =& $this->getLocale();
00078 
00079             $users =& new Users();
00080             $this->_userBlogs = $users->getUsersBlogs( $this->_userInfo->getId(), BLOG_STATUS_ACTIVE );            
00081         }
00082 
00087         function _getBlogInfo()
00088         {
00089             $session = HttpVars::getSession();
00090             $sessionInfo = $session["SessionInfo"];
00091 
00092             $this->_blogInfo = $sessionInfo->getValue( "blogInfo" );
00093         }
00094 
00099         function _getUserInfo()
00100         {
00101             $session = HttpVars::getSession();
00102             $sessionInfo = $session["SessionInfo"];
00103             $this->_userInfo = $sessionInfo->getValue("userInfo");
00104         }
00105 
00110         function &getLocale()
00111         {
00112             // don't like this so much...
00113             if( $this->_blogInfo != "" ) {
00114                 $this->_blogSettings = $this->_blogInfo->getSettings();
00115                 //$locale =& Locales::getLocale( $this->_blogSettings->getValue("locale"));
00116                 $locale =& $this->_blogInfo->getLocale();
00117             }
00118             else {
00119                 $locale =& Locales::getLocale( $this->_config->getValue("default_locale"));
00120             }
00121             
00122             return $locale;
00123         }
00124 
00132         function setCommonData( $copyFormValues = false )
00133         {   
00134             parent::setCommonData( $copyFormValues );
00135 
00136             // initialiaze plugins
00137             $this->_pm->setBlogInfo( $this->_blogInfo );
00138             $this->_pm->setUserInfo( $this->_userInfo );
00139             $this->_pm->getPlugins();           
00140             
00141             $this->_view->setValue( "user", $this->_userInfo );
00142             $this->_view->setValue( "userBlogs", $this->_userBlogs);
00143             $this->_view->setUserInfo( $this->_userInfo );
00144             $this->_view->setValue( "blog", $this->_blogInfo );
00145             $this->_view->setValue( "blogsettings", $this->_blogInfo->getSettings());
00146             $this->_view->setValue( "op", $this->_actionInfo->_actionParamValue );
00147             $this->_view->setValue( "locale", $this->_locale );
00148             $this->_view->setValue( "config", $this->_config );
00149         }
00150 
00155         function saveSession()
00156         {
00157             $this->_session->setValue( "blogInfo", $this->_blogInfo );
00158             $this->_session->setValue( "userInfo", $this->_userInfo );
00159             //$_SESSION["SessionInfo"] = $this->_session;
00160             $session = HttpVars::getSession();
00161             $session["SessionInfo"] = $this->_session;
00162             HttpVars::setSession( $session );
00163         }
00164 
00170         function mustAuthenticatePage()
00171         {
00172             $view = new AdminDefaultView();
00173             $locale = $this->getLocale();
00174             $view->setErrorMessage( $locale->tr("error_access_forbidden" ));
00175             return $view->render();
00176         }
00177         
00187         function notifyEvent( $eventType, $params = Array())
00188         {
00189             $params[ "from" ] = $this->_actionInfo->getActionParamValue();
00190             $params[ "request" ] = $this->_request;
00191             
00192             return $this->_pm->notifyEvent( $eventType, $params );
00193         }
00194     }
00195 ?>