Archived
1
0

Small changes

This commit is contained in:
Marcel
2018-10-28 15:33:06 +01:00
parent bc30382947
commit 2af398f730
162 changed files with 81 additions and 58 deletions

View File

@@ -1,62 +1,68 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
defined('BASEPATH') OR exit('No direct script access allowed');
use Coduo\PHPHumanizer\DateTimeHumanizer;
use Coduo\PHPHumanizer\DateTimeHumanizer;
class GeneralModel extends CI_Model {
function __construct()
class GeneralModel extends CI_Model
{
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) {
$date = strtotime($result['postPublishDate']);
$return .= '<div class="media">
<div class="pull-left">
<img src="' . $result['postImage'] . '?w=100" style="max-width:100px" class="img-fluid">
</div>
<div class="media-body">
<span class="media-heading"><a href="#">' . $result['postTitle'] . '</a></span>
<small class="muted">' . lang('footer_published') . ' ' . DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date"), $_SESSION['site_lang']) . '</small>
</div>
</div>';
function __construct()
{
parent::__construct();
$this->load->model('BlogModel', '', TRUE);
$this->load->model('NotificationModel', '', TRUE);
}
return $return;
}
function addFeedbackAnonymously($pageUrl, $message) {
$this->addFeedback($pageUrl, $message, true, NULL, NULL);
}
function getBlogPosts($count)
{
$posts = $this->BlogModel->getMostRecentPosts($count);
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');
$return = '';
foreach ($posts as $result) {
$date = strtotime($result['postPublishDate']);
$return .= '<div class="media">';
// Send notifications
$this->NotificationModel->rankNotificationNewFeedback($userID != NULL ? $userID : -1, 9, $pageUrl);
}
if ($result['postImage'] != '') {
$return .= '<img src="' . $result['postImage'] . '?w=100" style="width:75px" class="img-fluid mr-3">';
}
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";
}
$return .= '<div class="media-body">
<h6 class="my-0"><a href="#">' . $result['postTitle'] . '</a></h6>
<small class="text-white-50">' . lang('footer_published') . ' ' . DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date"), $_SESSION['site_lang']) . '</small>
</div>
</div>';
}
return $return;
}
}
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);
}
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";
}
}