Attached Files |
improvements_to_email_as_login.patch [^] (12,077 bytes) 2011-07-08 10:34
[Show Content]
Index: install/install_schema.sql
===================================================================
--- install/install_schema.sql (revision 14437)
+++ install/install_schema.sql (working copy)
@@ -237,7 +237,7 @@
CREATE TABLE PortalUser (
PortalUserId int(11) NOT NULL AUTO_INCREMENT,
- Login varchar(255) DEFAULT NULL,
+ Login varchar(255) NOT NULL,
`Password` varchar(255) DEFAULT 'd41d8cd98f00b204e9800998ecf8427e',
FirstName varchar(255) NOT NULL DEFAULT '',
LastName varchar(255) NOT NULL DEFAULT '',
@@ -267,16 +267,17 @@
DisplayToPublic text,
UserType tinyint(4) NOT NULL,
PrimaryGroupId int(11) DEFAULT NULL,
+ OldStyleLogin tinyint(4) NOT NULL,
PRIMARY KEY (PortalUserId),
UNIQUE KEY ResourceId (ResourceId),
- UNIQUE KEY Login (Login),
KEY CreatedOn (CreatedOn),
KEY `Status` (`Status`),
KEY Modified (Modified),
KEY dob (dob),
KEY IsBanned (IsBanned),
KEY AdminLanguage (AdminLanguage),
- KEY UserType (UserType)
+ KEY UserType (UserType),
+ KEY Login (Login)
);
CREATE TABLE PortalUserCustomData (
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 14437)
+++ install/upgrades.sql (working copy)
@@ -2012,4 +2012,15 @@
SET DisplayOrder = DisplayOrder + 0.01
WHERE `ModuleOwner` = 'In-Portal:Users' AND `Section` = 'in-portal:configure_users' AND DisplayOrder BETWEEN 10.12 AND 20.00;
-INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_AdminGroup', '11', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_admin_group', 'select', NULL, '0=lu_none||<SQL+>SELECT GroupId as OptionValue, Name as OptionName FROM <PREFIX>PortalGroup WHERE Enabled=1 AND Personal=0</SQL>', 10.12, 0, 1, NULL);
\ No newline at end of file
+INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_AdminGroup', '11', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_admin_group', 'select', NULL, '0=lu_none||<SQL+>SELECT GroupId as OptionValue, Name as OptionName FROM <PREFIX>PortalGroup WHERE Enabled=1 AND Personal=0</SQL>', 10.12, 0, 1, NULL);
+
+ALTER TABLE PortalUser
+ DROP INDEX Login,
+ ADD INDEX Login (Login);
+
+ALTER TABLE PortalUser CHANGE Login Login VARCHAR(255) NOT NULL;
+ALTER TABLE PortalUser ADD OldStyleLogin TINYINT NOT NULL;
+
+UPDATE PortalUser
+SET OldStyleLogin = 1
+WHERE (Login <> '') AND (Login NOT REGEXP '^[A-Z0-9_\\-\\.]+$');
\ No newline at end of file
Index: kernel/managers/cache_manager.php
===================================================================
--- kernel/managers/cache_manager.php (revision 14434)
+++ kernel/managers/cache_manager.php (working copy)
@@ -360,6 +360,7 @@
'KeepSessionOnBrowserClose',
'User_GuestGroup',
'User_LoggedInGroup',
+ 'Email_As_Login',
// output related
'UseModRewrite',
Index: units/users/users_config.php
===================================================================
--- units/users/users_config.php (revision 14437)
+++ units/users/users_config.php (working copy)
@@ -334,20 +334,24 @@
'Fields' => Array
(
'PortalUserId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
- 'Login' => Array ('type' => 'string', 'unique'=>Array('Login'), 'default' => null,'required'=>1, 'error_msgs' => Array('unique'=>'!lu_user_already_exist!')),
+ 'Login' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kFormatter', 'regexp' => '/^[A-Z\d_\-\.]+$/i',
+ 'error_msgs' => Array('unique' => '!lu_user_already_exist!', 'invalid_format' => '!la_error_InvalidLogin!'),
+ 'not_null' => 1, 'unique' => Array (), 'default' => '',
+ ),
'Password' => Array ('type' => 'string', 'formatter' => 'kPasswordFormatter', 'encryption_method' => 'md5', 'verify_field' => 'VerifyPassword', 'skip_empty' => 1, 'default' => md5('')),
'FirstName' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
'LastName' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
'Company' => Array ('type' => 'string','not_null' => 1,'default' => ''),
'Email' => Array (
- 'type' => 'string', 'formatter' => 'kFormatter',
- 'regexp'=>'/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i',
- 'sample_value' => 'email@domain.com', 'unique' => Array ('Email'), 'not_null' => 1,
- 'required' => 1,
- 'default' => '',
+ 'type' => 'string',
+ 'formatter' => 'kFormatter', 'regexp' => '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i',
+ 'sample_value' => 'email@domain.com',
'error_msgs' => Array (
- 'invalid_format'=>'!la_invalid_email!', 'unique'=>'!lu_email_already_exist!'
+ 'invalid_format' => '!la_invalid_email!', 'unique' => '!lu_email_already_exist!'
),
+ 'not_null' => 1, 'unique' => Array (), 'required' => 1, 'default' => ''
),
'CreatedOn' => Array('type'=>'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
'Phone' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
@@ -408,6 +412,11 @@
'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %1$s FROM ' . TABLE_PREFIX . 'PortalGroup WHERE Enabled = 1 AND FrontRegistration = 1', 'option_key_field' => 'GroupId', 'option_title_field' => 'Name',
'default' => NULL
),
+ 'OldStyleLogin' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 0
+ ),
),
'VirtualFields' => Array(
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 14446)
+++ units/users/users_event_handler.php (working copy)
@@ -423,13 +423,11 @@
if ( !$this->isSubscriberOnly($event) ) {
$object =& $event->getObject( Array('skip_autoload' => true) );
- /* @var $object kDBItem */
+ /* @var $object UsersItem */
if ( $this->Application->ConfigValue('User_Password_Auto') ) {
- $pass = kUtil::generatePassword( rand(5, 8) );
- $object->SetField('Password', $pass);
- $object->SetField('VerifyPassword', $pass);
- $this->Application->SetVar('user_password', $pass);
+ $password = $object->generatePassword( rand(5, 8) );
+ $this->Application->SetVar('user_password', $password);
}
parent::OnCreate($event);
@@ -501,7 +499,7 @@
$cs_helper->PopulateStates($event, 'State', 'Country');
$object =& $event->getObject();
- /* @var $object kDBItem */
+ /* @var $object UsersItem */
if ( $this->Application->ConfigValue('Email_As_Login') ) {
$field_options = $object->GetFieldOptions('Email');
@@ -509,7 +507,6 @@
$object->SetFieldOptions('Email', $field_options);
}
- $object->setLogin();
$this->setUserGroup($object);
$user_helper =& $this->Application->recallObject('UserHelper');
@@ -738,9 +735,8 @@
}
}
else {
- $password = makepassword4();
- $object->SetField('Password', $password);
- $object->SetField('VerifyPassword', $password);
+ $object->generatePassword();
+
$object->SetDBField('Email', $user_email);
$object->SetDBField('Login', $user_email);
$object->SetDBField('Status', STATUS_ACTIVE); // make user subscriber Active by default
@@ -936,13 +932,9 @@
$user_object->SetDBField('PwRequestTime', 0);
if ($exp_time > adodb_mktime()) {
- $newpw = kUtil::generatePassword();
-
+ $newpw = $user_object->generatePassword();
$this->Application->StoreVar('password', $newpw);
- $user_object->SetField('Password', $newpw);
- $user_object->SetField('VerifyPassword', $newpw);
-
$user_object->SetDBField('PassResetTime', adodb_mktime());
$user_object->SetDBField('PwResetConfirm', '');
$user_object->SetDBField('PwRequestTime', 0);
@@ -990,11 +982,6 @@
$cs_helper->CheckStateField($event, 'State', 'Country');
$cs_helper->PopulateStates($event, 'State', 'Country');
-
- $object =& $event->getObject();
- /* @var $object UsersItem */
-
- $object->setLogin();
}
/**
@@ -1405,6 +1392,8 @@
{
parent::OnAfterConfigRead($event);
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+
// 1. arrange user registration countries
$site_helper =& $this->Application->recallObject('SiteHelper');
/* @var $site_helper SiteHelper */
@@ -1415,7 +1404,6 @@
$first_country = $this->Application->ConfigValue('User_Default_Registration_Country');
}
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
if ($first_country) {
// update user country dropdown sql
@@ -1424,7 +1412,6 @@
// 2. set default user registration group
$fields['PrimaryGroupId']['default'] = $this->Application->ConfigValue('User_NewGroup');
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
// 3. allow avatar upload on Front-End
$file_helper =& $this->Application->recallObject('FileHelper');
@@ -1434,10 +1421,7 @@
if ($this->Application->isAdminUser) {
// 4. when in administrative console, then create all users with Active status
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
-// $fields['Password']['required'] = 1; // set password required (will broke approve/decline buttons)
$fields['Status']['default'] = STATUS_ACTIVE;
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
// 5. remove groups tab on editing forms when AdvancedUserManagement config variable not set
if (!$this->Application->ConfigValue('AdvancedUserManagement')) {
@@ -1457,6 +1441,13 @@
$this->Application->setUnitOption($event->Prefix, 'EditTabPresets', $edit_tab_presets);
}
}
+
+ if ( !$this->Application->ConfigValue('Email_As_Login') ) {
+ // Login becomes required only, when it's used in registration process
+ $fields['Login']['required'] = 1;
+ }
+
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
}
/**
@@ -1487,12 +1478,9 @@
function OnBeforeClone(&$event)
{
$object =& $event->getObject();
- /* @var $object kDBItem */
+ /* @var $object UsersItem */
- $password = kUtil::generatePassword();
- $object->SetField('Password', $password);
- $object->SetField('VerifyPassword', $password);
-
+ $object->generatePassword();
$object->SetDBField('ResourceId', 0); // this will reset it
// change email because it should be unique
Index: units/users/users_item.php
===================================================================
--- units/users/users_item.php (revision 14437)
+++ units/users/users_item.php (working copy)
@@ -41,18 +41,6 @@
}
}
- /**
- * Set's Login from Email if required by configuration settings
- *
- */
- function setLogin()
- {
- if( $this->Application->ConfigValue('Email_As_Login') )
- {
- $this->SetDBField('Login', $this->GetDBField('Email') );
- }
- }
-
function SendEmailEvents()
{
switch ($this->GetDBField('Status')) {
@@ -136,4 +124,20 @@
$this->SetDBField('LastName', $last_name);
}
+ /**
+ * Generates new password for given user
+ *
+ * @param int $length
+ * @return string
+ * @access public
+ */
+ public function generatePassword($length = 10)
+ {
+ $password = kUtil::generatePassword($length);
+
+ $this->SetField('Password', $password);
+ $this->SetField('VerifyPassword', $password);
+
+ return $password;
+ }
}
\ No newline at end of file
improvements_to_email_as_login_themes.patch [^] (2,183 bytes) 2011-07-13 06:28
[Show Content]
Index: platform/login/forgot_password.tpl
===================================================================
--- platform/login/forgot_password.tpl (revision 14446)
+++ platform/login/forgot_password.tpl (working copy)
@@ -42,10 +42,10 @@
<inp2:m_phrase name="lu_title_ForgotPassword"/>
</inp2:m_Capture>
- <inp2:m_if check="conf_ConfigValue" name="Email_As_Login">
+ <inp2:m_if check="u_UseUsernames">
+ <inp2:m_Phrase label="lu_EnterForgotUserEmail"/>
+ <inp2:m_else/>
<inp2:m_Phrase label="lu_EnterForgotEmail"/>
- <inp2:m_else/>
- <inp2:m_Phrase label="lu_EnterForgotUserEmail"/>
</inp2:m_if>
<br /><br />
@@ -57,7 +57,7 @@
<form method="post" action="<inp2:m_FormAction/>">
<table class="form-data fullwidth">
- <inp2:m_if check="m_ConfigEquals" name="Email_As_Login" value="0">
+ <inp2:m_if check="u_UseUsernames">
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="u" field="Login" title="lu_fld_Login"/>
<td class="field-value">
Index: platform/my_account/my_profile.tpl
===================================================================
--- platform/my_account/my_profile.tpl (revision 14446)
+++ platform/my_account/my_profile.tpl (working copy)
@@ -48,7 +48,11 @@
<form method="post" enctype="multipart/form-data" action="<inp2:m_FormAction/>">
<table class="form-data fullwidth">
- <inp2:m_RenderElement name="inp_label" prefix="u" field="Login" title="lu_fld_Login"/>
+ <inp2:m_if check="u_Field" name="OldStyleLogin" db="db">
+ <inp2:m_RenderElement name="inp_edit_box" prefix="u" field="Login" title="lu_fld_Login" style="width:155px"/>
+ <inp2:m_else/>
+ <inp2:m_RenderElement name="inp_label" prefix="u" field="Login" title="lu_fld_Login"/>
+ </inp2:m_if>
<inp2:m_RenderElement name="inp_edit_password" prefix="u" field="Password" title="lu_fld_Password" style="width:155px" />
<inp2:m_RenderElement name="inp_edit_password" prefix="u" field="VerifyPassword" title="lu_fld_VerifyPassword" style="width:155px" />
improvements_to_email_as_login_modules.patch [^] (573 bytes) 2011-07-27 10:13
[Show Content]
Index: in-commerce/units/affiliates/affiliates_event_handler.php
===================================================================
--- in-commerce/units/affiliates/affiliates_event_handler.php (revision 14446)
+++ in-commerce/units/affiliates/affiliates_event_handler.php (working copy)
@@ -218,7 +218,6 @@
list($id,$field_values) = each($items_info);
$user_object->SetFieldsFromHash($field_values);
$user_object->setID($id);
- $user_object->setLogin();
}
$require_affiliate = ($this->Application->GetVar('RegisterAsAffiliate') == 'on');
|