summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php
blob: 16c10e6fb978dd5a6b257baca76eaf47ad5c926e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

class ProjectDetails extends TPage
{
	private $allUsers = null;
	
	public function onLoad($param)
	{
		if(!$this->IsPostBack)
		{
			$this->manager->DataSource = $this->getUsersWithRole('manager');
			$this->manager->dataBind();
			$this->members->DataSource = $this->getUsersWithRole('consultant');
			$this->members->dataBind();
		}
	}
	
	protected function getUsersWithRole($role)
	{
		if(is_null($this->allUsers))
		{
			$dao = $this->Application->Modules['daos']->getDao('UserDao');
			$this->allUsers = $dao->getAllUsers();		
		}
		$users = array();
		foreach($this->allUsers as $user)
		{
			if($user->isInRole($role))
				$users[] = $user->Name;
		}
		return $users;
	}
}

?>