Initial commit
This commit is contained in:
65
app/plugins/notifications/plugin.php
Normal file
65
app/plugins/notifications/plugin.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/notifications/plugin.php
|
||||
*
|
||||
* This houses all of the main plugin info and functionality.
|
||||
*
|
||||
* @package TP Notifications
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Plugins;
|
||||
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
use TheTempusProject\Classes\Plugin;
|
||||
use TheTempusProject\Models\Notification;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
|
||||
class Notifications extends Plugin {
|
||||
public $pluginName = 'TP Notifications';
|
||||
public $configName = 'notifications';
|
||||
public $pluginAuthor = 'JoeyK';
|
||||
public $pluginWebsite = 'https://TheTempusProject.com';
|
||||
public $modelVersion = '1.0';
|
||||
public $pluginVersion = '3.0';
|
||||
public $pluginDescription = 'A simple plugin which adds a site wide notification system.';
|
||||
public $permissionMatrix = [
|
||||
'sendNotifications' => [
|
||||
'pretty' => 'Can send notifications',
|
||||
'default' => false,
|
||||
],
|
||||
];
|
||||
public $admin_links = [
|
||||
[
|
||||
'text' => '<i class="glyphicon glyphicon-bell"></i> Notify',
|
||||
'url' => '{ROOT_URL}admin/notifications',
|
||||
],
|
||||
];
|
||||
private static $loaded = false;
|
||||
public function __construct( $load = false ) {
|
||||
parent::__construct( $load );
|
||||
if ( $this->checkEnabled() && App::$isLoggedIn ) {
|
||||
$notifications = new Notification;
|
||||
Components::set( 'notificationCount', $notifications->getUnreadCount( App::$activeUser->ID ) );
|
||||
if ( $notifications->getUnreadCount( App::$activeUser->ID ) > 0 ) {
|
||||
$messageBadge = Views::simpleView( 'notifications.badge' );
|
||||
} else {
|
||||
$messageBadge = '';
|
||||
}
|
||||
Components::set( 'NBADGE', $messageBadge );
|
||||
if ( App::$isLoggedIn ) {
|
||||
Components::set( 'recentNotifications', Views::simpleView( 'notifications.nav.recentNotificationsDropdown', $notifications->getByUser( 10 ) ) );
|
||||
} else {
|
||||
Components::set( 'recentNotifications', '' );
|
||||
}
|
||||
if ( ! self::$loaded ) {
|
||||
App::$topNavRight .= '{recentNotifications}';
|
||||
App::$topNavRightDropdown .= '<li><a href="{ROOT_URL}notifications"><i class="glyphicon glyphicon-bell"></i> Notifications {NBADGE}</a></li>';
|
||||
self::$loaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user