From 9f108dd1a969473375341d92a7b1252fa2cedc9a Mon Sep 17 00:00:00 2001 From: mszulecki Date: Thu, 14 Jun 2007 17:09:01 +0000 Subject: Initial import. git-svn-id: http://svn.sukimashita.com/repos/mailadmin/trunk@2 4281df72-ff29-0410-8fee-2d9ac0c5f5a7 --- apps/admin/modules/user/actions/actions.class.php | 115 +++++++++++++++++++++ apps/admin/modules/user/config/generator.yml | 55 ++++++++++ apps/admin/modules/user/config/security.yml | 13 +++ .../modules/user/templates/_domain_permissions.php | 27 +++++ apps/admin/modules/user/templates/_last_login.php | 1 + apps/admin/modules/user/templates/_password.php | 3 + apps/admin/modules/user/templates/_password1.php | 3 + apps/admin/modules/user/templates/_password2.php | 3 + apps/admin/modules/user/templates/_role_id.php | 1 + apps/admin/modules/user/templates/loginSuccess.php | 12 +++ .../modules/user/templates/settingsSuccess.php | 22 ++++ apps/admin/modules/user/validate/create.yml | 37 +++++++ apps/admin/modules/user/validate/edit.yml | 40 +++++++ apps/admin/modules/user/validate/login.yml | 24 +++++ apps/admin/modules/user/validate/settings.yml | 43 ++++++++ 15 files changed, 399 insertions(+) create mode 100644 apps/admin/modules/user/actions/actions.class.php create mode 100644 apps/admin/modules/user/config/generator.yml create mode 100644 apps/admin/modules/user/config/security.yml create mode 100644 apps/admin/modules/user/templates/_domain_permissions.php create mode 100644 apps/admin/modules/user/templates/_last_login.php create mode 100644 apps/admin/modules/user/templates/_password.php create mode 100644 apps/admin/modules/user/templates/_password1.php create mode 100644 apps/admin/modules/user/templates/_password2.php create mode 100644 apps/admin/modules/user/templates/_role_id.php create mode 100644 apps/admin/modules/user/templates/loginSuccess.php create mode 100644 apps/admin/modules/user/templates/settingsSuccess.php create mode 100644 apps/admin/modules/user/validate/create.yml create mode 100644 apps/admin/modules/user/validate/edit.yml create mode 100644 apps/admin/modules/user/validate/login.yml create mode 100644 apps/admin/modules/user/validate/settings.yml (limited to 'apps/admin/modules/user') 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 @@ +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 @@ + +getRoleId() == Role::SUPERADMIN): ?> + + +getDomainPermissionsJoinDomain() ?> + + + +
+ + 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 @@ +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 @@ + 50, +)); echo $value ? $value : ' ' ?> 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 @@ + 50, +)); echo $value ? $value : ' ' ?> 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 @@ + 50, +)); echo $value ? $value : ' ' ?> 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 @@ +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 @@ +