Advertisement
mobal

Untitled

Mar 3rd, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. public function action_general()
  2. {
  3.     // New settings model.
  4.     $this->model = new Model_Settings;
  5.    
  6.     // Check for post.
  7.     if(HTTP_Request::POST == $this->request->method())
  8.     {
  9.         // Get current session instance.
  10.         $this->session = Session::instance();
  11.        
  12.         // Copy post array.
  13.         $update_info = $this->request->post();
  14.        
  15.         // Remove.
  16.         array_pop($update_info);
  17.        
  18.         // Update options.
  19.         try
  20.         {
  21.             // Update settingses.
  22.             $this->model->update_settings($update_info);
  23.            
  24.             // Set notification message.
  25.             $this->session->set('warning_message', 'Settings saved successfully!');
  26.         }
  27.         catch(Exception $e)
  28.         {
  29.             // Update failed. Set error message.
  30.             $this->session->set('error_message', 'Update failed: Failed to save settings.');
  31.         }
  32.        
  33.         $this->redirect($this->request->uri());
  34.     }
  35.    
  36.     // Set template title.
  37.     $this->template->set('title', 'General settings');
  38.        
  39.     // Set content.
  40.     $this->content = View::factory('administration/settings/index')
  41.         ->set('settings', ORM::factory('Settings')->find_all()->as_array('name', 'value'));
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement