summaryrefslogtreecommitdiffstats
path: root/apps/admin/modules/user
diff options
context:
space:
mode:
Diffstat (limited to 'apps/admin/modules/user')
-rw-r--r--apps/admin/modules/user/actions/actions.class.php115
-rw-r--r--apps/admin/modules/user/config/generator.yml55
-rw-r--r--apps/admin/modules/user/config/security.yml13
-rw-r--r--apps/admin/modules/user/templates/_domain_permissions.php27
-rw-r--r--apps/admin/modules/user/templates/_last_login.php1
-rw-r--r--apps/admin/modules/user/templates/_password.php3
-rw-r--r--apps/admin/modules/user/templates/_password1.php3
-rw-r--r--apps/admin/modules/user/templates/_password2.php3
-rw-r--r--apps/admin/modules/user/templates/_role_id.php1
-rw-r--r--apps/admin/modules/user/templates/loginSuccess.php12
-rw-r--r--apps/admin/modules/user/templates/settingsSuccess.php22
-rw-r--r--apps/admin/modules/user/validate/create.yml37
-rw-r--r--apps/admin/modules/user/validate/edit.yml40
-rw-r--r--apps/admin/modules/user/validate/login.yml24
-rw-r--r--apps/admin/modules/user/validate/settings.yml43
15 files changed, 399 insertions, 0 deletions
diff --git a/apps/admin/modules/user/actions/actions.class.php b/apps/admin/modules/user/actions/actions.class.php
new file mode 100644
index 0000000..1af2445
--- /dev/null
+++ b/apps/admin/modules/user/actions/actions.class.php
@@ -0,0 +1,115 @@
+<?php
+
+/**
+ * user actions.
+ *
+ * @package mailadmin
+ * @subpackage user
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
+ */
+class userActions extends autouserActions
+{
+ public function executeList()
+ {
+ // pageination
+ if($this->hasRequestParameter("max_per_page"))
+ $this->getUser()->setResultsPerPage($this->getRequestParameter("max_per_page"));
+
+ return parent::executeList();
+ }
+
+ public function executeCreate()
+ {
+ // populate preset values
+ $user = $this->getRequestParameter('user');
+ $user["parent_user_id"] = $this->getUser()->getId();
+ $this->getRequest()->setParameter('user', $user);
+
+ $this->setTemplate("edit");
+ return $this->executeEdit();
+ }
+
+ public function handleErrorCreate()
+ {
+ // populate preset values
+ $user = $this->getRequestParameter('user');
+ $user["parent_user_id"] = $this->getUser()->getId();
+ $this->getRequest()->setParameter('user', $user);
+
+ $this->setTemplate("edit");
+ return $this->handleErrorEdit();
+ }
+
+ public function executeLogin()
+ {
+ if($this->getRequest()->getMethod() != sfRequest::POST)
+ {
+ $this->getRequest()->setAttribute('referer', $this->getRequest()->getReferer());
+
+ return sfView::SUCCESS;
+ }
+ else
+ {
+ return $this->redirect($this->getRequestParameter('referer', '@homepage'));
+ }
+ }
+
+ public function handleErrorLogin()
+ {
+ return sfView::SUCCESS;
+ }
+
+ public function executeSettings()
+ {
+ $user = UserPeer::retrieveByPK($this->getUser()->getId());
+ $this->user = $user;
+
+ if($this->getRequest()->getMethod() != sfRequest::POST)
+ {
+ $this->getRequest()->setAttribute('referer', $this->getRequest()->getReferer());
+ }
+ else
+ {
+ if($this->getRequest()->getParameter("commit") == "Cancel")
+ return $this->redirect($this->getRequestParameter('referer', '@homepage'));
+
+ // update record
+ $user->setNickname($this->getRequestParameter("nickname"));
+ $user->setFirstName($this->getRequestParameter("first_name"));
+ $user->setLastName($this->getRequestParameter("last_name"));
+ $user->setEmail($this->getRequestParameter("email"));
+
+ // set new password
+ $password = $this->getRequestParameter("password2");
+ if($password != "")
+ $user->setPassword($password);
+
+ $user->save();
+
+ // update session
+ $this->getUser()->updateUserAttributes($user);
+
+ return $this->redirect($this->getRequestParameter('referer', '@homepage'));
+ }
+
+ return sfView::SUCCESS;
+ }
+
+ public function handleErrorSettings()
+ {
+ $user = UserPeer::retrieveByPK($this->getUser()->getId());
+ $this->user = $user;
+
+ if($this->getRequest()->getParameter("commit") == "Cancel")
+ return $this->redirect($this->getRequestParameter('referer', '@homepage'));
+
+ return sfView::SUCCESS;
+ }
+
+ public function executeLogout()
+ {
+ $this->getUser()->signOut($user);
+ $this->redirect("@homepage");
+ }
+}
diff --git a/apps/admin/modules/user/config/generator.yml b/apps/admin/modules/user/config/generator.yml
new file mode 100644
index 0000000..4764f5b
--- /dev/null
+++ b/apps/admin/modules/user/config/generator.yml
@@ -0,0 +1,55 @@
+generator:
+ class: sfPropelAdminGenerator
+ param:
+ model_class: User
+ theme: mailadmin
+
+ fields:
+ nickname: { name: Nickname }
+ full_name: { name: Name }
+ email: { name: E-Mail }
+ last_login: { name: Last Login }
+
+ list:
+ peer_method: doSelectJoinRole
+ title: List of Administrators
+ display: [=nickname, _role_id, _domain_permissions, full_name, email, _last_login]
+ filters: [nickname, role_id, email, parent_user_id, last_login, created_at]
+ max_per_page: '$this->getUser()->getResultsPerPage("pager")'
+ sort: [nickname, asc]
+ fields:
+ domain_permissions: { name: Associated Domains, params: align=left }
+ nickname: { params: align=left }
+ role_id: { params: align=left }
+ full_name: { params: align=left }
+ email: { params: align=left }
+ last_login: { params: align=right }
+ object_actions:
+ edit: { name: Edit, action: edit, icon: edit.gif }
+ delete: { name: Delete, action: delete, icon: trash.gif, params: confirm=Are you sure? }
+ actions: {}
+
+ create:
+ title: Create New Administrator
+
+ edit:
+ title: 'Editing Administrator %%nickname%%'
+ display:
+ 'General Settings': [nickname, first_name, last_name, email, parent_user_id]
+ 'Password Settings': [_password, _password2]
+ 'Permissions': [role_id, domain_permission]
+ fields:
+ domain_permission: { name: Assign Domains, type: admin_double_list, params: through_class=DomainPermission, help: Assign which domains the user is allowed to see (Ignored for superadmins) }
+ parent_user_id: { name: Parent User, only_for: edit }
+ nickname: { name: Nickname, params: size=50 }
+ first_name: { name: First Name, params: size=50 }
+ last_name: { name: Last Name, params: size=50 }
+ email: { name: E-Mail, params: size=50, help: Used for password requests or notifications }
+ role_id: { name: Role }
+ password: { name: Desired Password }
+ password2: { name: Re-Type New Password, only_for: edit, help: Leave blank if you do not want to change the password }
+ actions:
+ _save_and_list: { name: Save }
+ _save_and_add: { name: 'Save, then create new one' }
+ _list: { name: Cancel }
+
diff --git a/apps/admin/modules/user/config/security.yml b/apps/admin/modules/user/config/security.yml
new file mode 100644
index 0000000..dbe3ebb
--- /dev/null
+++ b/apps/admin/modules/user/config/security.yml
@@ -0,0 +1,13 @@
+settings:
+ is_secure: on
+ credentials: []
+
+login:
+ is_secure: off
+
+logout:
+ is_secure: off
+
+all:
+ is_secure: on
+ credentials: [superadmin]
diff --git a/apps/admin/modules/user/templates/_domain_permissions.php b/apps/admin/modules/user/templates/_domain_permissions.php
new file mode 100644
index 0000000..0d3e19d
--- /dev/null
+++ b/apps/admin/modules/user/templates/_domain_permissions.php
@@ -0,0 +1,27 @@
+<?php use_helper('I18N','Javascript'); ?>
+<?php if($user->getRoleId() == Role::SUPERADMIN): ?>
+<?php echo "All Domains" ?>
+<?php else: ?>
+<?php $list = $user->getDomainPermissionsJoinDomain() ?>
+<?php if(count($list) == 0): ?>
+<?php echo "None" ?>
+<?php else: ?>
+<div class="slidelist">
+<?php if(count($list) > sfConfig::get('app_user_domain_perm_collapse_count')): ?>
+<?php echo link_to_function(__("Multiple (%1% entries)", array('%1%' => count($list))), visual_effect(
+'toggle_slide', 'domain_permissionlist_'.$user->getId())) ?>
+<div id="domain_permissionlist_<?php echo $user->getId() ?>" style="display:none">
+<?php endif; ?>
+
+<ul>
+<?php foreach($list as $permission): ?>
+<li><?php echo ($permission->getDomain()) ?></li>
+<?php endforeach; ?>
+</ul>
+
+<?php if(count($list) > 1): ?>
+</div>
+<?php endif; ?>
+</div>
+<?php endif; ?>
+<?php endif; ?>
diff --git a/apps/admin/modules/user/templates/_last_login.php b/apps/admin/modules/user/templates/_last_login.php
new file mode 100644
index 0000000..f15439a
--- /dev/null
+++ b/apps/admin/modules/user/templates/_last_login.php
@@ -0,0 +1 @@
+<?php echo ($user->getLastLogin() ? $user->getLastLogin(): "Never") ?>
diff --git a/apps/admin/modules/user/templates/_password.php b/apps/admin/modules/user/templates/_password.php
new file mode 100644
index 0000000..e32e4ab
--- /dev/null
+++ b/apps/admin/modules/user/templates/_password.php
@@ -0,0 +1,3 @@
+<?php $value = input_password_tag("user[password]", '', array (
+ 'size' => 50,
+)); echo $value ? $value : '&nbsp;' ?>
diff --git a/apps/admin/modules/user/templates/_password1.php b/apps/admin/modules/user/templates/_password1.php
new file mode 100644
index 0000000..e32e4ab
--- /dev/null
+++ b/apps/admin/modules/user/templates/_password1.php
@@ -0,0 +1,3 @@
+<?php $value = input_password_tag("user[password]", '', array (
+ 'size' => 50,
+)); echo $value ? $value : '&nbsp;' ?>
diff --git a/apps/admin/modules/user/templates/_password2.php b/apps/admin/modules/user/templates/_password2.php
new file mode 100644
index 0000000..eab912d
--- /dev/null
+++ b/apps/admin/modules/user/templates/_password2.php
@@ -0,0 +1,3 @@
+<?php $value = input_password_tag("user[password2]", '', array (
+ 'size' => 50,
+)); echo $value ? $value : '&nbsp;' ?>
diff --git a/apps/admin/modules/user/templates/_role_id.php b/apps/admin/modules/user/templates/_role_id.php
new file mode 100644
index 0000000..bfaf818
--- /dev/null
+++ b/apps/admin/modules/user/templates/_role_id.php
@@ -0,0 +1 @@
+<?php echo $user->getRole() ?>
diff --git a/apps/admin/modules/user/templates/loginSuccess.php b/apps/admin/modules/user/templates/loginSuccess.php
new file mode 100644
index 0000000..f41a809
--- /dev/null
+++ b/apps/admin/modules/user/templates/loginSuccess.php
@@ -0,0 +1,12 @@
+ <div id="context">
+ <?php echo use_helper("I18N","Asset", "Form", "Validation") ?>
+ &nbsp; <?php echo form_tag("user/login")?>
+ <h1><?php echo __("Please authenticate yourself") ?>:</h1>
+ <hr size="1" />
+ <label for="nickname">Username: </label><?php echo input_tag("nickname", $sf_params->get("nickname"), "size=50") ?><?php echo form_error('nickname') ?><br />
+ <label for="password">Password: </label><?php echo input_password_tag("password", "", "size=50") ?><?php echo form_error('password') ?><br />
+ <?php echo input_hidden_tag("referer", $sf_request->getAttribute('referer')) ?>
+ <div class="formaction"><?php echo submit_tag("Login") ?></div>
+
+ </form>
+ </div>
diff --git a/apps/admin/modules/user/templates/settingsSuccess.php b/apps/admin/modules/user/templates/settingsSuccess.php
new file mode 100644
index 0000000..f1c49d7
--- /dev/null
+++ b/apps/admin/modules/user/templates/settingsSuccess.php
@@ -0,0 +1,22 @@
+ <div id="context">
+ <?php echo use_helper("Asset", "Form", "Object", "Validation") ?>
+ <?php echo form_tag("user/settings")?>
+ <h1>Update Settings:</h1>
+
+ <hr size="1" />
+
+ <h2>General Settings:</h2>
+
+ <label for="nickname">Username: </label><?php echo object_input_tag($user, "getNickname","size=50") ?><br /><?php echo form_error('nickname') ?>
+ <label for="first_name">First Name: </label><?php echo object_input_tag($user, "getFirstName","size=50") ?><br /><?php echo form_error('first_name') ?>
+ <label for="last_name">Last Name: </label><?php echo object_input_tag($user, "getLastName", "size=50") ?><br /><?php echo form_error('last_name') ?>
+ <label for="email">E-Mail: </label><?php echo object_input_tag($user, "getEmail", "size=50") ?><div class="sf_admin_edit_help">Used to retrieve your password or to send critical notifications</div><br /><?php echo form_error('email') ?><br />
+
+ <h2>Change Password:</h2>
+ <label for="password1">New Password: </label><?php echo input_password_tag("password1", "", "size=50") ?><br />
+ <label for="password2">Re-Type New Password: </label><?php echo input_password_tag("password2", "", "size=50") ?><br /><?php echo form_error('password2') ?>
+ <?php echo input_hidden_tag("referer", $sf_request->getAttribute('referer')) ?>
+
+ <div class="formaction"><?php echo submit_tag("Update") ?><?php echo submit_tag("Cancel") ?></div>
+ </form>
+ </div>
diff --git a/apps/admin/modules/user/validate/create.yml b/apps/admin/modules/user/validate/create.yml
new file mode 100644
index 0000000..7686c7b
--- /dev/null
+++ b/apps/admin/modules/user/validate/create.yml
@@ -0,0 +1,37 @@
+fillin:
+ enabled: true
+ param:
+ exclude_types: [password]
+
+validators:
+ myStringValidator:
+ class: sfStringValidator
+ param:
+ min: 2
+ min_error: This field is too short (2 characters minimum)
+ max: 100
+ max_error: This field is too long (100 characters maximum)
+
+fields:
+ user{nickname}:
+ required:
+ msg: The Username is required
+ sfStringValidator:
+ min: 5
+ min_error: Username must be 5 or more characters
+ sfPropelUniqueValidator:
+ class: User
+ column: nickname
+ unique_error: This Username does already exist
+ user{email}:
+ myStringValidator:
+ sfEmailValidator:
+ email_error: This E-Mail Address is invalid
+ user{password}:
+ required:
+ msg: You must define a password
+ myStringValidator:
+ user{role_id}:
+ required:
+ msg: You must set a role for this user
+
diff --git a/apps/admin/modules/user/validate/edit.yml b/apps/admin/modules/user/validate/edit.yml
new file mode 100644
index 0000000..6480b37
--- /dev/null
+++ b/apps/admin/modules/user/validate/edit.yml
@@ -0,0 +1,40 @@
+fillin:
+ enabled: true
+ param:
+ exclude_types: [password]
+
+validators:
+ myStringValidator:
+ class: sfStringValidator
+ param:
+ min: 2
+ min_error: This field is too short (2 characters minimum)
+ max: 100
+ max_error: This field is too long (100 characters maximum)
+
+fields:
+ user{nickname}:
+ required:
+ msg: The Username is required
+ sfStringValidator:
+ min: 5
+ min_error: Username must be 5 or more characters
+ sfPropelUniqueValidator:
+ class: User
+ column: nickname
+ unique_error: This Username does already exist
+ user{email}:
+ myStringValidator:
+ sfEmailValidator:
+ email_error: This E-Mail Address is invalid
+ user{role_id}:
+ required:
+ msg: You must set a role for this user
+ user{password}:
+ group: password_group
+ user{password2}:
+ group: password_group
+ sfCompareValidator:
+ check: "user[password]"
+ compare_error: The two passwords do not match
+
diff --git a/apps/admin/modules/user/validate/login.yml b/apps/admin/modules/user/validate/login.yml
new file mode 100644
index 0000000..d6ea563
--- /dev/null
+++ b/apps/admin/modules/user/validate/login.yml
@@ -0,0 +1,24 @@
+methods:
+ post: [nickname, password]
+
+names:
+ nickname:
+ required: true
+ required_msg: Your Username is required
+ validators: [nicknameValidator, userValidator]
+
+ password:
+ required: true
+ required_msg: Your password is required
+
+nicknameValidator:
+ class: sfStringValidator
+ param:
+ min: 5
+ min_error: Username must be 5 or more characters
+
+userValidator:
+ class: myLoginValidator
+ param:
+ password: password
+ login_error: This Username does not exist or you entered a wrong password
diff --git a/apps/admin/modules/user/validate/settings.yml b/apps/admin/modules/user/validate/settings.yml
new file mode 100644
index 0000000..0706d53
--- /dev/null
+++ b/apps/admin/modules/user/validate/settings.yml
@@ -0,0 +1,43 @@
+fillin:
+ enabled: true
+ param:
+ exclude_types: [password]
+
+validators:
+ myStringValidator:
+ class: sfStringValidator
+ param:
+ min: 2
+ min_error: This field is too short (2 characters minimum)
+ max: 100
+ max_error: This field is too long (100 characters maximum)
+
+fields:
+ nickname:
+ required:
+ msg: Your Username is required
+ sfStringValidator:
+ min: 5
+ min_error: Username must be 5 or more characters
+ myChangeNicknameValidator:
+ change_error: This Username does already exist
+
+ first_name:
+ myStringValidator:
+ last_name:
+ myStringValidator:
+
+ email:
+ required:
+ msg: Your must provide an E-Mail Address
+ myStringValidator:
+ sfEmailValidator:
+ email_error: This E-Mail Address is invalid
+
+ password1:
+ group: password_group
+ password2:
+ group: password_group
+ sfCompareValidator:
+ check: password1
+ compare_error: The two passwords do not match