summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes5
-rw-r--r--demos/time-tracker/protected/application.xml2
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.page4
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/ProjectList.page4
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/ReportProject.page4
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/ReportResource.page4
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/SiteMap.php51
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl14
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/TimeEntry.page4
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserCreate.page12
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserCreate.php18
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/config.xml2
12 files changed, 112 insertions, 12 deletions
diff --git a/.gitattributes b/.gitattributes
index 58dfdb5c..8fc3888a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1107,8 +1107,13 @@ demos/time-tracker/protected/pages/TimeTracker/Logout.page -text
demos/time-tracker/protected/pages/TimeTracker/Logout.php -text
demos/time-tracker/protected/pages/TimeTracker/MainLayout.php -text
demos/time-tracker/protected/pages/TimeTracker/MainLayout.tpl -text
+demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.page -text
+demos/time-tracker/protected/pages/TimeTracker/ProjectList.page -text
+demos/time-tracker/protected/pages/TimeTracker/ReportProject.page -text
+demos/time-tracker/protected/pages/TimeTracker/ReportResource.page -text
demos/time-tracker/protected/pages/TimeTracker/SiteMap.php -text
demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl -text
+demos/time-tracker/protected/pages/TimeTracker/TimeEntry.page -text
demos/time-tracker/protected/pages/TimeTracker/UserCreate.page -text
demos/time-tracker/protected/pages/TimeTracker/UserCreate.php -text
demos/time-tracker/protected/pages/TimeTracker/UserList.page -text
diff --git a/demos/time-tracker/protected/application.xml b/demos/time-tracker/protected/application.xml
index bb1f2fbb..801b6eb3 100644
--- a/demos/time-tracker/protected/application.xml
+++ b/demos/time-tracker/protected/application.xml
@@ -18,6 +18,6 @@
</module>
</modules>
<services>
- <service id="page" class="TPageService" DefaultPage="TimeTracker.UserList"/>
+ <service id="page" class="TPageService" DefaultPage="TimeTracker.TimeEntry"/>
</services>
</application> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.page b/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.page
new file mode 100644
index 00000000..a8a7d1d3
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.page
@@ -0,0 +1,4 @@
+<com:TContent ID="Main">
+<h1>Project Details</h1>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ProjectList.page b/demos/time-tracker/protected/pages/TimeTracker/ProjectList.page
new file mode 100644
index 00000000..1bc50a4b
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/ProjectList.page
@@ -0,0 +1,4 @@
+<com:TContent ID="Main">
+<h1>Projects</h1>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ReportProject.page b/demos/time-tracker/protected/pages/TimeTracker/ReportProject.page
new file mode 100644
index 00000000..699c2544
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/ReportProject.page
@@ -0,0 +1,4 @@
+<com:TContent ID="Main">
+<h1>Project Reports</h1>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ReportResource.page b/demos/time-tracker/protected/pages/TimeTracker/ReportResource.page
new file mode 100644
index 00000000..4d8b7b17
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/ReportResource.page
@@ -0,0 +1,4 @@
+<com:TContent ID="Main">
+<h1>Resource Report</h1>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
index 0b71eb68..1f452894 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
@@ -1,8 +1,57 @@
<?php
+/**
+ * SiteMap template class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $17/07/2006: $
+ * @package Demos
+ */
+/**
+ * SiteMap menu is rendered depending on user roles.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ $17/07/2006: $
+ * @package Demos
+ * @since 3.1
+ */
class SiteMap extends TTemplateControl
{
-
+ /**
+ * Sets the active menu item using css class.
+ */
+ public function onPreRender($param)
+ {
+ parent::onPreRender($param);
+
+ $page = explode('.',$this->Request->ServiceParameter);
+ $active = null;
+ switch($page[count($page)-1])
+ {
+ case 'ProjectList':
+ case 'ProjectDetails':
+ $active = $this->ProjectMenu;
+ break;
+ case 'UserList':
+ case 'UserCreate':
+ $active = $this->AdminMenu;
+ break;
+ case 'ReportProject':
+ case 'ReportResource':
+ $active = $this->ReportMenu;
+ break;
+ case 'TimeEntry':
+ $active = $this->LogMenu;
+ break;
+ }
+
+ //add 'active' string to place holder body.
+ if(!is_null($active))
+ $active->Controls[] = 'active';
+ }
}
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl
index 48187b52..808c233b 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl
+++ b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl
@@ -1,27 +1,33 @@
<com:TPanel CssClass="sitemap" Visible="true">
<ul class="level1">
- <li class="active"><a class="menuitem" href="?page=TimeTracker.TimeEntry">Log</a>
+ <li class="<com:TPlaceHolder ID="LogMenu" />">
+ <a class="menuitem" href="?page=TimeTracker.TimeEntry">Log</a>
</li>
- <li><span class="menuitem">Reports</span>
+ <com:TPlaceHolder Visible=<%= $this->User->isInRole('manager') %> >
+ <li class="<com:TPlaceHolder ID="ReportMenu" />">
+ <span class="menuitem">Reports</span>
<ul class="level2">
<li><a href="?page=TimeTracker.ReportProject">Project Reports</a></li>
<li><a href="?page=TimeTracker.ReportResource">Resources Report</a></li>
</ul>
</li>
- <li>
+ <li class="<com:TPlaceHolder ID="ProjectMenu" />">
<span class="menuitem">Projects</span>
<ul class="level2">
<li><a href="?page=TimeTracker.ProjectDetails">Create New Project</a></li>
<li><a href="?page=TimeTracker.ProjectList">List Projects</a></li>
</ul>
</li>
- <li>
+ </com:TPlaceHolder>
+ <com:TPlaceHolder Visible=<%= $this->User->isInRole('admin') %> >
+ <li class="<com:TPlaceHolder ID="AdminMenu" />">
<span class="menuitem">Adminstration</span>
<ul class="level2">
<li><a href="?page=TimeTracker.UserCreate">Create New User</a></li>
<li><a href="?page=TimeTracker.UserList">List Users</a></li>
</ul>
</li>
+ </com:TPlaceHolder>
</ul>
<com:TClientScript PradoScripts="prado">
Event.OnLoad(function()
diff --git a/demos/time-tracker/protected/pages/TimeTracker/TimeEntry.page b/demos/time-tracker/protected/pages/TimeTracker/TimeEntry.page
new file mode 100644
index 00000000..f934ca02
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/TimeEntry.page
@@ -0,0 +1,4 @@
+<com:TContent ID="Main">
+<h1>Time Entry</h1>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page
index fda7ba9b..41d97391 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page
@@ -56,7 +56,17 @@
ControlToValidate="email"
Display="Dynamic"
ErrorMessage="E-Mail address does not seem to be valid."
- ControlCssClass="required-field" /> </div>
+ ControlCssClass="required-field" />
+ </div>
+ <com:TPanel Visible=<%= $this->User->isInRole('admin') %> >
+ <com:TLabel ForControl="role" Text="New User Role:" />
+ <span class="required">*</span>
+ <com:TDropDownList ID="role">
+ <com:TListItem Text="Administrator" Value="admin,manager,consultant" />
+ <com:TListItem Text="Manager" Value="manager,consultant" />
+ <com:TListItem Text="Consultant" Value="consultant" />
+ </com:TDropDownList>
+ </com:TPanel>
<div class="create">
<com:TButton Text="Create User" OnClick="createNewUser" />
</div>
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
index 49e64458..f163ecd6 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
@@ -54,18 +54,26 @@ class UserCreate extends TPage
$newUser->EmailAddress = $this->email->Text;
$newUser->Name = $this->username->Text;
$newUser->IsGuest = false;
- $newUser->Roles = $this->Application->Parameters['NewUserRoles'];
+ if($this->User->isInRole('admin'))
+ $newUser->Roles = $this->role->SelectedValue;
+ else
+ $newUser->Roles = $this->Application->Parameters['NewUserRoles'];
//save the user
$userDao = $this->Application->Modules['daos']->getDao('UserDao');
$userDao->addNewUser($newUser, $this->password->Text);
//update the user
- $this->User->Manager->updateCredential($newUser);
-
- //return to requested page
- $this->Response->redirect($auth->getReturnUrl());
+ if(!$this->User->isInRole('admin'))
+ {
+ $auth = $this->Application->getModule('auth');
+ $auth->updateCredential($newUser);
+ //return to requested page
+ $this->Response->redirect($auth->getReturnUrl());
+ }
+ else
+ $this->Response->reload();
//goto default page.
//$url = $this->Service->constructUrl($this->Service->DefaultPage);
//$this->Response->redirect($url);
diff --git a/demos/time-tracker/protected/pages/TimeTracker/config.xml b/demos/time-tracker/protected/pages/TimeTracker/config.xml
index 16391c00..4497d9e3 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/config.xml
+++ b/demos/time-tracker/protected/pages/TimeTracker/config.xml
@@ -12,6 +12,8 @@
<authorization>
<allow roles="admin" />
+ <allow pages="ProjectList, ProjectDetails, ReportResource, ReportProject" roles="manager" />
+ <allow pages="TimeEntry" roles="consultant" />
<allow pages="UserCreate,Logout,Login" users="*" />
<deny users="*" />
</authorization>