Location: PHPKode > scripts > Todolist.php > Todolist.php-0.9.15.4/include/user.inc.php
<?php
/**
 * A class representing a User (and his session-data)
 */
class User {
	/** is this user an admin?
	 */
	var $is_admin;
	/** the users preferred language
	 */
	var $lang;
	/**
	 * stores all the projects a user is member of.
	 */
	var $my_projects;
	/**
	 * show only the tasks that are assigned to the user, or all?
	 */
	var $my_tasks;
	/**
	 * the users primary-project (the project to display after login)
	 */
	var $primary_project;
	/**
	 * the project selected at the moment
	 */
	var $selected_project;
	/**
         * show done tasks
         */
	var $show_done;
	/**
	 * the real name of the user
	 */
	var $realname;
	/**
	 * Does the user want to see icons?
	 */
	var $show_icons;
	/**
	 * DB-ID
	 */
	var $userid;

	/**
	 * Array which columns to show
	 */
	var $m_columns;
	
	/** Default-Constructor
	 */

	function User() {
		$this->m_columns=array (
				COLUMN_CHANGED_ON,
				COLUMN_COUNTER,
				COLUMN_DUE,
				COLUMN_NR_NOTES,
				COLUMN_PERCENTAGE,
				COLUMN_PRIORITY,
				COLUMN_RESPONSIBLE,
				COLUMN_STATUS,
				COLUMN_TEXT,
				COLUMN_PROJECT
				);

		$this->userid=false;
	}

	/**
	 * Check if user is an admin
	 */
	function isAdmin(){
		if ($this->is_admin == 1)
			return true;
		else
			return false;
	}

	/**
	 * get the name of the user
	 */
	function getRealName(){
		return $this->realname;
	}

	/**
	 * Check if user is member of that project, or not
	 */
	function isMemberOfProject($project_id){
		return in_array("$project_id", explode (",", substr($this->my_projects, 1, -1)));
	}

	/**
	 * Get the first project a User is member of
	 */
	function getFirstProject(){
		if (strpos($this->my_projects,',') === false) {
			// The user is member of <= 1 Project. TODO: no projects?!?!
			return substr($this->my_projects, 1, -1);
		} else {
			return substr($this->my_projects, 1, strpos($this->my_projects,',')-1);
		}
	}

	/**
	 * Does the user want to see icons?
	 */
	function showIcons(){
		if ($this->show_icons == 1)
			return true;
		else
			return false;
	}

	/**
	 * setColumns
	 * @param string the columns encoded as 1,2,3,4
	 */
	function setColumns($columns){
		if (is_array($columns)) {
			$this->m_columns = $columns;
		}
	}

	/**
	 * getColumns
	 * @return Array
	 */
	function getColumns(){
		return $this->m_columns;
	}

	/**
	 * Does the user want to see this column?
	 *
	 * @param	int		The constant of the column
	 * @return	boolean
	 */
	function showColumn($column){
		return in_array($column, $this->m_columns);
	}

	/**
	 * Show only the user's tasks?
	 * @return	boolean
	 */
	function showMyTasks(){
		if ($this->my_tasks == 1)
			return true;
		else
			return false;
	}

	/**
	 * get the id of that user
	 * @return	int
	 */
	function getUserid(){
		return $this->userid;
	}

}
/* vim: set si tw=110 ts=4 sw=4: */
?>
Return current item: Todolist.php