Skip to content

Commit

Permalink
Add SuspensionNotification Newsletter type. Only show hint to click i…
Browse files Browse the repository at this point in the history
…f images aren't display if there are images.
  • Loading branch information
thisismeonmounteverest committed Oct 21, 2023
1 parent 40167f0 commit 0dc3551
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 88 deletions.
2 changes: 1 addition & 1 deletion build/admin/massmail/adminmassmail.ctrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ public function massmailEnqueue() {
$id = $this->route_vars['id'];
$massmail = $this->model->getMassmail($id);
$page = new AdminMassmailEnqueuePage($this->model, $massmail);
$page->votersCount = $this->model->getSuggestionsReminderCount();
$page->mailToConfirmCount = $this->model->getMailToConfirmCount();
$page->incorrectBirthDateCount = $this->model->getIncorrectBirthDateCount();
$page->suspensionNotificationCount = $this->model->getSuspensionNotificationCount();
return $page;
}

Expand Down
103 changes: 51 additions & 52 deletions build/admin/massmail/adminmassmail.model.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,14 @@ public function getEnqueueAction($vars) {
$action = 'enqueueGroup';
} elseif (array_key_exists('enqueuereminder', $vars)) {
$action = 'enqueueReminder';
} elseif (array_key_exists('enqueuesuggestionsreminder', $vars)) {
$action = 'enqueueSuggestionsReminder';
} elseif (array_key_exists('enqueuemailtoconfirmreminder', $vars)) {
$action = 'enqueueMailToConfirmReminder';
} elseif (array_key_exists('enqueuecorrectbday', $vars)) {
$action = 'enqueueCorrectBirthDate';
} elseif (array_key_exists('enqueuetermsofuse', $vars)) {
$action = 'enqueueTermsOfUse';
} elseif (array_key_exists('enqueuesuspension', $vars)) {
$action = 'enqueueSuspensionNotification';
}
return $action;
}
Expand Down Expand Up @@ -473,6 +473,7 @@ public function massmailEnqueueVarsOk(&$vars) {
case 'enqueueMailToConfirmReminder':
case 'enqueueTermsOfUse':
case 'enqueueCorrectBirthDate':
case 'enqueueSuspensionNotification':
break;
default:
$errors[] = 'AdminMassMailEnqueueWrongAction';
Expand Down Expand Up @@ -612,8 +613,7 @@ private function enqueueMassmailReminder($id) {
return $count;
}

private function enqueueMassmailSuggestionsReminder($id) {
$pref_id = $this->getPreferenceIdForMassmail($id);
private function enqueueMassmailMailToConfirmReminder($id) {
$IdEnqueuer = $this->getLoggedInMember()->id;
$query = "
REPLACE
Expand All @@ -622,22 +622,15 @@ private function enqueueMassmailSuggestionsReminder($id) {
" . $id . ", m.id, " . $IdEnqueuer . ", 'ToApprove', NOW()
FROM
members AS m
LEFT JOIN
memberspreferences AS mp
ON (m.id = mp.IdMember AND mp.IdPreference = " . $pref_id . ")
WHERE
m.Status = 'Active'
AND (mp.Value = 'Yes' OR mp.Value IS NULL)
AND DATEDIFF(NOW(), m.LastLogin) < 180
ORDER BY
RAND()
LIMIT 0," . $this->getSuggestionsReminderCount();
m.Status = 'MailToConfirm'
AND created BETWEEN '2015-01-01' AND (NOW() - INTERVAL 1 WEEK)";
$r = $this->dao->query($query);
$count = $r->affectedRows();
return $count;
}

private function enqueueMassmailMailToConfirmReminder($id) {
private function enqueueMassmailCorrectBirthDate($id) {
$IdEnqueuer = $this->getLoggedInMember()->id;
$query = "
REPLACE
Expand All @@ -647,14 +640,14 @@ private function enqueueMassmailMailToConfirmReminder($id) {
FROM
members AS m
WHERE
m.Status = 'MailToConfirm'
AND created BETWEEN '2015-01-01' AND (NOW() - INTERVAL 1 WEEK)";
m.Status IN ('Active', 'OutOfRemind')
AND BirthDate < '1922-06-22'";
$r = $this->dao->query($query);
$count = $r->affectedRows();
return $count;
}

private function enqueueMassmailCorrectBirthDate($id) {
private function enqueueSuspensionNotification($id) {
$IdEnqueuer = $this->getLoggedInMember()->id;
$query = "
REPLACE
Expand All @@ -664,10 +657,22 @@ private function enqueueMassmailCorrectBirthDate($id) {
FROM
members AS m
WHERE
m.Status IN ('Active', 'OutOfRemind')
AND BirthDate < '1922-06-22'";
m.Status IN ('OutOfRemind')
AND m.NbRemindWithoutLogingIn >= 5";
$r = $this->dao->query($query);
$count = $r->affectedRows();

// Now set all those members to suspended
$query = "
UPDATE
members m
SET
m.status = 'SuspendedBeta'
WHERE
m.status = 'OutOfRemind' AND m.NbRemindWithoutLogingIn >= 5"
;
$this->dao->query($query);

return $count;
}

Expand Down Expand Up @@ -725,15 +730,15 @@ public function enqueueMassmail($vars) {
case 'enqueueReminder':
$count = $this->enqueueMassmailReminder($id);
break;
case 'enqueueSuggestionsReminder':
$count = $this->enqueueMassmailSuggestionsReminder($id);
break;
case 'enqueueMailToConfirmReminder':
$count = $this->enqueueMassmailMailToConfirmReminder($id);
break;
case 'enqueueCorrectBirthDate':
$count = $this->enqueueMassmailCorrectBirthDate($id);
break;
case 'enqueueSuspensionNotification':
$count = $this->enqueueSuspensionNotification($id);
break;
case 'enqueueTermsOfUse':
$count = $this->enqueueMassmailTermsOfUse($id);
break;
Expand Down Expand Up @@ -796,36 +801,6 @@ public function triggerMassMail($id) {
return $r->affectedRows();
}

/**
* Get the count of members to be invited randomly
*
* Maximum number of votes ever casted for one suggestion times three
*/
public function getSuggestionsReminderCount() {
// fixed number of voters based on the number of members
// that voted for the decision making process
$votersCount = 763 * 3;
$query = "
SELECT
count(memberHash) as votersCount
FROM
suggestions_votes
GROUP BY
suggestionId,
optionId
ORDER BY
votersCount DESC
";
$r = $this->dao->query($query);
if (!$r) {
return $votersCount;
}
$row = $r->fetch(PDB::FETCH_OBJ);
if (!isset($row->votersCount)) {
return $votersCount;
}
return $row->votersCount * 3;
}

/**
* Get the count of members with status MailToConfirm between January, 1st 2015 and now - 1 week
Expand Down Expand Up @@ -874,4 +849,28 @@ public function getIncorrectBirthDateCount() {
}
return $row->incorrectBirthDateCount;
}

/**
* Get the count of members who will be suspended as they didn't react on 5 login reminders
*/
public function getSuspensionNotificationCount() {
$query = "
SELECT
count(*) as suspensionNotificationCount
FROM
members
WHERE
status IN ('OutOfRemind')
AND NbRemindWithoutLogingIn >= 5
";
$r = $this->dao->query($query);
if (!$r) {
return 0;
}
$row = $r->fetch(PDB::FETCH_OBJ);
if (!isset($row->suspensionNotificationCount)) {
return 0;
}
return $row->suspensionNotificationCount;
}
}
20 changes: 10 additions & 10 deletions build/admin/massmail/pages/adminmassmailbase.page.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,22 @@ public function __construct($model) {
$this->newsletterSpecific = (stripos($scope, '"specific"') !== false);
$this->newsletterGeneral = (stripos($scope, '"general"') !== false);
$this->loginReminder = (stripos($scope, '"remindtologin"') !== false);
$this->suggestionsReminder = (stripos($scope, '"suggestionsreminder"') !== false);
$this->mailToConfirmReminder = (stripos($scope, '"mailtoconfirmreminder"') !== false);
$this->correctBirthDate = (stripos($scope, '"correctbirthdate"') !== false);
$this->termsOfUse = (stripos($scope, '"termsofuse"') !== false);
$this->suspendAfter5Reminders = (stripos($scope, '"suspendafter5reminders"') !== false);

// if no type is set assume all
if (!($this->newsletterSpecific || $this->newsletterGeneral || $this->loginReminder ||
$this->suggestionsReminder || $this->mailToConfirmReminder || $this->termsOfUse || $this->correctBirthDate)) {
if (!($this->newsletterSpecific || $this->newsletterGeneral || $this->loginReminder
|| $this->mailToConfirmReminder || $this->termsOfUse
|| $this->correctBirthDate || $this->suspendAfter5Reminders)) {
$this->newsletterSpecific = true;
$this->newsletterGeneral = true;
$this->loginReminder = true;
$this->suggestionsReminder = true;
$this->mailToConfirmReminder = true;
$this->correctBirthDate = true;
$this->termsOfUse = true;
$this->suspendAfter5Reminders = true;
}
$this->enqueueGroups = array();
$this->enqueueCountries = array();
Expand Down Expand Up @@ -105,23 +106,23 @@ public function __construct($model) {
}
}
$this->canEnqueueReminder = (stripos($scope, "reminder") !== false);
$this->canEnqueueSuggestionsReminder = (stripos($scope, "suggestionsreminder") !== false);
$this->canEnqueueMailToConfirmReminder = (stripos($scope, "mailtoconfirmreminder") !== false);
$this->canEnqueueTermsOfUse = (stripos($scope, "termsofuse") !== false);

// if no scope was given for enqueueing assume full scope
$enqueueAny = $this->canEnqueueMembers || $this->canEnqueueLocation || $this->canEnqueueGroup
|| $this->canEnqueueReminder || $this->canEnqueueSuggestionsReminder
|| $this->canEnqueueMailToConfirmReminder || $this->canEnqueueTermsOfUse;
|| $this->canEnqueueReminder || $this->canEnqueueMailToConfirmReminder
|| $this->canEnqueueTermsOfUse || $this->canEnqueueSuspensionNotification
;
if ($enqueueAny == false) {
$this->canEnqueueMembers = true;
$this->canEnqueueLocation = true;
$this->canEnqueueGroup = true;
$this->canEnqueueReminder = true;
$this->canEnqueueCorrectBirthDate = true;
$this->canEnqueueSuggestionsReminder = true;
$this->canEnqueueMailToConfirmReminder = true;
$this->canEnqueueTermsOfUse = true;
$this->canEnqueueSuspensionNotification = true;
}

if ($this->rights["MassMail"]["Level"] >= 1) {
Expand All @@ -137,16 +138,15 @@ public function __construct($model) {
$this->canEnqueueLocation = true;
$this->canEnqueueGroup = true;
$this->canEnqueueReminder = true;
$this->canEnqueueSuggestionsReminder = true;
$this->canEnqueueMailToConfirmReminder = true;
$this->canEnqueueTermsOfUse = true;
$this->canEnqueueCorrectBirthDate = true;
$this->canEnqueueSuspensionNotification = true;
$this->canChangeType = true;
$this->canTrigger = true;
$this->specificNewsletter = true;
$this->generalNewsletter = true;
$this->loginReminder = true;
$this->suggestionsReminder = true;
$this->mailToConfirmReminder = true;
$this->correctBirthDate = true;
$this->termsOfUse = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
echo '</strong>';
}
}
$purifier = MOD_htmlpure::getAdvancedHtmlPurifier();
$purifier = (new MOD_htmlpure())->getAdvancedHtmlPurifier();
echo '<tr class="blank"><td class="left" colspan="5"><strong>' . $words->get('AdminMassMailSubject') . '</strong>: '
. str_replace("%username%", "Username", $words->getAsIs('BroadCast_Title_' . $massmail->Name))
. '</td></tr>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
if ($this->loginReminder) {
$options["RemindToLog"] = $this->words->getSilent('AdminMassMailEditTypeLoginReminder');
}
if ($this->suggestionsReminder) {
$options["SuggestionReminder"] = $this->words->getSilent('AdminMassMailEditTypeSuggestionsReminder');
}
if ($this->termsOfUse) {
$options["TermsOfUse"] = $this->words->getSilent('AdminMassMailEditTypeTermsOfUse');
}
if ($this->correctBirthDate) {
$options["CorrectBirthDate"] = $this->words->getSilent('massmail.correct.birth.date');
}
if ($this->correctBirthDate) {
$options["SuspendAfter5Reminders"] = $this->words->getSilent('massmail.suspend.after.five.reminders');
}
if ($this->mailToConfirmReminder) {
$options["MailToConfirmReminder"] = $this->words->getSilent('AdminMassMailEditTypeMailToConfirmReminder');
}
Expand Down
Loading

0 comments on commit 0dc3551

Please sign in to comment.