summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/pages
diff options
context:
space:
mode:
Diffstat (limited to 'demos/time-tracker/protected/pages')
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/SiteMap.php2
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserCreate.page136
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserCreate.php64
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserList.page30
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserList.php34
5 files changed, 185 insertions, 81 deletions
diff --git a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
index 1f452894..1beed757 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
@@ -43,7 +43,7 @@ class SiteMap extends TTemplateControl
case 'ReportResource':
$active = $this->ReportMenu;
break;
- case 'TimeEntry':
+ default:
$active = $this->LogMenu;
break;
}
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page
index 41d97391..edc22bcd 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.page
@@ -2,74 +2,86 @@
<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>
- <com:TPanel Visible=<%= $this->User->isInRole('admin') %> >
+<com:TWizard ID="CreateUserWizard"
+ UseDefaultLayout="false"
+ NavigationStyle.CssClass="wizardNav"
+ OnNextButtonClick="userWizardNextStep"
+ OnCompleteButtonClick="createNewUser"
+ ShowSideBar="false" >
+ <com:TWizardStep>
+ <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>
+ </com:TWizardStep>
+ <com:TWizardStep>
<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>
+ </com:TDropDownList>
+ </com:TWizardStep>
+ <com:TWizardStep StepType="Complete">
+ New account has been successfully created.
+ <com:TPanel Visible=<%= !$this->User->isInRole('admin') %> CssClass="wizardNav">
+ <com:TButton Text="Continue" OnClick="wizardCompleted"/>
+ </com:TPanel>
+ </com:TWizardStep>
+</com:TWizard>
</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
index f163ecd6..ed8ea4f1 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
@@ -11,8 +11,10 @@
*/
/**
- * Create new user page class. Validate that the usernames are unique
- * and set the new user credentials as the current application credentials.
+ * Create new user wizard page class. Validate that the usernames are unique and
+ * set the new user credentials as the current application credentials.
+ *
+ * If logged in as admin, the user role can be change during creation.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Revision: $ $16/07/2006: $
@@ -22,6 +24,18 @@
class UserCreate extends TPage
{
/**
+ * Sets the default new user roles, default role is set in config.xml
+ */
+ public function onLoad($param)
+ {
+ if(!$this->IsPostBack)
+ {
+ $this->role->SelectedValue =
+ $this->Application->Parameters['NewUserRoles'];
+ }
+ }
+
+ /**
* Verify that the username is not taken.
* @param TControl custom validator that created the event.
* @param TServerValidateEventParameter validation parameters.
@@ -29,12 +43,27 @@ class UserCreate extends TPage
public function checkUsername($sender, $param)
{
$userDao = $this->Application->Modules['daos']->getDao('UserDao');
- $user = $userDao->getUserByName($this->username->Text);
- if(!is_null($user))
+ if($userDao->usernameExists($this->username->Text))
{
$param->IsValid = false;
$sender->ErrorMessage =
- "The user name is already taken, try '{$user->Name}01'";
+ "The user name is already taken, try '{$this->username->Text}01'";
+ }
+ }
+
+ /**
+ * Skip the role assignment step if not admin.
+ */
+ public function userWizardNextStep($sender, $param)
+ {
+ if($param->CurrentStepIndex == 0)
+ {
+ //create user with admin credentials
+ if(!$this->User->isInRole('admin'))
+ {
+ $this->createNewUser($sender, $param);
+ $param->NextStepIndex = 2;
+ }
}
}
@@ -54,31 +83,30 @@ class UserCreate extends TPage
$newUser->EmailAddress = $this->email->Text;
$newUser->Name = $this->username->Text;
$newUser->IsGuest = false;
- if($this->User->isInRole('admin'))
- $newUser->Roles = $this->role->SelectedValue;
- else
- $newUser->Roles = $this->Application->Parameters['NewUserRoles'];
+ $newUser->Roles = $this->role->SelectedValue;
//save the user
$userDao = $this->Application->Modules['daos']->getDao('UserDao');
$userDao->addNewUser($newUser, $this->password->Text);
- //update the user
+ //update the user credentials if not admin
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);
}
}
+
+ /**
+ * Continue with requested page.
+ */
+ public function wizardCompleted($sender, $param)
+ {
+ //return to requested page
+ $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/UserList.page b/demos/time-tracker/protected/pages/TimeTracker/UserList.page
index 48b2bbc7..f0c88112 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/UserList.page
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserList.page
@@ -1,3 +1,33 @@
<com:TContent ID="Main">
<h1>List Users</h1>
+<fieldset>
+ <legend>User List</legend>
+
+ <com:TRepeater ID="list" EnableViewState="false">
+ <prop:HeaderTemplate>
+ <table cellpadding="2">
+ <tr class="header">
+ <th>User Name</th>
+ <th>E-Mail Address</th>
+ </tr>
+ </prop:HeaderTemplate>
+ <prop:ItemTemplate>
+ <tr class="row0">
+ <td><%#$this->DataItem->Name %></td>
+ <td><%#$this->DataItem->EmailAddress %></td>
+ </tr>
+ </prop:ItemTemplate>
+ <prop:AlternatingItemTemplate>
+ <tr class="row1">
+ <td><%#$this->DataItem->Name %></td>
+ <td><%#$this->DataItem->EmailAddress %></td>
+ </tr>
+ </prop:AlternatingItemTemplate>
+ <prop:FooterTemplate>
+ </table>
+ </prop:FooterTemplate>
+</com:TRepeater>
+<div style="padding:1em">
+ <a href="?page=TimeTracker.UserCreate">Create New User</a>
+</div>
</com:TContent> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserList.php b/demos/time-tracker/protected/pages/TimeTracker/UserList.php
new file mode 100644
index 00000000..175a731a
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserList.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * UserList 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: $ $18/07/2006: $
+ * @package Demos
+ */
+
+/**
+ * List all users in a repeater.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ $18/07/2006: $
+ * @package Demos
+ * @since 3.1
+ */
+class UserList extends TPage
+{
+ /**
+ * Load all the users and display them in a repeater.
+ */
+ function onLoad($param)
+ {
+ $userDao = $this->Application->Modules['daos']->getDao('UserDao');
+ $this->list->DataSource = $userDao->getAllUsers();
+ $this->list->dataBind();
+ }
+}
+
+?> \ No newline at end of file