Skip to content

Commit

Permalink
Display list names on the messages page (#345)
Browse files Browse the repository at this point in the history
* Display the names of the lists to which a campaign has been or will be sent.
Limit to maximum of 3 list names

* Add id to the target lists of the view message page.
Link "and n more" to the target lists.
  • Loading branch information
bramley authored and michield committed Jun 29, 2018
1 parent f4df8b8 commit 39e3d8f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
11 changes: 6 additions & 5 deletions public_html/lists/admin/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,12 @@
// print '</table>';
}

if (empty($msgdata['sent'])) {
$content .= '<tr><td colspan="2"><h4>' . s('This campaign will be sent to subscribers who are member of the following lists') . ':</h4></td></tr>';
} else {
$content .= '<tr><td colspan="2"><h4>' . $GLOBALS['I18N']->get('This campaign has been sent to subscribers who are members of the following lists') . ':</h4></td></tr>';
}
$content .= sprintf(
'<tr id="targetlists"><td colspan="2"><h4>%s:</h4></td></tr>',
empty($msgdata['sent'])
? s('This campaign will be sent to subscribers who are member of the following lists')
: s('This campaign has been sent to subscribers who are members of the following lists')
);

$lists_done = array();
$result = Sql_Query(sprintf('select l.name, l.id from %s lm, %s l where lm.messageid = %d and lm.listid = l.id',
Expand Down
34 changes: 34 additions & 0 deletions public_html/lists/admin/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,40 @@
}
$ls->addColumn($listingelement, $GLOBALS['I18N']->get('Status'), $statusdiv);

/*
* Display the lists that have been selected for the campaign
*/
$maxListsDisplayed = 3;
$namesQuery = <<<END
SELECT SQL_CALC_FOUND_ROWS l.name
FROM {$tables['list']} l
JOIN {$tables['listmessage']} lm ON l.id = lm.listid
WHERE lm.messageid = {$msg['id']}
ORDER BY l.name
LIMIT $maxListsDisplayed
END;
$namesResult = Sql_Query($namesQuery);
$row = Sql_Fetch_Row_Query('SELECT FOUND_ROWS()');
$numberOfLists = $row[0];

if ($numberOfLists > 0) {
$listNames = array();

while ($row = Sql_Fetch_Assoc($namesResult)) {
$listNames[] = htmlspecialchars($row['name']);
}

if ($numberOfLists > $maxListsDisplayed) {
array_pop($listNames);
$listNames[] = sprintf(
'<a href="%s">%s</a>',
PageURL2('message', '', "id={$msg['id']}").'#targetlists',
htmlspecialchars(s('and %d more', $numberOfLists - ($maxListsDisplayed - 1)))
);
}
$ls->addRow($listingelement, s('Lists'), implode('<br/>', $listNames), '', 'left');
}

if ($msg['status'] != 'draft') {
// $ls->addColumn($listingelement,$GLOBALS['I18N']->get("total"), $msg['astext'] + $msg['ashtml'] + $msg['astextandhtml'] + $msg['aspdf'] + $msg['astextandpdf']);
// $ls->addColumn($listingelement,$GLOBALS['I18N']->get("text"), $msg['astext']);
Expand Down

0 comments on commit 39e3d8f

Please sign in to comment.