diff options
author | wei <> | 2006-07-17 23:19:39 +0000 |
---|---|---|
committer | wei <> | 2006-07-17 23:19:39 +0000 |
commit | 319df8f534520c8c926d0cdaa1f5577c7bd8a909 (patch) | |
tree | 743a3a2e3e7092e0f474baf8592b3ba3824fc506 /demos | |
parent | b230beea20bc18f05d51b8e1f76c99c74a12fff4 (diff) |
Update time-tracker application
Diffstat (limited to 'demos')
11 files changed, 107 insertions, 12 deletions
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 © 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>
|