Permalink
Browse files

Small simplifications

  • Loading branch information...
flack committed Oct 6, 2017
1 parent 48ebffc commit a84f22103af5fa5b1aa3f194e946181a4c455160
Showing with 8 additions and 20 deletions.
  1. +6 −12 lib/midcom/connection.php
  2. +1 −3 lib/midcom/services/auth/main.php
  3. +1 −5 lib/midcom/services/auth/sessionmgr.php
View
@@ -165,13 +165,10 @@ public static function is_user($person)
*/
public static function get_user()
{
$user = midgard_connection::get_instance()->get_user();
if (!$user) {
return 0;
if ($user = midgard_connection::get_instance()->get_user()) {
return $user->get_person()->id;
}
return $user->get_person()->id;
return 0;
}
/**
@@ -181,13 +178,10 @@ public static function get_user()
*/
public static function is_admin()
{
$user = midgard_connection::get_instance()->get_user();
if (!$user) {
return false;
if ($user = midgard_connection::get_instance()->get_user()) {
return $user->is_admin();
}
return $user->is_admin();
return false;
}
/**
@@ -251,9 +251,7 @@ private function _initialize_user_from_midgard()
if ( midcom_connection::get_user()
&& $user = $this->get_user(midcom_connection::get_user())) {
$this->user = $user;
if (midcom_connection::is_admin()) {
$this->admin = true;
}
$this->admin = midcom_connection::is_admin();
}
}
@@ -382,12 +382,8 @@ public function is_user_online($user)
$qb = new midgard_query_builder('midcom_core_login_session_db');
$qb->add_constraint('userid', '=', $user->id);
$qb->add_constraint('timestamp', '>=', $this->get_timeout());
$result = $qb->execute();
if (!$result) {
return 'offline';
}
return 'online';
return $qb->count() > 0 ? 'online' : 'offline';
}
/**

0 comments on commit a84f221

Please sign in to comment.