Example #1
0
 /**
  * @return	void
  */
 public function action_index()
 {
     $this->template->content->active = "options";
     $this->template->header->title = $this->river['name'] . ' ~ ' . __('Settings');
     $this->template->content->settings_content = View::factory('pages/river/settings/options');
     $this->template->content->settings_content->river = $this->river;
     $session = Session::instance();
     if ($this->request->method() == "POST") {
         try {
             $river_name = $this->request->post('river_name');
             $river_description = $this->request->post('river_description');
             $river_public = $this->request->post('river_public');
             $river = $this->river_service->update_river($this->river['id'], $river_name, $river_description, $river_public);
             // Redirect to the new URL with a success messsage
             Swiftriver_Messages::add_message('success', 'Success', __("River display settings were saved successfully."));
             $this->redirect($this->river_service->get_base_url($river) . '/settings', 302);
         } catch (SwiftRiver_API_Exception_BadRequest $e) {
             Kohana::$log->add(Log::DEBUG, var_export($e->get_errors(), TRUE));
             foreach ($e->get_errors() as $error) {
                 if ($error['field'] == 'name' && $error['code'] == 'duplicate') {
                     Swiftriver_Messages::add_message('failure', 'Failure', __("A river with the name ':name' already exists.", array(':name' => $river_name)), false);
                 }
             }
             $this->redirect($this->river_base_url . '/settings', 302);
         }
     }
 }
Example #2
0
 /**
  * Activates a newly created account
  * 
  * @return void
  */
 public function action_activate()
 {
     $email = $this->request->query('email');
     $token = $this->request->query('token');
     if (!isset($email) or !isset($token)) {
         $this->redirect('login', 302);
     }
     try {
         $this->account_service->activate_account($email, $token);
     } catch (SwiftRiver_API_Exception_BadRequest $e) {
         foreach ($e->get_errors() as $error) {
             $message = "Error";
             if ($error['field'] == 'token' and $error['code'] == 'invalid') {
                 $message = __('Account not found.');
             }
             Swiftriver_Messages::add_message('failure', __('Failure'), $message, FALSE);
         }
         $this->redirect(URL::site('login'), 302);
     } catch (SwiftRiver_API_Exception_NotFound $e) {
         Swiftriver_Messages::add_message('failure', __('Failure'), __('Account not found.'), FALSE);
         $this->redirect(URL::site('login'), 302);
     }
     Swiftriver_Messages::add_message('success', __('Success'), __('Account activated. Proceed to log in.'), FALSE);
     $this->redirect(URL::site('login'), 302);
 }