Attached Files |
Ability-for-Users-to-subscribe-to-mailing-Registration-CORE.patch [^] (2,412 bytes) 2010-12-02 11:12
[Show Content]
Index: units/users/users_config.php
===================================================================
--- units/users/users_config.php (revision 14094)
+++ units/users/users_config.php (working copy)
@@ -415,6 +415,12 @@
'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' => 0,
),
+ 'SubscribeToMailing' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter',
+ 'options' => Array(0 => 'lu_No', 1 => 'lu_Yes'),
+ 'use_phrases' => 1, 'default' => 0,
+ ),
),
'Grids' => Array(
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 14094)
+++ units/users/users_event_handler.php (working copy)
@@ -338,6 +338,11 @@
$sql = 'REPLACE INTO '.$ug_table.'(PortalUserId,GroupId,PrimaryGroup) VALUES (%s,%s,1)';
$this->Conn->Query( sprintf($sql, $object->GetID(), $group_id) );
+
+ // Front-End user selected to be subscribed to mailing
+ if (!$this->isAdmin && $object->GetDBField('SubscribeToMailing')) {
+ $this->AddSubscriberGroup($object->GetID(), 0);
+ }
}
}
@@ -1267,6 +1272,20 @@
$object =& $event->getObject();
/* @var $object UsersItem */
+ // registered user selected to update his subscription status via profile on Front-End
+ if (!$this->Application->isAdmin && !$this->Application->GetVar('IsSubscriber'))
+ {
+ $currently_subscriber = $this->GetGroupInfo($object->GetID());
+ if ($currently_subscriber && !$object->GetDBField('SubscribeToMailing')) {
+ // wants to unsubscribe
+ $this->RemoveSubscriberGroup($object->GetID());
+ }
+ elseif ($object->GetDBField('SubscribeToMailing')) {
+ // wants to subscribe
+ $this->AddSubscriberGroup($object->GetID(), 0);
+ }
+ }
+
if (!$this->Application->isAdmin || $object->IsTempTable()) {
return ;
}
@@ -1572,6 +1591,9 @@
/* @var $cs_helper kCountryStatesHelper */
$cs_helper->PopulateStates($event, 'State', 'Country');
+
+ // get user subscription status
+ $object->SetDBField('SubscribeToMailing', $this->GetGroupInfo($object->GetID())? 1 : 0);
}
/**
Ability-for-Users-to-subscribe-to-mailing-Registration-THEME.patch [^] (3,422 bytes) 2010-12-02 11:12
[Show Content]
Index: _install/english.lang
===================================================================
--- _install/english.lang (revision 14094)
+++ _install/english.lang (working copy)
@@ -189,6 +189,7 @@
<PHRASE Label="lu_fld_State" Module="Core" Type="0">U3RhdGU=</PHRASE>
<PHRASE Label="lu_fld_street" Module="Core" Type="0">U3RyZWV0</PHRASE>
<PHRASE Label="lu_fld_SubmittingTo" Module="Core" Type="0">U3VibWl0dGluZyB0bw==</PHRASE>
+ <PHRASE Label="lu_fld_SubscribeToMailing" Module="Core" Type="0">U3Vic2NyaWJlIHRvIE1haWxpbmcgbGlzdA==</PHRASE>
<PHRASE Label="lu_fld_title" Module="Core" Type="0">VGl0bGU=</PHRASE>
<PHRASE Label="lu_fld_translation" Module="Core" Type="0">VHJhbnNsYXRpb24=</PHRASE>
<PHRASE Label="lu_fld_UserGroup" Module="Core" Type="0">TWVtYmVyc2hpcCBHcm91cA==</PHRASE>
Index: platform/login/register.tpl
===================================================================
--- platform/login/register.tpl (revision 14094)
+++ platform/login/register.tpl (working copy)
@@ -76,13 +76,14 @@
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="City" title="lu_fld_City" style="width:155px" />
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="State" title="lu_fld_State" style="width:155px" />
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="Zip" title="lu_fld_Zip" style="width:55px" />
+ <inp2:m_RenderElement name="inp_edit_options" prefix="u" field="Country" title="lu_fld_Country" has_empty="1"/>
<inp2:m_if check="m_GetConfig" name="AllowSelectGroupOnFront">
<inp2:m_RenderElement name="inp_edit_options" prefix="u" field="UserGroup" has_empty="1" title="lu_fld_UserGroup" />
</inp2:m_if>
-
- <inp2:m_RenderElement name="inp_edit_options" prefix="u" field="Country" title="lu_fld_Country" has_empty="1" is_last="1"/>
-
+
+ <inp2:m_RenderElement name="inp_edit_checkbox" prefix="u" field="SubscribeToMailing" title="lu_fld_SubscribeToMailing" is_last="1"/>
+
<inp2:m_if check="m_ConfigEquals" option="RegistrationCaptcha" value="1">
<inp2:m_RenderElement name="inp_edit_field_separator" is_last="0"/>
<inp2:m_RenderElement name="inp_edit_captcha" prefix="u" style="width: 170px;" />
Index: platform/my_account/my_profile.tpl
===================================================================
--- platform/my_account/my_profile.tpl (revision 14094)
+++ platform/my_account/my_profile.tpl (working copy)
@@ -65,8 +65,11 @@
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="State" title="lu_fld_State" style="width:155px" />
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="Zip" title="lu_fld_Zip" style="width:55px" />
<inp2:m_RenderElement name="inp_edit_options" prefix="u" field="Country" title="lu_fld_Country" has_empty="1"/>
+
+ <inp2:m_RenderElement name="inp_edit_checkbox" prefix="u" field="SubscribeToMailing" title="lu_fld_SubscribeToMailing"/>
+
<inp2:m_RenderElement name="inp_edit_image_upload" prefix="u" field="PrimaryImage" title="lu_prompt_Avatar" is_last="1"/>
-
+
<inp2:m_RenderElement design="inp_edit_buttons">
<input class="button" type="submit" name="events[u][OnUpdate]" value="<inp2:m_Phrase label="lu_btn_Update" no_editing="1"/>"/>
<input type="hidden" name="next_template" value="platform/my_account/my_account"/>
Ability-for-Users-to-subscribe-to-mailing-Registration-CORE_v2.patch [^] (2,862 bytes) 2011-05-20 05:05
[Show Content]
Index: units/users/users_config.php
===================================================================
--- units/users/users_config.php (revision 14318)
+++ units/users/users_config.php (working copy)
@@ -434,6 +434,13 @@
'LocalImage' => Array ('type' => 'string', 'default' => ''),
'LocalPath' => Array ('type' => 'string', 'default' => ''),
'FullUrl' => Array ('type' => 'string', 'default' => ''),
+
+ 'SubscribeToMailing' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter',
+ 'options' => Array(0 => 'lu_No', 1 => 'lu_Yes'),
+ 'use_phrases' => 1, 'default' => 0,
+ ),
),
'Grids' => Array(
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 14318)
+++ units/users/users_event_handler.php (working copy)
@@ -338,6 +338,11 @@
$sql = 'REPLACE INTO '.$ug_table.'(PortalUserId,GroupId,PrimaryGroup) VALUES (%s,%s,1)';
$this->Conn->Query( sprintf($sql, $object->GetID(), $group_id) );
+
+ // Front-End user selected to be subscribed to mailing
+ if (!$this->isAdmin && $object->GetDBField('SubscribeToMailing')) {
+ $this->AddSubscriberGroup($object->GetID(), 0);
+ }
}
}
@@ -769,9 +774,11 @@
*/
function GetGroupInfo($user_id)
{
- $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'UserGroup
- WHERE (PortalUserId = ' . $user_id . ')
- AND (GroupId = ' . $this->Application->ConfigValue('User_SubscriberGroup') . ')';
+ $subscriber_group = $this->Application->ConfigValue('User_SubscriberGroup');
+
+ $sql = 'SELECT *
+ FROM ' . TABLE_PREFIX . 'UserGroup
+ WHERE (PortalUserId = ' . $user_id . ') AND (GroupId = ' . $subscriber_group . ')';
return $this->Conn->GetRow($sql);
}
@@ -1268,6 +1275,19 @@
$object =& $event->getObject();
/* @var $object UsersItem */
+ // registered user selected to update his subscription status via profile on Front-End
+ if (!$this->Application->isAdmin && !$this->Application->GetVar('IsSubscriber'))
+ {
+ $currently_subscribed = $this->GetGroupInfo( $object->GetID() );
+
+ if ( $object->GetDBField('SubscribeToMailing') && !$currently_subscribed ) {
+ $this->AddSubscriberGroup($object->GetID(), 0);
+ }
+ elseif ( !$object->GetDBField('SubscribeToMailing') && $currently_subscribed ) {
+ $this->RemoveSubscriberGroup($object->GetID());
+ }
+ }
+
if (!$this->Application->isAdmin || $object->IsTempTable()) {
return ;
}
@@ -1573,6 +1593,9 @@
/* @var $cs_helper kCountryStatesHelper */
$cs_helper->PopulateStates($event, 'State', 'Country');
+
+ // get user subscription status
+ $object->SetDBField('SubscribeToMailing', $this->GetGroupInfo($object->GetID())? 1 : 0);
}
/**
Ability-for-Users-to-subscribe-to-mailing-Registration-CORE_v2_520.patch [^] (3,729 bytes) 2011-10-03 11:43
[Show Content]
Index: units/users/users_config.php
===================================================================
--- units/users/users_config.php (revision 14596)
+++ units/users/users_config.php (working copy)
@@ -432,6 +432,11 @@
'LocalImage' => 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(
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 14596)
+++ units/users/users_event_handler.php (working copy)
@@ -289,7 +289,7 @@
{
$sync_manager =& $this->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,7 +1539,7 @@
/* @var $image_helper ImageHelper */
$object =& $event->getObject();
- /* @var $object kDBItem */
+ /* @var $object UsersItem */
$image_helper->LoadItemImages($object);
@@ -1537,6 +1547,9 @@
/* @var $cs_helper kCountryStatesHelper */
$cs_helper->PopulateStates($event, 'State', 'Country');
+
+ // get user subscription status
+ $object->SetDBField('SubscribeToMailing', $object->isSubscribed() ? 1 : 0);
}
/**
Ability-for-Users-to-subscribe-to-mailing-Registration-THEME_520.patch [^] (3,235 bytes) 2011-10-03 11:43
[Show Content]
Index: _install/english.lang
===================================================================
--- _install/english.lang (revision 14612)
+++ _install/english.lang (working copy)
@@ -192,6 +192,7 @@
<PHRASE Label="lu_fld_State" Module="Core" Type="0">U3RhdGU=</PHRASE>
<PHRASE Label="lu_fld_street" Module="Core" Type="0">U3RyZWV0</PHRASE>
<PHRASE Label="lu_fld_SubmittingTo" Module="Core" Type="0">U3VibWl0dGluZyB0bw==</PHRASE>
+ <PHRASE Label="lu_fld_SubscribeToMailing" Module="Core" Type="0">U3Vic2NyaWJlIHRvIE1haWxpbmcgbGlzdA==</PHRASE>
<PHRASE Label="lu_fld_title" Module="Core" Type="0">VGl0bGU=</PHRASE>
<PHRASE Label="lu_fld_translation" Module="Core" Type="0">VHJhbnNsYXRpb24=</PHRASE>
<PHRASE Label="lu_fld_UserGroup" Module="Core" Type="0">TWVtYmVyc2hpcCBHcm91cA==</PHRASE>
Index: platform/login/register.tpl
===================================================================
--- platform/login/register.tpl (revision 14593)
+++ platform/login/register.tpl (working copy)
@@ -77,13 +77,14 @@
<inp2:m_RenderElement name="inp_edit_box" prefix="u.register" field="City" title="lu_fld_City" style="width:155px" />
<inp2:m_RenderElement name="inp_edit_box" prefix="u.register" field="State" title="lu_fld_State" style="width:155px" />
<inp2:m_RenderElement name="inp_edit_box" prefix="u.register" field="Zip" title="lu_fld_Zip" style="width:55px" />
+ <inp2:m_RenderElement name="inp_edit_options" prefix="u.register" field="Country" title="lu_fld_Country" has_empty="1"/>
<inp2:m_if check="m_GetConfig" name="AllowSelectGroupOnFront">
<inp2:m_RenderElement name="inp_edit_options" prefix="u.register" field="PrimaryGroupId" title="lu_fld_UserGroup" />
</inp2:m_if>
-
- <inp2:m_RenderElement name="inp_edit_options" prefix="u.register" field="Country" title="lu_fld_Country" has_empty="1" is_last="1"/>
-
+
+ <inp2:m_RenderElement name="inp_edit_checkbox" prefix="u.register" field="SubscribeToMailing" title="lu_fld_SubscribeToMailing" is_last="1"/>
+
<inp2:m_if check="m_ConfigEquals" option="RegistrationCaptcha" value="1">
<inp2:m_RenderElement name="inp_edit_field_separator" is_last="0"/>
<inp2:m_RenderElement name="inp_edit_captcha" prefix="u.register" style="width: 170px;" />
Index: platform/my_account/my_profile.tpl
===================================================================
--- platform/my_account/my_profile.tpl (revision 14590)
+++ platform/my_account/my_profile.tpl (working copy)
@@ -69,6 +69,7 @@
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="State" title="lu_fld_State" style="width:155px" />
<inp2:m_RenderElement name="inp_edit_box" prefix="u" field="Zip" title="lu_fld_Zip" style="width:55px" />
<inp2:m_RenderElement name="inp_edit_options" prefix="u" field="Country" title="lu_fld_Country" has_empty="1"/>
+ <inp2:m_RenderElement name="inp_edit_checkbox" prefix="u" field="SubscribeToMailing" title="lu_fld_SubscribeToMailing"/>
<inp2:m_RenderElement name="inp_edit_image_upload" prefix="u" field="PrimaryImage" title="lu_prompt_Avatar" is_last="1"/>
<inp2:m_RenderElement design="inp_edit_buttons">
|