Location: PHPKode > projects > Todo Manager > todo/controllers/project_description.class.php
<?php
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/classes/controller.class.php";
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/classes/database.class.php";
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/classes/activerecord.class.php";
require_once $_SERVER["DOCUMENT_ROOT"]."/".FOLDER."/classes/authentication.class.php";

class ProjectDescription extends Controller {
	var $db;
	var $auth;
	var $project;

	function init() {
		// database connection
		$this->db = new Database(DATABASE_NAME, USER_NAME, PASSWORD);
		
		// authentication
		$this->auth = new Authentication($this->db);
		if (!$this->auth->isLogged())
			$this->redirect("login.php");
		
		// messages
		$this->loadMessages("messages/generic", "es");
		
		// default parameters
		$this->loadParams("project_id");
		$this->project_id = $this->getParam("project_id");
	}
	
	function onGet() {
		// parameters
		$this->project = new ActiveRecord($this->db, "project", $this->project_id);
	}
	
	function getTitle() {
		return $this->project->get("title");
	}
	
	function getStatus() {
		return $this->project->get("status");
	}
	
	function getDescription() {
		return $this->project->get("description");
	}
	
	function getLoginName() {
		$user_id = $this->auth->getUserId();
		$t = new ActiveRecord($this->db, "user", $user_id);
		return $t->get("username");
	}
	
	function getUsers() {
		$ret = array();
		$sql = "
		select
			u.username
		from user u
		inner join project_vs_user pu
			on pu.project_id = ".$this->project_id."
			and pu.user_id = u.id
		order by u.username";
		$result = $this->db->getResult($sql);
		while ($row = $this->db->getRow($result))
			array_push($ret, htmlentities($row["username"]));
			
		if (sizeof($ret) > 0)
			return implode(", ", $ret);
		return "(no hay usuarios en este proyecto)";
	}
}
?>
Return current item: Todo Manager