Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -N -r7391 -r7635 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 7391) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 7635) @@ -30,6 +30,26 @@ } /** + * Shows only admins when required + * + * @param kEvent $event + */ + function SetCustomQuery(&$event) + { + $object =& $event->getObject(); + /* @var $object kDBList */ + + if ($event->Special == 'admins') { + $object->addFilter('primary_filter', 'ug.GroupId = 11'); + } + + if ($event->Special == 'regular') { + $object->addFilter('primary_filter', 'ug.GroupId <> 11'); + } + } + + + /** * Checks permissions of user * * @param kEvent $event @@ -109,9 +129,12 @@ $prefix_special = $this->Application->IsAdmin() ? 'u.current' : 'u'; // "u" used on front not to change theme $object =& $this->Application->recallObject($prefix_special, null, Array('skip_autoload' => true)); $password = $this->Application->GetVar('password'); + + $invalid_pseudo = $this->Application->IsAdmin() ? 'la_invalid_password' : 'lu_invalid_password'; + if(!$password) { - $object->SetError('ValidateLogin', 'blank_password', 'lu_blank_password'); + $object->SetError('ValidateLogin', 'invalid_password', $invalid_pseudo); $event->status = erFAIL; return false; } @@ -121,17 +144,19 @@ $login_value = $this->Application->GetVar($submit_field); // process "Save Username" checkbox - $save_username = $this->Application->GetVar('cb_save_username') ? $login_value : ''; - $this->Application->Session->SetCookie('save_username', $save_username, adodb_mktime() + 31104000); // 1 year expiration - $this->Application->SetVar('save_username', $save_username); // cookie will be set on next refresh, but refresh won't occur if login error present, so duplicate cookie in HTTPQuery - + if ($this->Application->IsAdmin()) { + $save_username = $this->Application->GetVar('cb_save_username') ? $login_value : ''; + $this->Application->Session->SetCookie('save_username', $save_username, adodb_mktime() + 31104000); // 1 year expiration + $this->Application->SetVar('save_username', $save_username); // cookie will be set on next refresh, but refresh won't occur if login error present, so duplicate cookie in HTTPQuery + } + if ($this->Application->IsAdmin() && ($login_value == 'root')) { // logging in "root" (admin only) $root_password = $this->Application->ConfigValue('RootPass'); $password_formatter =& $this->Application->recallObject('kPasswordFormatter'); $test = $password_formatter->EncryptPassword($password, 'b38'); if ($root_password != $test) { - $object->SetError('ValidateLogin', 'invalid_password', 'lu_invalid_password'); + $object->SetError('ValidateLogin', 'invalid_password', $invalid_pseudo); $event->status = erFAIL; return false; } @@ -196,10 +221,10 @@ else { $object->SetID(-2); - $object->SetError('ValidateLogin', 'invalid_password', 'lu_invalid_password'); + $object->SetError('ValidateLogin', 'invalid_password', $invalid_pseudo); $event->status = erFAIL; } - + $event->SetRedirectParam('pass', 'm'); } @@ -313,7 +338,7 @@ if ($this->Application->ConfigValue('UseJSRedirect')) { $event->SetRedirectParam('js_redirect', 1); } - + $event->SetRedirectParam('pass', 'm'); } @@ -350,7 +375,7 @@ if ($object->mode == 't') { $ug_table = $this->Application->GetTempName($ug_table, 'prefix:'.$event->Prefix); } - + $sql = 'UPDATE '.$ug_table.' SET PrimaryGroup = 0 WHERE PortalUserId = '.$object->GetDBField('PortalUserId'); @@ -406,7 +431,7 @@ if($items_info) { list($id, $field_values) = each($items_info); - $user_email = $field_values['Email']; + $user_email = isset($field_values['Email']) ? $field_values['Email'] : false; if($user_email) { // check if is subscriber @@ -577,7 +602,7 @@ // used for error reporting only -> rewrite code + theme (by Alex) $object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too - + if (preg_match("/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/", $friend_email)) { $send_params = array(); @@ -594,7 +619,7 @@ else { // $event->redirect_params = array('opener' => 's', 'pass' => 'all'); // $event->redirect = $this->Application->GetVar('template_fail'); - + $object->ErrorMsgs['send_error'] = $this->Application->Phrase('lu_email_send_error'); $object->FieldErrors['Email']['pseudo'] = 'send_error'; $event->status = erFAIL; @@ -648,7 +673,7 @@ } } else { - // used for error reporting only -> rewrite code + theme (by Alex) + // used for error reporting only -> rewrite code + theme (by Alex) $object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too $object->ErrorMsgs['invalid_email'] = $this->Application->Phrase('lu_InvalidEmail'); $object->FieldErrors['SubscribeEmail']['pseudo'] = 'invalid_email'; @@ -751,7 +776,7 @@ function OnForgotPassword(&$event) { $user_object = &$this->Application->recallObject('u.forgot', null, Array('skip_autoload' => true)); - + // 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 @@ -862,7 +887,7 @@ $passed_key = $this->Application->GetVar('user_key'); $user_object = &$this->Application->recallObject('u.forgot'); - + // 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 @@ -1052,7 +1077,7 @@ } return parent::getPassedID($event); } - + /** * Allows to change root password * @@ -1065,15 +1090,15 @@ // not "root" can't change root's password via this event return false; } - + // put salt to user's config $field_options = $this->Application->getUnitOption($event->Prefix.'.RootPassword', 'Fields'); $field_options['salt'] = 'b38'; $this->Application->setUnitOption($event->Prefix.'.RootPassword', 'Fields', $field_options); - + $object =& $event->getObject( Array('skip_autoload' => true) ); /* @var $object UsersItem */ - + $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); if ($items_info) { list ($id, $field_values) = each($items_info);