import v1.0.0-RC4 | 2009-05-20
This commit is contained in:
89
modules/users/controllers/LoginController.php
Executable file
89
modules/users/controllers/LoginController.php
Executable file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_LoginController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$settings = new Settings();
|
||||
$this->view->maintenanceEnabled = $settings->isMaintenanceMode();
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->loginForm)) {
|
||||
$this->view->loginForm = $appSession->loginForm;
|
||||
unset($appSession->loginForm);
|
||||
} else {
|
||||
$this->view->loginForm = new LoginForm();
|
||||
}
|
||||
|
||||
if ($this->_config->SSL->enable_mixed_mode) {
|
||||
$this->view->loginTargetBase = 'https://' . $_SERVER['HTTP_HOST'] . $this->view->base;
|
||||
} else {
|
||||
$this->view->loginTargetBase = $this->view->base;
|
||||
}
|
||||
|
||||
$this->_helper->viewRenderer->setResponseSegment('sidebar');
|
||||
}
|
||||
|
||||
public function authenticateAction()
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
|
||||
$form = new LoginForm();
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession->loginForm = $form;
|
||||
$this->_redirectToNormalConnection('');
|
||||
}
|
||||
|
||||
$db = Zend_Db::factory($this->_config->database);
|
||||
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password', 'MD5(CONCAT(openid, ?))');
|
||||
$authAdapter->setIdentity($this->_request->getPost('username'));
|
||||
$authAdapter->setCredential($this->_request->getPost('password'));
|
||||
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
|
||||
if ($result->isValid()) {
|
||||
$users = new Users();
|
||||
$user = $users->getUser($result->getIdentity());
|
||||
|
||||
// $user might not exist when the openid validation passed, but there's no
|
||||
// user in the system with that openid identity
|
||||
if (!$user) {
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid credentials');
|
||||
} else {
|
||||
$auth->getStorage()->write($user);
|
||||
|
||||
if ($user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
|
||||
return $this->_redirectForMaintenance(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid credentials');
|
||||
$appSession->loginForm = $form;
|
||||
}
|
||||
|
||||
$this->_redirectToNormalConnection('');
|
||||
}
|
||||
|
||||
public function logoutAction()
|
||||
{
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
}
|
33
modules/users/controllers/ManageusersController.php
Normal file
33
modules/users/controllers/ManageusersController.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ManageusersController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$this->targetUser->delete();
|
||||
echo $this->view->translate('User has been deleted successfully');
|
||||
}
|
||||
|
||||
public function deleteunconfirmedAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$users->deleteUnconfirmed();
|
||||
}
|
||||
}
|
72
modules/users/controllers/PersonalinfoController.php
Normal file
72
modules/users/controllers/PersonalinfoController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_PersonalinfoController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function showAction()
|
||||
{
|
||||
$fields = new Fields();
|
||||
$this->view->fields = $fields->getValues($this->user);
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->personalInfoForm)) {
|
||||
$this->view->fields = $appSession->personalInfoForm->getElements();
|
||||
unset($appSession->personalInfoForm);
|
||||
} else {
|
||||
$personalInfoForm = new PersonalInfoForm(null, $this->user);
|
||||
$this->view->fields = $personalInfoForm->getElements();
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new PersonalInfoForm(null, $this->user);
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->personalInfoForm = $form;
|
||||
$this->_forward('edit');
|
||||
return;
|
||||
}
|
||||
|
||||
$fieldsValues = new FieldsValues();
|
||||
$fieldsValues->deleteForUser($this->user);
|
||||
|
||||
foreach ($form->getValues() as $fieldName => $fieldValue) {
|
||||
if (!$fieldValue) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fieldsValue = $fieldsValues->createRow();
|
||||
$fieldsValue->user_id = $this->user->id;
|
||||
|
||||
list(, $fieldId) = explode('_', $fieldName);
|
||||
$fieldsValue->field_id = $fieldId;
|
||||
|
||||
$fieldsValue->value = $fieldValue;
|
||||
|
||||
$fieldsValue->save();
|
||||
}
|
||||
|
||||
|
||||
$this->_forward('show');
|
||||
}
|
||||
}
|
22
modules/users/controllers/ProfileController.php
Executable file
22
modules/users/controllers/ProfileController.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ProfileController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (!$this->targetUser->id && $this->user->role != User::ROLE_ADMIN) {
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
}
|
307
modules/users/controllers/ProfilegeneralController.php
Normal file
307
modules/users/controllers/ProfilegeneralController.php
Normal file
@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_ProfilegeneralController extends Monkeys_Controller_Action
|
||||
{
|
||||
private $_users;
|
||||
|
||||
public function preDispatch()
|
||||
{
|
||||
if ($this->user->role != User::ROLE_ADMIN
|
||||
&& $this->targetUser->id != $this->user->id)
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
}
|
||||
|
||||
public function accountinfoAction()
|
||||
{
|
||||
}
|
||||
|
||||
public function editaccountinfoAction()
|
||||
{
|
||||
if ($this->targetUser->id != $this->user->id
|
||||
// this condition checks for an non-admin trying to add a new user
|
||||
&& ($this->targetUser->id != 0 || $this->user->role != User::ROLE_ADMIN))
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->accountInfoForm)) {
|
||||
$this->view->accountInfoForm = $appSession->accountInfoForm;
|
||||
unset($appSession->accountInfoForm);
|
||||
} else {
|
||||
$this->view->accountInfoForm = new AccountInfoForm(null, $this->targetUser);
|
||||
$this->view->accountInfoForm->populate(array(
|
||||
'username' => $this->targetUser->username,
|
||||
'firstname' => $this->targetUser->firstname,
|
||||
'lastname' => $this->targetUser->lastname,
|
||||
'email' => $this->targetUser->email,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function saveaccountinfoAction()
|
||||
{
|
||||
$isNewUser = is_null($this->targetUser->id)? true : false;
|
||||
|
||||
if (!$isNewUser && $this->targetUser->id != $this->user->id) {
|
||||
// admins can add new users, but not edit existing ones
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$form = new AccountInfoForm(null, $this->targetUser);
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
return $this->_redirectInvalidForm($form);
|
||||
}
|
||||
|
||||
$existingUsernameOrEmail = false;
|
||||
$newUsername = $form->getValue('username');
|
||||
if (($isNewUser && $this->_usernameAlreadyExists($newUsername))
|
||||
|| (!$isNewUser && ($this->targetUser->username != $newUsername)
|
||||
&& $this->_usernameAlreadyExists($newUsername)))
|
||||
{
|
||||
$form->username->addError($this->view->translate('This username is already in use'));
|
||||
$existingUsernameOrEmail = true;
|
||||
}
|
||||
|
||||
$newEmail = $form->getValue('email');
|
||||
if (($isNewUser && $this->_emailAlreadyExists($newEmail))
|
||||
|| (!$isNewUser && ($this->targetUser->email != $newEmail)
|
||||
&& $this->_emailAlreadyExists($newEmail)))
|
||||
{
|
||||
$form->email->addError($this->view->translate('This E-mail is already in use'));
|
||||
$existingUsernameOrEmail = true;
|
||||
}
|
||||
|
||||
if ($existingUsernameOrEmail) {
|
||||
return $this->_redirectInvalidForm($form);
|
||||
}
|
||||
|
||||
$this->targetUser->username = $newUsername;
|
||||
$this->targetUser->firstname = $form->getValue('firstname');
|
||||
$this->targetUser->lastname = $form->getValue('lastname');
|
||||
$this->targetUser->email = $newEmail;
|
||||
if ($isNewUser) {
|
||||
$this->targetUser->accepted_eula = 1;
|
||||
$this->targetUser->registration_date = date('Y-m-d');
|
||||
$this->targetUser->openid = $this->_generateOpenId($this->targetUser->username);
|
||||
$this->targetUser->role = User::ROLE_REGISTERED;
|
||||
$this->targetUser->setClearPassword($form->getValue('password1'));
|
||||
}
|
||||
$this->targetUser->save();
|
||||
|
||||
/**
|
||||
* When the form is submitted through a YUI request using a file, an iframe is used,
|
||||
* so the framework doesn't detected it as ajax, so we have to manually ensure the
|
||||
* layout is not shown.
|
||||
*/
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_forward('accountinfo', null , null, array('userid' => $this->targetUser->id));
|
||||
}
|
||||
|
||||
private function _usernameAlreadyExists($username)
|
||||
{
|
||||
$users = $this->_getUsers();
|
||||
return $users->getUser($username);
|
||||
}
|
||||
|
||||
private function _emailAlreadyExists($email)
|
||||
{
|
||||
$users = $this->_getUsers();
|
||||
return $users->getUserWithEmail($email);
|
||||
}
|
||||
|
||||
private function _redirectInvalidForm(Zend_Form $form)
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->accountInfoForm = $form;
|
||||
|
||||
/**
|
||||
* When the form is submitted through a YUI request using a file, an iframe is used,
|
||||
* so the framework doesn't detected it as ajax, so we have to manually ensure the
|
||||
* layout is not shown.
|
||||
*/
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_forward('editaccountinfo', null , null, array('userid' => $this->targetUser->id));
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the users themselves can change their passwords
|
||||
*/
|
||||
public function changepasswordAction()
|
||||
{
|
||||
if ($this->targetUser->id != $this->user->id)
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->changePasswordForm)) {
|
||||
$this->view->changePasswordForm = $appSession->changePasswordForm;
|
||||
unset($appSession->changePasswordForm);
|
||||
} else {
|
||||
$this->view->changePasswordForm = new ChangePasswordForm();
|
||||
}
|
||||
}
|
||||
|
||||
public function savepasswordAction()
|
||||
{
|
||||
if ($this->targetUser->id != $this->user->id)
|
||||
{
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
|
||||
$form = new ChangePasswordForm();
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->changePasswordForm = $form;
|
||||
return $this->_forward('changepassword', null , null, array('userid' => $this->targetUser->id));
|
||||
}
|
||||
|
||||
$this->targetUser->setClearPassword($form->getValue('password1'));
|
||||
$this->targetUser->save();
|
||||
|
||||
return $this->_forward('accountinfo', null , null, array('userid' => $this->targetUser->id));
|
||||
}
|
||||
|
||||
public function confirmdeleteAction()
|
||||
{
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$mail = self::getMail();
|
||||
$mail->setFrom('support@community-id.org');
|
||||
$mail->addTo($this->_config->email->supportemail);
|
||||
$mail->setSubject('Community-ID user deletion');
|
||||
|
||||
$userFullname = $this->user->getFullName();
|
||||
|
||||
$reasonsChecked = array();
|
||||
if ($this->_getParam('reason_test')) {
|
||||
$reasonsChecked[] = 'This was just a test account';
|
||||
}
|
||||
if ($this->_getParam('reason_foundbetter')) {
|
||||
$reasonsChecked[] = 'I found a better service';
|
||||
}
|
||||
if ($this->_getParam('reason_lackedfeatures')) {
|
||||
$reasonsChecked[] = 'Service lacked some key features I needed';
|
||||
}
|
||||
if ($this->_getParam('reason_none')) {
|
||||
$reasonsChecked[] = 'No particular reason';
|
||||
}
|
||||
|
||||
if ($reasonsChecked) {
|
||||
$reasonsChecked = implode("\r\n", $reasonsChecked);
|
||||
} else {
|
||||
$reasonsChecked = 'None (no checkbox was ticked).';
|
||||
}
|
||||
|
||||
$comment = $this->_getParam('reason_comments');
|
||||
|
||||
$body = <<<EOT
|
||||
Dear Admin:
|
||||
|
||||
The user $userFullname has deleted his account, giving the following feedback:
|
||||
|
||||
Reasons checked:
|
||||
$reasonsChecked
|
||||
|
||||
Comment:
|
||||
$comment
|
||||
EOT;
|
||||
$mail->setBodyText($body);
|
||||
try {
|
||||
$mail->send();
|
||||
} catch (Zend_Mail_Protocol_Exception $e) {
|
||||
if ($this->_config->logging->level == Zend_Log::DEBUG) {
|
||||
$this->_helper->FlashMessenger->addMessage('Account was deleted, but feedback form couldn\'t be sent to admins');
|
||||
}
|
||||
}
|
||||
|
||||
$users = $this->_getUsers();
|
||||
$users->deleteUser($this->user);
|
||||
Zend_Auth::getInstance()->clearIdentity();
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Your acccount has been successfully deleted'));
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
private function _generateOpenId($username)
|
||||
{
|
||||
$selfUrl = Zend_OpenId::selfUrl();
|
||||
if (!preg_match('#(.*)/users/profile.*#', $selfUrl, $matches)) {
|
||||
throw new Exception('Couldn\'t retrieve current URL');
|
||||
}
|
||||
|
||||
if ($this->_config->subdomain->enabled) {
|
||||
$openid = $this->_getProtocol() . '://' . $username . '.' . $this->_config->subdomain->hostname;
|
||||
} else {
|
||||
$openid = $matches[1] . "/identity/$username";
|
||||
}
|
||||
|
||||
if ($this->_config->SSL->enable_mixed_mode) {
|
||||
$openid = str_replace('http://', 'https://', $openid);
|
||||
}
|
||||
|
||||
Zend_OpenId::normalizeUrl($openid);
|
||||
|
||||
return $openid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zend_Mail
|
||||
* @throws Zend_Mail_Protocol_Exception
|
||||
*/
|
||||
public static function getMail()
|
||||
{
|
||||
// can't use $this->_config 'cause it's a static function
|
||||
$configEmail = Zend_Registry::get('config')->email;
|
||||
|
||||
switch (strtolower($configEmail->transport)) {
|
||||
case 'smtp':
|
||||
Zend_Mail::setDefaultTransport(
|
||||
new Zend_Mail_Transport_Smtp(
|
||||
$configEmail->host,
|
||||
$configEmail->toArray()
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'mock':
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
|
||||
break;
|
||||
default:
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
|
||||
}
|
||||
|
||||
$mail = new Zend_Mail();
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
private function _getUsers()
|
||||
{
|
||||
if (!isset($this->_users)) {
|
||||
$this->_users = new Users();
|
||||
}
|
||||
|
||||
return $this->_users;
|
||||
}
|
||||
}
|
141
modules/users/controllers/RecoverpasswordController.php
Executable file
141
modules/users/controllers/RecoverpasswordController.php
Executable file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_RecoverpasswordController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
return $this->_redirectForMaintenance();
|
||||
}
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->recoverPasswordForm)) {
|
||||
$this->view->form = $appSession->recoverPasswordForm;
|
||||
unset($appSession->recoverPasswordForm);
|
||||
} else {
|
||||
$this->view->form = new RecoverPasswordForm();
|
||||
}
|
||||
|
||||
$this->_helper->actionStack('index', 'login', 'users');
|
||||
}
|
||||
|
||||
public function sendAction()
|
||||
{
|
||||
$form = new RecoverPasswordForm();
|
||||
$formData = $this->_request->getPost();
|
||||
|
||||
$form->populate($formData);
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->recoverPasswordForm = $form;
|
||||
return $this->_forward('index');
|
||||
}
|
||||
|
||||
$users = new Users();
|
||||
$user = $users->getUserWithEmail($form->getValue('email'));
|
||||
if (!$user) {
|
||||
$form->email->addError($this->view->translate('This E-mail is not registered in the system'));
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->recoverPasswordForm = $form;
|
||||
return $this->_forward('index');
|
||||
}
|
||||
|
||||
$user->token = User::generateToken();
|
||||
$user->save();
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
if (file_exists(APP_DIR . "/resources/$locale/passwordreset_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/passwordreset_mail.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/passwordreset_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/passwordreset_mail.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/passwordreset_mail.txt";
|
||||
}
|
||||
|
||||
$emailTemplate = file_get_contents($file);
|
||||
$emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
|
||||
$emailTemplate = str_replace('{IP}', $_SERVER['REMOTE_ADDR'], $emailTemplate);
|
||||
|
||||
// $_SERVER['SCRIPT_URI'] is not always available
|
||||
$URI = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
preg_match('#(.*)/users/recoverpassword#', $URI, $matches);
|
||||
$emailTemplate = str_replace('{passwordResetURL}',
|
||||
$matches[1] . '/users/recoverpassword/reset?token=' . $user->token,
|
||||
$emailTemplate);
|
||||
|
||||
$this->_sendMail($user->email, $this->view->translate('Community-ID password reset'), $emailTemplate);
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Password reset E-mail has been sent'));
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
public function resetAction()
|
||||
{
|
||||
$users = new Users();
|
||||
$user = $users->getUserWithToken($this->_getParam('token'));
|
||||
if (!$user) {
|
||||
$this->_helper->FlashMessenger->addMessage('Wrong Token');
|
||||
$this->_redirect('');
|
||||
return;
|
||||
}
|
||||
|
||||
$newPassword = $user->generateRandomPassword();
|
||||
$user->setClearPassword($newPassword);
|
||||
|
||||
// reset token
|
||||
$user->token = User::generateToken();
|
||||
|
||||
$user->save();
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
if (file_exists(APP_DIR . "/resources/$locale/passwordreset2_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/passwordreset2_mail.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/passwordreset2_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/passwordreset2_mail.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/passwordreset2_mail.txt";
|
||||
}
|
||||
|
||||
$emailTemplate = file_get_contents($file);
|
||||
$emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
|
||||
$emailTemplate = str_replace('{password}', $newPassword, $emailTemplate);
|
||||
|
||||
$this->_sendMail($user->email, $this->view->translate('Community-ID password reset'), $emailTemplate);
|
||||
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('You\'ll receive your new password via E-mail'));
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
private function _sendMail($to, $subject, $body)
|
||||
{
|
||||
if (strtolower($this->_config->email->transport) == 'smtp') {
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($this->_config->email->host, $this->_config->email->toArray()));
|
||||
} else {
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
|
||||
}
|
||||
$mail = new Zend_Mail('utf-8');
|
||||
$mail->setBodyText($body);
|
||||
$mail->setFrom($this->_config->email->supportemail);
|
||||
$mail->addTo($to);
|
||||
$mail->setSubject($subject);
|
||||
$mail->send();
|
||||
}
|
||||
}
|
227
modules/users/controllers/RegisterController.php
Executable file
227
modules/users/controllers/RegisterController.php
Executable file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_RegisterController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
|
||||
return $this->_redirectForMaintenance();
|
||||
}
|
||||
|
||||
if (!$this->_config->environment->registrations_enabled) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate(
|
||||
'Sorry, registrations are currently disabled'
|
||||
));
|
||||
return $this->_redirect('');
|
||||
}
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
if (isset($appSession->registerForm)) {
|
||||
$form = $appSession->registerForm;
|
||||
unset($appSession->registerForm);
|
||||
} else {
|
||||
$form = new RegisterForm(null, $this->view->base);
|
||||
}
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$form = new RegisterForm(null, $this->view->base);
|
||||
$formData = $this->_request->getPost();
|
||||
$form->populate($formData);
|
||||
|
||||
if (!$form->isValid($formData)) {
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->registerForm = $form;
|
||||
return $this->_forward('index', null, null);
|
||||
}
|
||||
|
||||
$users = new Users();
|
||||
|
||||
if ($users->getUser($form->getValue('username'))) {
|
||||
$form->username->addError($this->view->translate('This username is already in use'));
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->registerForm = $form;
|
||||
return $this->_forward('index', null, null);
|
||||
}
|
||||
|
||||
if ($users->getUserWithEmail($form->getValue('email'))) {
|
||||
$form->email->addError($this->view->translate('This E-mail is already in use'));
|
||||
$appSession = Zend_Registry::get('appSession');
|
||||
$appSession->registerForm = $form;
|
||||
return $this->_forward('index', null, null);
|
||||
}
|
||||
|
||||
$user = $users->createRow();
|
||||
|
||||
$user->firstname = $form->getValue('firstname');
|
||||
$user->lastname = $form->getValue('lastname');
|
||||
$user->email = $form->getValue('email');
|
||||
$user->username = $form->getValue('username');
|
||||
|
||||
$currentUrl = Zend_OpenId::selfURL();
|
||||
preg_match('#(.*)/users/register/save#', $currentUrl, $matches);
|
||||
if ($this->_config->subdomain->enabled) {
|
||||
$openid = $this->_getProtocol() . '://' . $user->username . '.' . $this->_config->subdomain->hostname;
|
||||
} else {
|
||||
$openid = $matches[1] . '/identity/' . $user->username;
|
||||
}
|
||||
|
||||
if ($this->_config->SSL->enable_mixed_mode) {
|
||||
$openid = str_replace('http://', 'https://', $openid);
|
||||
}
|
||||
Zend_OpenId::normalizeUrl($openid);
|
||||
$user->openid = $openid;
|
||||
|
||||
$user->setClearPassword($form->getValue('password1'));
|
||||
$user->role = User::ROLE_GUEST;
|
||||
$registrationToken = User::generateToken();
|
||||
$user->token = $registrationToken;
|
||||
$user->accepted_eula = 0;
|
||||
$user->registration_date = date('Y-m-d');
|
||||
$user->save();
|
||||
|
||||
$mail = $this->getMail($user);
|
||||
try {
|
||||
$mail->send();
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('Thank you.'));
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('You will receive an E-mail with instructions to activate the account.'));
|
||||
} catch (Zend_Mail_Protocol_Exception $e) {
|
||||
$this->_helper->FlashMessenger->addMessage($this->view->translate('The account was created but the E-mail could not be sent'));
|
||||
if ($this->_config->logging->level == Zend_Log::DEBUG) {
|
||||
$this->_helper->FlashMessenger->addMessage($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
public function eulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
if ($this->_request->getParam('token') == ''
|
||||
|| !($user = $users->getUserWithToken($this->_request->getParam('token')))) {
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid token');
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
$this->view->token = $user->token;
|
||||
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
|
||||
if (file_exists(APP_DIR . "/resources/$locale/eula.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/eula.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/eula.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/eula.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/eula.txt";
|
||||
}
|
||||
|
||||
$this->view->eula = file_get_contents($file);
|
||||
}
|
||||
|
||||
public function declineeulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
if (!($user = $users->getUserWithToken($this->_request->getParam('token'))) || $this->_request->getParam('token') == '') {
|
||||
Zend_Registry::get('logger')->log('invalid token', Zend_Log::DEBUG);
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid token');
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
$this->_helper->FlashMessenger->addMessage('Your account has been deleted');
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
public function accepteulaAction()
|
||||
{
|
||||
$users = new Users();
|
||||
if (!($user = $users->getUserWithToken($this->_request->getParam('token'))) || $this->_request->getParam('token') == '') {
|
||||
$this->_helper->FlashMessenger->addMessage('Invalid token');
|
||||
$this->_redirect('');
|
||||
}
|
||||
|
||||
$user->role = User::ROLE_REGISTERED;
|
||||
$user->accepted_eula = 1;
|
||||
$user->registration_date = date('Y-m-d');
|
||||
$user->token = '';
|
||||
$user->save();
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$auth->getStorage()->write($user);
|
||||
|
||||
$this->_redirect('/users/profile');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zend_Mail
|
||||
* @throws Zend_Mail_Protocol_Exception
|
||||
*/
|
||||
public function getMail(User $user)
|
||||
{
|
||||
$locale = Zend_Registry::get('Zend_Locale');
|
||||
$localeElements = explode('_', $locale);
|
||||
if (file_exists(APP_DIR . "/resources/$locale/registration_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/$locale/registration_mail.txt";
|
||||
} else if (count($localeElements == 2)
|
||||
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/registration_mail.txt")) {
|
||||
$file = APP_DIR . "/resources/".$localeElements[0]."/registration_mail.txt";
|
||||
} else {
|
||||
$file = APP_DIR . "/resources/en/registration_mail.txt";
|
||||
}
|
||||
|
||||
$emailTemplate = file_get_contents($file);
|
||||
$emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
|
||||
|
||||
$currentUrl = Zend_OpenId::selfURL();
|
||||
preg_match('#(.*)/register/save#', $currentUrl, $matches);
|
||||
$emailTemplate = str_replace('{registrationURL}', $matches[1] . '/register/eula?token=' . $user->token, $emailTemplate);
|
||||
|
||||
// can't use $this-_config 'cause it's a static function
|
||||
$configEmail = Zend_Registry::get('config')->email;
|
||||
|
||||
switch (strtolower($configEmail->transport)) {
|
||||
case 'smtp':
|
||||
Zend_Mail::setDefaultTransport(
|
||||
new Zend_Mail_Transport_Smtp(
|
||||
$configEmail->host,
|
||||
$configEmail->toArray()
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'mock':
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
|
||||
break;
|
||||
default:
|
||||
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
|
||||
}
|
||||
|
||||
$mail = new Zend_Mail();
|
||||
$mail->setBodyText($emailTemplate);
|
||||
$mail->setFrom('support@community-id.org');
|
||||
$mail->addTo($user->email);
|
||||
$mail->setSubject($this->view->translate('Community-ID registration confirmation'));
|
||||
|
||||
return $mail;
|
||||
}
|
||||
}
|
67
modules/users/controllers/UserslistController.php
Executable file
67
modules/users/controllers/UserslistController.php
Executable file
@ -0,0 +1,67 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Users_UserslistController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
|
||||
$users = new Users();
|
||||
|
||||
switch($this->_getParam('filter')) {
|
||||
case 'confirmed':
|
||||
$where = "accepted_eula=1 AND role != '".User::ROLE_ADMIN."'";
|
||||
break;
|
||||
case 'unconfirmed':
|
||||
$where = "accepted_eula=0 AND role != '".User::ROLE_ADMIN."'";
|
||||
break;
|
||||
default:
|
||||
$where = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$usersRows = $users->getUsers(
|
||||
$this->_getParam('startIndex'),
|
||||
$this->_getParam('results'),
|
||||
$this->_getParam('sort', 'registration'),
|
||||
$this->_getParam('dir', Users::DIR_DESC),
|
||||
$where);
|
||||
|
||||
$jsonObj = new StdClass();
|
||||
$jsonObj->recordsReturned = count($usersRows);
|
||||
$jsonObj->totalRecords = $users->getNumUsers($where);
|
||||
$jsonObj->totalUnconfirmedUsers = $users->getNumUnconfirmedUsers();
|
||||
$jsonObj->startIndex = $_GET['startIndex'];
|
||||
$jsonObj->sort = $this->_getParam('sort');
|
||||
$jsonObj->dir = $this->_getParam('dir');
|
||||
$jsonObj->records = array();
|
||||
|
||||
foreach ($usersRows as $user) {
|
||||
if ($user->role == User::ROLE_ADMIN) {
|
||||
$status = $this->view->translate('admin');
|
||||
} else if ($user->accepted_eula) {
|
||||
$status = $this->view->translate('confirmed');
|
||||
} else {
|
||||
$status = $this->view->translate('unconfirmed');
|
||||
}
|
||||
$jsonObjUser = new StdClass();
|
||||
$jsonObjUser->id = $user->id;
|
||||
$jsonObjUser->name = $user->getFullName();
|
||||
$jsonObjUser->registration = $user->registration_date;
|
||||
$jsonObjUser->role = $user->role;
|
||||
$jsonObjUser->status = $status;
|
||||
$jsonObj->records[] = $jsonObjUser;
|
||||
}
|
||||
|
||||
echo Zend_Json::encode($jsonObj);
|
||||
}
|
||||
}
|
63
modules/users/forms/AccountInfoForm.php
Normal file
63
modules/users/forms/AccountInfoForm.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class AccountInfoForm extends Zend_Form
|
||||
{
|
||||
private $_targetUser;
|
||||
|
||||
public function __construct($options = null, $user = null)
|
||||
{
|
||||
$this->_targetUser = $user;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$username = new Monkeys_Form_Element_Text('username');
|
||||
translate('Username');
|
||||
$username->setLabel('Username');
|
||||
|
||||
$firstname = new Monkeys_Form_Element_Text('firstname');
|
||||
translate('First Name');
|
||||
$firstname->setLabel('First Name')
|
||||
->setRequired(true);
|
||||
|
||||
$lastname = new Monkeys_Form_Element_Text('lastname');
|
||||
translate('Last Name');
|
||||
$lastname->setLabel('Last Name')
|
||||
->setRequired(true);
|
||||
|
||||
$email = new Monkeys_Form_Element_Text('email');
|
||||
translate('E-mail');
|
||||
$email->setLabel('E-mail')
|
||||
->addFilter('StringToLower')
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$this->addElements(array($username, $firstname, $lastname, $email));
|
||||
|
||||
if (!$this->_targetUser->id) {
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter password');
|
||||
$password1->setLabel('Enter password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
$password2->setLabel('Enter password again')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($password1, $password2));
|
||||
}
|
||||
}
|
||||
}
|
30
modules/users/forms/ChangePasswordForm.php
Normal file
30
modules/users/forms/ChangePasswordForm.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class ChangePasswordForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter password');
|
||||
$password1->setLabel('Enter password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
$password2->setLabel('Enter password again')
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElements(array($password1, $password2));
|
||||
}
|
||||
}
|
22
modules/users/forms/LoginForm.php
Executable file
22
modules/users/forms/LoginForm.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class LoginForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$username = new Zend_Form_Element_Text('username');
|
||||
translate('USERNAME');
|
||||
$username->setLabel('USERNAME')
|
||||
->setRequired(true);
|
||||
|
||||
$password = new Zend_Form_Element_Password('password');
|
||||
translate('PASSWORD');
|
||||
$password->setLabel('PASSWORD')
|
||||
->setRequired(true);
|
||||
|
||||
$rememberme = new Zend_Form_Element_Checkbox('rememberme');
|
||||
$rememberme->setLabel('Remember me');
|
||||
|
||||
$this->addElements(array($username, $password, $rememberme));
|
||||
}
|
||||
}
|
65
modules/users/forms/PersonalInfoForm.php
Normal file
65
modules/users/forms/PersonalInfoForm.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class PersonalInfoForm extends Zend_Form
|
||||
{
|
||||
private $_sregProps;
|
||||
private $_formElements = array();
|
||||
|
||||
public function __construct($options = null, $user = null, $sregProps = null)
|
||||
{
|
||||
$this->_sregProps = $sregProps;
|
||||
|
||||
$fields = new Fields();
|
||||
$fieldsArr = $fields->getValues($user);
|
||||
for ($i = 0; $i < count($fieldsArr); $i++) {
|
||||
$this->_formElements[$fieldsArr[$i]->openid] = array(
|
||||
'field' => $fieldsArr[$i],
|
||||
'element' => $fieldsArr[$i]->getFormElement(),
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
if ($this->_sregProps) {
|
||||
foreach ($this->_sregProps as $fieldName => $mandatory) {
|
||||
if (isset($this->_formElements[$fieldName])) {
|
||||
$element = $this->_formElements[$fieldName]['element'];
|
||||
if ($mandatory) {
|
||||
// override label
|
||||
$element->setLabel($this->_formElements[$fieldName]['field']->name);
|
||||
$element->setRequired(true);
|
||||
}
|
||||
} else {
|
||||
$element = new Monkeys_Form_Element_Text("openid.sreg.$fieldName");
|
||||
$element->setLabel($fieldName);
|
||||
if ($mandatory) {
|
||||
$element->setRequired(true);
|
||||
}
|
||||
}
|
||||
|
||||
// user openid standard notation for the field names, instead of
|
||||
// our field IDs.
|
||||
$element->setName('openid_sreg_' . $fieldName);
|
||||
|
||||
$this->addElement($element);
|
||||
}
|
||||
} else {
|
||||
foreach ($this->_formElements as $formElement) {
|
||||
$this->addElement($formElement['element']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
modules/users/forms/RecoverPasswordForm.php
Normal file
25
modules/users/forms/RecoverPasswordForm.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class RecoverPasswordForm extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$email = new Zend_Form_Element_Text('email');
|
||||
$email->setLabel('')
|
||||
->addFilter('StringToLower')
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$this->addElement($email);
|
||||
}
|
||||
}
|
76
modules/users/forms/RegisterForm.php
Executable file
76
modules/users/forms/RegisterForm.php
Executable file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class RegisterForm extends Zend_Form
|
||||
{
|
||||
private $_baseWebDir;
|
||||
|
||||
public function __construct($options = null, $baseWebDir = null)
|
||||
{
|
||||
$this->_baseWebDir = $baseWebDir;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$firstName = new Monkeys_Form_Element_Text('firstname');
|
||||
translate('First Name');
|
||||
$firstName->setLabel('First Name')
|
||||
->setRequired(true);
|
||||
|
||||
$lastName = new Monkeys_Form_Element_Text('lastname');
|
||||
translate('Last Name');
|
||||
$lastName->setLabel('Last Name')
|
||||
->setRequired(true);
|
||||
|
||||
$email = new Monkeys_Form_Element_Text('email');
|
||||
translate('E-mail');
|
||||
$email->setLabel('E-mail')
|
||||
->addFilter('StringToLower')
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$username = new Monkeys_Form_Element_Text('username');
|
||||
translate('Username');
|
||||
$username->setLabel('Username')
|
||||
->setRequired(true);
|
||||
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter desired password');
|
||||
$password1->setLabel('Enter desired password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
$password2->setLabel('Enter password again')
|
||||
->setRequired(true);
|
||||
|
||||
// ZF has some bugs when using mutators here, so I have to use the config array
|
||||
translate('Please enter the text below');
|
||||
$captcha = new Monkeys_Form_Element_Captcha('captcha', array(
|
||||
'label' => 'Please enter the text below',
|
||||
'captcha' => array(
|
||||
'captcha' => 'Image',
|
||||
'sessionClass' => get_class(Zend_Registry::get('appSession')),
|
||||
'font' => APP_DIR . '/libs/Monkeys/fonts/Verdana.ttf',
|
||||
'imgDir' => WEB_DIR. '/captchas',
|
||||
'imgUrl' => $this->_baseWebDir . '/captchas',
|
||||
'wordLen' => 4,
|
||||
'fontSize' => 30,
|
||||
'timeout' => 300,
|
||||
)
|
||||
));
|
||||
|
||||
$this->addElements(array($firstName, $lastName, $email, $username, $password1, $password2, $captcha));
|
||||
}
|
||||
}
|
53
modules/users/models/OpenIdUser.php
Normal file
53
modules/users/models/OpenIdUser.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class OpenIdUser extends Zend_OpenId_Provider_User
|
||||
{
|
||||
private $_auth;
|
||||
private $_user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_auth = Zend_Auth::getInstance();
|
||||
}
|
||||
|
||||
public function setLoggedInUser($id)
|
||||
{
|
||||
|
||||
$users = new Users();
|
||||
$this->_user = $users->getuserWithOpenId($id);
|
||||
$this->_auth->getStorage()->write($this->_user);
|
||||
}
|
||||
|
||||
public function getLoggedInUser()
|
||||
{
|
||||
$users = new Users();
|
||||
if ($this->_auth->hasIdentity()) {
|
||||
$user = $this->_auth->getStorage()->read();
|
||||
$user->init();
|
||||
|
||||
// reactivate row as live data
|
||||
$user->setTable($users);
|
||||
|
||||
return $user->openid;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delLoggedInUser()
|
||||
{
|
||||
$this->_auth->clearIdentity();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
59
modules/users/models/User.php
Executable file
59
modules/users/models/User.php
Executable file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class User extends Zend_Db_Table_Row_Abstract
|
||||
{
|
||||
const ROLE_GUEST = 'guest';
|
||||
const ROLE_REGISTERED = 'registered';
|
||||
const ROLE_ADMIN = 'admin';
|
||||
|
||||
/**
|
||||
* To identify the app that owns the user obj in the session.
|
||||
* Useful when sharing the user between apps.
|
||||
*/
|
||||
|
||||
public function getFullName()
|
||||
{
|
||||
return $this->firstname . ' ' . $this->lastname;
|
||||
}
|
||||
|
||||
public function generateRandomPassword()
|
||||
{
|
||||
return substr(md5($this->getFullName() . time()), 0, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Password is stored using md5($this->openid.$password) because
|
||||
* that's what's used in Zend_OpenId
|
||||
*/
|
||||
public function setClearPassword($password)
|
||||
{
|
||||
$this->password = md5($this->openid.$password);
|
||||
$this->password_changed = date('Y-m-d');
|
||||
}
|
||||
|
||||
public function isAllowed($resource, $privilege)
|
||||
{
|
||||
$acl = Zend_Registry::get('acl');
|
||||
return $acl->isAllowed($this->role, $resource, $privilege);
|
||||
}
|
||||
|
||||
public static function generateToken()
|
||||
{
|
||||
$token = '';
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
$token .= chr(rand(48, 122));
|
||||
}
|
||||
|
||||
return md5($token.time());
|
||||
}
|
||||
}
|
347
modules/users/models/Users.php
Executable file
347
modules/users/models/Users.php
Executable file
@ -0,0 +1,347 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Users extends Monkeys_Db_Table_Gateway
|
||||
{
|
||||
protected $_name = 'users';
|
||||
protected $_primary = 'id';
|
||||
protected $_rowClass = 'User';
|
||||
|
||||
const DIR_ASC = 0;
|
||||
const DIR_DESC = 1;
|
||||
|
||||
private $_sortFields = array(
|
||||
'name' => array('firstname', 'lastname'),
|
||||
'registration' => array('registration_date', 'firstname', 'lastname'),
|
||||
'status' => array('accepted_eula', 'registration_date', 'firstname', 'lastname'),
|
||||
);
|
||||
|
||||
public function createRow()
|
||||
{
|
||||
return parent::createRow(array(
|
||||
'openid' => '',
|
||||
'password_changed' => '0000-00-00',
|
||||
'role' => User::ROLE_GUEST,
|
||||
'passwordreset_token' => '',
|
||||
));
|
||||
}
|
||||
|
||||
public function getUsers($startIndex = false, $results = false, $sort = false, $dir = false, $where = false)
|
||||
{
|
||||
$select = $this->select();
|
||||
|
||||
if ($startIndex !== false && $results !== false) {
|
||||
$select = $select->limit($results, $startIndex);
|
||||
}
|
||||
|
||||
if ($sort && isset($this->_sortFields[$sort])) {
|
||||
$dir = ($dir == self::DIR_ASC? 'ASC' : 'DESC');
|
||||
$sortSql = array();
|
||||
foreach ($this->_sortFields[$sort] as $field) {
|
||||
$sortSql[] = "$field $dir";
|
||||
}
|
||||
|
||||
$select = $select->order($sortSql);
|
||||
}
|
||||
|
||||
if ($where) {
|
||||
$select = $select->where($where);
|
||||
}
|
||||
|
||||
return $this->fetchAll($select);
|
||||
}
|
||||
|
||||
public function getNumUsers($where = false)
|
||||
{
|
||||
$users = $this->getUsers(false, false, false, false, $where);
|
||||
|
||||
return count($users);
|
||||
}
|
||||
|
||||
public function getNumUnconfirmedUsers()
|
||||
{
|
||||
$users = $this->getUsers(false, false, false, false, "accepted_eula=0 AND role != '".User::ROLE_ADMIN."'");
|
||||
|
||||
return count($users);
|
||||
}
|
||||
|
||||
public function getUserWithToken($token)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('token=?', $token);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUserWithEmail($email)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('email=?', $email);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUserWithOpenId($openid)
|
||||
{
|
||||
$select = $this->select()
|
||||
->where('openid=?', $openid);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function getUser($identity)
|
||||
{
|
||||
$select = $this->select()->where('username=?', $identity);
|
||||
|
||||
return $this->fetchRow($select);
|
||||
}
|
||||
|
||||
public function deleteUser(User $user)
|
||||
{
|
||||
$where = $this->getAdapter()->quoteInto('id=?', $user->id);
|
||||
$this->delete($where);
|
||||
}
|
||||
|
||||
public function deleteTestEntries()
|
||||
{
|
||||
$this->delete('test=1');
|
||||
}
|
||||
|
||||
public function deleteUnconfirmed()
|
||||
{
|
||||
$this->delete("accepted_eula=0 AND role = '".User::ROLE_GUEST."'");
|
||||
}
|
||||
|
||||
protected $_metadata = array(
|
||||
'id' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'id',
|
||||
'COLUMN_POSITION' => 1,
|
||||
'DATA_TYPE' => 'int',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => true,
|
||||
'PRIMARY_POSITION' => 1,
|
||||
'IDENTITY' => true,
|
||||
),
|
||||
'test' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'test',
|
||||
'COLUMN_POSITION' => 2,
|
||||
'DATA_TYPE' => 'tinyint',
|
||||
'DEFAULT' => '0',
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'username' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'username',
|
||||
'COLUMN_POSITION' => 3,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'openid' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'openid',
|
||||
'COLUMN_POSITION' => 4,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '100',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'accepted_eula' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'accepted_eula',
|
||||
'COLUMN_POSITION' => 5,
|
||||
'DATA_TYPE' => 'tinyint',
|
||||
'DEFAULT' => '0',
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'registration_date' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'registration_date',
|
||||
'COLUMN_POSITION' => 6,
|
||||
'DATA_TYPE' => 'date',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'password' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'password',
|
||||
'COLUMN_POSITION' => 7,
|
||||
'DATA_TYPE' => 'char',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '40',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'password_changed' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'password_changed',
|
||||
'COLUMN_POSITION' => 8,
|
||||
'DATA_TYPE' => 'date',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => NULL,
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'firstname' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'firstname',
|
||||
'COLUMN_POSITION' => 9,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'lastname' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'lastname',
|
||||
'COLUMN_POSITION' => 10,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'email' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'email',
|
||||
'COLUMN_POSITION' => 11,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'role' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'role',
|
||||
'COLUMN_POSITION' => 12,
|
||||
'DATA_TYPE' => 'varchar',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '50',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
'token' =>
|
||||
array (
|
||||
'SCHEMA_NAME' => NULL,
|
||||
'TABLE_NAME' => 'users',
|
||||
'COLUMN_NAME' => 'token',
|
||||
'COLUMN_POSITION' => 13,
|
||||
'DATA_TYPE' => 'char',
|
||||
'DEFAULT' => NULL,
|
||||
'NULLABLE' => false,
|
||||
'LENGTH' => '32',
|
||||
'SCALE' => NULL,
|
||||
'PRECISION' => NULL,
|
||||
'UNSIGNED' => NULL,
|
||||
'PRIMARY' => false,
|
||||
'PRIMARY_POSITION' => NULL,
|
||||
'IDENTITY' => false,
|
||||
),
|
||||
);
|
||||
}
|
79
modules/users/views/scripts/login/index.phtml
Executable file
79
modules/users/views/scripts/login/index.phtml
Executable file
@ -0,0 +1,79 @@
|
||||
<? if ($this->user->role != User::ROLE_GUEST ): ?>
|
||||
<h3>
|
||||
<?= $this->translate('Hello, %s', Zend_Filter::get($this->user->username, 'HtmlEntities')) ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/profile"><?= $this->translate('Account') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/personalinfo"><?= $this->translate('Personal Info') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/sites"><?= $this->translate('Sites database') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/history"><?= $this->translate('History Log') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/login/logout"><?= $this->translate('Logout') ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
<? if ($this->user->role == User::ROLE_ADMIN): ?>
|
||||
<hr />
|
||||
<h3><?= $this->translate('Admin options') ?></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/users/manageusers"><?= $this->translate('Manage Users') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/messageusers"><?= $this->translate('Message Users') ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<? if ($this->maintenanceEnabled): ?>
|
||||
<a href="<?= $this->base ?>/maintenancemode/disable"><?= $this->translate('Disable Maintenance Mode') ?></a>
|
||||
<? else: ?>
|
||||
<a href="<?= $this->base ?>/maintenancemode/enable"><?= $this->translate('Enable Maintenance Mode') ?></a>
|
||||
<? endif ?>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $this->base ?>/stats"><?= $this->translate('Statistics') ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
<? endif ?>
|
||||
<? else: ?>
|
||||
<? if ($this->underMaintenance): ?>
|
||||
<div class="messages_small">
|
||||
<?= $this->translate('User access is currently disabled for system maintenance.<br />Please try again later') ?>
|
||||
</div>
|
||||
<? endif ?>
|
||||
<form id="loginForm" action="<?= $this->loginTargetBase ?>/users/login/authenticate" method="post">
|
||||
<dl id="credentials">
|
||||
<?= $this->loginForm->username ?>
|
||||
<?= $this->loginForm->password ?>
|
||||
</dl>
|
||||
<dl id="rememberMe">
|
||||
<!-- to hard to do in the ZF -->
|
||||
<input type="checkbox" name="rememberme" style="top:0" />
|
||||
<label><?= $this->translate('Remember me') ?></label>
|
||||
</dl>
|
||||
<div id="loginButton">
|
||||
<input type="submit" id="login" value="<?= $this->translate('Log in') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("login");
|
||||
</script>
|
||||
</div>
|
||||
<p>
|
||||
<a href="<?= $this->base ?>/users/recoverpassword" class="panel_link"><?= $this->translate('Forgot you password?') ?></a>
|
||||
</p>
|
||||
</form>
|
||||
<hr/>
|
||||
<div id="registerNow">
|
||||
<p>
|
||||
<?= $this->translate('You don\'t have an account?') ?>
|
||||
<div>
|
||||
<a href="<?= $this->base ?>/users/register"><?= $this->translate('REGISTER NOW!') ?></a>
|
||||
</div>
|
||||
</p> <!-- safari bug workaround -->
|
||||
</div>
|
||||
<? endif; ?>
|
53
modules/users/views/scripts/manageusers/index.phtml
Normal file
53
modules/users/views/scripts/manageusers/index.phtml
Normal file
@ -0,0 +1,53 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["datasource", "datatable", "paginator", "json", "connection", "dragdrop"],
|
||||
function() {COMMID.usersList.init('all')}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<div class="links_topright">
|
||||
<a href="#" id="links_topright_all" onclick="COMMID.usersList.init('all'); return false;">
|
||||
<?= $this->translate('All') ?>
|
||||
</a>
|
||||
| <a href="#" id="links_topright_confirmed" onclick="COMMID.usersList.init('confirmed'); return false;">
|
||||
<?= $this->translate('Confirmed') ?>
|
||||
</a>
|
||||
| <a href="#" id="links_topright_unconfirmed" onclick="COMMID.usersList.init('unconfirmed'); return false;">
|
||||
<?= $this->translate('Unconfirmed') ?>
|
||||
</a>
|
||||
</div>
|
||||
<div id="paging"></div>
|
||||
<div id="dt"></div>
|
||||
<? if ($this->user->role == User::ROLE_ADMIN): ?>
|
||||
<div style="margin-top:10px">
|
||||
<?= $this->translate('Total users:') ?> <span id="totalUsers"></span><br />
|
||||
<?= $this->translate('Total confirmed users:') ?> <span id="totalConfirmedUsers"></span><br />
|
||||
<?= $this->translate('Total unconfirmed users:') ?> <span id="totalUnconfirmedUsers"></span><br />
|
||||
</div>
|
||||
<div style="margin-top:10px">
|
||||
<input type="button" id="addUser" value="<?= $this->translate('Add User') ?>" onclick="location.href='<?= $this->base ?>/users/profile?userid=0'" />
|
||||
<span id="deleteUnconfirmedSpan">
|
||||
<input type="button" id="deleteUnconfirmed" value="<?= $this->translate('Delete Unconfirmed Users') ?>" />
|
||||
</span>
|
||||
<script type="text/javascript">
|
||||
new YAHOO.widget.Button(
|
||||
"addUser",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {
|
||||
location.href='<?= $this->base ?>/users/profile?userid=0'
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
new YAHOO.widget.Button(
|
||||
"deleteUnconfirmed",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.usersList.deleteUnconfirmed()}}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</div>
|
||||
<? endif ?>
|
60
modules/users/views/scripts/personalinfo/edit.phtml
Normal file
60
modules/users/views/scripts/personalinfo/edit.phtml
Normal file
@ -0,0 +1,60 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["connection"],
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
COMMID.editPersonalInfo = function() {
|
||||
|
||||
return {
|
||||
save: function() {
|
||||
YAHOO.util.Connect.setForm("personalInfoForm");
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'personalinfo/save',
|
||||
{
|
||||
success: function (responseObj) {COMMID.utils.replaceContent(responseObj, "personalInfo")},
|
||||
failure: COMMID.utils.asyncFailed
|
||||
},
|
||||
null
|
||||
);
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
var transaction = YAHOO.util.Connect.asyncRequest(
|
||||
'GET',
|
||||
'personalinfo/show',
|
||||
{
|
||||
success: function (responseObj) {COMMID.utils.replaceContent(responseObj, "personalInfo")},
|
||||
failure: COMMID.utils.asyncFailed
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
}();
|
||||
</script>
|
||||
<form name="personalInfoForm" class="formGrid" >
|
||||
<? foreach ($this->fields as $field): ?>
|
||||
<?= $field ?>
|
||||
<? endforeach ?><br />
|
||||
<input type="button" id="save" value="<?= $this->translate('Save') ?>" onclick="COMMID.editPersonalInfo.save()" />
|
||||
<input type="button" id="cancel" value="<?= $this->translate('Cancel') ?>" onclick="COMMID.editPersonalInfo.cancel()" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"save",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.editPersonalInfo.save}
|
||||
}
|
||||
);
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.editPersonalInfo.cancel}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</form>
|
28
modules/users/views/scripts/personalinfo/index.phtml
Normal file
28
modules/users/views/scripts/personalinfo/index.phtml
Normal file
@ -0,0 +1,28 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
// "connection" is required by COMMID.personalInfo.edit()
|
||||
["connection"],
|
||||
null
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<div id="article">
|
||||
<div id="generalTab" class="dataSection">
|
||||
<div class="formHeader">
|
||||
<h2><?= $this->translate('Personal Info') ?></h2>
|
||||
<div>
|
||||
<a href="javascript:void(0);" onclick="COMMID.personalInfo.edit();">
|
||||
<?= $this->translate('Edit') ?>
|
||||
</a>
|
||||
<img id="loadingEditPersonalInfo" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin:10px 0">
|
||||
<em><?= $this->translate('This information will be used to automatically populate registration fields to any OpenID transaction that requires so') ?></em>
|
||||
</div>
|
||||
<div id="personalInfo">
|
||||
<?= $this->action('show', 'personalinfo', 'users', array('userid' => $this->targetUser->id)) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
12
modules/users/views/scripts/personalinfo/show.phtml
Normal file
12
modules/users/views/scripts/personalinfo/show.phtml
Normal file
@ -0,0 +1,12 @@
|
||||
<div class="formGrid">
|
||||
<? foreach ($this->fields as $field): ?>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate($field->name) ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= is_null($field->value)? $this->translate('Not Entered') : $field->value ?>
|
||||
</div>
|
||||
</div>
|
||||
<? endforeach ?>
|
||||
</div>
|
44
modules/users/views/scripts/profile/index.phtml
Executable file
44
modules/users/views/scripts/profile/index.phtml
Executable file
@ -0,0 +1,44 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
// "connection" is required by COMMID.general methods
|
||||
["connection"],
|
||||
null
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="accountForm">
|
||||
<div>
|
||||
<h2><?= $this->translate('Account info') ?></h2>
|
||||
<? if ($this->targetUser->id == $this->user->id): ?>
|
||||
<div class="profileLinks">
|
||||
<a href="javascript:void(0);" onclick="COMMID.general.editAccountInfo();">
|
||||
<?= $this->translate('Edit') ?>
|
||||
</a> |
|
||||
<a href="javascript:void(0);" onclick="COMMID.general.changePassword()" >
|
||||
<?= $this->translate('Change Password') ?>
|
||||
</a>
|
||||
<img id="loadingAccountInfo" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" />
|
||||
</div>
|
||||
<? endif ?>
|
||||
</div>
|
||||
<div id="accountInfo">
|
||||
<? if ($this->targetUser->id) {
|
||||
echo $this->action('accountinfo', 'profilegeneral', 'users', array('userid' => $this->targetUser->id));
|
||||
} else {
|
||||
// user id == 0 means we're entering info for a new user
|
||||
echo $this->action('editaccountinfo', 'profilegeneral', 'users', array('userid' => $this->targetUser->id));
|
||||
} ?>
|
||||
</div>
|
||||
<? if ($this->targetUser->id && $this->targetUser->id == $this->user->id): ?>
|
||||
<div class="accountForm">
|
||||
<div class="profileLinks" >
|
||||
<a href="<?= $this->base ?>/users/profilegeneral/confirmdelete">
|
||||
<?= $this->translate('Delete Account') ?>
|
||||
</a>
|
||||
<img id="loadingAccountInfoDummy" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" /><!-- just for layout -->
|
||||
</div>
|
||||
</div>
|
||||
<? endif ?>
|
||||
</div>
|
34
modules/users/views/scripts/profilegeneral/accountinfo.phtml
Normal file
34
modules/users/views/scripts/profilegeneral/accountinfo.phtml
Normal file
@ -0,0 +1,34 @@
|
||||
<div class="formGrid">
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('Username') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->username ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('Name') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->getfullName() ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('E-mail') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->email ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first">
|
||||
<?= $this->translate('OpenID') ?>:
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<?= $this->targetUser->openid ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,56 @@
|
||||
<script>
|
||||
COMMID.changePassword = function() {
|
||||
return {
|
||||
save: function() {
|
||||
YAHOO.util.Connect.setForm("changePasswordForm");
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
"POST",
|
||||
"profilegeneral/savepassword?userid=<?= $this->targetUser->id ?>",
|
||||
{
|
||||
success: function (responseObj) {COMMID.utils.replaceContent(responseObj, "accountInfo")},
|
||||
failure: COMMID.utils.asyncFailed
|
||||
},
|
||||
null
|
||||
);
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
var transaction = YAHOO.util.Connect.asyncRequest(
|
||||
'GET',
|
||||
'profilegeneral/accountinfo?userid=' + <?= $this->targetUser->id ?>,
|
||||
{
|
||||
success: function (responseObj) {COMMID.utils.replaceContent(responseObj, "accountInfo")},
|
||||
failure: COMMID.utils.asyncFailed
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}();
|
||||
</script>
|
||||
<form name="changePasswordForm" class="formGrid" >
|
||||
<?= $this->changePasswordForm->password1 ?>
|
||||
<?= $this->changePasswordForm->password2 ?>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first"> </div>
|
||||
<div class="yui-u">
|
||||
<input type="button" id="save" value="<?= $this->translate('Save') ?>" onclick="COMMID.changePassword.save()" />
|
||||
<input type="button" id="cancel" value="<?= $this->translate('Cancel') ?>" onclick="COMMID.changePassword.cancel()" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"save",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.changePassword.save}
|
||||
}
|
||||
);
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: COMMID.changePassword.cancel}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
37
modules/users/views/scripts/profilegeneral/confirmdelete.phtml
Executable file
37
modules/users/views/scripts/profilegeneral/confirmdelete.phtml
Executable file
@ -0,0 +1,37 @@
|
||||
<form id="confirmDeleteForm" method="post" action="<?= $this->base ?>/users/profilegeneral/delete">
|
||||
<p>
|
||||
<?= $this->translate('Why do you want to delete your Community-ID account?') ?><br />
|
||||
<?= $this->translate('Please check all that apply:') ?>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<input type="checkbox" name="reason_test" style="top:0" /><?= $this->translate('This was just a test account') ?>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="reason_foundbetter" style="top:0" /><?= $this->translate('I found a better service') ?>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="reason_lackedfeatures" style="top:0" /><?= $this->translate('Service lacked some key features I needed') ?>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="reason_none" style="top:0" /><?= $this->translate('No particular reason') ?>
|
||||
</li>
|
||||
</ul>
|
||||
<label for="reason_comments"><?= $this->translate('Additional comments:') ?></label>
|
||||
<textarea id="reason_comments" name="reason_comments"></textarea><br />
|
||||
<input type="submit" id="delete" value="<?= $this->translate('Delete Account') ?>" />
|
||||
<input type="button" id="cancel" value="<?= $this->translate('Cancel') ?>" onclick="location.href='<?= $this->base ?>/users/profile'" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("delete");
|
||||
var oButton = new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {
|
||||
location.href='<?= $this->base ?>/users/profile'
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</form>
|
@ -0,0 +1,35 @@
|
||||
<form name="accountInfoForm" class="formGrid">
|
||||
<?= $this->accountInfoForm->username ?>
|
||||
<?= $this->accountInfoForm->firstname ?>
|
||||
<?= $this->accountInfoForm->lastname ?>
|
||||
<?= $this->accountInfoForm->email ?>
|
||||
<? if (!$this->targetUser->id) {
|
||||
echo $this->accountInfoForm->password1;
|
||||
echo $this->accountInfoForm->password2;
|
||||
} ?>
|
||||
<div class="yui-gf">
|
||||
<div class="yui-u first"> </div>
|
||||
<div class="yui-u">
|
||||
<input type="button" id="save" value="<?= $this->translate('Save') ?>" onclick="COMMID.editAccountInfo.save()" />
|
||||
<input type="button" id="cancel" value="<?= $this->translate('Cancel') ?>" onclick="COMMID.editAccountInfo.cancel()" />
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
new YAHOO.widget.Button(
|
||||
"save",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.editAccountInfo.save()}}
|
||||
}
|
||||
);
|
||||
new YAHOO.widget.Button(
|
||||
"cancel",
|
||||
{
|
||||
type : "push",
|
||||
onclick : {fn: function() {COMMID.editAccountInfo.cancel()}}
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
8
modules/users/views/scripts/recoverpassword/index.phtml
Executable file
8
modules/users/views/scripts/recoverpassword/index.phtml
Executable file
@ -0,0 +1,8 @@
|
||||
<?= $this->translate('Please enter your E-mail below to receive a link to reset your password') ?>
|
||||
<form method="post" action="<?= $this->base ?>/users/recoverpassword/send">
|
||||
<?= $this->form->email ?>
|
||||
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
</form>
|
30
modules/users/views/scripts/register/eula.phtml
Executable file
30
modules/users/views/scripts/register/eula.phtml
Executable file
@ -0,0 +1,30 @@
|
||||
<h2><?= $this->translate('Please read the following EULA in order to continue') ?></h2>
|
||||
<form name="eulaForm" action="accepteula" method="post">
|
||||
<input type="hidden" name="token" value="<?= $this->token ?>" />
|
||||
<div>
|
||||
<textarea rows="30" style="width:700px"><?= $this->eula ?></textarea>
|
||||
</div>
|
||||
<div style="margin-top:20px">
|
||||
<input type="submit" id="agree" value="<?= $this->translate('I AGREE') ?>" />
|
||||
<input type="submit" id="disagree" value="<?= $this->translate('I DISAGREE') ?>" onclick="this.form.action='declineeula'; return true" />
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["button"],
|
||||
function() {
|
||||
new YAHOO.widget.Button("disagree", {
|
||||
type: "push",
|
||||
label: "I DISAGREE",
|
||||
onclick : {fn: function(){
|
||||
document.eulaForm.action = 'declineeula';
|
||||
document.eulaForm.submit();
|
||||
}}
|
||||
});
|
||||
new YAHOO.widget.Button("disagree");
|
||||
new YAHOO.widget.Button("agree");
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</form>
|
14
modules/users/views/scripts/register/index.phtml
Executable file
14
modules/users/views/scripts/register/index.phtml
Executable file
@ -0,0 +1,14 @@
|
||||
<h2><?= $this->translate('Registration Form') ?></h2>
|
||||
<form name="registration" method="post" action="<?= $this->base ?>/users/register/save" class="formGrid" >
|
||||
<?= $this->form->firstname ?>
|
||||
<?= $this->form->lastname ?>
|
||||
<?= $this->form->email ?>
|
||||
<?= $this->form->username ?>
|
||||
<?= $this->form->password1 ?>
|
||||
<?= $this->form->password2 ?>
|
||||
<?= $this->form->captcha ?>
|
||||
<input type="submit" id="send" value="<?= $this->translate('Send') ?>" />
|
||||
<script type="text/javascript">
|
||||
var oButton = new YAHOO.widget.Button("send");
|
||||
</script>
|
||||
</form>
|
Reference in New Issue
Block a user