import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -9,20 +9,20 @@
* @packager Keyboard Monkeys
*/
class Users_LoginController extends Monkeys_Controller_Action
/**
* We don't use the session with the login form to simplify the dynamic appearance of the captcha
*/
class Users_LoginController extends CommunityID_Controller_Action
{
public function indexAction()
{
$settings = new Settings();
$settings = new Model_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();
}
$authAttempts = new Users_Model_AuthAttempts();
$attempt = $authAttempts->get();
$this->view->useCaptcha = $attempt && $attempt->surpassedMaxAllowed();
$this->view->loginForm = new Users_Form_Login(null, $this->view->base, $this->view->useCaptcha);
if ($this->_config->SSL->enable_mixed_mode) {
$this->view->loginTargetBase = 'https://' . $_SERVER['HTTP_HOST'] . $this->view->base;
@ -35,46 +35,43 @@ class Users_LoginController extends Monkeys_Controller_Action
public function authenticateAction()
{
$auth = Zend_Auth::getInstance();
$authAttempts = new Users_Model_AuthAttempts();
$attempt = $authAttempts->get();
$form = new LoginForm();
$form = new Users_Form_Login(null, $this->view->base, $attempt && $attempt->surpassedMaxAllowed());
$formData = $this->_request->getPost();
$form->populate($formData);
$appSession = Zend_Registry::get('appSession');
if (!$form->isValid($formData)) {
$appSession->loginForm = $form;
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
$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'));
$users = new Users_Model_Users();
$result = $users->authenticate($this->_request->getPost('username'),
$this->_request->getPost('password'));
$result = $auth->authenticate($authAdapter);
if ($result) {
$user = $users->getUser();
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) {
if ($attempt) {
$attempt = $authAttempts->delete();
}
if ($user->role != Users_Model_User::ROLE_ADMIN && $this->underMaintenance) {
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);
}
return $this->_redirectForMaintenance(true);
}
} else {
$this->_helper->FlashMessenger->addMessage('Invalid credentials');
$appSession->loginForm = $form;
if (!$attempt) {
$authAttempts->create();
} else {
$attempt->addFailure();
$attempt->save();
}
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials'));
}
$this->_redirectToNormalConnection('');

View File

@ -9,7 +9,7 @@
* @packager Keyboard Monkeys
*/
class Users_ManageusersController extends Monkeys_Controller_Action
class Users_ManageusersController extends CommunityID_Controller_Action
{
public function indexAction()
{
@ -27,7 +27,76 @@ class Users_ManageusersController extends Monkeys_Controller_Action
public function deleteunconfirmedAction()
{
$users = new Users();
$users->deleteUnconfirmed();
$this->_helper->viewRenderer->setNeverRender(true);
$users = new Users_Model_Users();
$users->deleteUnconfirmed($this->_getParam('olderthan'));
}
public function sendreminderAction()
{
$this->_helper->viewRenderer->setNeverRender(true);
$users = new Users_Model_Users();
foreach ($users->getUnconfirmedUsers($this->_getParam('olderthan')) as $user) {
$mail = self::getMail($user, $this->view->translate('Community-ID registration reminder'));
try {
$mail->send();
} catch (Zend_Mail_Protocol_Exception $e) {
Zend_Registry::get('logger')->log($e->getMessage(), Zend_Log::ERR);
}
}
}
/**
* @return Zend_Mail
* @throws Zend_Mail_Protocol_Exception
*/
public static function getMail(User $user, $subject)
{
$locale = Zend_Registry::get('Zend_Locale');
$localeElements = explode('_', $locale);
if (file_exists(APP_DIR . "/resources/$locale/reminder_mail.txt")) {
$file = APP_DIR . "/resources/$locale/reminder_mail.txt";
} else if (count($localeElements == 2)
&& file_exists(APP_DIR . "/resources/".$localeElements[0]."/reminder_mail.txt")) {
$file = APP_DIR . "/resources/".$localeElements[0]."/reminder_mail.txt";
} else {
$file = APP_DIR . "/resources/en/reminder_mail.txt";
}
$emailTemplate = file_get_contents($file);
$emailTemplate = str_replace('{userName}', $user->getFullName(), $emailTemplate);
$currentUrl = Zend_OpenId::selfURL();
preg_match('#(.*)/manageusers/sendreminder#', $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('UTF-8');
$mail->setBodyText($emailTemplate);
$mail->setFrom($configEmail->supportemail);
$mail->addTo($user->email);
$mail->setSubject($subject);
return $mail;
}
}

View File

@ -9,7 +9,7 @@
* @packager Keyboard Monkeys
*/
class Users_PersonalinfoController extends Monkeys_Controller_Action
class Users_PersonalinfoController extends CommunityID_Controller_Action
{
public function indexAction()
{
@ -18,7 +18,7 @@ class Users_PersonalinfoController extends Monkeys_Controller_Action
public function showAction()
{
$fields = new Fields();
$fields = new Model_Fields();
$this->view->fields = $fields->getValues($this->user);
}
@ -29,14 +29,14 @@ class Users_PersonalinfoController extends Monkeys_Controller_Action
$this->view->fields = $appSession->personalInfoForm->getElements();
unset($appSession->personalInfoForm);
} else {
$personalInfoForm = new PersonalInfoForm(null, $this->user);
$personalInfoForm = new Users_Form_PersonalInfo(null, $this->user);
$this->view->fields = $personalInfoForm->getElements();
}
}
public function saveAction()
{
$form = new PersonalInfoForm(null, $this->user);
$form = new Users_Form_PersonalInfo(null, $this->user);
$formData = $this->_request->getPost();
$form->populate($formData);
@ -47,7 +47,7 @@ class Users_PersonalinfoController extends Monkeys_Controller_Action
return;
}
$fieldsValues = new FieldsValues();
$fieldsValues = new Model_FieldsValues();
$fieldsValues->deleteForUser($this->user);
foreach ($form->getValues() as $fieldName => $fieldValue) {

View File

@ -9,11 +9,11 @@
* @packager Keyboard Monkeys
*/
class Users_ProfileController extends Monkeys_Controller_Action
class Users_ProfileController extends CommunityID_Controller_Action
{
public function indexAction()
{
if (!$this->targetUser->id && $this->user->role != User::ROLE_ADMIN) {
if (!$this->targetUser->id && $this->user->role != Users_Model_User::ROLE_ADMIN) {
throw new Monkeys_AccessDeniedException();
}

View File

@ -9,13 +9,13 @@
* @packager Keyboard Monkeys
*/
class Users_ProfilegeneralController extends Monkeys_Controller_Action
class Users_ProfilegeneralController extends CommunityID_Controller_Action
{
private $_users;
public function preDispatch()
{
if ($this->user->role != User::ROLE_ADMIN
if ($this->user->role != Users_Model_User::ROLE_ADMIN
&& $this->targetUser->id != $this->user->id)
{
throw new Monkeys_AccessDeniedException();
@ -30,7 +30,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
{
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))
&& ($this->targetUser->id != 0 || $this->user->role != Users_Model_User::ROLE_ADMIN))
{
throw new Monkeys_AccessDeniedException();
}
@ -40,7 +40,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
$this->view->accountInfoForm = $appSession->accountInfoForm;
unset($appSession->accountInfoForm);
} else {
$this->view->accountInfoForm = new AccountInfoForm(null, $this->targetUser);
$this->view->accountInfoForm = new Users_Form_AccountInfo(null, $this->targetUser);
$this->view->accountInfoForm->populate(array(
'username' => $this->targetUser->username,
'firstname' => $this->targetUser->firstname,
@ -59,7 +59,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
throw new Monkeys_AccessDeniedException();
}
$form = new AccountInfoForm(null, $this->targetUser);
$form = new Users_Form_AccountInfo(null, $this->targetUser);
$formData = $this->_request->getPost();
$form->populate($formData);
@ -98,7 +98,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
$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->role = Users_Model_User::ROLE_REGISTERED;
$this->targetUser->setClearPassword($form->getValue('password1'));
}
$this->targetUser->save();
@ -115,7 +115,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
private function _usernameAlreadyExists($username)
{
$users = $this->_getUsers();
return $users->getUser($username);
return $users->getUserWithUsername($username);
}
private function _emailAlreadyExists($email)
@ -154,7 +154,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
$this->view->changePasswordForm = $appSession->changePasswordForm;
unset($appSession->changePasswordForm);
} else {
$this->view->changePasswordForm = new ChangePasswordForm();
$this->view->changePasswordForm = new Users_Form_ChangePassword();
}
}
@ -165,7 +165,7 @@ class Users_ProfilegeneralController extends Monkeys_Controller_Action
throw new Monkeys_AccessDeniedException();
}
$form = new ChangePasswordForm();
$form = new Users_Form_ChangePassword();
$formData = $this->_request->getPost();
$form->populate($formData);
if (!$form->isValid($formData)) {
@ -252,7 +252,7 @@ EOT;
}
if ($this->_config->subdomain->enabled) {
$openid = $this->_getProtocol() . '://' . $username . '.' . $this->_config->subdomain->hostname;
$openid = $this->getProtocol() . '://' . $username . '.' . $this->_config->subdomain->hostname;
} else {
$openid = $matches[1] . "/identity/$username";
}
@ -299,7 +299,7 @@ EOT;
private function _getUsers()
{
if (!isset($this->_users)) {
$this->_users = new Users();
$this->_users = new Users_Model_Users();
}
return $this->_users;

View File

@ -9,13 +9,13 @@
* @packager Keyboard Monkeys
*/
class Users_RecoverpasswordController extends Monkeys_Controller_Action
class Users_RecoverpasswordController extends CommunityID_Controller_Action
{
public function init()
{
parent::init();
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
if ($this->user->role != Users_Model_User::ROLE_ADMIN && $this->underMaintenance) {
return $this->_redirectForMaintenance();
}
}
@ -27,7 +27,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
$this->view->form = $appSession->recoverPasswordForm;
unset($appSession->recoverPasswordForm);
} else {
$this->view->form = new RecoverPasswordForm();
$this->view->form = new Users_Form_RecoverPassword();
}
$this->_helper->actionStack('index', 'login', 'users');
@ -35,7 +35,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
public function sendAction()
{
$form = new RecoverPasswordForm();
$form = new Users_Form_RecoverPassword();
$formData = $this->_request->getPost();
$form->populate($formData);
@ -45,7 +45,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
return $this->_forward('index');
}
$users = new Users();
$users = new Users_Model_Users();
$user = $users->getUserWithEmail($form->getValue('email'));
if (!$user) {
$form->email->addError($this->view->translate('This E-mail is not registered in the system'));
@ -54,7 +54,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
return $this->_forward('index');
}
$user->token = User::generateToken();
$user->token = Users_Model_User::generateToken();
$user->save();
$locale = Zend_Registry::get('Zend_Locale');
@ -87,7 +87,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
public function resetAction()
{
$users = new Users();
$users = new Users_Model_Users();
$user = $users->getUserWithToken($this->_getParam('token'));
if (!$user) {
$this->_helper->FlashMessenger->addMessage('Wrong Token');
@ -99,7 +99,7 @@ class Users_RecoverpasswordController extends Monkeys_Controller_Action
$user->setClearPassword($newPassword);
// reset token
$user->token = User::generateToken();
$user->token = Users_Model_User::generateToken();
$user->save();

View File

@ -9,7 +9,7 @@
* @packager Keyboard Monkeys
*/
class Users_RegisterController extends Monkeys_Controller_Action
class Users_RegisterController extends CommunityID_Controller_Action
{
protected $_numCols = 1;
@ -17,7 +17,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
{
parent::init();
if ($this->user->role != User::ROLE_ADMIN && $this->underMaintenance) {
if ($this->user->role != Users_Model_User::ROLE_ADMIN && $this->underMaintenance) {
return $this->_redirectForMaintenance();
}
@ -36,14 +36,14 @@ class Users_RegisterController extends Monkeys_Controller_Action
$form = $appSession->registerForm;
unset($appSession->registerForm);
} else {
$form = new RegisterForm(null, $this->view->base);
$form = new Users_Form_Register(null, $this->view->base);
}
$this->view->form = $form;
}
public function saveAction()
{
$form = new RegisterForm(null, $this->view->base);
$form = new Users_Form_Register(null, $this->view->base);
$formData = $this->_request->getPost();
$form->populate($formData);
@ -53,9 +53,9 @@ class Users_RegisterController extends Monkeys_Controller_Action
return $this->_forward('index', null, null);
}
$users = new Users();
$users = new Users_Model_Users();
if ($users->getUser($form->getValue('username'))) {
if ($users->getUserWithUsername($form->getValue('username'))) {
$form->username->addError($this->view->translate('This username is already in use'));
$appSession = Zend_Registry::get('appSession');
$appSession->registerForm = $form;
@ -79,7 +79,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
$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;
$openid = $this->getProtocol() . '://' . $user->username . '.' . $this->_config->subdomain->hostname;
} else {
$openid = $matches[1] . '/identity/' . $user->username;
}
@ -91,14 +91,14 @@ class Users_RegisterController extends Monkeys_Controller_Action
$user->openid = $openid;
$user->setClearPassword($form->getValue('password1'));
$user->role = User::ROLE_GUEST;
$registrationToken = User::generateToken();
$user->role = Users_Model_User::ROLE_GUEST;
$registrationToken = Users_Model_User::generateToken();
$user->token = $registrationToken;
$user->accepted_eula = 0;
$user->registration_date = date('Y-m-d');
$user->save();
$mail = $this->getMail($user);
$mail = self::getMail($user, $this->view->translate('Community-ID registration confirmation'));
try {
$mail->send();
$this->_helper->FlashMessenger->addMessage($this->view->translate('Thank you.'));
@ -115,7 +115,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
public function eulaAction()
{
$users = new Users();
$users = new Users_Model_Users();
if ($this->_request->getParam('token') == ''
|| !($user = $users->getUserWithToken($this->_request->getParam('token')))) {
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid token'));
@ -141,7 +141,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
public function declineeulaAction()
{
$users = new Users();
$users = new Users_Model_Users();
if ($this->_request->getParam('token') == ''
|| !($user = $users->getUserWithToken($this->_request->getParam('token')))) {
@ -157,14 +157,14 @@ class Users_RegisterController extends Monkeys_Controller_Action
public function accepteulaAction()
{
$users = new Users();
$users = new Users_Model_Users();
if ($this->_request->getParam('token') == ''
|| !($user = $users->getUserWithToken($this->_request->getParam('token')))) {
$this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid token'));
$this->_redirect('');
}
$user->role = User::ROLE_REGISTERED;
$user->role = Users_Model_User::ROLE_REGISTERED;
$user->accepted_eula = 1;
$user->registration_date = date('Y-m-d');
$user->token = '';
@ -180,7 +180,7 @@ class Users_RegisterController extends Monkeys_Controller_Action
* @return Zend_Mail
* @throws Zend_Mail_Protocol_Exception
*/
public function getMail(User $user)
public static function getMail(Users_Model_User $user, $subject)
{
$locale = Zend_Registry::get('Zend_Locale');
$localeElements = explode('_', $locale);
@ -221,9 +221,9 @@ class Users_RegisterController extends Monkeys_Controller_Action
$mail = new Zend_Mail('UTF-8');
$mail->setBodyText($emailTemplate);
$mail->setFrom($this->_config->email->supportemail);
$mail->setFrom($configEmail->supportemail);
$mail->addTo($user->email);
$mail->setSubject($this->view->translate('Community-ID registration confirmation'));
$mail->setSubject($subject);
return $mail;
}

View File

@ -9,20 +9,20 @@
* @packager Keyboard Monkeys
*/
class Users_UserslistController extends Monkeys_Controller_Action
class Users_UserslistController extends CommunityID_Controller_Action
{
public function indexAction()
{
$this->_helper->viewRenderer->setNeverRender(true);
$users = new Users();
$users = new Users_Model_Users();
switch($this->_getParam('filter')) {
case 'confirmed':
$where = "accepted_eula=1 AND role != '".User::ROLE_ADMIN."'";
$where = "accepted_eula=1 AND role != '".Users_Model_User::ROLE_ADMIN."'";
break;
case 'unconfirmed':
$where = "accepted_eula=0 AND role != '".User::ROLE_ADMIN."'";
$where = "accepted_eula=0 AND role != '".Users_Model_User::ROLE_ADMIN."'";
break;
default:
$where = false;
@ -33,20 +33,22 @@ class Users_UserslistController extends Monkeys_Controller_Action
$this->_getParam('startIndex'),
$this->_getParam('results'),
$this->_getParam('sort', 'registration'),
$this->_getParam('dir', Users::DIR_DESC),
$where);
$this->_getParam('dir', Users_Model_Users::DIR_DESC),
$where,
trim($this->_getParam('search')));
$jsonObj = new StdClass();
$jsonObj->recordsReturned = count($usersRows);
$jsonObj->totalRecords = $users->getNumUsers();
$jsonObj->totalRecords = $users->getNumUsers($where, trim($this->_getParam('search')));
$jsonObj->totalUsers = $users->getNumUsers();
$jsonObj->totalUnconfirmedUsers = $users->getNumUnconfirmedUsers();
$jsonObj->startIndex = $_GET['startIndex'];
$jsonObj->startIndex = $this->_getParam('startIndex');
$jsonObj->sort = $this->_getParam('sort');
$jsonObj->dir = $this->_getParam('dir');
$jsonObj->records = array();
foreach ($usersRows as $user) {
if ($user->role == User::ROLE_ADMIN) {
if ($user->role == Users_Model_User::ROLE_ADMIN) {
$status = $this->view->translate('admin');
} else if ($user->accepted_eula) {
$status = $this->view->translate('confirmed');

View 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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Users_Form_AccountInfo 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')
->addValidator(new Monkeys_Validate_Username())
->setRequired(true);
$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));
}
}
}

View 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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Users_Form_ChangePassword 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));
}
}

62
modules/users/forms/Login.php Executable file
View File

@ -0,0 +1,62 @@
<?php
class Users_Form_Login extends Zend_Form
{
private $_baseWebDir;
private $_useCaptcha;
public function __construct($options = null, $baseWebDir = null, $useCaptcha= false)
{
$this->_baseWebDir = $baseWebDir;
$this->_useCaptcha = $useCaptcha;
parent::__construct($options);
}
public function init()
{
$username = new Monkeys_Form_Element_Text('username');
translate('USERNAME');
$username->setLabel('USERNAME')
->setDecoratorOptions(array(
'separateLine' => true,
'dontMarkRequired' => true,
))
->setRequired(true);
$password = new Monkeys_Form_Element_Password('password');
translate('PASSWORD');
$password->setLabel('PASSWORD')
->setDecoratorOptions(array(
'separateLine' => true,
'dontMarkRequired' => true,
))
->setRequired(true);
$rememberme = new Monkeys_Form_Element_Checkbox('rememberme');
$rememberme->setLabel('Remember me');
$this->addElements(array($username, $password, $rememberme));
if ($this->_useCaptcha) {
$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,
)
));
$captcha->setDecoratorOptions(array(
'separateLine' => true,
'dontMarkRequired' => true,
));
$this->addElement($captcha);
}
}
}

View File

@ -0,0 +1,78 @@
<?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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Users_Form_PersonalInfo extends Zend_Form
{
private $_sregProps;
private $_formElements = array();
public function __construct($options = null, $user = null, $sregProps = null)
{
$this->_sregProps = $sregProps;
$fields = new Model_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']);
}
}
}
/**
* This removes the "openid_sreg_" prefix from the field names
*/
public function getUnqualifiedValues()
{
$values = array();
foreach ($this->getValues() as $key => $value) {
$values[substr($key, 12)] = $value;
}
return $values;
}
}

View 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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Users_Form_RecoverPassword extends Zend_Form
{
public function init()
{
$email = new Zend_Form_Element_Text('email');
$email->setLabel('')
->addFilter('StringToLower')
->setRequired(true)
->addValidator('EmailAddress');
$this->addElement($email);
}
}

View File

@ -0,0 +1,77 @@
<?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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Users_Form_Register 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')
->addValidator(new Monkeys_Validate_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));
}
}

View File

@ -0,0 +1,29 @@
<?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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Users_Model_AuthAttempt extends Zend_Db_Table_Row_Abstract
{
const MAX_ATTEMPTS_ALLOWED = 3;
const MIN_MINUTES_BETWEEN_ATTEMPTS = 30;
public function addFailure()
{
$this->failed_attempts++;
$this->last_attempt = date('Y-m-d H:i:s');
}
public function surpassedMaxAllowed()
{
return ($this->failed_attempts >= self::MAX_ATTEMPTS_ALLOWED)
&& $this->last_attempt > date('Y-m-d H:i:s', time() - self::MIN_MINUTES_BETWEEN_ATTEMPTS * 60);
}
}

View File

@ -0,0 +1,51 @@
<?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 CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Users_Model_AuthAttempts extends Monkeys_Db_Table_Gateway
{
protected $_name = 'auth_attempts';
protected $_primary = 'id';
protected $_rowClass = 'Users_Model_AuthAttempt';
/**
* This method first searches for a match on the session_id.
* If nothing is found, it searches for a match on the IP.
*/
public function get()
{
$ip = @$_SERVER['REMOTE_ADDR'];
$select = $this->select()
->where('session_id=?', session_id());
$row = $this->fetchRow($select);
if ($row) {
return $row;
}
$select = $select->where('IP=?', $ip);
return $this->fetchRow($select);
}
public function create()
{
$ip = @$_SERVER['REMOTE_ADDR'];
$attempt = $this->createRow();
$attempt->IP = $ip;
$attempt->session_id = session_id();
$attempt->failed_attempts = 1;
$attempt->last_attempt = date('Y-m-d H:i:s');
$attempt->save();
}
}

View File

@ -4,13 +4,13 @@
* @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
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class User extends Zend_Db_Table_Row_Abstract
class Users_Model_User extends Zend_Db_Table_Row_Abstract
{
const ROLE_GUEST = 'guest';
const ROLE_REGISTERED = 'registered';

View File

@ -4,21 +4,23 @@
* @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
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Users extends Monkeys_Db_Table_Gateway
class Users_Model_Users extends Monkeys_Db_Table_Gateway
{
protected $_name = 'users';
protected $_primary = 'id';
protected $_rowClass = 'User';
const DIR_ASC = 0;
const DIR_DESC = 1;
protected $_name = 'users';
protected $_primary = 'id';
protected $_rowClass = 'Users_Model_User';
private $_user;
private $_sortFields = array(
'name' => array('firstname', 'lastname'),
'registration' => array('registration_date', 'firstname', 'lastname'),
@ -30,12 +32,74 @@ class Users extends Monkeys_Db_Table_Gateway
return parent::createRow(array(
'openid' => '',
'password_changed' => '0000-00-00',
'role' => User::ROLE_GUEST,
'role' => Users_Model_User::ROLE_GUEST,
'passwordreset_token' => '',
));
}
public function getUsers($startIndex = false, $results = false, $sort = false, $dir = false, $where = false)
/**
* In CID we chose from the beginning not to use SET NAMES, and instead leave the charset encodings configurations
* to remain in the database server side (my.cnf).
*
* CID's strings are UTF8. If character_set_client is not UTF8 but latin1 for example (unfortunatly that's the common case), non-latin1
* characters will appear garbled when manually browsing the db, but they should show OK in CID's web pages.
*
* When authenticating below, we use MySQL's MD5 function. From my tests, it looks like the argument of this function
* gets automatically converted to the charset of that field. Sorta like if we had implicitly MD5(CONVERT(arg using charset)).
* When the tables are build during setup, the charset of string fields are set accordingly to the my.cnf directives
* character-set-server and collation-server.
* If those directives don't match character_set_client, the conversion inside MD5 will in fact transform the string, and we'll
* get the MD5 of a different string than what we had intended (well, only if the string contains non-latin1 characters).
* For this reason we have to override that conversion, converting to the charset specified in character_set_client, as shown below.
*
* @return Zend_Auth_Result
*/
public function authenticate($identity, $password, $isOpenId = false)
{
$auth = Zend_Auth::getInstance();
$db = $this->getAdapter();
$result = $db->query("SHOW VARIABLES LIKE 'character_set_client'")->fetch();
$clientCharset = $result['Value'];
if ($isOpenId) {
if (!Zend_OpenId::normalize($identity)) {
return false;
}
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'openid', 'password',
'MD5(CONCAT(CONVERT(openid using ' . $clientCharset . '), CONVERT(? using ' . $clientCharset . ')))');
} else {
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password',
'MD5(CONCAT(CONVERT(openid using ' . $clientCharset . '), CONVERT(? using ' . $clientCharset . ')))');
}
$authAdapter->setIdentity($identity);
$authAdapter->setCredential($password);
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
if ($isOpenId) {
$this->_user = $this->getUserWithOpenId($identity);
} else {
$this->_user = $this->getUserWithUsername($identity);
}
$auth->getStorage()->write($this->_user);
Zend_Registry::set('user', $this->_user);
return true;
}
return false;
}
public function getUser()
{
return $this->_user;
}
public function getUsers($startIndex = false, $results = false, $sort = false, $dir = false, $where = false, $search = false)
{
$select = $this->select();
@ -57,19 +121,23 @@ class Users extends Monkeys_Db_Table_Gateway
$select = $select->where($where);
}
if ($search) {
$select = $select->where('firstname LIKE ? OR lastname LIKE ?', "%$search%", "%$search%");
}
return $this->fetchAll($select);
}
public function getNumUsers($where = false)
public function getNumUsers($where = false, $search = false)
{
$users = $this->getUsers(false, false, false, false, $where);
$users = $this->getUsers(false, false, false, false, $where, $search);
return count($users);
}
public function getNumUnconfirmedUsers()
{
$users = $this->getUsers(false, false, false, false, "accepted_eula=0 AND role != '".User::ROLE_ADMIN."'");
$users = $this->getUsers(false, false, false, false, "accepted_eula=0 AND role != '".Users_Model_User::ROLE_ADMIN."'");
return count($users);
}
@ -90,6 +158,14 @@ class Users extends Monkeys_Db_Table_Gateway
return $this->fetchRow($select);
}
public function getUserWithUsername($username)
{
$select = $this->select()
->where('username=?', $username);
return $this->fetchRow($select);
}
public function getUserWithOpenId($openid)
{
$select = $this->select()
@ -98,11 +174,14 @@ class Users extends Monkeys_Db_Table_Gateway
return $this->fetchRow($select);
}
public function getUser($identity)
public function getUnconfirmedUsers($olderThanDays)
{
$select = $this->select()->where('username=?', $identity);
$date = date('Y-m-d', strtotime("$olderThanDays days ago"));
$select = $this->select()
->where('accepted_eula=0')
->where('registration_date < ?', $date);
return $this->fetchRow($select);
return $this->fetchAll($select);
}
public function deleteUser(User $user)
@ -116,9 +195,11 @@ class Users extends Monkeys_Db_Table_Gateway
$this->delete('test=1');
}
public function deleteUnconfirmed()
public function deleteUnconfirmed($olderThanDays)
{
$this->delete("accepted_eula=0 AND role = '".User::ROLE_GUEST."'");
$olderThanDays = (int) $olderThanDays;
$date = date('Y-m-d', strtotime("$olderThanDays days ago"));
$this->delete("accepted_eula=0 AND role = '".Users_Model_User::ROLE_GUEST."' AND registration_date < '$date'");
}
protected $_metadata = array(

View File

@ -1,79 +1,85 @@
<? if ($this->user->role != User::ROLE_GUEST ): ?>
<?php if ($this->user->role != Users_Model_User::ROLE_GUEST ): ?>
<h3>
<?= $this->translate('Hello, %s', Zend_Filter::get($this->user->username, 'HtmlEntities')) ?>
<?php echo $this->translate('Hello, %s', $this->escape($this->user->username)) ?>
</h3>
<ul>
<li>
<a href="<?= $this->base ?>/users/profile"><?= $this->translate('Account') ?></a>
<a href="<?php echo $this->base ?>/users/profile"><?= $this->translate('Account') ?></a>
</li>
<li>
<a href="<?= $this->base ?>/users/personalinfo"><?= $this->translate('Personal Info') ?></a>
<a href="<?php echo $this->base ?>/users/personalinfo"><?= $this->translate('Personal Info') ?></a>
</li>
<li>
<a href="<?= $this->base ?>/sites"><?= $this->translate('Sites database') ?></a>
<a href="<?php echo $this->base ?>/sites"><?= $this->translate('Sites database') ?></a>
</li>
<li>
<a href="<?= $this->base ?>/history"><?= $this->translate('History Log') ?></a>
<a href="<?php echo $this->base ?>/history"><?= $this->translate('History Log') ?></a>
</li>
<li>
<a href="<?= $this->base ?>/users/login/logout"><?= $this->translate('Logout') ?></a>
<a href="<?php echo $this->base ?>/users/login/logout"><?= $this->translate('Logout') ?></a>
</li>
</ul>
<? if ($this->user->role == User::ROLE_ADMIN): ?>
<?php if ($this->user->role == Users_Model_User::ROLE_ADMIN): ?>
<hr />
<h3><?= $this->translate('Admin options') ?></h3>
<h3><?php echo $this->translate('Admin options') ?></h3>
<ul>
<li>
<a href="<?= $this->base ?>/users/manageusers"><?= $this->translate('Manage Users') ?></a>
<a href="<?php echo $this->base ?>/users/manageusers"><?= $this->translate('Manage Users') ?></a>
</li>
<li>
<a href="<?= $this->base ?>/messageusers"><?= $this->translate('Message Users') ?></a>
<a href="<?php echo $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 ?>
<?php if ($this->maintenanceEnabled): ?>
<a href="<?php echo $this->base ?>/maintenancemode/disable"><?= $this->translate('Disable Maintenance Mode') ?></a>
<?php else: ?>
<a href="<?php echo $this->base ?>/maintenancemode/enable"><?= $this->translate('Enable Maintenance Mode') ?></a>
<?php endif ?>
</li>
<li>
<a href="<?= $this->base ?>/stats"><?= $this->translate('Statistics') ?></a>
<a href="<?php echo $this->base ?>/stats"><?= $this->translate('Statistics') ?></a>
</li>
<li>
<a href="<?php echo $this->base ?>/cid"><?= $this->translate('About Community-ID') ?></a>
</li>
</ul>
<? endif ?>
<? else: ?>
<? if ($this->underMaintenance): ?>
<?php endif ?>
<?php else: ?>
<?php if ($this->underMaintenance): ?>
<div class="messages_small">
<?= $this->translate('User access is currently disabled for system maintenance.<br />Please try again later') ?>
<?php echo $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">
<?php endif ?>
<form id="loginForm" action="<?php echo $this->loginTargetBase ?>/users/login/authenticate" method="post" class="formGrid">
<div id="credentials">
<?php echo $this->loginForm->username ?>
<?php echo $this->loginForm->password ?>
<?php if ($this->useCaptcha): ?>
<?php echo $this->loginForm->captcha ?>
<?php endif ?>
</div>
<div id="rememberMe">
<!-- to hard to do in the ZF -->
<input type="checkbox" name="rememberme" style="top:0" />
<label><?= $this->translate('Remember me') ?></label>
</dl>
<input type="checkbox" name="rememberme" style="top:0; width:15px" />
<label><?php echo $this->translate('Remember me') ?></label>
</div>
<div id="loginButton">
<input type="submit" id="login" value="<?= $this->translate('Log in') ?>" />
<input type="submit" id="login" value="<?php echo $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>
<a href="<?php echo $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?') ?>
<?php echo $this->translate('You don\'t have an account?') ?>
<div>
<a href="<?= $this->base ?>/users/register"><?= $this->translate('REGISTER NOW!') ?></a>
<a href="<?php echo $this->base ?>/users/register"><?= $this->translate('REGISTER NOW!') ?></a>
</div>
</p>&nbsp;<!-- safari bug workaround -->
</div>
<? endif; ?>
<?php endif; ?>

View File

@ -6,29 +6,37 @@ YAHOO.util.Event.onDOMReady(function () {
);
});
</script>
<div class="links_topright">
<a href="#" id="links_topright_all" onclick="COMMID.usersList.init('all'); return false;">
<?= $this->translate('All') ?>
<div class="links_topleft">
<div>
<input type="text" id="search" name="search" value="<?php echo $this->translate('Enter search string') ?>" onclick="(function () {COMMID.usersList.clickOnSearch()})()" />
<input type="button" id="goSearch" value="<?php echo $this->translate('Go') ?>" />
<input type="button" id="clearSearch" value="<?php echo $this->translate('Clear') ?>" />
</div>
<a href="#" id="links_topleft_all" onclick="COMMID.usersList.init('all'); return false;">
<?php echo $this->translate('All') ?>
</a>
| <a href="#" id="links_topright_confirmed" onclick="COMMID.usersList.init('confirmed'); return false;">
<?= $this->translate('Confirmed') ?>
| <a href="#" id="links_topleft_confirmed" onclick="COMMID.usersList.init('confirmed'); return false;">
<?php echo $this->translate('Confirmed') ?>
</a>
| <a href="#" id="links_topright_unconfirmed" onclick="COMMID.usersList.init('unconfirmed'); return false;">
<?= $this->translate('Unconfirmed') ?>
| <a href="#" id="links_topleft_unconfirmed" onclick="COMMID.usersList.init('unconfirmed'); return false;">
<?php echo $this->translate('Unconfirmed') ?>
</a>
</div>
<div id="paging"></div>
<div id="dt"></div>
<? if ($this->user->role == User::ROLE_ADMIN): ?>
<?php if ($this->user->role == Users_Model_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 />
<?php echo $this->translate('Total users:') ?> <span id="totalUsers"></span><br />
<?php echo $this->translate('Total confirmed users:') ?> <span id="totalConfirmedUsers"></span><br />
<?php echo $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'" />
<input type="button" id="addUser" value="<?php echo $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') ?>" />
<input type="button" id="deleteUnconfirmed" value="<?php echo $this->translate('Delete Unconfirmed Users') ?>" />
</span>
<span id="sendReminderSpan">
<input type="button" id="sendReminder" value="<?php echo $this->translate('Send Reminder') ?>" />
</span>
<script type="text/javascript">
new YAHOO.widget.Button(
@ -36,7 +44,7 @@ YAHOO.util.Event.onDOMReady(function () {
{
type : "push",
onclick : {fn: function() {
location.href='<?= $this->base ?>/users/profile?userid=0'
location.href='<?php echo $this->base ?>/users/profile?userid=0'
}
}
}
@ -48,6 +56,27 @@ YAHOO.util.Event.onDOMReady(function () {
onclick : {fn: function() {COMMID.usersList.deleteUnconfirmed()}}
}
);
new YAHOO.widget.Button(
"sendReminder",
{
type : "push",
onclick : {fn: function() {COMMID.usersList.sendReminder()}}
}
);
new YAHOO.widget.Button(
"goSearch",
{
type : "push",
onclick : {fn: function() {COMMID.usersList.submitSearch()}}
}
);
new YAHOO.widget.Button(
"clearSearch",
{
type : "push",
onclick : {fn: function() {COMMID.usersList.clearSearch()}}
}
);
</script>
</div>
<? endif ?>
<?php endif ?>

View File

@ -1,59 +1,29 @@
<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
},
<form name="personalInfoForm" class="formGrid" >
<?php foreach ($this->fields as $field): ?>
<?php echo $field ?>
<?php endforeach ?><br />
<input type="button" id="save" value="<?php echo $this->translate('Save') ?>" onclick="COMMID.editPersonalInfo.save()" />
<input type="button" id="cancel" value="<?php echo $this->translate('Cancel') ?>" onclick="COMMID.editPersonalInfo.cancel()" />
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function () {
COMMID.loader.insert(
["connection"],
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}
onclick : {fn: COMMID.personalInfo.save}
}
);
var oButton = new YAHOO.widget.Button(
"cancel",
{
type : "push",
onclick : {fn: COMMID.editPersonalInfo.cancel}
onclick : {fn: COMMID.personalInfo.cancel}
}
);
</script>

View File

@ -10,19 +10,19 @@ YAHOO.util.Event.onDOMReady(function () {
<div id="article">
<div id="generalTab" class="dataSection">
<div class="formHeader">
<h2><?= $this->translate('Personal Info') ?></h2>
<h2><?php echo $this->translate('Personal Info') ?></h2>
<div>
<a href="javascript:void(0);" onclick="COMMID.personalInfo.edit();">
<?= $this->translate('Edit') ?>
<?php echo $this->translate('Edit') ?>
</a>
<img id="loadingEditPersonalInfo" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" />
<img id="loadingEditPersonalInfo" src="<?php echo $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>
<em><?php echo $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)) ?>
<?php echo $this->action('show', 'personalinfo', 'users', array('userid' => $this->targetUser->id)) ?>
</div>
</div>
</div>

View File

@ -1,12 +1,12 @@
<div class="formGrid">
<? foreach ($this->fields as $field): ?>
<?php foreach ($this->fields as $field): ?>
<div class="yui-gf">
<div class="yui-u first">
<?= $this->translate($field->name) ?>:
<?php echo $this->translate($field->name) ?>:
</div>
<div class="yui-u">
<?= is_null($field->value)? $this->translate('Not Entered') : $field->value ?>
<?php echo is_null($field->value)? $this->translate('Not Entered') : $field->value ?>
</div>
</div>
<? endforeach ?>
<?php endforeach ?>
</div>

View File

@ -10,35 +10,35 @@ YAHOO.util.Event.onDOMReady(function () {
<div class="accountForm">
<div>
<h2><?= $this->translate('Account info') ?></h2>
<? if ($this->targetUser->id == $this->user->id): ?>
<div class="profileLinks">
<h2><?php echo $this->translate('Account info') ?></h2>
<?php if ($this->targetUser->id == $this->user->id): ?>
<div class="linksTopRight">
<a href="javascript:void(0);" onclick="COMMID.general.editAccountInfo();">
<?= $this->translate('Edit') ?>
<?php echo $this->translate('Edit') ?>
</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" onclick="COMMID.general.changePassword()" >
<?= $this->translate('Change Password') ?>
<?php echo $this->translate('Change Password') ?>
</a>
<img id="loadingAccountInfo" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" />
<img id="loadingAccountInfo" src="<?php echo $this->base ?>/images/progress.gif" style="visibility:hidden" />
</div>
<? endif ?>
<?php endif ?>
</div>
<div id="accountInfo">
<? if ($this->targetUser->id) {
<?php 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): ?>
<?php 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') ?>
<div class="linksTopRight" >
<a href="<?php echo $this->base ?>/users/profilegeneral/confirmdelete">
<?php echo $this->translate('Delete Account') ?>
</a>
<img id="loadingAccountInfoDummy" src="<?= $this->base ?>/images/progress.gif" style="visibility:hidden" /><!-- just for layout -->
<img id="loadingAccountInfoDummy" src="<?php echo $this->base ?>/images/progress.gif" style="visibility:hidden" /><!-- just for layout -->
</div>
</div>
<? endif ?>
<?php endif ?>
</div>

View File

@ -1,34 +1,34 @@
<div class="formGrid">
<div class="yui-gf">
<div class="yui-u first">
<?= $this->translate('Username') ?>:
<?php echo $this->translate('Username') ?>:
</div>
<div class="yui-u">
<?= $this->targetUser->username ?>
<?php echo $this->targetUser->username ?>
</div>
</div>
<div class="yui-gf">
<div class="yui-u first">
<?= $this->translate('Name') ?>:
<?php echo $this->translate('Name') ?>:
</div>
<div class="yui-u">
<?= $this->targetUser->getfullName() ?>
<?php echo $this->targetUser->getfullName() ?>
</div>
</div>
<div class="yui-gf">
<div class="yui-u first">
<?= $this->translate('E-mail') ?>:
<?php echo $this->translate('E-mail') ?>:
</div>
<div class="yui-u">
<?= $this->targetUser->email ?>
<?php echo $this->targetUser->email ?>
</div>
</div>
<div class="yui-gf">
<div class="yui-u first">
<?= $this->translate('OpenID') ?>:
<?php echo $this->translate('OpenID') ?>:
</div>
<div class="yui-u">
<?= $this->targetUser->openid ?>
<?php echo $this->targetUser->openid ?>
</div>
</div>
</div>

View File

@ -1,53 +1,24 @@
<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 ?>
<?php echo $this->changePasswordForm->password1 ?>
<?php echo $this->changePasswordForm->password2 ?>
<div class="yui-gf">
<div class="yui-u first">&nbsp;</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()" />
<input type="button" id="save" value="<?php echo $this->translate('Save') ?>" onclick="COMMID.changePassword.save()" />
<input type="button" id="cancel" value="<?php echo $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}
onclick : {fn: function() {COMMID.changePassword.save(<?php echo $this->targetUser->id ?>)}}
}
);
var oButton = new YAHOO.widget.Button(
"cancel",
{
type : "push",
onclick : {fn: COMMID.changePassword.cancel}
onclick : {fn: function() {COMMID.changePassword.cancel(<?php echo $this->targetUser->id ?>)}}
}
);
</script>

View File

@ -1,26 +1,26 @@
<form id="confirmDeleteForm" method="post" action="<?= $this->base ?>/users/profilegeneral/delete">
<form id="confirmDeleteForm" method="post" action="<?php echo $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:') ?>
<?php echo $this->translate('Why do you want to delete your Community-ID account?') ?><br />
<?php echo $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') ?>
<input type="checkbox" name="reason_test" style="top:0" /><?php echo $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') ?>
<input type="checkbox" name="reason_foundbetter" style="top:0" /><?php echo $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') ?>
<input type="checkbox" name="reason_lackedfeatures" style="top:0" /><?php echo $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') ?>
<input type="checkbox" name="reason_none" style="top:0" /><?php echo $this->translate('No particular reason') ?>
</li>
</ul>
<label for="reason_comments"><?= $this->translate('Additional comments:') ?></label>
<label for="reason_comments"><?php echo $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'" />
<input type="submit" id="delete" value="<?php echo $this->translate('Delete Account') ?>" />
<input type="button" id="cancel" value="<?php echo $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(
@ -28,7 +28,7 @@
{
type : "push",
onclick : {fn: function() {
location.href='<?= $this->base ?>/users/profile'
location.href='<?php echo $this->base ?>/users/profile'
}
}
}

View File

@ -1,17 +1,17 @@
<form name="accountInfoForm" class="formGrid">
<?= $this->accountInfoForm->username ?>
<?= $this->accountInfoForm->firstname ?>
<?= $this->accountInfoForm->lastname ?>
<?= $this->accountInfoForm->email ?>
<? if (!$this->targetUser->id) {
<?php echo $this->accountInfoForm->username ?>
<?php echo $this->accountInfoForm->firstname ?>
<?php echo $this->accountInfoForm->lastname ?>
<?php echo $this->accountInfoForm->email ?>
<?php if (!$this->targetUser->id) {
echo $this->accountInfoForm->password1;
echo $this->accountInfoForm->password2;
} ?>
<div class="yui-gf">
<div class="yui-u first">&nbsp;</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()" />
<input type="button" id="save" value="<?php echo $this->translate('Save') ?>" onclick="COMMID.editAccountInfo.save()" />
<input type="button" id="cancel" value="<?php echo $this->translate('Cancel') ?>" onclick="COMMID.editAccountInfo.cancel()" />
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function () {
new YAHOO.widget.Button(

View File

@ -1,7 +1,7 @@
<?= $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') ?>" />
<?php echo $this->translate('Please enter your E-mail below to receive a link to reset your password') ?>
<form method="post" action="<?php echo $this->base ?>/users/recoverpassword/send">
<?php echo $this->form->email ?>
<input type="submit" id="send" value="<?php echo $this->translate('Send') ?>" />
<script type="text/javascript">
var oButton = new YAHOO.widget.Button("send");
</script>

View File

@ -1,12 +1,12 @@
<h2><?= $this->translate('Please read the following EULA in order to continue') ?></h2>
<h2><?php echo $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 ?>" />
<input type="hidden" name="token" value="<?php echo $this->token ?>" />
<div>
<textarea rows="30" style="width:700px"><?= $this->eula ?></textarea>
<textarea rows="30" style="width:700px"><?php echo $this->eula ?></textarea>
</div>
<div style="margin-top:20px">
<input type="submit" id="agree" value="<?= $this->translate('I AGREE') ?>" />&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" id="disagree" value="<?= $this->translate('I DISAGREE') ?>" onclick="this.form.action='declineeula'; return true" />
<input type="submit" id="agree" value="<?php echo $this->translate('I AGREE') ?>" />&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" id="disagree" value="<?php echo $this->translate('I DISAGREE') ?>" onclick="this.form.action='declineeula'; return true" />
<script>
YAHOO.util.Event.onDOMReady(function () {
COMMID.loader.insert(

View File

@ -1,13 +1,13 @@
<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') ?>" />
<h2><?php echo $this->translate('Registration Form') ?></h2>
<form name="registration" method="post" action="<?php echo $this->base ?>/users/register/save" class="formGrid" >
<?php echo $this->form->firstname ?>
<?php echo $this->form->lastname ?>
<?php echo $this->form->email ?>
<?php echo $this->form->username ?>
<?php echo $this->form->password1 ?>
<?php echo $this->form->password2 ?>
<?php echo $this->form->captcha ?>
<input type="submit" id="send" value="<?php echo $this->translate('Send') ?>" />
<script type="text/javascript">
var oButton = new YAHOO.widget.Button("send");
</script>