2018-10-16 16:28:42 +00:00
|
|
|
<?php
|
2018-10-28 14:33:06 +00:00
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
2018-10-16 16:28:42 +00:00
|
|
|
|
2018-10-28 14:33:06 +00:00
|
|
|
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
2018-10-16 16:28:42 +00:00
|
|
|
|
2018-10-28 14:33:06 +00:00
|
|
|
class GeneralModel extends CI_Model
|
2018-10-16 16:28:42 +00:00
|
|
|
{
|
|
|
|
|
2018-10-28 14:33:06 +00:00
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->model('BlogModel', '', TRUE);
|
|
|
|
$this->load->model('NotificationModel', '', TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getBlogPosts($count)
|
|
|
|
{
|
|
|
|
$posts = $this->BlogModel->getMostRecentPosts($count);
|
|
|
|
|
|
|
|
$return = '';
|
|
|
|
foreach ($posts as $result) {
|
2019-01-08 21:42:54 +00:00
|
|
|
$date = strtotime($result['initialRelease']);
|
2018-10-28 14:33:06 +00:00
|
|
|
$return .= '<div class="media">';
|
|
|
|
|
2019-01-08 21:42:54 +00:00
|
|
|
if ($result['image'] != '') {
|
|
|
|
$return .= '<img src="' . $result['image'] . '?w=100" style="width:75px" class="img-fluid mr-3">';
|
2018-10-28 14:33:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$return .= '<div class="media-body">
|
2019-01-08 21:42:54 +00:00
|
|
|
<h6 class="my-0"><a href="#">' . $result['title'] . '</a></h6>
|
2018-10-28 14:33:06 +00:00
|
|
|
<small class="text-white-50">' . lang('footer_published') . ' ' . DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date"), $_SESSION['site_lang']) . '</small>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
return $return;
|
2018-10-16 16:28:42 +00:00
|
|
|
}
|
2018-10-28 14:33:06 +00:00
|
|
|
|
|
|
|
function addFeedbackAnonymously($pageUrl, $message)
|
|
|
|
{
|
|
|
|
$this->addFeedback($pageUrl, $message, true, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
function addFeedback($pageUrl, $message, $anonymous, $userID, $email)
|
|
|
|
{
|
|
|
|
$this->db->query('INSERT INTO feedback (page, message, anonymous, userID, email) VALUES (?, ?, ?, ?, ?)', [$pageUrl, $message, $anonymous, $userID, $email]);
|
|
|
|
$this->db->cache_delete('admin', 'feedback');
|
|
|
|
|
|
|
|
// Send notifications
|
|
|
|
$this->NotificationModel->rankNotificationNewFeedback($userID != NULL ? $userID : -1, 9, $pageUrl);
|
|
|
|
}
|
|
|
|
|
2018-11-02 15:23:16 +00:00
|
|
|
function addContactMessage($email, $userID, $message) {
|
|
|
|
$this->db->query('INSERT INTO contact_messages (userID, userEmail, message) VALUES (?, ?, ?)', [$userID, $email, $message]);
|
|
|
|
$this->db->cache_delete('admin', 'contact');
|
|
|
|
|
|
|
|
// Send notifications
|
|
|
|
$this->NotificationModel->rankNotificationContactMessage($userID != NULL ? $userID : -1, 8, substr($message, 0, 30));
|
|
|
|
}
|
|
|
|
|
2018-10-28 14:33:06 +00:00
|
|
|
function getRankName($rankID)
|
|
|
|
{
|
|
|
|
$ranks = [
|
|
|
|
0 => "Nutzer",
|
|
|
|
1 => "Registrierter Nutzer",
|
|
|
|
2 => "Premium-Nutzer",
|
|
|
|
3 => "Plus-Nutzer",
|
|
|
|
6 => "Autor (Blog)",
|
|
|
|
7 => "Editor (Blog)",
|
|
|
|
8 => "Moderator",
|
|
|
|
9 => "Admin",
|
|
|
|
10 => "Admin"
|
|
|
|
];
|
|
|
|
return isset($ranks[$rankID]) ? $ranks[$rankID] : "Nutzer";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|