Attached Files |
sidebox_mix_errors_fix_core.patch [^] (15,210 bytes) 2011-08-10 05:04
[Show Content]
Index: admin_templates/login.tpl
===================================================================
--- admin_templates/login.tpl (revision 14472)
+++ admin_templates/login.tpl (working copy)
@@ -127,18 +127,18 @@
<table class="login-table">
<tr>
<td colspan="2" style="text-align: center">
- <inp2:m_if check="u.current_HasError" field="any">
- <span class="error-cell"><inp2:u.current_Error field="ValidateLogin"/></span>
+ <inp2:m_if check="u.login-admin_HasError" field="any">
+ <span class="error-cell"><inp2:u.login-admin_Error field="UserLogin"/></span>
</inp2:m_if><br/>
</td>
</tr>
<tr>
<td class="text"><inp2:m_phrase name="la_Text_Login"/>:</td>
- <td><input type="text" name="login" class="text" value="<inp2:u_CookieUsername submit_field="login"/>" style="width: 150px;"></td>
+ <td><input type="text" name="<inp2:u.login-admin_InputName name='UserLogin'/>" class="text" value="<inp2:u.login-admin_CookieUsername field='UserLogin'/>" style="width: 150px;"></td>
</tr>
<tr>
<td class="text"><inp2:m_phrase name="la_prompt_Password"/>:</td>
- <td><input type="password" name="password" class="text" style="width: 150px;"></td>
+ <td><input type="password" name="<inp2:u.login-admin_InputName name='UserPassword'/>" class="text" style="width: 150px;"></td>
</tr>
<tr>
<td colspan="2">
@@ -165,8 +165,7 @@
<div id="footer-div"></div>
<inp2:m_if check="m_Param" name="http_auth">
- <input type="hidden" name="events[u]" value="OnLogin"/>
- <input type="hidden" name="next_template" value="<inp2:m_if check="m_GetEquals" name="next_template" value="">index<inp2:m_else/><inp2:m_get var="next_template"/></inp2:m_if>"/>
+ <input type="hidden" name="next_template" value="<inp2:m_if check='m_GetEquals' name='next_template' value="">index<inp2:m_else/><inp2:m_get var='next_template'/></inp2:m_if>"/>
<input type="hidden" name="skip_last_template" value="1"/>
<script type="text/javascript">
@@ -174,6 +173,7 @@
$(document).ready(
function() {
$("input[name='login']").focus();
+ Application.SetVar('events[u.login-admin]', 'OnLogin');
}
);
Index: units/users/users_config.php
===================================================================
--- units/users/users_config.php (revision 14472)
+++ units/users/users_config.php (working copy)
@@ -439,6 +439,45 @@
'LocalImage' => Array ('type' => 'string', 'default' => ''),
'LocalPath' => Array ('type' => 'string', 'default' => ''),
'FullUrl' => Array ('type' => 'string', 'default' => ''),
+
+ // for login form
+ 'UserLogin' => Array (
+ 'type' => 'string',
+ 'error_msgs' => Array (
+ 'no_permission' => '!la_no_permissions!', 'invalid_password' => '!la_invalid_password!'
+ ),
+ 'default' => ''
+ ),
+ 'UserPassword' => Array ('type' => 'string', 'default' => ''),
+ 'UserRememberLogin' => Array ('type' => 'int', 'default' => 0),
+
+ // for recommend form
+ 'RecommendEmail' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kFormatter', 'regexp' => '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i',
+ 'error_msgs' => Array ('required' => '!lu_InvalidEmail!', 'invalid_format' => '!lu_InvalidEmail!', 'send_error' => '!lu_email_send_error!'),
+ 'sample_value' => 'email@domain.com', 'default' => ''
+ ),
+
+ // for forgot password form
+ 'ForgotLogin' => Array (
+ 'type' => 'string',
+ 'error_msgs' => Array (
+ 'required' => '!lu_ferror_forgotpw_nodata!',
+ 'unknown_username' => '!lu_ferror_unknown_username!',
+ 'reset_denied' => '!lu_ferror_reset_denied!',
+ ),
+ 'default' => ''
+ ),
+ 'ForgotEmail' => Array (
+ 'type' => 'string',
+ 'error_msgs' => Array (
+ 'required' => '!lu_ferror_forgotpw_nodata!',
+ 'unknown_email' => '!lu_ferror_unknown_email!',
+ 'reset_denied' => '!lu_ferror_reset_denied!',
+ ),
+ 'default' => ''
+ ),
),
'Grids' => Array(
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 14472)
+++ units/users/users_event_handler.php (working copy)
@@ -208,11 +208,14 @@
*/
function OnLogin(&$event)
{
- $email_as_login = $this->Application->ConfigValue('Email_As_Login');
- $username = $this->Application->GetVar($email_as_login && !$this->Application->isAdmin ? 'email' : 'login');
- $password = $this->Application->GetVar('password');
- $rember_login = $this->Application->GetVar('cb_remember_login') == 1;
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+ $object->SetFieldsFromHash( $this->getSubmittedFields($event) );
+ $username = $object->GetDBField('UserLogin');
+ $password = $object->GetDBField('UserPassword');
+ $rember_login = $object->GetDBField('UserRememberLogin') == 1;
+
$user_helper =& $this->Application->recallObject('UserHelper');
/* @var $user_helper UserHelper */
@@ -220,17 +223,8 @@
$result = $user_helper->loginUser($username, $password, false, $rember_login);
if ($result != LOGIN_RESULT_OK) {
- $object =& $user_helper->getUserObject();
-
- if ($result == LOGIN_RESULT_NO_PERMISSION) {
- $object->SetError('ValidateLogin', 'no_permission', 'la_no_permissions');
- }
- else {
- $object->SetID(USER_GUEST);
- $object->SetError('ValidateLogin', 'invalid_password', 'la_invalid_password');
- }
-
$event->status = erFAIL;
+ $object->SetError('UserLogin', $result == LOGIN_RESULT_NO_PERMISSION ? 'no_permission' : 'invalid_password');
}
}
@@ -566,56 +560,35 @@
*/
function OnRecommend(&$event)
{
- $friend_email = $this->Application->GetVar('friend_email');
- $friend_name = $this->Application->GetVar('friend_email');
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
- // used for error reporting only -> rewrite code + theme (by Alex)
- $object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too
- /* @var $object UsersItem */
+ $object->setRequired('RecommendEmail');
+ $object->SetFieldsFromHash( $this->getSubmittedFields($event) );
- if (preg_match('/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i', $friend_email))
- {
- /*$cutoff = adodb_mktime() + (int)$this->Application->ConfigValue('Suggest_MinInterval');
- $sql = 'SELECT *
- FROM ' . TABLE_PREFIX . 'SuggestMail
- WHERE email = ' . $this->Conn->qstr($friend_email) . ' AND sent < ' . $cutoff;
- if ($this->Conn->GetRow($sql) !== false) {
- $object->SetError('Email', 'send_error', 'lu_email_already_suggested');
- $event->status = erFAIL;
- return ;
- }*/
+ if ( !$object->ValidateField('RecommendEmail') ) {
+ $event->status = erFAIL;
- $send_params = Array ();
- $send_params['to_email'] = $friend_email;
- $send_params['to_name'] = $friend_name;
+ return ;
+ }
- $user_id = $this->Application->RecallVar('user_id');
- $email_event =& $this->Application->EmailEventUser('USER.SUGGEST', $user_id, $send_params);
- $email_event =& $this->Application->EmailEventAdmin('USER.SUGGEST');
+ $send_params = Array (
+ 'to_email' => $object->GetDBField('RecommendEmail'),
+ 'to_name' => $object->GetDBField('RecommendEmail'),
+ );
- if ($email_event->status == erSUCCESS){
- /*$fields_hash = Array (
- 'email' => $friend_email,
- 'sent' => adodb_mktime(),
- );
+ $user_id = $this->Application->RecallVar('user_id');
+ $email_event =& $this->Application->EmailEventUser('USER.SUGGEST', $user_id, $send_params);
+ $email_event =& $this->Application->EmailEventAdmin('USER.SUGGEST');
- $this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'SuggestMail');*/
-
- $event->redirect_params = array('opener' => 's', 'pass' => 'all');
- $event->redirect = $this->Application->GetVar('template_success');
- }
- else {
-// $event->redirect_params = array('opener' => 's', 'pass' => 'all');
-// $event->redirect = $this->Application->GetVar('template_fail');
-
- $object->SetError('Email', 'send_error', 'lu_email_send_error');
- $event->status = erFAIL;
- }
- }
- else {
- $object->SetError('Email', 'invalid_email', 'lu_InvalidEmail');
+ if ( $email_event->status == erSUCCESS ) {
+ $event->SetRedirectParam('pass', 'all');
+ $event->redirect = $this->Application->GetVar('template_success');
+ }
+ else {
$event->status = erFAIL;
- }
+ $object->SetError('RecommendEmail', 'send_error');
+ }
}
/**
@@ -778,38 +751,39 @@
return $this->Conn->GetRow($sql);
}
+ /**
+ * Checks, that user can reset his password
+ *
+ * @param kEvent $event
+ */
function OnForgotPassword(&$event)
{
- $user_object =& $this->Application->recallObject('u.forgot', null, Array('skip_autoload' => true));
- /* @var $user_object UsersItem */
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
- // used for error reporting only -> rewrite code + theme (by Alex)
- $user_current_object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too
- /* @var $user_current_object UsersItem */
+ $object->SetFieldsFromHash( $this->getSubmittedFields($event) );
- $username = $this->Application->GetVar('username');
- $email = $this->Application->GetVar('email');
+ $user_object =& $this->Application->recallObject('u.tmp', null, Array('skip_autoload' => true));
+ /* @var $user_object UsersItem */
+
$found = false;
$allow_reset = true;
+ $username = $object->GetDBField('ForgotLogin');
+ $email = $object->GetDBField('ForgotEmail');
- if (strlen($username)) {
+ if ( strlen($username) ) {
$user_object->Load($username, 'Login');
- if ($user_object->isLoaded()) {
- $found = ($user_object->GetDBField("Login")==$username && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password"));
- }
}
- else if(strlen($email)) {
+ elseif ( strlen($email) ) {
$user_object->Load($email, 'Email');
- if ($user_object->isLoaded()) {
- $found = ($user_object->GetDBField("Email")==$email && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password"));
- }
}
- if ($user_object->isLoaded()) {
+ if ( $user_object->isLoaded() ) {
+ $found = $user_object->GetDBField('Status') == STATUS_ACTIVE;
+
$PwResetConfirm = $user_object->GetDBField('PwResetConfirm');
$PwRequestTime = $user_object->GetDBField('PwRequestTime');
$PassResetTime = $user_object->GetDBField('PassResetTime');
- //$MinPwResetDelay = $user_object->GetDBField('MinPwResetDelay');
$MinPwResetDelay = $this->Application->ConfigValue('Users_AllowReset');
$allow_reset = (strlen($PwResetConfirm) ?
@@ -817,45 +791,36 @@
adodb_mktime() > $PassResetTime + $MinPwResetDelay);
}
- if ($found && $allow_reset) {
- $this->Application->StoreVar('tmp_user_id', $user_object->GetDBField("PortalUserId"));
- $this->Application->StoreVar('tmp_email', $user_object->GetDBField("Email"));
+ if ( $found && $allow_reset ) {
+ $this->Application->StoreVar('tmp_user_id', $user_object->GetID());
+ $this->Application->StoreVar('tmp_email', $user_object->GetDBField('Email'));
$confirm_template = $this->Application->GetVar('reset_confirm_template');
- if (!$confirm_template) {
+
+ if ( !$confirm_template ) {
$this->Application->SetVar('reset_confirm_template', 'platform/login/forgotpass_reset');
}
- $this->Application->EmailEventUser('USER.PSWDC', $user_object->GetDBField('PortalUserId'));
+ $this->Application->EmailEventUser('USER.PSWDC', $user_object->GetID());
$event->redirect = $this->Application->GetVar('template_success');
}
else {
- if (!strlen($username) && !strlen($email)) {
- $user_current_object->SetError('Login', 'forgotpw_nodata', 'lu_ferror_forgotpw_nodata');
- $user_current_object->SetError('Email', 'forgotpw_nodata', 'lu_ferror_forgotpw_nodata');
+ if ( !strlen($username) && !strlen($email) ) {
+ $object->SetError('ForgotLogin', 'required');
+ $object->SetError('ForgotEmail', 'required');
}
else {
- if ($allow_reset) {
- if (strlen($username)) {
- $user_current_object->SetError('Login', 'unknown_username', 'lu_ferror_unknown_username');
- }
- if (strlen($email)) {
- $user_current_object->SetError('Email', 'unknown_email', 'lu_ferror_unknown_email');
- }
+ if ( strlen($username) ) {
+ $object->SetError('ForgotLogin', $allow_reset ? 'unknown_username' : 'reset_denied');
}
- else {
- if (strlen($username)) {
- $user_current_object->SetError('Login', 'reset_denied', 'lu_ferror_reset_denied');
- }
- if (strlen($email)) {
- $user_current_object->SetError('Email', 'reset_denied', 'lu_ferror_reset_denied');
- }
+ if ( strlen($email) ) {
+ $object->SetError('ForgotEmail', $allow_reset ? 'unknown_email' : 'reset_denied');
}
}
- if($user_current_object->FieldErrors){
- $event->redirect = false;
+ if ( !$object->ValidateField('ForgotLogin') || !$object->ValidateField('ForgotEmail') ) {
+ $event->status = erFAIL;
}
}
}
@@ -1081,6 +1046,11 @@
*/
function getPassedID(&$event)
{
+ if ( preg_match('/^(login|register|recommend|subscribe|forgot)/', $event->Special) ) {
+ // this way we can have 2+ objects stating with same special, e.g. "u.login-sidebox" and "u.login-main"
+ return USER_GUEST;
+ }
+
switch ($event->Special) {
case 'ord':
$order =& $this->Application->recallObject('ord');
Index: units/users/users_tag_processor.php
===================================================================
--- units/users/users_tag_processor.php (revision 14472)
+++ units/users/users_tag_processor.php (working copy)
@@ -230,9 +230,10 @@
function CookieUsername($params)
{
- $submit_value = $this->Application->GetVar($params['submit_field']);
- if ($submit_value !== false) {
- return $submit_value;
+ $items_info = $this->Application->GetVar( $this->getPrefixSpecial(true) );
+
+ if ( $items_info !== false ) {
+ return $items_info[USER_GUEST][ $params['field'] ];
}
$username = $this->Application->GetVar('save_username'); // from cookie
@@ -240,6 +241,7 @@
if ($username == 'super-root') {
$username = 'root';
}
+
return $username === false ? '' : $username;
}
sidebox_mix_errors_fix_themes.patch [^] (7,462 bytes) 2011-08-10 05:04
[Show Content]
Index: advanced/platform/elements/side_boxes/login.elm.tpl
===================================================================
--- advanced/platform/elements/side_boxes/login.elm.tpl (revision 14472)
+++ advanced/platform/elements/side_boxes/login.elm.tpl (working copy)
@@ -84,33 +84,33 @@
<form method="post" action="<inp2:m_FormAction />">
<inp2:m_if check="u_UseUsernames">
<inp2:m_phrase label="lu_username"/><br />
- <input class="input-text" type="text" name="login" style="width:155px" /><br />
<inp2:m_else/>
<inp2:m_phrase label="lu_email"/><br />
- <input class="input-text" type="text" name="email" style="width:155px" /><br />
</inp2:m_if>
+ <input class="input-text" type="text" name="<inp2:u.login-sidebox_InputName name='UserLogin'/>" value="<inp2:u.login-sidebox_Field name='UserLogin'/>" style="width:155px" /><br />
+
<img src="<inp2:m_TemplatesBase module="In-Portal"/>img/s.gif" width="1" height="5" alt=""/><br />
<inp2:m_Phrase label="lu_Password"/><br />
- <input type="password" class="input-text" name="password" style="width:155px" /><br />
+ <input type="password" class="input-text" name="<inp2:u.login-sidebox_InputName name='UserPassword'/>" value="<inp2:u.login-sidebox_Field name='UserPassword'/>" style="width:155px" /><br />
<img src="<inp2:m_TemplatesBase module="In-Portal"/>img/s.gif" alt="" width="1" height="10" border="0" /><br />
<table>
<tr>
<td width="10">
- <input class="button" name="events[u][OnLogin]" type="submit" value="<inp2:m_Phrase label='lu_Login' no_editing='1'/>" /><br />
+ <input class="button" name="events[u.login-sidebox][OnLogin]" type="submit" value="<inp2:m_Phrase label='lu_Login' no_editing='1'/>" /><br />
</td>
<td align="left">
- <input type="checkbox" name="cb_remember_login" value="1"/> <span class="remember-login"><inp2:m_Phrase label="lu_remember_login"/></span>
+ <input type="checkbox" name="<inp2:u.login-sidebox_InputName name='UserRememberLogin'/>" id="<inp2:u.login-sidebox_InputName name='UserRememberLogin'/>" value="1"/> <label for="<inp2:u.login-sidebox_InputName name='UserRememberLogin'/>" class="remember-login"><inp2:m_Phrase label="lu_remember_login"/></label>
</td>
</tr>
</table>
<img src="<inp2:m_TemplatesBase module="In-Portal"/>img/s.gif" alt="" width="5" height="5" border="0" /><br />
- <inp2:m_if check="u_HasError" field="any">
- <span class="field-error"><inp2:u_Error field="ValidateLogin"/></span><br />
+ <inp2:m_if check="u.login-sidebox_HasError" field="any">
+ <span class="field-error"><inp2:u.login-sidebox_Error field="UserLogin"/></span><br />
</inp2:m_if>
<inp2:m_if check="u_RegistrationEnabled">
Index: advanced/platform/elements/side_boxes/recommend_site.elm.tpl
===================================================================
--- advanced/platform/elements/side_boxes/recommend_site.elm.tpl (revision 14472)
+++ advanced/platform/elements/side_boxes/recommend_site.elm.tpl (working copy)
@@ -6,11 +6,11 @@
<img src="<inp2:m_TemplatesBase module="In-Portal"/>img/s.gif" alt="" width="1" height="5" border="0" /><br />
<form method="POST" action="<inp2:m_FormAction />">
- <input type="text" class="input-text" name="friend_email" value="" style="width: 155px;" /><br />
- <inp2:m_if check="u_HasError" field="any">
- <span class="field-error"><inp2:u_Error field="Email"/></span><br />
+ <input type="text" class="input-text" name="<inp2:u.recommend-sidebox_InputName name='RecommendEmail'/>" value="<inp2:u.recommend-sidebox_Field name='RecommendEmail'/>" style="width: 155px;" /><br />
+ <inp2:m_if check="u.recommend-sidebox_HasError" field="any">
+ <span class="field-error"><inp2:u.recommend-sidebox_Error field="RecommendEmail"/></span><br />
</inp2:m_if>
<br />
- <input class="button" name="events[u][OnRecommend]" type="submit" value="<inp2:m_Phrase label='lu_btn_Recommend' no_editing='1'/>" />
+ <input class="button" name="events[u.recommend-sidebox][OnRecommend]" type="submit" value="<inp2:m_Phrase label='lu_btn_Recommend' no_editing='1'/>" />
<input type="hidden" name="template_success" value="platform/recommend/recommend" />
</form>
\ No newline at end of file
Index: advanced/platform/login/forgot_password.tpl
===================================================================
--- advanced/platform/login/forgot_password.tpl (revision 14472)
+++ advanced/platform/login/forgot_password.tpl (working copy)
@@ -49,7 +49,7 @@
</inp2:m_if>
<br /><br />
- <inp2:m_if check="u_HasError" field="any">
+ <inp2:m_if check="u.forgot_HasError" field="any">
<inp2:m_RenderElement name="error_message"/>
</inp2:m_if>
@@ -57,17 +57,8 @@
<form method="post" action="<inp2:m_FormAction/>">
<table class="form-data fullwidth">
- <inp2:m_if check="m_ConfigEquals" name="Email_As_Login" value="0">
- <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">
- <inp2:m_if check="u_HasError" field="Login">
- <span class="field-error"><inp2:u_Error field="Login"/></span><br />
- </inp2:m_if>
- <input type="text" class="input-text" name="username" value="<inp2:m_Get name="username"/>" tabindex="<inp2:m_get param="tab_index"/>" style="width: 155px;">
- </td>
- </tr>
- <inp2:m_RenderElement name="inp_edit_field_separator" is_last="0"/>
+ <inp2:m_if check="u_UseUsernames">
+ <inp2:m_RenderElement name="inp_edit_box" prefix="u.forgot" field="ForgotLogin" title="lu_fld_Login" style="width: 155px;"/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<td class="field-name"></td>
@@ -78,21 +69,13 @@
<inp2:m_RenderElement name="inp_edit_field_separator" is_last="0"/>
</inp2:m_if>
- <tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
- <inp2:m_RenderElement name="inp_edit_field_caption" prefix="u" field="Email" title="lu_fld_Email"/>
- <td class="field-value">
- <inp2:m_if check="u_HasError" field="Email">
- <span class="field-error"><inp2:u_Error field="Email"/></span><br />
- </inp2:m_if>
- <input type="text" class="input-text" name="email" value="<inp2:m_Get name="email"/>" tabindex="<inp2:m_get param="tab_index"/>" style="width: 155px;">
- </td>
- </tr>
+ <inp2:m_RenderElement name="inp_edit_box" prefix="u.forgot" field="ForgotEmail" title="lu_fld_Email" style="width: 155px;"/>
<inp2:m_RenderElement design="inp_edit_buttons">
<input type="hidden" name="template_success" value="platform/login/forgot_password_reset_notice"/>
<input type="hidden" name="reset_confirm_template" value="platform/login/forgot_password_reset"/>
- <input type="submit" class="button" name="events[u][OnForgotPassword]" value="<inp2:m_Phrase label="lu_btn_SendPassword" no_editing="1"/>" />
+ <input type="submit" class="button" name="events[u.forgot][OnForgotPassword]" value="<inp2:m_Phrase label='lu_btn_SendPassword' no_editing='1'/>" />
<input type="button" class="button" onclick="redirect('<inp2:m_Link template="index"/>');" value="<inp2:m_Phrase label="lu_btn_Cancel" no_editing="1"/>">
</inp2:m_RenderElement>
</table>
|