Ejemplo n.º 1
0
 public static function set_location(midgardmvc_helper_location_spot $location)
 {
     $midcom = midgardmvc_core::get_instance();
     if ($midcom->authentication->is_user()) {
         // Set to user's location log
         return midgardmvc_helper_location_user::set_location_for_person($location, $midcom->authentication->get_person());
     }
     // Set to session
     $session = new midgardmvc_core_services_sessioning('midgardmvc_helper_location_user');
     return $session->set('location', $location);
 }
Ejemplo n.º 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();
 }