mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 02:39:46 +02:00
Add a notification central plugin UserNotification
this will be responsible to handle all the top bar bell button
This commit is contained in:
parent
f17bb1ee0c
commit
2f2fdc4923
33 changed files with 1481 additions and 123 deletions
|
@ -155,6 +155,7 @@ Options All -Indexes
|
|||
|
||||
|
||||
#for the video name
|
||||
RewriteRule ^video/([0-9]+)/poster.png$ view/videoGetPoster.php?videos_id=$1 [QSA]
|
||||
RewriteRule ^video/([0-9]+)/?$ view/?v=$1 [QSA]
|
||||
RewriteRule ^video/([^!#$&'()*,\/:;=?@[\]]+)/?$ view/?videoName=$1 [QSA]
|
||||
RewriteRule ^video/([^!#$&'()*,\/:;=?@[\]]+)/page/([0-9]+)/??$ view/?videoName=$1&page=$2 [QSA]
|
||||
|
|
|
@ -400,7 +400,7 @@ abstract class ObjectYPT implements ObjectInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
private static function ignoreTableSecurityCheck(){
|
||||
static function ignoreTableSecurityCheck(){
|
||||
|
||||
$ignoreArray = array('vast_campaigns_logs','videos', 'CachesInDB', 'plugins', 'users_login_history', 'live_transmitions_history', 'logincontrol_history', 'wallet','wallet_log', 'live_restreams_logs');
|
||||
return in_array(static::getTableName(),$ignoreArray );
|
||||
|
|
|
@ -9279,3 +9279,9 @@ function isOnDeveloperMode(){
|
|||
global $global;
|
||||
return (!empty($global['developer_mode']) || (!empty($global['developer_mode_admin_only']) && User::isAdmin()));
|
||||
}
|
||||
|
||||
function setDefaultSort($defaultSortColumn, $defaultSortOrder) {
|
||||
if (empty($_REQUEST['sort']) && empty($_GET['sort']) && empty($_POST['sort']) && empty($_GET['order'][0]['dir'])) {
|
||||
$_POST['sort'][$defaultSortColumn] = $defaultSortOrder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,10 @@ class Like
|
|||
}
|
||||
if ($like==1) {
|
||||
Video::updateLikesDislikes($videos_id, 'likes', '+1');
|
||||
AVideoPlugin::onVideoLikeDislike($videos_id,$this->users_id, true);
|
||||
} elseif ($like==-1) {
|
||||
Video::updateLikesDislikes($videos_id, 'dislikes', '+1');
|
||||
AVideoPlugin::onVideoLikeDislike($videos_id,$this->users_id, false);
|
||||
}
|
||||
}
|
||||
//exit;
|
||||
|
|
|
@ -72,9 +72,18 @@ class Subscribe extends ObjectYPT{
|
|||
if (!empty($this->id)) {
|
||||
$sql = "UPDATE subscribes SET status = '{$this->status}', notify = '{$this->notify}',ip = '" . getRealIpAddr() . "', modified = now() WHERE id = {$this->id}";
|
||||
} else {
|
||||
$sql = "INSERT INTO subscribes ( users_id, email,status,ip, created, modified, subscriber_users_id) VALUES ('{$this->users_id}','{$this->email}', 'a', '" . getRealIpAddr() . "',now(), now(), '$this->subscriber_users_id')";
|
||||
$this->status = 'a';
|
||||
$sql = "INSERT INTO subscribes ( users_id, email,status,ip, created, modified, subscriber_users_id) VALUES ('{$this->users_id}','{$this->email}', '{$this->status}', '" . getRealIpAddr() . "',now(), now(), '$this->subscriber_users_id')";
|
||||
}
|
||||
return sqlDAL::writeSql($sql);
|
||||
$saved = sqlDAL::writeSql($sql);
|
||||
if($saved){
|
||||
//var_dump($saved, $this->status);exit;
|
||||
if($this->status == 'a'){
|
||||
AVideoPlugin::onNewSubscription($this->users_id, $this->subscriber_users_id);
|
||||
}
|
||||
}
|
||||
|
||||
return $saved;
|
||||
}
|
||||
|
||||
public static function getSubscribe($id)
|
||||
|
|
|
@ -689,6 +689,36 @@ class AVideoPlugin
|
|||
}
|
||||
}
|
||||
|
||||
public static function onVideoLikeDislike($videos_id, $users_id, $isLike){
|
||||
if(empty($videos_id)){
|
||||
return false;
|
||||
}
|
||||
$plugins = Plugin::getAllEnabled();
|
||||
foreach ($plugins as $value) {
|
||||
self::YPTstart();
|
||||
$p = static::loadPlugin($value['dirName']);
|
||||
if (is_object($p)) {
|
||||
$p->onVideoLikeDislike($videos_id, $users_id, $isLike);
|
||||
}
|
||||
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onNewSubscription($users_id, $subscriber_users_id){
|
||||
if(empty($subscriber_users_id) || empty($users_id)){
|
||||
return false;
|
||||
}
|
||||
$plugins = Plugin::getAllEnabled();
|
||||
foreach ($plugins as $value) {
|
||||
self::YPTstart();
|
||||
$p = static::loadPlugin($value['dirName']);
|
||||
if (is_object($p)) {
|
||||
$p->onNewSubscription($users_id, $subscriber_users_id);
|
||||
}
|
||||
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onNewVideo($videos_id){
|
||||
if(empty($videos_id)){
|
||||
return false;
|
||||
|
@ -813,6 +843,18 @@ class AVideoPlugin
|
|||
}
|
||||
}
|
||||
|
||||
public static function getUserNotificationButton(){
|
||||
$plugins = Plugin::getAllEnabled();
|
||||
foreach ($plugins as $value) {
|
||||
self::YPTstart();
|
||||
$p = static::loadPlugin($value['dirName']);
|
||||
if (is_object($p)) {
|
||||
$p->getUserNotificationButton();
|
||||
}
|
||||
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getVideoManagerButton()
|
||||
{
|
||||
$plugins = Plugin::getAllEnabled();
|
||||
|
@ -2326,6 +2368,7 @@ class AVideoPlugin
|
|||
'PlayerSkins', // PlayerSkins
|
||||
'Permissions', // Permissions
|
||||
'Scheduler', // Permissions
|
||||
'UserNotifications',
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
|
@ -2335,6 +2378,7 @@ class AVideoPlugin
|
|||
'e9a568e6-ef61-4dcc-aad0-0109e9be8e36', // PlayerSkins
|
||||
'Permissions-5ee8405eaaa16', // Permissions
|
||||
'Scheduler-5ee8405eaaa16', // Permissions
|
||||
'UserNotifications-5ee8405eaaa16', // Permissions
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
}
|
||||
}
|
||||
} else {
|
||||
echo '<!-- '.basename(__FILE__).' -->';
|
||||
include $global['systemRootPath'] . 'plugin/Gallery/view/modeGalleryCategoryLive.php';
|
||||
$ob = _ob_get_clean();
|
||||
_ob_start();
|
||||
|
|
|
@ -39,6 +39,7 @@ $_REQUEST['rowCount'] = $obj->CategoriesRowCount;
|
|||
$_GET['catName'] = $_cat['clean_name'];
|
||||
if (!empty($liveobj) && empty($liveobj->doNotShowLiveOnCategoryList)) {
|
||||
$currentCat = $_cat;
|
||||
echo '<!-- '.basename(__FILE__).' -->';
|
||||
include $global['systemRootPath'] . 'plugin/Gallery/view/modeGalleryCategoryLive.php';
|
||||
}
|
||||
unset($_POST['sort']);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
global $global;
|
||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/Live/Objects/LiveTransmition.php';
|
||||
|
@ -494,7 +493,6 @@ class Live extends PluginAbstract {
|
|||
$obj->whoCanRestream = $o;
|
||||
self::addDataObjectHelper('whoCanRestream', 'Who can Restream');
|
||||
|
||||
|
||||
$obj->disableDVR = false;
|
||||
self::addDataObjectHelper('disableDVR', 'Disable DVR', 'Enable or disable the DVR Feature, you can control the DVR length in your nginx.conf on the parameter hls_playlist_length');
|
||||
$obj->disableGifThumbs = false;
|
||||
|
@ -3630,7 +3628,6 @@ Click <a href=\"{link}\">here</a> to join our live.";
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getPermissionsOptions() {
|
||||
$permissions = array();
|
||||
$permissions[] = new PluginPermissionOption(self::PERMISSION_CAN_RESTREAM, __("Can Restream"), __("Can restream live videos"), 'Live');
|
||||
|
@ -3663,6 +3660,27 @@ Click <a href=\"{link}\">here</a> to join our live.";
|
|||
return $permission;
|
||||
}
|
||||
|
||||
public static function _getUserNotificationButton() {
|
||||
if (Live::canStreamWithWebRTC()) {
|
||||
?>
|
||||
<button class="btn btn-default btn-sm faa-parent animated-hover " onclick="avideoModalIframeFull(webSiteRootURL + 'plugin/Live/webcamFullscreen.php');" data-toggle="tooltip" title="<?php echo __('Go Live') ?>" >
|
||||
<i class="fas fa-circle faa-flash" style="color:red;"></i> <span class="hidden-sm hidden-xs"><?php echo __($buttonTitle); ?></span>
|
||||
</button>
|
||||
<?php
|
||||
}
|
||||
if (Live::canScheduleLive()) {
|
||||
?>
|
||||
<button class="btn btn-primary btn-sm" onclick="avideoModalIframeFull(webSiteRootURL + 'plugin/Live/view/Live_schedule/panelIndex.php');" data-toggle="tooltip" title="<?php echo __('Schedule') ?>" >
|
||||
<i class="far fa-calendar"></i> <span class="hidden-sm hidden-xs"><?php echo __('Schedule'); ?></span>
|
||||
</button>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserNotificationButton() {
|
||||
self::_getUserNotificationButton();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LiveImageType {
|
||||
|
|
|
@ -57,75 +57,6 @@ if (User::canStream()) {
|
|||
}
|
||||
?>
|
||||
</style>
|
||||
<li class="dropdown" id="TopLiveNotificationButton" onclick="setTimeout(function () {
|
||||
lazyImage();
|
||||
}, 500);
|
||||
setTimeout(function () {
|
||||
lazyImage();
|
||||
}, 1000);
|
||||
setTimeout(function () {
|
||||
lazyImage();
|
||||
}, 1500);">
|
||||
<a href="#" class="faa-parent animated-hover btn btn-default navbar-btn" data-toggle="dropdown">
|
||||
<span class="fas fa-bell faa-ring"></span>
|
||||
<span class="badge onlineApplications" style=" background: rgba(255,0,0,1); color: #FFF;">0</span>
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-right notify-drop" >
|
||||
<?php
|
||||
if (Live::canStreamWithWebRTC() || Live::canScheduleLive()) {
|
||||
?>
|
||||
<div class="btn-group btn-group-justified" style="padding: 5px;">
|
||||
<?php
|
||||
if (Live::canStreamWithWebRTC()) {
|
||||
?>
|
||||
<button class="btn btn-default btn-sm faa-parent animated-hover " onclick="avideoModalIframeFull(webSiteRootURL + 'plugin/Live/webcamFullscreen.php');" data-toggle="tooltip" title="<?php echo __('Go Live') ?>" >
|
||||
<i class="fas fa-circle faa-flash" style="color:red;"></i> <span class="hidden-sm hidden-xs"><?php echo __($buttonTitle); ?></span>
|
||||
</button>
|
||||
<?php
|
||||
}
|
||||
if (Live::canScheduleLive()) {
|
||||
?>
|
||||
<button class="btn btn-primary btn-sm" onclick="avideoModalIframeFull(webSiteRootURL + 'plugin/Live/view/Live_schedule/panelIndex.php');" data-toggle="tooltip" title="<?php echo __('Schedule') ?>" >
|
||||
<i class="far fa-calendar"></i> <span class="hidden-sm hidden-xs"><?php echo __('Schedule'); ?></span>
|
||||
</button>
|
||||
<?php }
|
||||
?>
|
||||
</div>
|
||||
<?php }
|
||||
?>
|
||||
<div id="availableLiveStream">
|
||||
|
||||
</div>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<div class="col-lg-12 col-sm-12 col-xs-12 bottom-border hidden extraVideosModel liveVideo">
|
||||
<a href="" class="videoLink" class="videoLink galleryLink " >
|
||||
<div class="aspectRatio16_9" style="min-height: 70px;" >
|
||||
<img src="<?php echo getURL('videos/userPhoto/logo.png'); ?>" class="thumbsJPG img-responsive" height="130" itemprop="thumbnailUrl" alt="Logo" />
|
||||
<img src="" style="position: absolute; top: 0; display: none;" class="thumbsGIF img-responsive" height="130" />
|
||||
<span class="label label-danger liveNow faa-flash faa-slow animated"><?php echo __("LIVE NOW"); ?></span>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<a class="h6 galleryLink " href="_link_" >
|
||||
<strong class="title liveTitle"><?php echo __("Title"); ?></strong>
|
||||
</a>
|
||||
<div class="galeryDetails" style="overflow: hidden;">
|
||||
<div>
|
||||
<img src="" class="photoImg img img-circle img-responsive" style="max-width: 20px;">
|
||||
</div>
|
||||
<div class="liveUser"><?php echo __("User"); ?></div>
|
||||
<div class="galleryTags">
|
||||
<?php
|
||||
if (AVideoPlugin::isEnabledByName("LiveUsers") && method_exists("LiveUsers", "getLabels")) {
|
||||
echo LiveUsers::getLabels('extraVideosModelOnLineLabels');
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function refreshGetLiveImage(selector) {
|
||||
|
@ -360,6 +291,8 @@ if (isVideo()) {
|
|||
$('#liveVideos .extraVideos').prepend(html);
|
||||
$('#liveVideos').slideDown();
|
||||
}
|
||||
processUserNotificationFromApplication(application);
|
||||
|
||||
setTimeout(function () {
|
||||
lazyImage();
|
||||
}, 1000);
|
||||
|
@ -385,6 +318,20 @@ if (!empty($obj->playLiveInFullScreenOnIframe)) {
|
|||
}
|
||||
}
|
||||
|
||||
function processUserNotificationFromApplication(application){
|
||||
var itemsArray = {};
|
||||
itemsArray.priority = 3;
|
||||
itemsArray.image = application.poster;
|
||||
itemsArray.title = application.title;
|
||||
itemsArray.href = application.href;
|
||||
itemsArray.element_class = application.className;
|
||||
itemsArray.element_id = application.className;
|
||||
itemsArray.icon = 'fas fa-video';
|
||||
itemsArray.type = 'info';
|
||||
itemsArray.html = '<span class="label label-danger liveNow faa-flash faa-slow animated" style="display:inline-block; float:right;">LIVE NOW</span>';
|
||||
addTemplateFromArray(itemsArray);
|
||||
}
|
||||
|
||||
function socketLiveONCallback(json) {
|
||||
//console.log('socketLiveONCallback processLiveStats', json);
|
||||
processLiveStats(json.stats);
|
||||
|
|
|
@ -322,6 +322,9 @@ class PlayerSkins extends PluginAbstract {
|
|||
}
|
||||
}
|
||||
$videos_id = getVideos_id();
|
||||
|
||||
$event = "updateMediaSessionMetadata();";
|
||||
PlayerSkins::getStartPlayerJS($event);
|
||||
if (!empty($videos_id) && Video::getEPG($videos_id)) {
|
||||
PlayerSkins::getStartPlayerJS(file_get_contents("{$global['systemRootPath']}plugin/PlayerSkins/epgButton.js"));
|
||||
}
|
||||
|
|
|
@ -73,17 +73,28 @@ if (empty($MediaMetadata)) {
|
|||
key = 0;
|
||||
live_servers_id = 0;
|
||||
live_schedule_id = 0;
|
||||
if (!empty(player.playlist) && typeof playerPlaylist !== 'undefined' && !empty(playerPlaylist)) {
|
||||
|
||||
if (typeof player.playlist == 'function') {
|
||||
if (typeof playerPlaylist == 'undefined') {
|
||||
playerPlaylist = player.playlist();
|
||||
console.log('updateMediaSessionMetadata playerPlaylist was undefined', playerPlaylist);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof player.playlist == 'function' && typeof playerPlaylist !== 'undefined' && !empty(playerPlaylist)) {
|
||||
index = player.playlist.currentIndex();
|
||||
if (!empty(playerPlaylist[index])) {
|
||||
videos_id = playerPlaylist[index].videos_id;
|
||||
console.log('updateMediaSessionMetadata playerPlaylist[index].videos_id', videos_id);
|
||||
}
|
||||
} else if (mediaId) {
|
||||
videos_id = mediaId;
|
||||
console.log('updateMediaSessionMetadata mediaId', mediaId);
|
||||
} else if (isLive) {
|
||||
key = isLive.key;
|
||||
live_servers_id = isLive.live_servers_id;
|
||||
live_schedule_id = isLive.live_schedule_id;
|
||||
console.log('updateMediaSessionMetadata isLive', key);
|
||||
}
|
||||
if (videos_id) {
|
||||
console.log('updateMediaSessionMetadata', videos_id);
|
||||
|
@ -97,6 +108,7 @@ if (empty($MediaMetadata)) {
|
|||
'live_schedule_id': live_schedule_id,
|
||||
},
|
||||
success: function (response) {
|
||||
console.log('updateMediaSessionMetadata response', response);
|
||||
navigator.mediaSession.metadata = new MediaMetadata(response);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -235,6 +235,14 @@ abstract class PluginAbstract {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function onVideoLikeDislike($videos_id, $users_id, $isLike) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onNewSubscription($users_id, $subscriber_users_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function afterDonation($from_users_id, $how_much, $videos_id, $users_id, $extraParameters) {
|
||||
return false;
|
||||
}
|
||||
|
@ -298,6 +306,10 @@ abstract class PluginAbstract {
|
|||
return "";
|
||||
}
|
||||
|
||||
public function getUserNotificationButton() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getVideoManagerButton() {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class TopMenu extends PluginAbstract {
|
|||
|
||||
public function getHeadCode() {
|
||||
global $global;
|
||||
$css = '<link href="' .getCDN() . 'plugin/TopMenu/style.css" rel="stylesheet" type="text/css"/>';
|
||||
$css = '<link href="' .getURL('plugin/TopMenu/style.css') . '" rel="stylesheet" type="text/css"/>';
|
||||
return $css;
|
||||
}
|
||||
|
||||
|
|
23
plugin/UserNotifications/HTMLMenuRight.php
Normal file
23
plugin/UserNotifications/HTMLMenuRight.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!-- right menu start -->
|
||||
<li class="dropdown" id="topMenuUserNotifications" data-toggle="tooltip" title="<?php echo __('Notifications'); ?>" data-placement="bottom">
|
||||
<a href="#" class="faa-parent animated-hover btn btn-default btn-light navbar-btn" data-toggle="dropdown" data-toggle="tooltip" title="<?php echo __('Notifications'); ?>" data-placement="bottom" >
|
||||
<i class="fas fa-bell faa-ring"></i>
|
||||
<span class="badge badge-notify animate_animated animate__bounceIn">0</span>
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<div class="btn-group btn-group-justified">
|
||||
<?php
|
||||
echo AVideoPlugin::getUserNotificationButton();
|
||||
?>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<?php
|
||||
for($i=1;$i<=10;$i++){
|
||||
echo '<div class="priority priority'.$i.'"></div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</ul>
|
||||
</li>
|
||||
<!-- right menu start -->
|
169
plugin/UserNotifications/Objects/User_notifications.php
Normal file
169
plugin/UserNotifications/Objects/User_notifications.php
Normal file
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||
|
||||
class User_notifications extends ObjectYPT {
|
||||
|
||||
protected $id,$msg,$title,$type,$status,$time_readed,$users_id,$image,$icon,$href,$onclick,$element_class,$element_id,$priority;
|
||||
|
||||
static function getSearchFieldsNames() {
|
||||
return array('msg','type','image','icon','href','onclick','element_class','element_id');
|
||||
}
|
||||
|
||||
static function getTableName() {
|
||||
return 'user_notifications';
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title): void {
|
||||
$this->title = safeString($title);
|
||||
}
|
||||
|
||||
function setId($id) {
|
||||
$this->id = intval($id);
|
||||
}
|
||||
|
||||
function setMsg($msg) {
|
||||
$this->msg = safeString($msg);
|
||||
}
|
||||
|
||||
function setType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
function setStatus($status) {
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
function setTime_readed($time_readed) {
|
||||
$this->time_readed = $time_readed;
|
||||
}
|
||||
|
||||
function setUsers_id($users_id) {
|
||||
$this->users_id = intval($users_id);
|
||||
}
|
||||
|
||||
function setImage($image) {
|
||||
$this->image = safeString($image);
|
||||
}
|
||||
|
||||
function setIcon($icon) {
|
||||
$this->icon = safeString($icon);
|
||||
}
|
||||
|
||||
function setHref($href) {
|
||||
$this->href = safeString($href);
|
||||
}
|
||||
|
||||
function setOnclick($onclick) {
|
||||
$this->onclick = $onclick;
|
||||
}
|
||||
|
||||
function setElement_class($element_class) {
|
||||
$this->element_class = safeString($element_class);
|
||||
}
|
||||
|
||||
function setElement_Id($element_id) {
|
||||
$this->element_id = safeString($element_id);
|
||||
}
|
||||
|
||||
function setPriority($priority) {
|
||||
$this->priority = intval($priority);
|
||||
}
|
||||
|
||||
function getElement_Id() {
|
||||
return $this->element_id;
|
||||
}
|
||||
|
||||
function getMsg() {
|
||||
return $this->msg;
|
||||
}
|
||||
|
||||
function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
function getStatus() {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
function getTime_readed() {
|
||||
return $this->time_readed;
|
||||
}
|
||||
|
||||
function getUsers_id() {
|
||||
return intval($this->users_id);
|
||||
}
|
||||
|
||||
function getImage() {
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
function getIcon() {
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
function getHref() {
|
||||
return $this->href;
|
||||
}
|
||||
|
||||
function getOnclick() {
|
||||
return $this->onclick;
|
||||
}
|
||||
|
||||
function getElement_class() {
|
||||
return $this->element_class;
|
||||
}
|
||||
|
||||
function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
function getPriority() {
|
||||
return intval($this->priority);
|
||||
}
|
||||
|
||||
public static function getAll(){
|
||||
setDefaultSort('id', 'DESC');
|
||||
return parent::getAll();
|
||||
}
|
||||
|
||||
public static function getAllForUsers_id($users_id, $limit=10){
|
||||
global $global;
|
||||
if (!static::isTableInstalled()) {
|
||||
return false;
|
||||
}
|
||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? ORDER BY id DESC LIMIT ?";
|
||||
$res = sqlDAL::readSql($sql, 'ii', [$users_id, $limit]);
|
||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||
sqlDAL::close($res);
|
||||
$rows = [];
|
||||
if ($res !== false) {
|
||||
foreach ($fullData as $row) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function deleteForUsers_id($users_id){
|
||||
global $global;
|
||||
if (!empty($users_id)) {
|
||||
|
||||
if(!self::ignoreTableSecurityCheck() && isUntrustedRequest("DELETE " . static::getTableName())){
|
||||
return false;
|
||||
}
|
||||
$sql = "DELETE FROM " . static::getTableName() . " ";
|
||||
$sql .= " WHERE users_id = ?";
|
||||
$global['lastQuery'] = $sql;
|
||||
//_error_log("Delete Query: ".$sql);
|
||||
return sqlDAL::writeSql($sql, "i", [$users_id]);
|
||||
}
|
||||
_error_log("Id for table " . static::getTableName() . " not defined for deletion ". json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)), AVideoLog::$ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
255
plugin/UserNotifications/UserNotifications.php
Normal file
255
plugin/UserNotifications/UserNotifications.php
Normal file
|
@ -0,0 +1,255 @@
|
|||
<?php
|
||||
|
||||
global $global;
|
||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||
|
||||
require_once $global['systemRootPath'] . 'plugin/UserNotifications/Objects/User_notifications.php';
|
||||
|
||||
class UserNotifications extends PluginAbstract {
|
||||
|
||||
const type_success = 'success';
|
||||
const type_warning = 'warning';
|
||||
const type_info = 'info';
|
||||
const type_danger = 'danger';
|
||||
const types = array(self::type_success, self::type_warning, self::type_info, self::type_danger);
|
||||
const requiredUserNotificationTemplateFields = array('href', 'onclick', 'status', 'element_class', 'element_id', 'type', 'image', 'icon', 'title', 'msg', 'html', 'id', 'created');
|
||||
|
||||
public function getDescription() {
|
||||
$desc = "This plugin will handle all your user's notification on the top bell bar";
|
||||
//$desc .= $this->isReadyLabel(array('YPTWallet'));
|
||||
return $desc;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return "UserNotifications";
|
||||
}
|
||||
|
||||
public function getUUID() {
|
||||
return "UserNotifications-5ee8405eaaa16";
|
||||
}
|
||||
|
||||
public function getPluginVersion() {
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
public function updateScript() {
|
||||
global $global;
|
||||
/*
|
||||
if (AVideoPlugin::compareVersion($this->getName(), "2.0") < 0) {
|
||||
sqlDal::executeFile($global['systemRootPath'] . 'plugin/PayPerView/install/updateV2.0.sql');
|
||||
}
|
||||
*
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getEmptyDataObject() {
|
||||
$obj = new stdClass();
|
||||
/*
|
||||
$obj->textSample = "text";
|
||||
$obj->checkboxSample = true;
|
||||
$obj->numberSample = 5;
|
||||
|
||||
$o = new stdClass();
|
||||
$o->type = array(0=>__("Default"))+array(1,2,3);
|
||||
$o->value = 0;
|
||||
$obj->selectBoxSample = $o;
|
||||
|
||||
$o = new stdClass();
|
||||
$o->type = "textarea";
|
||||
$o->value = "";
|
||||
$obj->textareaSample = $o;
|
||||
*/
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function getPluginMenu() {
|
||||
global $global;
|
||||
return '<button onclick="avideoModalIframeLarge(webSiteRootURL+\'plugin/UserNotifications/View/editor.php\')" class="btn btn-primary btn-sm btn-xs btn-block"><i class="fa fa-edit"></i> Edit</button>';
|
||||
}
|
||||
|
||||
public function getHeadCode() {
|
||||
global $global;
|
||||
$css = '<link href="' . getURL('plugin/UserNotifications/style.css') . '" rel="stylesheet" type="text/css"/>';
|
||||
|
||||
$js = '<script>var user_notification_template = ' . json_encode(self::getTemplate()) . '</script>';
|
||||
$js .= '<script>var requiredUserNotificationTemplateFields = ' . json_encode(self::requiredUserNotificationTemplateFields) . '</script>';
|
||||
return $css . $js;
|
||||
}
|
||||
|
||||
public function getFooterCode() {
|
||||
global $global;
|
||||
include $global['systemRootPath'] . 'plugin/UserNotifications/footer.php';
|
||||
}
|
||||
|
||||
public function getHTMLMenuRight() {
|
||||
global $global;
|
||||
include $global['systemRootPath'] . 'plugin/UserNotifications/HTMLMenuRight.php';
|
||||
}
|
||||
|
||||
static function getTemplate() {
|
||||
global $_user_notification_template, $global;
|
||||
if (empty($_user_notification_template)) {
|
||||
$file = $global['systemRootPath'] . 'plugin/UserNotifications/template.html';
|
||||
$_user_notification_template = file_get_contents($file);
|
||||
}
|
||||
return $_user_notification_template;
|
||||
}
|
||||
|
||||
static function createTemplateFromArray($itemsArray) {
|
||||
global $global;
|
||||
$template = self::getTemplate();
|
||||
foreach ($itemsArray as $search => $replace) {
|
||||
if ($search == 'icon') {
|
||||
$replace = '<i class="' . $replace . '"></i>';
|
||||
} else if ($search == 'image' && !empty($replace) && !isValidURL($replace)) {
|
||||
$replace = $global['webSiteRootURL'] . $replace;
|
||||
} else if ($search == 'element_class') {
|
||||
$replace .= " UserNotifications_{$itemsArray['id']}";
|
||||
}
|
||||
$template = str_replace("{{$search}}", $replace, $template);
|
||||
}
|
||||
$template = self::cleanUpTemplate($template);
|
||||
return $template;
|
||||
}
|
||||
|
||||
static function cleanUpTemplate($template) {
|
||||
foreach (self::requiredUserNotificationTemplateFields as $search) {
|
||||
$template = str_replace("{{$search}}", '', $template);
|
||||
}
|
||||
$template = str_replace('<img src="" class="media-object">', '', $template);
|
||||
return $template;
|
||||
}
|
||||
|
||||
public static function notifySocket($array, $to_users_id = 0) {
|
||||
if (!empty($to_users_id)) {
|
||||
$socketObj = sendSocketMessageToUsers_id($array, $to_users_id, 'socketUserNotificationCallback');
|
||||
} else {
|
||||
$socketObj = sendSocketMessageToAll($array, 'socketUserNotificationCallback');
|
||||
}
|
||||
return $socketObj;
|
||||
}
|
||||
|
||||
public function createNotificationFromVideosAndUsers_id($videos_id, $users_id, $title, $msg, $element_id, $type, $icon='') {
|
||||
global $global;
|
||||
$identification = User::getNameIdentificationById($users_id);
|
||||
$video = new Video('', '', $videos_id);
|
||||
$to_users_id = $video->getUsers_id();
|
||||
$image = "user/{$users_id}/foto.png";
|
||||
$href = Video::getLinkToVideo($videos_id);
|
||||
$videoTitle = safeString($video->getTitle());
|
||||
$msg = "{$identification} " . $msg . ': ' . $videoTitle;
|
||||
$element_id = "{$element_id}_{$videos_id}_{$users_id}";
|
||||
|
||||
return self::createNotification($title, $msg, $to_users_id, $image, $href, $type, $element_id, $icon);
|
||||
}
|
||||
|
||||
public function onVideoLikeDislike($videos_id, $users_id, $isLike) {
|
||||
global $global;
|
||||
if ($isLike) {
|
||||
$title = __('You have a new like');
|
||||
$type = self::type_success;
|
||||
$msg = __('liked your video');
|
||||
$element_id = "UserNotificationLike";
|
||||
$icon = 'fas fa-thumbs-up';
|
||||
} else {
|
||||
$title = __('You have a new dislike');
|
||||
$type = self::type_warning;
|
||||
$msg = __('disliked your video');
|
||||
$element_id = "UserNotificationDisLike";
|
||||
$icon = 'fas fa-thumbs-down';
|
||||
}
|
||||
return self::createNotificationFromVideosAndUsers_id($videos_id, $users_id, $title, $msg, $element_id, $type, $icon);
|
||||
}
|
||||
|
||||
public function afterNewComment($comments_id) {
|
||||
global $global;
|
||||
$c = new Comment('', 0, $comments_id);
|
||||
$users_id = $c->getUsers_id();
|
||||
$videos_id = $c->getVideos_id();
|
||||
$title = __('You have a new comment');
|
||||
$type = self::type_success;
|
||||
$msg = __('comment your video');
|
||||
$element_id = "UserNotificationComment";
|
||||
$icon = 'far fa-comment';
|
||||
return self::createNotificationFromVideosAndUsers_id($videos_id, $users_id, $title, $msg, $element_id, $type, $icon);
|
||||
}
|
||||
|
||||
public function afterNewResponse($comments_id) {
|
||||
global $global;
|
||||
$c = new Comment('', 0, $comments_id);
|
||||
$users_id = $c->getUsers_id();
|
||||
$videos_id = $c->getVideos_id();
|
||||
$comments_id_parent = $c->getComments_id_pai();
|
||||
$cp = new Comment('', 0, $comments_id_parent);
|
||||
$to_users_id = $cp->getUsers_id();
|
||||
$video = new Video('', '', $videos_id);
|
||||
$videoTitle = safeString($video->getTitle());
|
||||
$title = __('You have a new response');
|
||||
$identification = User::getNameIdentificationById($users_id);
|
||||
$msg = $identification. ' '.__('respond your comment on video').': '.$videoTitle;
|
||||
$type = self::type_success;
|
||||
$element_id = "UserNotificationResponse_{$comments_id}_{$to_users_id}_{$users_id}_{$videos_id}";
|
||||
$image = "user/{$users_id}/foto.png";
|
||||
$href = Video::getLinkToVideo($videos_id);
|
||||
$icon = 'far fa-comments';
|
||||
return self::createNotification($title, $msg, $to_users_id, $image, $href, $type, $element_id, $icon);
|
||||
}
|
||||
|
||||
public function onNewSubscription($users_id, $subscriber_users_id) {
|
||||
global $global;
|
||||
$title = __('You have a new subscription');
|
||||
$type = self::type_success;
|
||||
$element_id = "UserNotificationSubscription_{$users_id}_{$subscriber_users_id}";
|
||||
$identification = User::getNameIdentificationById($subscriber_users_id);
|
||||
$msg = $identification. ' '.__('subscribe to you');
|
||||
$image = "user/{$subscriber_users_id}/foto.png";
|
||||
$href = 'subscribes';
|
||||
$msg = "{$identification} " . $msg . ': ' . $videoTitle;
|
||||
$icon = 'fas fa-user-check';
|
||||
return self::createNotification($title, $msg, $users_id, $image, $href, $type, $element_id, $icon);
|
||||
}
|
||||
|
||||
public function createNotification($title, $msg = '', $to_users_id = 0, $image = '', $href = '', $type = '', $element_id = '', $icon = '', $element_class = '', $onclick = '', $priority = '') {
|
||||
$element_class .= ' canDelete';
|
||||
$o = new User_notifications();
|
||||
$o->setMsg($msg);
|
||||
$o->setTitle($title);
|
||||
$o->setStatus('a');
|
||||
$o->setUsers_id($to_users_id);
|
||||
$o->setType($type);
|
||||
$o->setImage($image);
|
||||
$o->setIcon($icon);
|
||||
$o->setHref($href);
|
||||
$o->setOnclick($onclick);
|
||||
$o->setElement_class($element_class);
|
||||
$o->setElement_id($element_id);
|
||||
$o->setPriority($priority);
|
||||
if ($id = $o->save()) {
|
||||
$array = array(
|
||||
'id' => $id,
|
||||
'title' => $title,
|
||||
'msg' => $msg,
|
||||
'image' => $image,
|
||||
'href' => $href,
|
||||
'type' => $type,
|
||||
'element_class' => $element_class,
|
||||
'element_id' => $element_id,
|
||||
'icon' => $icon,
|
||||
'onclick' => $onclick,
|
||||
'priority' => $priority,
|
||||
'toast' => true,
|
||||
);
|
||||
self::notifySocket($array, $to_users_id);
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserNotificationButton() {
|
||||
?>
|
||||
<button class="btn btn-default btn-sm" onclick="deleteAllNotifications();" data-toggle="tooltip" title="<?php echo __('Delete All Notifications') ?>" >
|
||||
<i class="fas fa-trash"></i> <span class="hidden-sm hidden-xs"><?php echo __('Delete All'); ?></span>
|
||||
</button>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once '../../../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/UserNotifications/Objects/User_notifications.php';
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
$obj->msg = "";
|
||||
|
||||
$plugin = AVideoPlugin::loadPluginIfEnabled('UserNotifications');
|
||||
|
||||
if(!User::isAdmin()){
|
||||
$obj->msg = "You cant do this";
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
$o = new User_notifications(@$_POST['id']);
|
||||
$o->setMsg($_POST['msg']);
|
||||
$o->setTitle($_POST['title']);
|
||||
$o->setType($_POST['type']);
|
||||
$o->setStatus($_POST['status']);
|
||||
//$o->setTime_readed($_POST['time_readed']);
|
||||
$o->setUsers_id($_POST['User_notificationsusers_id']);
|
||||
$o->setImage($_POST['image']);
|
||||
$o->setIcon($_POST['User_notificationsicon']);
|
||||
$o->setHref($_POST['href']);
|
||||
$o->setOnclick($_POST['onclick']);
|
||||
$o->setElement_class($_POST['element_class']);
|
||||
$o->setElement_id($_POST['element_id']);
|
||||
$o->setPriority($_POST['priority']);
|
||||
|
||||
if($id = $o->save()){
|
||||
$obj->error = false;
|
||||
}
|
||||
|
||||
echo json_encode($obj);
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
require_once '../../../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/UserNotifications/Objects/User_notifications.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
$obj->msg = '';
|
||||
$obj->id = intval(@$_POST['id']);
|
||||
|
||||
$plugin = AVideoPlugin::loadPluginIfEnabled('UserNotifications');
|
||||
|
||||
if(!User::isLogged()){
|
||||
forbiddenPage("Please login first");
|
||||
}
|
||||
$obj->users_id = User::getId();
|
||||
if(!empty($obj->id)){
|
||||
$row = new User_notifications($obj->id);
|
||||
//var_dump($row->getElement_Id());exit;
|
||||
if(!empty($row->getElement_Id())){
|
||||
if(!User::isAdmin()){
|
||||
if($row->getUsers_id() != User::getId()){
|
||||
forbiddenPage("This notification does not belong to you");
|
||||
}
|
||||
}
|
||||
$obj->error = !$row->delete();
|
||||
}else{
|
||||
$obj->msg = 'Message was already deleted';
|
||||
$obj->error = false;
|
||||
}
|
||||
}else{
|
||||
$obj->error = !User_notifications::deleteForUsers_id($obj->users_id);
|
||||
}
|
||||
|
||||
|
||||
die(json_encode($obj));
|
||||
?>
|
29
plugin/UserNotifications/View/User_notifications/index.php
Normal file
29
plugin/UserNotifications/View/User_notifications/index.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
global $global, $config;
|
||||
if (!isset($global['systemRootPath'])) {
|
||||
require_once '../../videos/configuration.php';
|
||||
}
|
||||
if (!User::isAdmin()) {
|
||||
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $_SESSION['language']; ?>">
|
||||
<head>
|
||||
<title><?php echo $config->getWebSiteTitle(); ?> :: UserNotifications</title>
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/head.php';
|
||||
include $global['systemRootPath'] . 'plugin/UserNotifications/View/{$classname}/index_head.php';
|
||||
?>
|
||||
</head>
|
||||
<body class="<?php echo $global['bodyClass']; ?>">
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/navbar.php';
|
||||
include $global['systemRootPath'] . 'plugin/UserNotifications/View/{$classname}/index_body.php';
|
||||
include $global['systemRootPath'] . 'view/include/footer.php';
|
||||
?>
|
||||
<script type="text/javascript" src="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.js"></script>
|
||||
</body>
|
||||
</html>
|
300
plugin/UserNotifications/View/User_notifications/index_body.php
Normal file
300
plugin/UserNotifications/View/User_notifications/index_body.php
Normal file
|
@ -0,0 +1,300 @@
|
|||
<?php
|
||||
global $global, $config;
|
||||
if (!isset($global['systemRootPath'])) {
|
||||
require_once '../../videos/configuration.php';
|
||||
}
|
||||
if (!User::isAdmin()) {
|
||||
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<i class="fas fa-cog"></i> <?php echo __("Configurations"); ?>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="panel panel-default ">
|
||||
<div class="panel-heading"><i class="far fa-plus-square"></i> <?php echo __("Create"); ?></div>
|
||||
<div class="panel-body">
|
||||
<form id="panelUser_notificationsForm">
|
||||
<div class="row">
|
||||
<input type="hidden" name="id" id="User_notificationsid" value="" >
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="User_notifications_title"><?php echo __("Title"); ?>:</label>
|
||||
<input type="text" id="User_notifications_title" name="title" class="form-control input-sm" placeholder="<?php echo __("Title"); ?>">
|
||||
</div>
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="User_notificationsmsg"><?php echo __("Message"); ?>:</label>
|
||||
<textarea id="User_notificationsmsg" name="msg" class="form-control input-sm" placeholder="<?php echo __("Msg"); ?>" required="true"></textarea>
|
||||
</div>
|
||||
<div class="form-group col-sm-12">
|
||||
<?php
|
||||
$autocomplete = Layout::getUserAutocomplete(0, 'User_notificationsusers_id');
|
||||
?>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="User_notificationstype"><?php echo __("Type"); ?>:</label>
|
||||
|
||||
<select class="form-control input-sm" name="type" id="User_notificationstype">
|
||||
<?php
|
||||
foreach (UserNotifications::types as $value) {
|
||||
echo "<option value=\"{$value}\">{$value}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="status"><?php echo __("Status"); ?>:</label>
|
||||
<select class="form-control input-sm" name="status" id="User_notificationsstatus">
|
||||
<option value="a"><?php echo __("Active"); ?></option>
|
||||
<option value="i"><?php echo __("Inactive"); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="User_notificationspriority"><?php echo __("Priority"); ?>:</label>
|
||||
|
||||
<select class="form-control input-sm" name="priority" id="User_notificationspriority">
|
||||
<?php
|
||||
for ($index = 1; $index <= 10; $index++) {
|
||||
echo "<option value=\"{$index}\">{$index}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="User_notificationsimage"><?php echo __("Image"); ?>:</label>
|
||||
<input type="text" id="User_notificationsimage" name="image" class="form-control input-sm" placeholder="<?php echo __("Image"); ?>">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="User_notificationsicon"><?php echo __("Icon"); ?>:</label>
|
||||
<?php
|
||||
echo Layout::getIconsSelect("User_notificationsicon");
|
||||
?>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="User_notificationshref"><?php echo __("Href"); ?>:</label>
|
||||
<input type="text" id="User_notificationshref" name="href" class="form-control input-sm" placeholder="<?php echo __("Href"); ?>" >
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="User_notificationsonclick"><?php echo __("Onclick"); ?>:</label>
|
||||
<input type="text" id="User_notificationsonclick" name="onclick" class="form-control input-sm" placeholder="<?php echo __("Onclick"); ?>" >
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="User_notificationselement_class"><?php echo __("Element Class"); ?>:</label>
|
||||
<input type="text" id="User_notificationselement_class" name="element_class" class="form-control input-sm" placeholder="<?php echo __("Class"); ?>" >
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="User_notificationselement_id"><?php echo __("Element ID"); ?>:</label>
|
||||
<input type="text" name="element_id" id="User_notificationselement_id" class="form-control input-sm" placeholder="<?php echo __("Element ID"); ?>" >
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="form-group col-sm-12">
|
||||
<div class="btn-group pull-right">
|
||||
<span class="btn btn-success" id="newUser_notificationsLink" onclick="clearUser_notificationsForm()"><i class="fas fa-plus"></i> <?php echo __("New"); ?></span>
|
||||
<button class="btn btn-primary" type="submit"><i class="fas fa-save"></i> <?php echo __("Save"); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="panel panel-default ">
|
||||
<div class="panel-heading"><i class="fas fa-edit"></i> <?php echo __("Edit"); ?></div>
|
||||
<div class="panel-body">
|
||||
<table id="User_notificationsTable" class="display table table-bordered table-responsive table-striped table-hover table-condensed" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?php echo __("Title"); ?></th>
|
||||
<th><?php echo __("Type"); ?></th>
|
||||
<th><?php echo __("Status"); ?></th>
|
||||
<th><?php echo __("Time Readed"); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?php echo __("Title"); ?></th>
|
||||
<th><?php echo __("Type"); ?></th>
|
||||
<th><?php echo __("Status"); ?></th>
|
||||
<th><?php echo __("Time Readed"); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="User_notificationsbtnModelLinks" style="display: none;">
|
||||
<div class="btn-group pull-right">
|
||||
<button href="" class="edit_User_notifications btn btn-default btn-xs">
|
||||
<i class="fa fa-edit"></i>
|
||||
</button>
|
||||
<button href="" class="delete_User_notifications btn btn-danger btn-xs">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function clearUser_notificationsForm() {
|
||||
$('#User_notificationsid').val('');
|
||||
$('#User_notifications_title').val('');
|
||||
$('#User_notificationsmsg').val('');
|
||||
$('#User_notificationstype').val('');
|
||||
$('#User_notificationsstatus').val('');
|
||||
//$('#User_notificationstime_readed').val('');
|
||||
$('#User_notificationsusers_id').val('');
|
||||
$('#User_notificationsimage').val('');
|
||||
$('#User_notificationsicon').val('');
|
||||
$("select[name='User_notificationsicon']").val('');
|
||||
$("select[name='User_notificationsicon']").trigger('change');
|
||||
$('#User_notificationshref').val('');
|
||||
$('#User_notificationsonclick').val('');
|
||||
$('#User_notificationselement_class').val('');
|
||||
$('#User_notificationselement_id').val('');
|
||||
$('#User_notificationspriority').val('');
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$('#addUser_notificationsBtn').click(function () {
|
||||
$.ajax({
|
||||
url: webSiteRootURL + 'plugin/UserNotifications/View/addUser_notificationsVideo.php',
|
||||
data: $('#panelUser_notificationsForm').serialize(),
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
if (response.error) {
|
||||
avideoAlertError(response.msg);
|
||||
} else {
|
||||
avideoToast("<?php echo __("Your register has been saved!"); ?>");
|
||||
$("#panelUser_notificationsForm").trigger("reset");
|
||||
}
|
||||
clearUser_notificationsForm();
|
||||
tableVideos.ajax.reload();
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
});
|
||||
});
|
||||
var User_notificationstableVar = $('#User_notificationsTable').DataTable({
|
||||
serverSide: true,
|
||||
order: [[0, 'desc']],
|
||||
"ajax": webSiteRootURL + "plugin/UserNotifications/View/User_notifications/list.json.php",
|
||||
"columns": [
|
||||
{"data": "id"},
|
||||
{
|
||||
sortable: true,
|
||||
data: 'title',
|
||||
"render": function (data, type, full, meta) {
|
||||
var iconHTML = '';
|
||||
if(!empty(full.icon)){
|
||||
iconHTML = '<i class="'+full.icon+'"></i> ';
|
||||
}
|
||||
|
||||
return iconHTML+full.title;
|
||||
}
|
||||
},
|
||||
{"data": "type"},
|
||||
{"data": "status"},
|
||||
{"data": "time_readed"},
|
||||
{
|
||||
sortable: false,
|
||||
data: null,
|
||||
defaultContent: $('#User_notificationsbtnModelLinks').html()
|
||||
}
|
||||
],
|
||||
select: true,
|
||||
});
|
||||
$('#newUser_notifications').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('#panelUser_notificationsForm').trigger("reset");
|
||||
$('#User_notificationsid').val('');
|
||||
});
|
||||
$('#panelUser_notificationsForm').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
url: '<?php echo $global['webSiteRootURL']; ?>plugin/UserNotifications/View/User_notifications/add.json.php',
|
||||
data: $('#panelUser_notificationsForm').serialize(),
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
if (response.error) {
|
||||
avideoAlertError(response.msg);
|
||||
} else {
|
||||
avideoToast("<?php echo __("Your register has been saved!"); ?>");
|
||||
$("#panelUser_notificationsForm").trigger("reset");
|
||||
}
|
||||
User_notificationstableVar.ajax.reload();
|
||||
$('#User_notificationsid').val('');
|
||||
modal.hidePleaseWait();
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#User_notificationsTable').on('click', 'button.delete_User_notifications', function (e) {
|
||||
e.preventDefault();
|
||||
var tr = $(this).closest('tr')[0];
|
||||
var data = User_notificationstableVar.row(tr).data();
|
||||
swal({
|
||||
title: "<?php echo __("Are you sure?"); ?>",
|
||||
text: "<?php echo __("You will not be able to recover this action!"); ?>",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
})
|
||||
.then(function (willDelete) {
|
||||
if (willDelete) {
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?php echo $global['webSiteRootURL']; ?>plugin/UserNotifications/View/User_notifications/delete.json.php",
|
||||
data: data
|
||||
|
||||
}).done(function (resposta) {
|
||||
if (resposta.error) {
|
||||
avideoAlertError(resposta.msg);
|
||||
}
|
||||
User_notificationstableVar.ajax.reload();
|
||||
modal.hidePleaseWait();
|
||||
});
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#User_notificationsTable').on('click', 'button.edit_User_notifications', function (e) {
|
||||
e.preventDefault();
|
||||
var tr = $(this).closest('tr')[0];
|
||||
var data = User_notificationstableVar.row(tr).data();
|
||||
$('#User_notificationsid').val(data.id);
|
||||
$('#User_notifications_title').val(data.title);
|
||||
$('#User_notificationsmsg').val(data.msg);
|
||||
$('#User_notificationstype').val(data.type);
|
||||
$('#User_notificationsstatus').val(data.status);
|
||||
//$('#User_notificationstime_readed').val(data.time_readed);
|
||||
$('#User_notificationsusers_id').val(data.users_id);
|
||||
$('#User_notificationsimage').val(data.image);
|
||||
$('#User_notificationsicon').val(data.icon);
|
||||
$("select[name='User_notificationsicon']").val(data.icon);
|
||||
$("select[name='User_notificationsicon']").trigger('change');
|
||||
$('#User_notificationshref').val(data.href);
|
||||
$('#User_notificationsonclick').val(data.onclick);
|
||||
$('#User_notificationselement_class').val(data.element_class);
|
||||
$('#User_notificationselement_id').val(data.element_id);
|
||||
$('#User_notificationspriority').val(data.priority);
|
||||
<?php echo $autocomplete; ?>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script> $(document).ready(function () {
|
||||
$('#User_notificationstime_readed').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose: true});
|
||||
});</script>
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
$plugin = AVideoPlugin::loadPluginIfEnabled('UserNotifications');
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.css"/>
|
||||
<link href="<?php echo $global['webSiteRootURL']; ?>view/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css"/>
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
require_once '../../../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/UserNotifications/Objects/User_notifications.php';
|
||||
header('Content-Type: application/json');
|
||||
$rows = User_notifications::getAll();
|
||||
$total = User_notifications::getTotal();
|
||||
|
||||
?>
|
||||
{"data": <?php echo json_encode($rows); ?>, "draw": <?php echo intval(@$_REQUEST['draw']); ?>, "recordsTotal":<?php echo $total; ?>, "recordsFiltered":<?php echo $total; ?>}
|
46
plugin/UserNotifications/View/editor.php
Normal file
46
plugin/UserNotifications/View/editor.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
require_once '../../../videos/configuration.php';
|
||||
AVideoPlugin::loadPlugin("UserNotifications");
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $_SESSION['language']; ?>">
|
||||
<head>
|
||||
<title><?php echo $config->getWebSiteTitle(); ?> :: UserNotifications</title>
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/head.php';
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.css"/>
|
||||
<link href="<?php echo $global['webSiteRootURL']; ?>view/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body class="<?php echo $global['bodyClass']; ?>">
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/navbar.php';
|
||||
?>
|
||||
<div class="container-fluid">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><?php echo __('UserNotifications') ?>
|
||||
<div class="pull-right">
|
||||
<?php echo AVideoPlugin::getSwitchButton("UserNotifications"); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#User_notifications"><?php echo __("User Notifications"); ?></a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="User_notifications" class="tab-pane fade in active" style="padding: 10px;">
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'plugin/UserNotifications/View/User_notifications/index_body.php';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.js"></script>
|
||||
<script src="<?php echo $global['webSiteRootURL']; ?>js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
|
||||
<?php
|
||||
include $global['systemRootPath'] . 'view/include/footer.php';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
6
plugin/UserNotifications/footer.php
Normal file
6
plugin/UserNotifications/footer.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<script src="<?php echo getURL('plugin/UserNotifications/script.js'); ?>" type="text/javascript"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
});
|
||||
</script>
|
14
plugin/UserNotifications/getNotifications.json.php
Normal file
14
plugin/UserNotifications/getNotifications.json.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once '../../videos/configuration.php';
|
||||
$obj = new stdClass();
|
||||
$obj->msg = '';
|
||||
$obj->error = false;
|
||||
$obj->users_id = User::getId();
|
||||
$obj->notifications = User_notifications::getAllForUsers_id($obj->users_id);
|
||||
usort($obj->notifications, 'cmpNotifications');
|
||||
echo json_encode($obj);
|
||||
|
||||
function cmpNotifications($a, $b) {
|
||||
return $a['id']-$b['id'];
|
||||
}
|
30
plugin/UserNotifications/install/install.sql
Normal file
30
plugin/UserNotifications/install/install.sql
Normal file
|
@ -0,0 +1,30 @@
|
|||
CREATE TABLE IF NOT EXISTS `user_notifications` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`msg` TEXT NOT NULL,
|
||||
`type` VARCHAR(45) NOT NULL,
|
||||
`created` DATETIME NULL,
|
||||
`modified` DATETIME NULL,
|
||||
`status` CHAR(1) NOT NULL,
|
||||
`time_readed` DATETIME NULL,
|
||||
`users_id` INT(11) NULL,
|
||||
`image` VARCHAR(255) NULL,
|
||||
`icon` VARCHAR(255) NULL,
|
||||
`href` VARCHAR(255) NULL,
|
||||
`onclick` VARCHAR(255) NULL,
|
||||
`element_class` VARCHAR(255) NULL,
|
||||
`element_id` VARCHAR(255) NULL,
|
||||
`priority` INT NOT NULL,
|
||||
`timezone` VARCHAR(255) NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fk_user_notifications_users1_idx` (`users_id` ASC) ,
|
||||
INDEX `index_user_notification_type` (`type` ASC) ,
|
||||
INDEX `index_user_notification_status` (`status` ASC) ,
|
||||
INDEX `index_user_notification_priority` (`priority` ASC) ,
|
||||
UNIQUE INDEX `unique_element_id` (`element_id` ASC) ,
|
||||
CONSTRAINT `fk_user_notifications_users1`
|
||||
FOREIGN KEY (`users_id`)
|
||||
REFERENCES `users` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE)
|
||||
ENGINE = InnoDB;
|
198
plugin/UserNotifications/script.js
Normal file
198
plugin/UserNotifications/script.js
Normal file
|
@ -0,0 +1,198 @@
|
|||
function getTemplateFromArray(itemsArray) {
|
||||
var template = user_notification_template;
|
||||
for (var search in itemsArray) {
|
||||
var replace = itemsArray[search];
|
||||
if (typeof replace == 'function') {
|
||||
continue;
|
||||
}
|
||||
if (search == 'icon') {
|
||||
replace = '<i class="' + replace + '"></i>';
|
||||
} else if (search == 'image' && !empty(replace) && !isValidURL(replace)) {
|
||||
replace = webSiteRootURL + replace;
|
||||
} else if (search == 'element_class' && !empty(itemsArray.id)) {
|
||||
replace += " UserNotificationsJS_" + itemsArray.id;
|
||||
} else if (search == 'created') {
|
||||
m = moment.tz(itemsArray.created, itemsArray.timezone).local();
|
||||
replace = m.fromNow();
|
||||
}
|
||||
template = template.replace(new RegExp('{' + search + '}', 'g'), replace);
|
||||
}
|
||||
template = cleanUpTemplate(template);
|
||||
return template;
|
||||
}
|
||||
|
||||
function addTemplateFromArray(itemsArray) {
|
||||
if(typeof itemsArray === 'function'){
|
||||
return false;
|
||||
}
|
||||
//console.log('addTemplateFromArray', itemsArray);
|
||||
if (!empty(itemsArray.element_id) && $('#' + (itemsArray.element_id)).length) {
|
||||
return false;
|
||||
}
|
||||
var template = getTemplateFromArray(itemsArray);
|
||||
|
||||
var priority = 6;
|
||||
if(!isNaN(itemsArray.priority)){
|
||||
priority = itemsArray.priority;
|
||||
}
|
||||
if(empty(priority)){
|
||||
priority = 6;
|
||||
}
|
||||
var selector = '#topMenuUserNotifications ul .list-group .priority'+priority;
|
||||
console.log('addTemplateFromArray prepend', selector);
|
||||
$(selector).prepend(template);
|
||||
return true;
|
||||
}
|
||||
|
||||
function cleanUpTemplate(template) {
|
||||
for (var index in requiredUserNotificationTemplateFields) {
|
||||
var search = requiredUserNotificationTemplateFields[index];
|
||||
if (typeof search !== 'string') {
|
||||
continue;
|
||||
}
|
||||
//console.log('cleanUpTemplate', search);
|
||||
template = template.replace(new RegExp('\{' + search + '\}', 'g'), '');
|
||||
}
|
||||
template = template.replace(/<img src="" class="media-object">/g, "");
|
||||
return template;
|
||||
}
|
||||
|
||||
function userNotification(itemsArray, toast, customTitle) {
|
||||
addTemplateFromArray(itemsArray);
|
||||
|
||||
var title = itemsArray.title;
|
||||
if (!empty(customTitle)) {
|
||||
title = customTitle;
|
||||
}
|
||||
if (empty(title)) {
|
||||
title = itemsArray.msg;
|
||||
}
|
||||
|
||||
if (!empty(toast) && !empty(title)) {
|
||||
switch (itemsArray.type) {
|
||||
case 'success':
|
||||
avideoToastSuccess(title);
|
||||
break;
|
||||
case 'warning':
|
||||
avideoToastWarning(title);
|
||||
break;
|
||||
case 'danger':
|
||||
avideoToastError(title);
|
||||
break;
|
||||
case 'info':
|
||||
avideoToastInfo(title);
|
||||
break;
|
||||
default:
|
||||
avideoToast(title);
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateUserNotificationCount();
|
||||
}
|
||||
|
||||
function socketUserNotificationCallback(json) {
|
||||
|
||||
var toast = false;
|
||||
var customTitle = false;
|
||||
if (!empty(json.toast)) {
|
||||
toast = json.toast;
|
||||
}
|
||||
if (!empty(json.customTitle)) {
|
||||
customTitle = json.customTitle;
|
||||
}
|
||||
|
||||
console.log('socketUserNotificationCallback', json, toast, customTitle);
|
||||
userNotification(json, toast, customTitle);
|
||||
}
|
||||
|
||||
var _updateUserNotificationCountTimeout;
|
||||
function updateUserNotificationCount() {
|
||||
clearTimeout(_updateUserNotificationCountTimeout);
|
||||
_updateUserNotificationCountTimeout = setTimeout(function () {
|
||||
var valueNow = parseInt($('#topMenuUserNotifications a > span.badge-notify').text());
|
||||
var total = $('#topMenuUserNotifications > ul .list-group a').length;
|
||||
if (total != valueNow) {
|
||||
//Avoid dropdown menu close on click inside
|
||||
$(document).on('click', '#topMenuUserNotifications .dropdown-menu', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
animateChilds('#topMenuUserNotifications .dropdown-menu .list-group .priority', 'animate__bounceInRight', 0.05);
|
||||
$('#topMenuUserNotifications a > span.badge-notify').hide();
|
||||
setTimeout(function () {
|
||||
var selector = '#topMenuUserNotifications a > span.badge-notify';
|
||||
countToOrRevesrse(selector, total);
|
||||
$(selector).show();
|
||||
}, 1);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
async function getUserNotification() {
|
||||
var url = webSiteRootURL + 'plugin/UserNotifications/getNotifications.json.php';
|
||||
$.ajax({
|
||||
url: url,
|
||||
success: function (response) {
|
||||
modal.hidePleaseWait();
|
||||
if (response.error) {
|
||||
avideoToastError(response.msg);
|
||||
} else {
|
||||
for (var item in response.notifications) {
|
||||
var itemsArray = response.notifications[item];
|
||||
if(typeof itemsArray === 'function'){
|
||||
continue;
|
||||
}
|
||||
addTemplateFromArray(itemsArray);
|
||||
}
|
||||
updateUserNotificationCount();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteUserNotification(id, t) {
|
||||
//modal.showPleaseWait();
|
||||
$(t).parent().removeClass('animate__bounceInRight');
|
||||
$(t).parent().addClass('animate__flipOutX');
|
||||
var url = webSiteRootURL + 'plugin/UserNotifications/View/User_notifications/delete.json.php';
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: {id: id},
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
//modal.hidePleaseWait();
|
||||
if (response.error) {
|
||||
avideoAlertError(response.msg);
|
||||
} else {
|
||||
//avideoToastSuccess(response.msg);
|
||||
setTimeout(function(){
|
||||
$(t).parent().remove();
|
||||
updateUserNotificationCount();
|
||||
},500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAllNotifications(){
|
||||
animateChilds('#topMenuUserNotifications .dropdown-menu .list-group .canDelete', 'animate__flipOutX', 0.05);
|
||||
var url = webSiteRootURL + 'plugin/UserNotifications/View/User_notifications/delete.json.php';
|
||||
$.ajax({
|
||||
url: url,
|
||||
success: function (response) {
|
||||
//modal.hidePleaseWait();
|
||||
if (response.error) {
|
||||
avideoAlertError(response.msg);
|
||||
} else {
|
||||
//avideoToastSuccess(response.msg);
|
||||
setTimeout(function(){
|
||||
$('#topMenuUserNotifications .dropdown-menu .list-group .canDelete').remove();
|
||||
updateUserNotificationCount();
|
||||
},500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
getUserNotification();
|
||||
});
|
56
plugin/UserNotifications/style.css
Normal file
56
plugin/UserNotifications/style.css
Normal file
|
@ -0,0 +1,56 @@
|
|||
#topMenuUserNotifications span.badge-notify{
|
||||
background:red;
|
||||
}
|
||||
|
||||
#topMenuUserNotifications .dropdown-menu .list-group{
|
||||
min-width: 360px;
|
||||
max-height: calc(100vh - 150px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#topMenuUserNotifications .dropdown-menu img{
|
||||
max-width: 100px;
|
||||
height: 60px;
|
||||
margin: 10px 0 0 10px;
|
||||
}
|
||||
|
||||
#topMenuUserNotifications > ul .list-group a {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#topMenuUserNotifications > ul .list-group a > div > div.media-body > strong{
|
||||
white-space: nowrap;
|
||||
|
||||
}
|
||||
#topMenuUserNotifications .icon{
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 5px;
|
||||
padding: 2px 4px;
|
||||
border-radius: 20px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
#topMenuUserNotifications .dropdown-menu .list-group .deleteBtn{
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
border-width: 0;
|
||||
display: none;
|
||||
opacity: 0.5;
|
||||
background-color: transparent;
|
||||
}
|
||||
#topMenuUserNotifications .dropdown-menu .list-group .deleteBtn:hover{
|
||||
opacity: 1;
|
||||
}
|
||||
#topMenuUserNotifications .dropdown-menu .list-group div.canDelete:hover .deleteBtn{
|
||||
display: inline-block;
|
||||
}
|
||||
#topMenuUserNotifications .dropdown-menu .list-group .priority > div{
|
||||
position: relative;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
#topMenuUserNotifications .dropdown-menu .list-group{
|
||||
max-height: calc(100vh - 300px);
|
||||
}
|
||||
|
||||
}
|
24
plugin/UserNotifications/template.html
Normal file
24
plugin/UserNotifications/template.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<div class="{element_class} {type}" id="{element_id}">
|
||||
<a href="{href}" onclick="{onclick}" class="list-group-item {status}">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<img src="{image}" class="media-object">
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<strong class="media-heading">
|
||||
{title}
|
||||
</strong>
|
||||
<p>{msg}</p>
|
||||
{html}
|
||||
<small class="pull-right">{created}</small>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<div class="icon bg-{type}">{icon}</div>
|
||||
<button class="btn btn-default btn-outline deleteBtn"
|
||||
onclick="deleteUserNotification({id}, this);return false;"
|
||||
data-toggle="tooltip" title="Delete"
|
||||
data-placement="left">
|
||||
<i class="fas fa-times-circle"></i>
|
||||
</button>
|
||||
</div>
|
|
@ -54,7 +54,10 @@ showAlertMessage();
|
|||
<script src="<?php echo getURL('node_modules/jquery-lazy/jquery.lazy.min.js'); ?>" type="text/javascript"></script>
|
||||
<script src="<?php echo getURL('node_modules/jquery-lazy/jquery.lazy.plugins.min.js'); ?>" type="text/javascript"></script>
|
||||
<script src="<?php echo getURL('node_modules/moment/min/moment.min.js'); ?>"></script>
|
||||
<?php echo getTagIfExists('node_modules/moment/locale/'. getLanguage().'.js'); ?>
|
||||
<?php
|
||||
echo getTagIfExists('node_modules/moment/locale/'. getLanguage().'.js');
|
||||
?>
|
||||
<script src="<?php echo getURL('node_modules/moment-timezone/builds/moment-timezone-with-data.min.js'); ?>"></script>
|
||||
<script src="<?php echo getURL('view/js/script.js'); ?>" type="text/javascript"></script>
|
||||
<script src="<?php echo getURL('node_modules/jquery-ui-dist/jquery-ui.min.js'); ?>" type="text/javascript"></script>
|
||||
<?php
|
||||
|
|
|
@ -1690,6 +1690,22 @@ function pauseIfIsPlayinAds() { // look like the mobile does not know if is play
|
|||
}
|
||||
}
|
||||
|
||||
function countToOrRevesrse(selector, total){
|
||||
var text = $(selector).text();
|
||||
if (isNaN(text)) {
|
||||
current = 0;
|
||||
} else {
|
||||
current = parseInt(text);
|
||||
}
|
||||
total = parseInt(total);
|
||||
|
||||
if(current<=total){
|
||||
countTo(selector, total);
|
||||
}else{
|
||||
countToReverse(selector, total);
|
||||
}
|
||||
}
|
||||
|
||||
function countTo(selector, total) {
|
||||
var text = $(selector).text();
|
||||
if (isNaN(text)) {
|
||||
|
@ -1715,6 +1731,31 @@ function countTo(selector, total) {
|
|||
}, timeout);
|
||||
}
|
||||
|
||||
function countToReverse(selector, total) {
|
||||
var text = $(selector).text();
|
||||
if (isNaN(text)) {
|
||||
return false;
|
||||
} else {
|
||||
current = parseInt(text);
|
||||
}
|
||||
total = parseInt(total);
|
||||
if (!total || current <= total) {
|
||||
$(selector).removeClass('loading');
|
||||
return;
|
||||
}
|
||||
var rest = (current-total);
|
||||
var step = parseInt(rest / 100);
|
||||
if (step < 1) {
|
||||
step = 1;
|
||||
}
|
||||
current -= step;
|
||||
$(selector).text(current);
|
||||
var timeout = (500 / rest);
|
||||
setTimeout(function () {
|
||||
countToReverse(selector, total);
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
if (typeof showPleaseWaitTimeOut == 'undefined') {
|
||||
var showPleaseWaitTimeOut = 0;
|
||||
}
|
||||
|
@ -1938,7 +1979,7 @@ function convertDBDateToLocal(dbDateString) {
|
|||
//console.log('convertDBDateToLocal format does not match', dbDateString);
|
||||
return dbDateString;
|
||||
}
|
||||
|
||||
checkMoment();
|
||||
dbDateString = $.trim(dbDateString.replace(/[^ 0-9:-]/g, ''));
|
||||
var m;
|
||||
if (!_serverDBTimezone) {
|
||||
|
@ -1961,12 +2002,22 @@ function convertDateFromTimezoneToLocal(dbDateString, timezone) {
|
|||
//console.log('convertDBDateToLocal format does not match', dbDateString);
|
||||
return dbDateString;
|
||||
}
|
||||
checkMoment();
|
||||
dbDateString = $.trim(dbDateString.replace(/[^ 0-9:-]/g, ''));
|
||||
timezone = $.trim(timezone);
|
||||
var m = moment.tz(dbDateString, timezone).local();
|
||||
return m.format("YYYY-MM-DD HH:mm:ss");
|
||||
}
|
||||
|
||||
function checkMoment(){
|
||||
/*
|
||||
while(typeof moment === 'undefined' || moment.tz !== 'function'){
|
||||
console.log('checkMoment Waiting moment.tz to load');
|
||||
delay(1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
function addGetParam(_url, _key, _value) {
|
||||
if (typeof _url !== 'string') {
|
||||
return false;
|
||||
|
@ -2967,7 +3018,7 @@ function isValidURL(value) {
|
|||
if (/^(ws|wss):\/\//i.test(value)) {
|
||||
return true;
|
||||
}
|
||||
if (/^(https?|ftp):\/\/localhost/i.test(value)) {
|
||||
if (/^(https?|ftp):\/\//i.test(value)) {
|
||||
return true;
|
||||
}
|
||||
return /^(?:(?:(?:https?|ftp|ws|wss):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value);
|
||||
|
@ -3152,3 +3203,7 @@ function setCookie(cname, cvalue, exdays) {
|
|||
function getCookie(cname) {
|
||||
return Cookies.get(cname);
|
||||
}
|
||||
|
||||
function delay(time) {
|
||||
return new Promise(resolve => setTimeout(resolve, time));
|
||||
}
|
7
view/videoGetPoster.php
Normal file
7
view/videoGetPoster.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
require_once '../videos/configuration.php';
|
||||
|
||||
$poster = Video::getPoster($_REQUEST['videos_id']);
|
||||
|
||||
header("Location: {$poster}");
|
||||
exit;
|
Loading…
Add table
Add a link
Reference in a new issue