Index: branches/5.2.x/core/units/users/users_event_handler.php =================================================================== diff -u -N -r14596 -r14617 --- branches/5.2.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14596) +++ branches/5.2.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14617) @@ -1,6 +1,6 @@ Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize')); /* @var $sync_manager UsersSyncronizeManager */ - + $sync_manager->performAction('LoginUser', $event->getEventParam('user'), $event->getEventParam('pass') ); if ($event->redirect && is_string($event->redirect)) { @@ -307,7 +307,7 @@ { $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize')); /* @var $sync_manager UsersSyncronizeManager */ - + $sync_manager->performAction('LogoutUser'); } @@ -591,7 +591,7 @@ if ( $items_info ) { list ($id, $field_values) = each($items_info); - + if ( $id > 0 ) { $object->Load($id); } @@ -744,7 +744,7 @@ /** * Validates forgot password form and sends password reset confirmation e-mail - * + * * @param kEvent $event * @return void */ @@ -1220,7 +1220,7 @@ $this->saveUserImages($event); $object =& $event->getObject(); - /* @var $object kDBItem */ + /* @var $object UsersItem */ if ( $object->GetDBField('EmailPassword') && $object->GetDBField('Password_plain') ) { $email_passwords = $this->Application->RecallVar('email_passwords'); @@ -1229,6 +1229,16 @@ $email_passwords[ $object->GetID() ] = $object->GetDBField('Password_plain'); $this->Application->StoreVar('email_passwords', serialize($email_passwords)); } + + // update user subscription status (via my profile or new user registration) + if ( !$this->Application->isAdmin && !$object->isSubscriberOnly() ) { + if ( $object->GetDBField('SubscribeToMailing') && !$object->isSubscribed() ) { + $this->AddSubscriberGroup($object); + } + elseif ( !$object->GetDBField('SubscribeToMailing') && $object->isSubscribed() ) { + $this->RemoveSubscriberGroup( $object->GetID() ); + } + } } /** @@ -1440,7 +1450,7 @@ protected function OnBeforeClone(&$event) { parent::OnBeforeClone($event); - + $object =& $event->getObject(); /* @var $object UsersItem */ @@ -1529,14 +1539,17 @@ /* @var $image_helper ImageHelper */ $object =& $event->getObject(); - /* @var $object kDBItem */ + /* @var $object UsersItem */ $image_helper->LoadItemImages($object); $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); /* @var $cs_helper kCountryStatesHelper */ $cs_helper->PopulateStates($event, 'State', 'Country'); + + // get user subscription status + $object->SetDBField('SubscribeToMailing', $object->isSubscribed() ? 1 : 0); } /** Index: branches/5.2.x/core/units/users/users_config.php =================================================================== diff -u -N -r14596 -r14617 --- branches/5.2.x/core/units/users/users_config.php (.../users_config.php) (revision 14596) +++ branches/5.2.x/core/units/users/users_config.php (.../users_config.php) (revision 14617) @@ -1,6 +1,6 @@ Array ('default' => ''), 'LocalPath' => Array ('default' => ''), 'FullUrl' => Array ('default' => ''), + + 'SubscribeToMailing' => Array ( + 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'lu_No', 1 => 'lu_Yes'), 'use_phrases' => 1, + 'default' => 0, + ), ), ), @@ -550,6 +555,7 @@ 'LocalImage' => Array ('type' => 'string'), 'LocalPath' => Array ('type' => 'string'), 'FullUrl' => Array ('type' => 'string'), + 'SubscribeToMailing' => Array ('type' => 'int'), ), 'Grids' => Array(