Various changes including contact messages in database, contact message notifications, notification emails, bugfixes and more
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
require_once 'notifications/PostReportNotification.php';
|
||||
require_once 'notifications/NotificationUser.php';
|
||||
require_once 'notifications/NewFeedbackNotification.php';
|
||||
require_once 'notifications/ContactMessageNotification.php';
|
||||
|
||||
class NotificationModel extends CI_Model
|
||||
{
|
||||
@@ -20,6 +21,7 @@
|
||||
$_SESSION['site_lang'] = $lang;
|
||||
$this->lang->load('notification', 'de');
|
||||
$this->lang->load('notification', $_SESSION['site_lang']);
|
||||
$this->load->model('EmailModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function getUserNotificationsRaw($userID, $limit = 20, $offset = 0)
|
||||
@@ -78,6 +80,13 @@
|
||||
]);
|
||||
}
|
||||
$this->db->cache_delete('Main', 'getNotifications');
|
||||
|
||||
// Send email
|
||||
$email = $this->UserModel->getUserEmailByID($notification->sender->getId());
|
||||
$group = new NotificationGroup([$notification], 1);
|
||||
$messageData = $group->message();
|
||||
$message = sprintf(lang($messageData['line']), ...$messageData['attributes']);
|
||||
$this->EmailModel->sendMail($email, sprintf('Neue Benachrichtigung auf KingOfDog.eu: "%1$s"', $message), 'notification', ['group' => $group, 'message' => $message]);
|
||||
}
|
||||
|
||||
public function markAsRead(array $notifications) {
|
||||
@@ -117,6 +126,9 @@
|
||||
case 'admin.reportedPost':
|
||||
$items[] = new \Notification\Users\PostReportNotification($item);
|
||||
break;
|
||||
case 'admin.contactMessage':
|
||||
$items[] = new \Notification\Admin\ContactMessageNotification($item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$groups[] = new NotificationGroup($items, $group['count']);
|
||||
@@ -171,7 +183,7 @@
|
||||
}
|
||||
|
||||
public function rankNotificationNewUserRegistered($senderID, $rankRecipientID) {
|
||||
$rankUsers = $this->db->query('SELECT ID FROM users WHERE rank >= ?', [$rankRecipientID])->result_array();
|
||||
$rankUsers = $this->getRankUsers($rankRecipientID);
|
||||
foreach ($rankUsers as $user) {
|
||||
$notification = new \Notification\Admin\UserRegisteredNotification([
|
||||
'senderID' => $senderID,
|
||||
@@ -183,7 +195,7 @@
|
||||
}
|
||||
|
||||
public function rankNotificationNewFeedback($senderID, $rankRecipientID, $pageName) {
|
||||
$rankUsers = $this->db->query('SELECT ID FROM users WHERE rank >= ?', [$rankRecipientID])->result_array();
|
||||
$rankUsers = $this->getRankUsers($rankRecipientID);
|
||||
foreach ($rankUsers as $user) {
|
||||
$notification = new \Notification\Admin\NewFeedbackNotification([
|
||||
'senderID' => $senderID,
|
||||
@@ -194,8 +206,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function rankNotificationContactMessage($senderID, $rankRecipientID, $message) {
|
||||
$rankUsers = $this->getRankUsers($rankRecipientID);
|
||||
foreach ($rankUsers as $user) {
|
||||
$notification = new \Notification\Admin\ContactMessageNotification([
|
||||
'senderID' => $senderID,
|
||||
'recipientID' => $user['ID'],
|
||||
'referenceID' => $senderID,
|
||||
'parameters' => $message
|
||||
]);
|
||||
$this->add($notification);
|
||||
}
|
||||
}
|
||||
|
||||
public function rankNotificationPostReport($senderID, $rankRecipientID, $postID, $postUUID) {
|
||||
$rankUsers = $this->db->query('SELECT ID FROM users WHERE rank >= ?', [$rankRecipientID])->result_array();
|
||||
$rankUsers = $this->getRankUsers($rankRecipientID);
|
||||
foreach ($rankUsers as $user) {
|
||||
$notification = new \Notification\Users\PostReportNotification([
|
||||
'senderID' => $senderID,
|
||||
@@ -207,6 +232,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
private function getRankUsers($rankID) {
|
||||
return $this->db->query('SELECT ID FROM users WHERE rank >= ?', [$rankID])->result_array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user