import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
@ -45,14 +45,32 @@ class Users_Form_AccountInfo extends Zend_Form
|
||||
->setRequired(true)
|
||||
->addValidator('EmailAddress');
|
||||
|
||||
$this->addElements(array($username, $firstname, $lastname, $email));
|
||||
$authMethod = new Monkeys_Form_Element_Select('authMethod');
|
||||
translate('Auth Method');
|
||||
$authMethod->setLabel('Auth Method')
|
||||
->addMultiOption(Users_Model_User::AUTH_PASSWORD, 'Password')
|
||||
->addMultiOption(Users_Model_User::AUTH_YUBIKEY, 'YubiKey')
|
||||
->setAttrib('onchange', 'COMMID.general.toggleYubikey()');
|
||||
|
||||
$yubikey = new Monkeys_Form_Element_Text('yubikey');
|
||||
translate('Associated YubiKey');
|
||||
$yubikey->setLabel('Associated YubiKey')
|
||||
->setAttrib('class', 'yubiKeyInput');
|
||||
|
||||
$this->addElements(array($username, $firstname, $lastname, $email, $authMethod, $yubikey));
|
||||
|
||||
if (!$this->_targetUser->id) {
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter password');
|
||||
$passwordValidator = new Monkeys_Validate_Password();
|
||||
$password1->setLabel('Enter password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation())
|
||||
->addValidator($passwordValidator);
|
||||
|
||||
if ($restrictions = $passwordValidator->getPasswordRestrictionsDescription()) {
|
||||
$password1->setDescription($restrictions);
|
||||
}
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
@ -12,13 +12,27 @@
|
||||
|
||||
class Users_Form_ChangePassword extends Zend_Form
|
||||
{
|
||||
private $_username;
|
||||
|
||||
public function __construct($options = null, $username = null)
|
||||
{
|
||||
$this->_username = $username;
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter password');
|
||||
$passwordValidator = new Monkeys_Validate_Password($this->_username);
|
||||
$password1->setLabel('Enter password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation())
|
||||
->addValidator($passwordValidator);
|
||||
|
||||
if ($restrictions = $passwordValidator->getPasswordRestrictionsDescription()) {
|
||||
$password1->setDescription($restrictions);
|
||||
}
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
|
13
modules/users/forms/Login.php
Executable file → Normal file
13
modules/users/forms/Login.php
Executable file → Normal file
@ -28,14 +28,19 @@ class Users_Form_Login extends Zend_Form
|
||||
$password->setLabel('PASSWORD')
|
||||
->setDecoratorOptions(array(
|
||||
'separateLine' => true,
|
||||
'dontMarkRequired' => true,
|
||||
))
|
||||
->setRequired(true);
|
||||
));
|
||||
|
||||
$yubikey = new Monkeys_Form_Element_Text('yubikey');
|
||||
$yubikey->setLabel('YUBIKEY')
|
||||
->setDecoratorOptions(array(
|
||||
'separateLine' => true,
|
||||
))
|
||||
->setAttrib('class', 'yubiKeyInput');
|
||||
|
||||
$rememberme = new Monkeys_Form_Element_Checkbox('rememberme');
|
||||
$rememberme->setLabel('Remember me');
|
||||
|
||||
$this->addElements(array($username, $password, $rememberme));
|
||||
$this->addElements(array($username, $password, $yubikey, $rememberme));
|
||||
|
||||
if ($this->_useCaptcha) {
|
||||
$captcha = new Monkeys_Form_Element_Captcha('captcha', array(
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
@ -12,15 +12,19 @@
|
||||
|
||||
class Users_Form_PersonalInfo extends Zend_Form
|
||||
{
|
||||
private $_profile;
|
||||
private $_sregRequest;
|
||||
private $_sregProps;
|
||||
private $_formElements = array();
|
||||
|
||||
public function __construct($options = null, $user = null, $sregProps = null)
|
||||
public function __construct($options = null, Users_Model_Profile $profile = null, $sregRequest = null, $sregProps = null)
|
||||
{
|
||||
$this->_profile = $profile;
|
||||
$this->_sregRequest= $sregRequest;
|
||||
$this->_sregProps = $sregProps;
|
||||
|
||||
$fields = new Model_Fields();
|
||||
$fieldsArr = $fields->getValues($user);
|
||||
$fieldsArr = $fields->getValues($this->_profile);
|
||||
for ($i = 0; $i < count($fieldsArr); $i++) {
|
||||
$this->_formElements[$fieldsArr[$i]->openid] = array(
|
||||
'field' => $fieldsArr[$i],
|
||||
@ -57,6 +61,14 @@ class Users_Form_PersonalInfo extends Zend_Form
|
||||
$this->addElement($element);
|
||||
}
|
||||
} else {
|
||||
$profileName = new Monkeys_Form_Element_Text('profileName');
|
||||
translate('Profile Name');
|
||||
$profileName->setLabel('Profile Name')
|
||||
->setRequired(true)
|
||||
->setValue($this->_profile->name);
|
||||
|
||||
$this->addElement($profileName);
|
||||
|
||||
foreach ($this->_formElements as $formElement) {
|
||||
$this->addElement($formElement['element']);
|
||||
}
|
||||
@ -75,4 +87,44 @@ class Users_Form_PersonalInfo extends Zend_Form
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function getSregRequest()
|
||||
{
|
||||
return $this->_sregRequest;
|
||||
}
|
||||
|
||||
public function getPolicyUrl()
|
||||
{
|
||||
$args = $this->_sregRequest->getExtensionArgs();
|
||||
|
||||
if (!$args || !isset($args['policy_url'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $args['policy_url'];
|
||||
}
|
||||
|
||||
public static function getForm(Auth_OpenID_Request $request, Users_Model_Profile $profile)
|
||||
{
|
||||
// The class Auth_OpenID_SRegRequest is included in the following file
|
||||
require_once 'libs/Auth/OpenID/SReg.php';
|
||||
|
||||
$sregRequest = Auth_OpenID_SRegRequest::fromOpenIDRequest($request);
|
||||
$props = $sregRequest->allRequestedFields();
|
||||
$args = $sregRequest->getExtensionArgs();
|
||||
if (isset($args['required'])) {
|
||||
$required = explode(',', $args['required']);
|
||||
} else {
|
||||
$required = false;
|
||||
}
|
||||
|
||||
$sregProps = array();
|
||||
foreach ($props as $field) {
|
||||
$sregProps[$field] = $required && in_array($field, $required);
|
||||
}
|
||||
|
||||
$personalInfoForm = new Users_Form_PersonalInfo(null, $profile, $sregRequest, $sregProps);
|
||||
|
||||
return $personalInfoForm;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
|
12
modules/users/forms/Register.php
Executable file → Normal file
12
modules/users/forms/Register.php
Executable file → Normal file
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since CommunityID 0.9
|
||||
@ -13,10 +13,12 @@
|
||||
class Users_Form_Register extends Zend_Form
|
||||
{
|
||||
private $_baseWebDir;
|
||||
private $_config;
|
||||
|
||||
public function __construct($options = null, $baseWebDir = null)
|
||||
{
|
||||
$this->_baseWebDir = $baseWebDir;
|
||||
$this->_config = Zend_Registry::get('config');
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
@ -47,9 +49,15 @@ class Users_Form_Register extends Zend_Form
|
||||
|
||||
$password1 = new Monkeys_Form_Element_Password('password1');
|
||||
translate('Enter desired password');
|
||||
$passwordValidator = new Monkeys_Validate_Password();
|
||||
$password1->setLabel('Enter desired password')
|
||||
->setRequired(true)
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation());
|
||||
->addValidator(new Monkeys_Validate_PasswordConfirmation())
|
||||
->addValidator($passwordValidator);
|
||||
|
||||
if ($restrictions = $passwordValidator->getPasswordRestrictionsDescription()) {
|
||||
$password1->setDescription($restrictions);
|
||||
}
|
||||
|
||||
$password2 = new Monkeys_Form_Element_Password('password2');
|
||||
translate('Enter password again');
|
||||
|
30
modules/users/forms/SigninImage.php
Normal file
30
modules/users/forms/SigninImage.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2010 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_SigninImage extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$image = new Monkeys_Form_Element_File('image');
|
||||
$image->setLabel('')
|
||||
->setRequired(true)
|
||||
->setDescription('Only files of type jpg, jpeg, png and gif are allowed.<br />Maximum size is 2 MB.')
|
||||
->addValidator('Count', false, 1)
|
||||
->addValidator('Size', false, 2097152) // 2 MB
|
||||
->addValidator('Extension', false, 'jpg, jpeg, png, gif')
|
||||
->addFilter('StripNewlines'); // just a hack to circumvent ZF bug
|
||||
translate('Only files of type jpg, jpeg, png and gif are allowed.<br />Maximum size is 2 MB.');
|
||||
|
||||
$this->addElements(array($image));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user