Index: branches/5.2.x/core/install/install_data.sql
===================================================================
diff -u -r14606 -r14633
--- branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 14606)
+++ branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 14633)
@@ -171,6 +171,7 @@
INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, Module, Description, Type, AllowChangingSender, AllowChangingRecipient) VALUES(DEFAULT, 'FORM.SUBMISSION.REPLY.FROM.USER.BOUNCED', NULL, 1, 0, 'Core', 'Form Submission Admin Reply Delivery Failure', 1, 1, 1);
INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, Module, Description, Type, AllowChangingSender, AllowChangingRecipient) VALUES(DEFAULT, 'USER.NEW.PASSWORD', NULL, 1, 0, 'Core', 'Sends new password to an existing user', 0, 1, 0);
INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, Module, Description, Type, AllowChangingSender, AllowChangingRecipient) VALUES(DEFAULT, 'USER.ADD.BYADMIN', NULL, 1, 0, 'Core', 'Sends password to a new user', 0, 1, 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, Module, Description, Type, AllowChangingSender, AllowChangingRecipient) VALUES(DEFAULT, 'ROOT.RESET.PASSWORD', NULL, 1, 0, 'Core', 'Root Reset Password', 1, 1, 0);
INSERT INTO IdGenerator VALUES ('100');
Index: branches/5.2.x/core/units/users/users_event_handler.php
===================================================================
diff -u -r14630 -r14633
--- branches/5.2.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14630)
+++ branches/5.2.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14633)
@@ -1,6 +1,6 @@
Name == 'OnResetRootPassword' ) {
+ return defined('DBG_RESET_ROOT') && DBG_RESET_ROOT;
+ }
+
if ( !$this->Application->isAdminUser ) {
$user_id = $this->Application->RecallVar('user_id');
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
@@ -238,8 +242,10 @@
* Checks user data and logs it in if allowed
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnLogin(&$event)
+ protected function OnLogin(&$event)
{
$object =& $event->getObject( Array ('form_name' => 'login') );
/* @var $object kDBItem */
@@ -311,7 +317,14 @@
$sync_manager->performAction('LogoutUser');
}
- function OnLogout(&$event)
+ /**
+ * Performs user logout
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnLogout(&$event)
{
$user_helper =& $this->Application->recallObject('UserHelper');
/* @var $user_helper UserHelper */
@@ -387,8 +400,10 @@
* Returns subscribed user ID by given e-mail address
*
* @param string $email
+ * @return int|bool
+ * @access protected
*/
- function getSubscriberByEmail($email)
+ protected function getSubscriberByEmail($email)
{
$verify_user =& $this->Application->recallObject('u.verify', null, Array ('skip_autoload' => true));
/* @var $verify_user UsersItem */
@@ -406,6 +421,8 @@
function autoLoginUser(&$event)
{
$object =& $event->getObject();
+ /* @var $object UsersItem */
+
$this->Application->SetVar('u.current_id', $object->GetID());
if ( $object->GetDBField('Status') == STATUS_ACTIVE ) {
@@ -810,7 +827,13 @@
}
}
- function OnUpdate(&$event)
+ /**
+ * Updates kDBItem
+ *
+ * @param kEvent $event
+ * @access protected
+ */
+ protected function OnUpdate(&$event)
{
parent::OnUpdate($event);
@@ -946,8 +969,8 @@
if ($records) {
$conditions = Array();
foreach ($records as $record) {
- $email_event_user =& $this->Application->EmailEventUser('USER.MEMBERSHIP.EXPIRATION.NOTICE', $record['PortalUserId']);
- $email_event_admin =& $this->Application->EmailEventAdmin('USER.MEMBERSHIP.EXPIRATION.NOTICE');
+ $this->Application->EmailEventUser('USER.MEMBERSHIP.EXPIRATION.NOTICE', $record['PortalUserId']);
+ $this->Application->EmailEventAdmin('USER.MEMBERSHIP.EXPIRATION.NOTICE');
$conditions[] = '(PortalUserId = '.$record['PortalUserId'].' AND GroupId = '.$record['GroupId'].')';
}
$sql = 'UPDATE '.TABLE_PREFIX.'UserGroup
@@ -964,8 +987,8 @@
$user_ids = $this->Conn->GetCol($sql);
if ($user_ids) {
foreach ($user_ids as $id) {
- $email_event_user =& $this->Application->EmailEventUser('USER.MEMBERSHIP.EXPIRED', $id);
- $email_event_admin =& $this->Application->EmailEventAdmin('USER.MEMBERSHIP.EXPIRED');
+ $this->Application->EmailEventUser('USER.MEMBERSHIP.EXPIRED', $id);
+ $this->Application->EmailEventAdmin('USER.MEMBERSHIP.EXPIRED');
}
}
$sql = 'DELETE FROM '.TABLE_PREFIX.'UserGroup
@@ -1013,9 +1036,10 @@
}
/**
- * Overwritten to return user from order by special .ord
+ * Return user from order by special .ord
*
* @param kEvent $event
+ * @return int
*/
function getPassedID(&$event)
{
@@ -1148,28 +1172,37 @@
$event->SetRedirectParam('opener', 'u');
}
- function OnMassResetSettings(&$event)
+ /**
+ * Resets grid settings, remembered in each user record
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnMassResetSettings(&$event)
{
- if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+ if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) {
$event->status = kEvent::erFAIL;
return;
}
$ids = $this->StoreSelectedIDs($event);
$default_user_id = $this->Application->ConfigValue('DefaultSettingsUserId');
- if (in_array($default_user_id, $ids)) {
+ if ( in_array($default_user_id, $ids) ) {
array_splice($ids, array_search($default_user_id, $ids), 1);
}
- if ($ids) {
- $q = 'DELETE FROM '.TABLE_PREFIX.'PersistantSessionData WHERE PortalUserId IN ('.join(',', $ids).') AND
+
+ if ( $ids ) {
+ $q = 'DELETE FROM ' . TABLE_PREFIX . 'PersistantSessionData WHERE PortalUserId IN (' . join(',', $ids) . ') AND
(VariableName LIKE "%_columns_%"
OR
VariableName LIKE "%_filter%"
OR
VariableName LIKE "%_PerPage%")';
$this->Conn->Query($q);
}
+
$this->clearSelectedIDs($event);
}
@@ -1706,4 +1739,26 @@
}
}
}
+
+ /**
+ * Generates new Root password and email it
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnResetRootPassword(&$event)
+ {
+ $password_formatter =& $this->Application->recallObject('kPasswordFormatter');
+ /* @var $password_formatter kPasswordFormatter */
+
+ $new_root_password = kUtil::generatePassword();
+ $new_root_password_encrypted = $password_formatter->EncryptPassword($new_root_password, 'b38');
+
+ $this->Application->SetConfigValue('RootPass', $new_root_password_encrypted);
+ $this->Application->EmailEventAdmin('ROOT.RESET.PASSWORD', null, Array ('password' => $new_root_password));
+
+ $event->SetRedirectParam('reset', 1);
+ $event->SetRedirectParam('pass', 'm');
+ }
}
Index: branches/5.2.x/tools/debug_sample.php
===================================================================
diff -u -r14244 -r14633
--- branches/5.2.x/tools/debug_sample.php (.../debug_sample.php) (revision 14244)
+++ branches/5.2.x/tools/debug_sample.php (.../debug_sample.php) (revision 14633)
@@ -1,6 +1,6 @@
" class="kx-login-button roundbutton">
+
+
+