Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

some formatting and changed message session key

  • Loading branch information...
commit 62a0ec525db1ffb62ee76bd4c3dfcbd7d23d4e64 1 parent 670a214
@rafsoaken authored
View
22 classes/useradmin/controller/app.php
@@ -92,29 +92,31 @@ public function before()
{
session_destroy();
}
+
// Execute parent::before first
parent::before();
+
// Open session
$this->session = Session::instance();
//if we're not logged in, but auth type is orm. gives us chance to auto login
- $supports_auto_login = new ReflectionClass(get_class(Auth::instance()));
- $supports_auto_login = $supports_auto_login->hasMethod('auto_login');
- if(!Auth::instance()->logged_in() && $supports_auto_login){
+ $auth_class_inspector = new ReflectionClass(get_class(Auth::instance()));
+
+ if(!Auth::instance()->logged_in() && $auth_class_inspector->hasMethod('auto_login'))
+ {
Auth::instance()->auto_login();
}
// Check user auth and role
- $action_name = Request::current()->action();
- if
- (
+ $action_name = Request::$current->action();
+ if (
// auth is required AND user role given in auth_required is NOT logged in
( $this->auth_required !== FALSE && Auth::instance()->logged_in($this->auth_required) === FALSE ) ||
// OR secure_actions is set AND the user role given in secure_actions is NOT logged in
( is_array($this->secure_actions) && array_key_exists($action_name, $this->secure_actions) && Auth::instance()->logged_in($this->secure_actions[$action_name]) === FALSE )
)
{
- if (Auth::instance()->logged_in())
+ if ( Auth::instance()->logged_in() )
{
// user is logged in but not on the secure_actions list
$this->access_required();
@@ -124,7 +126,8 @@ public function before()
$this->login_required();
}
}
- if ($this->auto_render)
+
+ if ( $this->auto_render )
{
// only load the template if the template has not been set..
$this->template = View::factory($this->template);
@@ -166,10 +169,11 @@ public function after()
// Display profile if its enabled and request by query profile
$this->template->profile = (isset($_REQUEST['profile']) && Kohana::$profiling)?"<div id=\"kohana-profiler\">".View::factory('profiler/stats')."</div>":"";
-
+
// Assign the template as the request response and render it
$this->response->body($this->template);
}
parent::after();
+
}
}
View
4 classes/useradmin/controller/user.php
@@ -324,7 +324,8 @@ public function action_login()
{
$this->auto_render = false;
$this->request->headers('Content-Type', 'application/json');
- if (Auth::instance()->logged_in() != 0)
+
+ if ( Auth::instance()->logged_in() != 0 )
{
$this->response->status(200);
$this->template->content = $this->request->body('{ "success": "true" }');
@@ -339,6 +340,7 @@ public function action_login()
return;
}
}
+
$this->response->status(500);
$this->template->content = $this->request->body('{ "success": "false" }');
return;
View
30 classes/useradmin/message.php
@@ -2,34 +2,41 @@
class Useradmin_Message {
+ /*
+ * the session key we use to store useradmin messages
+ */
+ public static $messages_session_key = 'useradmin_messages';
+
public static function add($type, $message)
{
- // get session messages
- $messages = Session::instance()->get('messages');
- // initialize if necessary
+ // get session messages
+ $messages = Session::instance()->get(self::$messages_session_key);
+ // initialize if necessary
if (! is_array($messages))
{
$messages = array();
}
- // append to messages
+ // append to messages
$messages[$type][] = $message;
- // set messages
- Session::instance()->set('messages', $messages);
+ // set messages
+ Session::instance()->set(self::$messages_session_key, $messages);
}
public static function count()
{
- return count(Session::instance()->get('messages'));
+ return count(Session::instance()->get(self::$messages_session_key));
}
public static function output()
{
$str = '';
- $messages = Session::instance()->get('messages');
- Session::instance()->delete('messages');
- if (! empty($messages))
+ $messages = Session::instance()->get(self::$messages_session_key);
+
+ Session::instance()->delete(self::$messages_session_key);
+
+ if ( !empty($messages) )
{
- foreach ($messages as $type => $messages)
+ foreach ( $messages as $type => $messages )
{
foreach ($messages as $message)
{
@@ -37,6 +44,7 @@ public static function output()
}
}
}
+
return $str;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.