umfassende updates
This commit is contained in:
parent
3331f08091
commit
50cd802d33
16 changed files with 441 additions and 78 deletions
|
|
@ -23,10 +23,17 @@ class Roundmail {
|
|||
/**
|
||||
* Anzahl aller protokollierten Mails.
|
||||
*
|
||||
* @param bool $excludeReminders Automatische Erinnerungen (Betreff REMINDER_TOPIC) nicht mitzählen
|
||||
* @return int
|
||||
*/
|
||||
public static function count() {
|
||||
public static function count($excludeReminders = false) {
|
||||
$db = Database::getConnection();
|
||||
if ($excludeReminders) {
|
||||
$stmt = $db->prepare("SELECT COUNT(*) FROM roundmails WHERE topic <> :topic");
|
||||
$stmt->bindValue(':topic', self::REMINDER_TOPIC);
|
||||
$stmt->execute();
|
||||
return (int)$stmt->fetchColumn();
|
||||
}
|
||||
return (int)$db->query("SELECT COUNT(*) FROM roundmails")->fetchColumn();
|
||||
}
|
||||
|
||||
|
|
@ -35,19 +42,25 @@ class Roundmail {
|
|||
*
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @param bool $excludeReminders Automatische Erinnerungen (Betreff REMINDER_TOPIC) auslassen
|
||||
* @return array
|
||||
*/
|
||||
public static function getPage($limit, $offset) {
|
||||
public static function getPage($limit, $offset, $excludeReminders = false) {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"SELECT m.id, m.send_date, m.topic, m.recipients, COALESCE(u.name, 'Automailer') AS sender_name
|
||||
FROM roundmails m
|
||||
LEFT JOIN users u ON u.id = m.user_id
|
||||
ORDER BY m.send_date DESC, m.id DESC
|
||||
LIMIT ? OFFSET ?"
|
||||
);
|
||||
$stmt->bindValue(1, (int)$limit, \PDO::PARAM_INT);
|
||||
$stmt->bindValue(2, (int)$offset, \PDO::PARAM_INT);
|
||||
$sql = "SELECT m.id, m.send_date, m.topic, m.recipients, COALESCE(u.name, 'Automailer') AS sender_name
|
||||
FROM roundmails m
|
||||
LEFT JOIN users u ON u.id = m.user_id";
|
||||
if ($excludeReminders) {
|
||||
$sql .= " WHERE m.topic <> :topic";
|
||||
}
|
||||
$sql .= " ORDER BY m.send_date DESC, m.id DESC LIMIT :limit OFFSET :offset";
|
||||
|
||||
$stmt = $db->prepare($sql);
|
||||
if ($excludeReminders) {
|
||||
$stmt->bindValue(':topic', self::REMINDER_TOPIC);
|
||||
}
|
||||
$stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);
|
||||
$stmt->bindValue(':offset', (int)$offset, \PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue