Quote:
Originally Posted by anihil2
Hello, I found one issue with vBMail. When user click on unsubscribe link in email he/she will get feedback pool before getting unscubscribe. Lets assume that at this time noone else did unsubscribe. After user unsubscribed in View Mail History admin should see for this specific mail only one person in 'Unsubscribed Users' column. That is correct if user used unsubscribe link only once. But if user go to this unsubscribe link without even setting feedback option it will automatically increment this 'Unsubscribed Users' counter. In my example below I have one user test which press link unsubscribe several times and I get:
Could it be fixed to count only users that actually unsubscribed from mailing list and not how many time they clikc on unsubscribe link?
|
Didn't have time to wait for fix

so I fix it myself. Fix description below.
In file dbtech\vbmail\actions\mailinglists.php from lines 1053-1069 move code:
PHP Code:
if ($vbulletin->GPC['mailid'])
{
// We have a mail id
if ($mail = $db->query_first_slave("SELECT unsubscriptions FROM " . TABLE_PREFIX . "dbtech_vbmail_mail WHERE mailid = " . intval($vbulletin->GPC['mailid'])))
{
// Mail id was valid
if (!$subscribeflag OR $mail['unsubscriptions'])
{
// We're either unsubscribing, or we can decrement it successfully
$db->query_write("
UPDATE " . TABLE_PREFIX . "dbtech_vbmail_mail
SET unsubscriptions = unsubscriptions " . (!$subscribeflag ? '+' : '-') . " 1
WHERE mailid = " . intval($vbulletin->GPC['mailid'])
);
}
}
}
Before line 1043 which is:
PHP Code:
VBMAIL::$db->insert('dbtech_vbmail_subscriptionlog', array(
After change it code should look like this:
PHP Code:
else if ($exists)
{
if ($vbulletin->GPC['mailid'])
{
// We have a mail id
if ($mail = $db->query_first_slave("SELECT unsubscriptions FROM " . TABLE_PREFIX . "dbtech_vbmail_mail WHERE mailid = " . intval($vbulletin->GPC['mailid'])))
{
// Mail id was valid
if (!$subscribeflag OR $mail['unsubscriptions'])
{
// We're either unsubscribing, or we can decrement it successfully
$db->query_write("
UPDATE " . TABLE_PREFIX . "dbtech_vbmail_mail
SET unsubscriptions = unsubscriptions " . (!$subscribeflag ? '+' : '-') . " 1
WHERE mailid = " . intval($vbulletin->GPC['mailid'])
);
}
}
}
// We either subscribed or unsubscribed
VBMAIL::$db->insert('dbtech_vbmail_subscriptionlog', array(
'userid' => $user['userid'],
'mailinglistid' => $mailinglist['mailinglistid'],
'dateline' => TIMENOW,
'subscribed' => $subscribeflag,
'reason' => (!$subscribeflag ? 'un' : '') . 'subscribed',
'mailid' => $vbulletin->GPC['mailid']
));
}
What this change will give you?
When user hit link with unsubscribe it will increment counter "Unsubscribed Users" only when user flag in database change from Subscribed to Unsubscribed. If user try to hit unsubscribe link again it will not increment this counter anymore.
I hope this will help someone.