public static function get_location(midgard_datetime $when = null)
 {
     $midcom = midgardmvc_core::get_instance();
     if ($midcom->authentication->is_user()) {
         // Get from user's location log
         return midgardmvc_helper_location_user::get_location_for_person($midcom->authentication->get_person(), $when);
     }
     // Get from session
     $session = new midgardmvc_core_services_sessioning('midgardmvc_helper_location_user');
     if (!$session->exists('location')) {
         return null;
     }
     return $session->get('location');
 }
Example #2
0
 /**
  * Store unshown UI messages from the stack to user session.
  */
 public function store()
 {
     if (count($this->message_stack) == 0) {
         // No unshown messages
         return true;
     }
     // We have to be careful what messages to store to session to prevent them
     // from accumulating
     $messages_to_store = array();
     foreach ($this->message_stack as $id => $message) {
         // Check that the messages were not coming from earlier session
         if (!in_array($id, $this->messages_from_session)) {
             $messages_to_store[$id] = $message;
         }
     }
     if (count($messages_to_store) == 0) {
         // We have only messages coming from earlier sessions, and we ditch those
         return true;
     }
     $session = new midgardmvc_core_services_sessioning('midgardmvc_services_uimessages');
     // Check if some other request has added stuff to session as well
     if ($session->exists('midgardmvc_services_uimessages_stack')) {
         $old_stack = $session->get('midgardmvc_services_uimessages_stack');
         $messages_to_store = array_merge($old_stack, $messages_to_store);
     }
     $session->set('midgardmvc_services_uimessages_stack', $messages_to_store);
     $this->message_stack = array();
 }