summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/pages/TimeTracker
diff options
context:
space:
mode:
authorwei <>2006-07-16 06:19:36 +0000
committerwei <>2006-07-16 06:19:36 +0000
commitc7d41e5bea4a5f96979a08da9cc9f79355edfe70 (patch)
tree8f21cba052c1eae7c7204ac272dd8c5e9d6fe110 /demos/time-tracker/protected/pages/TimeTracker
parentaf68030fcf0c266300feb2c100149ecadef7d364 (diff)
Update Time Tracker demo.
Diffstat (limited to 'demos/time-tracker/protected/pages/TimeTracker')
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/Login.page38
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/Login.php53
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/Logout.page0
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/Logout.php34
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/MainLayout.php7
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/MainLayout.tpl40
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/SiteMap.php8
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl43
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserCreate.page65
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserCreate.php78
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserList.page3
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/config.xml24
12 files changed, 393 insertions, 0 deletions
diff --git a/demos/time-tracker/protected/pages/TimeTracker/Login.page b/demos/time-tracker/protected/pages/TimeTracker/Login.page
new file mode 100644
index 00000000..dbc16de1
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/Login.page
@@ -0,0 +1,38 @@
+<%@ Title="My Company - Time Tracker - Site Logon" %>
+<com:TContent ID="Main">
+<h2>Time Tracker Website Login</h2>
+
+<fieldset class="login"><legend>User Login</legend>
+ <div class="username">
+ <com:TLabel ForControl="username" Text="User Name:" />
+ <span class="required">*</span>
+ <com:TTextBox ID="username" />
+ <com:TRequiredFieldValidator
+ ControlToValidate="username"
+ ErrorMessage="Please enter your username."
+ ControlCssClass="required-field" />
+ </div>
+ <div class="password">
+ <com:TLabel ForControl="password" Text="Password:" />
+ <span class="required">*</span>
+ <com:TTextBox ID="password" TextMode="Password" />
+ <com:TRequiredFieldValidator
+ ControlToValidate="password"
+ ErrorMessage="Please enter your password."
+ ControlCssClass="required-field" />
+ </div>
+ <div class="remember">
+ <com:TCheckBox ID="remember" Text="Remember me next time" />
+ </div>
+ <com:TCustomValidator
+ ControlToValidate="password"
+ Display="Dynamic"
+ Text="Your login attempt was not successful. Please try again."
+ OnServerValidate="validateUser" />
+ <div class="signin">
+ <com:TButton Text="Log In" OnClick="doLogin" />
+ </div>
+ <div class="create">
+ <a href="?page=TimeTracker.UserCreate">Create New User</a>
+ </fieldset>
+ </com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/Login.php b/demos/time-tracker/protected/pages/TimeTracker/Login.php
new file mode 100644
index 00000000..376953a5
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/Login.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Login Page 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: $ $16/07/2006: $
+ * @package Demos
+ */
+
+/**
+ * Login page class.
+ *
+ * Validate the user credentials and redirect to requested page
+ * if successful.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ $16/07/2006: $
+ * @package Demos
+ * @since 3.1
+ */
+class Login extends TPage
+{
+ /**
+ * Validates the username and password.
+ * @param TControl custom validator that created the event.
+ * @param TServerValidateEventParameter validation parameters.
+ */
+ public function validateUser($sender, $param)
+ {
+ $authManager=$this->Application->getModule('auth');
+ if(!$authManager->login($this->username->Text,$this->password->Text))
+ $param->IsValid=false;;
+ }
+
+ /**
+ * Redirect to the requested page if login is successful.
+ * @param TControl button control that created the event.
+ * @param TEventParameter event parameters.
+ */
+ public function doLogin($sender, $param)
+ {
+ if($this->Page->IsValid)
+ {
+ $auth = $this->Application->getModule('auth');
+ $this->Response->redirect($auth->getReturnUrl());
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/Logout.page b/demos/time-tracker/protected/pages/TimeTracker/Logout.page
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/Logout.page
diff --git a/demos/time-tracker/protected/pages/TimeTracker/Logout.php b/demos/time-tracker/protected/pages/TimeTracker/Logout.php
new file mode 100644
index 00000000..08fdfaf6
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/Logout.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Logout 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: $ $16/07/2006: $
+ * @package Demos
+ */
+
+/**
+ * Logout page class.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ $16/07/2006: $
+ * @package Demos
+ * @since 3.1
+ */
+class Logout extends TPage
+{
+ /**
+ * Logs out the current user and redirect to default page.
+ */
+ function onLoad($param)
+ {
+ $this->Application->getModule('auth')->logout();
+ $url = $this->Service->constructUrl($this->Service->DefaultPage);
+ $this->Response->redirect($url);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/MainLayout.php b/demos/time-tracker/protected/pages/TimeTracker/MainLayout.php
new file mode 100644
index 00000000..253d6c03
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/MainLayout.php
@@ -0,0 +1,7 @@
+<?php
+
+class MainLayout extends TTemplateControl
+{
+}
+
+?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/MainLayout.tpl b/demos/time-tracker/protected/pages/TimeTracker/MainLayout.tpl
new file mode 100644
index 00000000..2d8bad44
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/MainLayout.tpl
@@ -0,0 +1,40 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<com:THead Title="My Company - Time Tracker - Log" />
+<body>
+
+<com:TForm>
+
+<h1 class="heading">
+ <a href="index.php">My Company
+ <span class="subheading">Time Tracker</span>
+ </a>
+</h1>
+<div class="minheading">
+<h2 class="login">
+ <com:TLabel CssClass="name" Text="Welcome <%= $this->User->Name %>" />
+ <com:THyperLink
+ Text="Login"
+ NavigateUrl=<%= $this->Service->constructUrl('TimeTracker.Login') %>
+ Visible=<%= $this->User->getIsGuest() %> />
+ <com:THyperLink
+ Text="Logout"
+ NavigateUrl=<%= $this->Service->constructUrl('TimeTracker.Logout') %>
+ Visible=<%= !$this->User->getIsGuest() %> />
+</h2>
+<h2 class="help"><a href="?page=Welcome">Help</a></h2>
+<h2 class="guide"><a href="?page=Docs.Home">Implementation Guide</a></h2>
+</div>
+
+<com:Application.pages.TimeTracker.SiteMap
+ Visible=<%= !$this->User->getIsGuest() %> />
+
+<div class="main">
+<com:TContentPlaceHolder ID="Main" />
+</div>
+
+</com:TForm>
+
+</body>
+</html> \ 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
new file mode 100644
index 00000000..0b71eb68
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
@@ -0,0 +1,8 @@
+<?php
+
+class SiteMap extends TTemplateControl
+{
+
+}
+
+?> \ 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
new file mode 100644
index 00000000..48187b52
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl
@@ -0,0 +1,43 @@
+<com:TPanel CssClass="sitemap" Visible="true">
+<ul class="level1">
+ <li class="active"><a class="menuitem" href="?page=TimeTracker.TimeEntry">Log</a>
+ </li>
+ <li><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>
+ <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>
+ <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>
+</ul>
+<com:TClientScript PradoScripts="prado">
+ Event.OnLoad(function()
+ {
+ menuitems = $$(".menuitem");
+ menuitems.each(function(el)
+ {
+ Event.observe(el, "mouseover", function(ev)
+ {
+ menuitems.each(function(item)
+ {
+ Element.removeClassName(item.parentNode, "active");
+ });
+ Element.addClassName(Event.element(ev).parentNode, "active");
+ });
+ });
+ });
+</com:TClientScript>
+</com:TPanel> \ 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
new file mode 100644
index 00000000..fda7ba9b
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page
@@ -0,0 +1,65 @@
+<com:TContent ID="Main">
+<h2>Create New User</h2>
+
+<fieldset class="signup"><legend>User Details</legend>
+ <h4>Sign Up for Your New Account</h4>
+ <div class="username">
+ <com:TLabel ForControl="username" Text="User Name:" />
+ <span class="required">*</span>
+ <com:TTextBox ID="username" />
+ <com:TRequiredFieldValidator
+ ControlToValidate="username"
+ Display="Dynamic"
+ ErrorMessage="Please enter your username."
+ ControlCssClass="required-field" />
+ <com:TCustomValidator
+ ControlToValidate="username"
+ Display="Dynamic"
+ OnServerValidate="checkUsername" />
+ </div>
+ <div class="password">
+ <com:TLabel ForControl="password" Text="Password:" />
+ <span class="required">*</span>
+ <com:TTextBox ID="password" TextMode="Password" />
+ <com:TRequiredFieldValidator
+ ControlToValidate="password"
+ Display="Dynamic"
+ ErrorMessage="Please enter your password (6 or more characters)."
+ ControlCssClass="required-field" />
+ <com:TRegularExpressionValidator
+ ControlToValidate="password"
+ Display="Dynamic"
+ RegularExpression="\w{6,}"
+ ErrorMessage="Please enter 6 or more characters."
+ ControlCssClass="required-field" />
+ </div>
+ <div class="password">
+ <com:TLabel ForControl="password2" Text="Confirm Password:" />
+ <span class="required">*</span>
+ <com:TTextBox ID="password2" TextMode="Password" />
+ <com:TCompareValidator
+ ControlToValidate="password"
+ ControlToCompare="password2"
+ ErrorMessage="The Password and Confirmation Password must match."
+ ControlCssClass="required-field" />
+ </div>
+ <div class="email">
+ <com:TLabel ForControl="email" Text="E-Mail Address:" />
+ <span class="required">*</span>
+ <com:TTextBox ID="email" Style="width:20em"/>
+ <com:TRequiredFieldValidator
+ ControlToValidate="email"
+ Display="Dynamic"
+ ErrorMessage="Please enter your E-Mail address."
+ ControlCssClass="required-field" />
+ <com:TEmailAddressValidator
+ ControlToValidate="email"
+ Display="Dynamic"
+ ErrorMessage="E-Mail address does not seem to be valid."
+ ControlCssClass="required-field" /> </div>
+ <div class="create">
+ <com:TButton Text="Create User" OnClick="createNewUser" />
+ </div>
+</fieldset>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
new file mode 100644
index 00000000..b337bfca
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * UserCreate page 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: $ $16/07/2006: $
+ * @package Demos
+ */
+
+/**
+ * Create new user page class. Validate that the usernames are unique
+ * and set the new user credentials as the current application credentials.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ $16/07/2006: $
+ * @package Demos
+ * @since 3.1
+ */
+class UserCreate extends TPage
+{
+ /**
+ * Verify that the username is not taken.
+ * @param TControl custom validator that created the event.
+ * @param TServerValidateEventParameter validation parameters.
+ */
+ public function checkUsername($sender, $param)
+ {
+ $userDao = $this->Application->Modules['daos']->getDao('UserDao');
+ $user = $userDao->getUserByName($this->username->Text);
+ if(!is_null($user))
+ {
+ $param->IsValid = false;
+ $sender->ErrorMessage =
+ "The user name is already taken, try '{$user->Name}01'";
+ }
+ }
+
+ /**
+ * Create a new user if all data entered are valid.
+ * The default user roles are obtained from "config.xml". The new user
+ * details is saved to the database and the new credentials are used as the
+ * application user. The user is redirected to the requested page.
+ * @param TControl button control that created the event.
+ * @param TEventParameter event parameters.
+ */
+ public function createNewUser($sender, $param)
+ {
+ if($this->IsValid)
+ {
+ $newUser = new TimeTrackerUser($this->User->Manager);
+ $newUser->EmailAddress = $this->email->Text;
+ $newUser->Name = $this->username->Text;
+ $newUser->IsGuest = false;
+ $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
+ $auth = $this->Application->getModule('auth');
+ $auth->updateSessionUser($newUser);
+ $this->Application->User = $newUser;
+
+ //return to requested page
+ $this->Response->redirect($auth->getReturnUrl());
+
+ //goto default page.
+ //$url = $this->Service->constructUrl($this->Service->DefaultPage);
+ //$this->Response->redirect($url);
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserList.page b/demos/time-tracker/protected/pages/TimeTracker/UserList.page
new file mode 100644
index 00000000..48b2bbc7
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserList.page
@@ -0,0 +1,3 @@
+<com:TContent ID="Main">
+<h1>List Users</h1>
+</com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/config.xml b/demos/time-tracker/protected/pages/TimeTracker/config.xml
new file mode 100644
index 00000000..dac6465d
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/config.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+
+ <modules>
+ <!-- user manager module -->
+ <module id="users" class="Application.App_Code.UserManager" />
+ <!-- auth manager module -->
+ <module id="auth" class="System.Security.TAuthManager"
+ UserManager="users" LoginPage="TimeTracker.Login" />
+ </modules>
+
+ <authorization>
+ <allow roles="admin" />
+ <allow pages="UserCreate,Logout,Login" users="*" />
+ <deny users="*" />
+ </authorization>
+
+ <pages MasterClass="Application.pages.TimeTracker.MainLayout" Theme="TimeTracker" />
+
+ <parameters>
+ <parameter id="NewUserRoles" value="admin,manager,consultant" />
+ </parameters>
+</configuration> \ No newline at end of file