<?PHP
/* $Id: mgw.class.inc,v 1.7 2002/04/23 17:06:53 hondzik Exp $ */

// =======================================================
// class holding user rights for each module
// =======================================================

class rights
{
	var $modulename;			// name of module
	var $read;				// read priv.
	var $write;				// write priv.
	var $delete;			// delete priv.
	var $delete_others;		// delete others priv.
	var $modify;			// modify priv.
	var $modify_others;		// modify others priv.
	var $module_level;		// level in spec. module

	function rights($name, $read, $write, $del, $delo, $mod, $modo, $mlevel) {
		$this->modulename = $name;
		if($read==1) $this->read = true; else $this->read = false;
		if($write==1) $this->write = true; else $this->write = false;
		if($del==1) $this->delete = true; else $this->delete = false;
		if($delo==1) $this->delete_others = true; else $this->delete_others = false;
		if($mod==1) $this->modify = true; else $this->modify = false;
		if($modo==1) $this->modify_others = true; else $this->modify_others = false;
		$this->module_level = $mlevel;
	}
}	

// =======================================================
// class holding user/application attributes for moregw
// =======================================================

class mgw
{
	var $spkz;					// languagecode which the user selected (for example en=english)
	var $fullusername;			// full name (first and lastname of user logged on)
	var $username;				// username of user logged on
	var $userid;				// userid of user logged on
	var $login;					// his login
	var $password;				// his pw
	var $charset;				// current HTML charset based on selected language

	var $rights = array();		// user rights (rights-object-array)
	var $settings = array(); 	// user settings (asoc. Array)
	
	var $post = array();		// asco. Array with actual post vars
	var $get = array();			// asco. Array with actual get vars
	
	function mgw() {}
	
	function setRights($rightsobj, $modulename) {
		if(isset($this->rights[$modulename])) {
			//
			// allready defined rights for this module
			// now check if the rights are better and add them
			// if necessary
			//
			if(!$this->rights[$modulename]->read)
				$this->rights[$modulename]->read = $rightsobj->read;
			if(!$this->rights[$modulename]->write)
				$this->rights[$modulename]->write = $rightsobj->write;
			if(!$this->rights[$modulename]->delete)
				$this->rights[$modulename]->delete = $rightsobj->delete;
			if(!$this->rights[$modulename]->delete_others)
				$this->rights[$modulename]->delete_others = $rightsobj->delete_others;
			if(!$this->rights[$modulename]->modify)
				$this->rights[$modulename]->modify = $rightsobj->modify;
			if(!$this->rights[$modulename]->modify_others)
				$this->rights[$modulename]->modify_others = $rightsobj->modify_others;
			if($this->rights[$modulename]->module_level < $rightsobj->module_level)
				$this->rights[$modulename]->module_level = $rightsobj->module_level;
		}
		else {
			// 
			// no rights available so far for this module
			// so just append this rights (no matter how bad they are :))
			//
			$this->rights[$modulename] = $rightsobj;
		}
	}
}
?>