[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/action/admin/ -> adminupdateglobalsettingsaction.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/view/admin/adminglobalsettingslistview.class.php" );
   5  
   6      /**
   7       * \ingroup Action
   8       * @private
   9       *
  10       * Updates the settings of the site
  11       */
  12      class AdminUpdateGlobalSettingsAction extends AdminAction 
  13      {
  14  
  15          var $_newConfigOpts;
  16  
  17      	function AdminUpdateGlobalSettingsAction( $actionInfo, $request )
  18          {
  19              $this->AdminAction( $actionInfo, $request );
  20  
  21              $this->requireAdminPermission( "update_global_settings" );
  22          }
  23  
  24          function validate()
  25          {
  26              // all the seettings come from a very nice array from the html form
  27              $this->_newConfigOpts = Array();
  28              $this->_newConfigOpts = $this->_request->getValue( "config" );
  29  
  30              // the xmlrpc_ping_hosts requires special treatment, since we need to
  31              // split the input returned from the textbox into an array
  32              if( isset( $this->_newConfigOpts["xmlrpc_ping_hosts"])) {
  33                  $array = Array();
  34                  foreach(explode( "\r\n", $this->_newConfigOpts["xmlrpc_ping_hosts"] ) as $host ) {
  35                      trim($host);
  36                      if( $host != "" && $host != "\r\n" && $host != "\r" && $host != "\n" )
  37                          array_push( $array, $host );
  38                  }
  39                  $this->_newConfigOpts["xmlrpc_ping_hosts"] = $array;
  40              }
  41  
  42              // the 'locales' and 'arrays' settings are not coming from the request
  43              $configOpts = $this->_config->getAsArray();
  44              $locales = new Locales();
  45              $this->_newConfigOpts["locales"] = $locales->getAvailableLocales();
  46              $this->_newConfigOpts["templates"] = $configOpts["templates"];
  47              
  48              // the default_blog_id setting is coming from a chooser, so it won't be automatically picked up
  49              $blogId = $this->_request->getValue( "blogId" );
  50              if($blogId)
  51                  $this->_newConfigOpts["default_blog_id"] = $blogId;
  52  
  53              return true;
  54          }
  55  
  56          function perform()
  57          {
  58              // get the global setting section
  59              $show = $this->_request->getValue( "show" );
  60              
  61              // we can proceed to update the config
  62              foreach( $this->_newConfigOpts as $key => $value ) {
  63                  $this->_config->setValue( $key, $value );
  64              }
  65              // and finally save everything
  66              $res = $this->_config->save();
  67  
  68              // depending on the result, we shall show one thing or another...
  69              if( $res ) {
  70                  $this->_view = new AdminGlobalSettingsListView( $this->_blogInfo, $show );
  71                  $this->_view->setSuccessMessage( $this->_locale->tr("site_config_saved_ok"));
  72                  $this->setCommonData();
  73                  // clear the contents of all the caches
  74                  CacheControl::resetAllCaches();
  75              }
  76              else {
  77                  $this->_view = new AdminGlobalSettingsListView( $this->_blogInfo, $show );
  78                  $this->_view->setErrorMessage( $this->_locale->tr("error_saving_site_config"));
  79                  $this->setCommonData();
  80              }
  81  
  82              return $res;
  83          }
  84      }
  85  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics