public static getNotices ( $id, $limit = 50, $timestamp = FALSE ) |
public static function &getNotices($id, $limit = 50, $timestamp = FALSE)
{
$dbo =& Pommo::$_dbo;
$limit = intval($limit);
if ($limit == 0) {
$limit = false;
}
if (!$timestamp) {
$query = "\n SELECT notice FROM " . $dbo->table['mailing_notices'] . "\n WHERE mailing_id = %i ORDER BY touched DESC, id DESC [LIMIT %I]";
$query = $dbo->prepare($query, array($id, $limit));
return $dbo->getAll($query, 'assoc', 'notice');
}
$o = array();
$query = "\n SELECT touched,notice FROM " . $dbo->table['mailing_notices'] . "\n WHERE mailing_id = %i ORDER BY touched DESC, id DESC [LIMIT %I]";
$query = $dbo->prepare($query, array($id, $limit));
while ($row = $dbo->getRows($query)) {
if (!isset($o[$row['touched']])) {
$o[$row['touched']] = array();
}
array_push($o[$row['touched']], $row['notice']);
}
return $o;
}
$mailingIDS = $_REQUEST['mailings']; if (!is_array($mailingIDS)) { $mailingIDS = array($mailingIDS); } /********************************** JSON OUTPUT INITIALIZATION *********************************/ require_once Pommo::$_baseDir . 'classes/Pommo_Json.php'; $json = new Pommo_Json(false); // do not toggle escaping // EXAMINE CALL switch ($_REQUEST['call']) { case 'notice': foreach ($mailingIDS as $id) { $logger->AddMsg('<br /><br />###' . sprintf(Pommo::_T('Displaying notices for mailing %s'), Pommo_Mailing::getSubject($id)) . ' ###<br /><br />'); $notices = Pommo_Mailing::getNotices($id); $logger->AddMsg($notices); } break; case 'reload': require_once Pommo::$_baseDir . 'classes/Pommo_Groups.php'; $mailing = current(Pommo_Mailing::get(array('id' => $_REQUEST['mailings']))); // change group name to ID $groups = Pommo_Groups::getNames(); $gid = 'all'; foreach ($groups as $group) { if ($group['name'] == $mailing['group']) { $gid = $group['id']; } } Pommo_Api::stateReset(array('mailing'));