<?php
	/**
	 * Simple user message system class.
	 * 
	 * @link http://www.oldauntie.org
	 * @author Maggie Marple <oldauntie@oldauntie.org>
	 * @version 1.0
	 */
	class Message{
		const MESSAGE_TYPE_DANGER	= 'danger';
		const MESSAGE_TYPE_WARNING	= 'warning';
		const MESSAGE_TYPE_INFO		= 'info';
		const MESSAGE_TYPE_SUCCESS	= 'success';
		
		
		/**
         * Creates a new Connection object.
         *
         * @param string $dbUser the user who connet to the database
         * @param string $dbPwd the password who connet to the database
         * @param string $dbName the database name to connect to
         * @param string $dbName the database host
         * @param boolean $autocommit set it to true if you don't want to change transaction isolation model
         * 
         */
		function __construct($message = '', $type = 'danger'){
			if(isset($message) == true && empty($message) == false){
				$this->set($message, $type);
			}
		}
		
		
		static function set($message, $type){
			$_SESSION['message'][] = array ('message' => $message, 'type' => $type);

		}
		
		
		static function get(){
			if(isset($_SESSION['message']) == true && empty($_SESSION['message']) == false){
				return $_SESSION['message'];
			}else{
				return false;
			}
		}
		
				
		static function reset(){
			$_SESSION['message'] = array();
		}
	}
