mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 18:29:39 +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
|
#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/([0-9]+)/?$ view/?v=$1 [QSA]
|
||||||
RewriteRule ^video/([^!#$&'()*,\/:;=?@[\]]+)/?$ view/?videoName=$1 [QSA]
|
RewriteRule ^video/([^!#$&'()*,\/:;=?@[\]]+)/?$ view/?videoName=$1 [QSA]
|
||||||
RewriteRule ^video/([^!#$&'()*,\/:;=?@[\]]+)/page/([0-9]+)/??$ view/?videoName=$1&page=$2 [QSA]
|
RewriteRule ^video/([^!#$&'()*,\/:;=?@[\]]+)/page/([0-9]+)/??$ view/?videoName=$1&page=$2 [QSA]
|
||||||
|
|
|
@ -400,7 +400,7 @@ abstract class ObjectYPT implements ObjectInterface
|
||||||
return false;
|
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');
|
$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 );
|
return in_array(static::getTableName(),$ignoreArray );
|
||||||
|
|
|
@ -590,7 +590,7 @@ function sendSiteEmail($to, $subject, $message, $fromEmail = '', $fromName = '')
|
||||||
$advancedCustom = AVideoPlugin::loadPlugin("CustomizeAdvanced");
|
$advancedCustom = AVideoPlugin::loadPlugin("CustomizeAdvanced");
|
||||||
}
|
}
|
||||||
|
|
||||||
_error_log('sendSiteEmail: subject= '.$subject);
|
_error_log('sendSiteEmail: subject= ' . $subject);
|
||||||
$subject = UTF8encode($subject);
|
$subject = UTF8encode($subject);
|
||||||
$message = UTF8encode($message);
|
$message = UTF8encode($message);
|
||||||
$message = createEmailMessageFromTemplate($message);
|
$message = createEmailMessageFromTemplate($message);
|
||||||
|
@ -614,7 +614,7 @@ function sendSiteEmail($to, $subject, $message, $fromEmail = '', $fromName = '')
|
||||||
$webSiteTitle = $config->getWebSiteTitle();
|
$webSiteTitle = $config->getWebSiteTitle();
|
||||||
try {
|
try {
|
||||||
if (!is_array($to)) {
|
if (!is_array($to)) {
|
||||||
_error_log('sendSiteEmail: send single email '.$to);
|
_error_log('sendSiteEmail: send single email ' . $to);
|
||||||
$mail = new \PHPMailer\PHPMailer\PHPMailer();
|
$mail = new \PHPMailer\PHPMailer\PHPMailer();
|
||||||
setSiteSendMessage($mail);
|
setSiteSendMessage($mail);
|
||||||
$mail->setFrom($fromEmail, $fromName);
|
$mail->setFrom($fromEmail, $fromName);
|
||||||
|
@ -2424,7 +2424,7 @@ function getTagIfExists($relativePath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageTagIfExists($relativePath, $title = '', $id = '', $style = '', $class = 'img img-responsive', $lazyLoad = false, $preloadImage=false) {
|
function getImageTagIfExists($relativePath, $title = '', $id = '', $style = '', $class = 'img img-responsive', $lazyLoad = false, $preloadImage = false) {
|
||||||
global $global;
|
global $global;
|
||||||
$relativePathOriginal = $relativePath;
|
$relativePathOriginal = $relativePath;
|
||||||
$relativePath = getRelativePath($relativePath);
|
$relativePath = getRelativePath($relativePath);
|
||||||
|
@ -2464,8 +2464,8 @@ function getImageTagIfExists($relativePath, $title = '', $id = '', $style = '',
|
||||||
$img .= " src=\"{$url}\" ";
|
$img .= " src=\"{$url}\" ";
|
||||||
}
|
}
|
||||||
$img .= "/>";
|
$img .= "/>";
|
||||||
if($preloadImage){
|
if ($preloadImage) {
|
||||||
$img = "<link rel=\"prefetch\" href=\"{$url}\" />".$img;
|
$img = "<link rel=\"prefetch\" href=\"{$url}\" />" . $img;
|
||||||
}
|
}
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
|
@ -2486,7 +2486,7 @@ function createWebPIfNotExists($path) {
|
||||||
return $nextGenPath;
|
return $nextGenPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVideoImagewithHoverAnimation($relativePath, $relativePathHoverAnimation = '', $title = '', $preloadImage=false) {
|
function getVideoImagewithHoverAnimation($relativePath, $relativePathHoverAnimation = '', $title = '', $preloadImage = false) {
|
||||||
$id = uniqid();
|
$id = uniqid();
|
||||||
//getImageTagIfExists($relativePath, $title = '', $id = '', $style = '', $class = 'img img-responsive', $lazyLoad = false, $preloadImage=false)
|
//getImageTagIfExists($relativePath, $title = '', $id = '', $style = '', $class = 'img img-responsive', $lazyLoad = false, $preloadImage=false)
|
||||||
$img = getImageTagIfExists($relativePath, $title, "thumbsJPG{$id}", '', 'thumbsJPG img img-responsive', false, true) . PHP_EOL;
|
$img = getImageTagIfExists($relativePath, $title, "thumbsJPG{$id}", '', 'thumbsJPG img img-responsive', false, true) . PHP_EOL;
|
||||||
|
@ -2715,24 +2715,24 @@ function thereIsAnyRemoteUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function UTF8encode($data) {
|
function UTF8encode($data) {
|
||||||
if(emptyHTML($data)){
|
if (emptyHTML($data)) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
global $advancedCustom, $global;
|
global $advancedCustom, $global;
|
||||||
|
|
||||||
if (!empty($advancedCustom->utf8Encode)) {
|
if (!empty($advancedCustom->utf8Encode)) {
|
||||||
$newData = utf8_encode($data);
|
$newData = utf8_encode($data);
|
||||||
if(!empty($newData)){
|
if (!empty($newData)) {
|
||||||
return $newData;
|
return $newData;
|
||||||
}else{
|
} else {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($advancedCustom->utf8Decode)) {
|
if (!empty($advancedCustom->utf8Decode)) {
|
||||||
$newData = utf8_decode($data);
|
$newData = utf8_decode($data);
|
||||||
if(!empty($newData)){
|
if (!empty($newData)) {
|
||||||
return $newData;
|
return $newData;
|
||||||
}else{
|
} else {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8492,9 +8492,9 @@ function convertFromDefaultTimezoneTimeToMyTimezone($date) {
|
||||||
return convertDateFromToTimezone($date, getDefaultTimezone(), date_default_timezone_get());
|
return convertDateFromToTimezone($date, getDefaultTimezone(), date_default_timezone_get());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultTimezone(){
|
function getDefaultTimezone() {
|
||||||
global $advancedCustom, $_getDefaultTimezone;
|
global $advancedCustom, $_getDefaultTimezone;
|
||||||
if(!empty($_getDefaultTimezone)){
|
if (!empty($_getDefaultTimezone)) {
|
||||||
return $_getDefaultTimezone;
|
return $_getDefaultTimezone;
|
||||||
}
|
}
|
||||||
if (empty($advancedCustom)) {
|
if (empty($advancedCustom)) {
|
||||||
|
@ -9275,7 +9275,13 @@ function getMP3ANDMP4DownloadLinksFromHLS($videos_id, $video_type) {
|
||||||
return $downloadOptions;
|
return $downloadOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isOnDeveloperMode(){
|
function isOnDeveloperMode() {
|
||||||
global $global;
|
global $global;
|
||||||
return (!empty($global['developer_mode']) || (!empty($global['developer_mode_admin_only']) && User::isAdmin()));
|
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) {
|
if ($like==1) {
|
||||||
Video::updateLikesDislikes($videos_id, 'likes', '+1');
|
Video::updateLikesDislikes($videos_id, 'likes', '+1');
|
||||||
|
AVideoPlugin::onVideoLikeDislike($videos_id,$this->users_id, true);
|
||||||
} elseif ($like==-1) {
|
} elseif ($like==-1) {
|
||||||
Video::updateLikesDislikes($videos_id, 'dislikes', '+1');
|
Video::updateLikesDislikes($videos_id, 'dislikes', '+1');
|
||||||
|
AVideoPlugin::onVideoLikeDislike($videos_id,$this->users_id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//exit;
|
//exit;
|
||||||
|
|
|
@ -72,9 +72,18 @@ class Subscribe extends ObjectYPT{
|
||||||
if (!empty($this->id)) {
|
if (!empty($this->id)) {
|
||||||
$sql = "UPDATE subscribes SET status = '{$this->status}', notify = '{$this->notify}',ip = '" . getRealIpAddr() . "', modified = now() WHERE id = {$this->id}";
|
$sql = "UPDATE subscribes SET status = '{$this->status}', notify = '{$this->notify}',ip = '" . getRealIpAddr() . "', modified = now() WHERE id = {$this->id}";
|
||||||
} else {
|
} 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)
|
public static function getSubscribe($id)
|
||||||
|
|
|
@ -688,6 +688,36 @@ class AVideoPlugin
|
||||||
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
|
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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){
|
public static function onNewVideo($videos_id){
|
||||||
if(empty($videos_id)){
|
if(empty($videos_id)){
|
||||||
|
@ -812,6 +842,18 @@ class AVideoPlugin
|
||||||
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
|
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
public static function getVideoManagerButton()
|
||||||
{
|
{
|
||||||
|
@ -2326,6 +2368,7 @@ class AVideoPlugin
|
||||||
'PlayerSkins', // PlayerSkins
|
'PlayerSkins', // PlayerSkins
|
||||||
'Permissions', // Permissions
|
'Permissions', // Permissions
|
||||||
'Scheduler', // Permissions
|
'Scheduler', // Permissions
|
||||||
|
'UserNotifications',
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
|
@ -2335,6 +2378,7 @@ class AVideoPlugin
|
||||||
'e9a568e6-ef61-4dcc-aad0-0109e9be8e36', // PlayerSkins
|
'e9a568e6-ef61-4dcc-aad0-0109e9be8e36', // PlayerSkins
|
||||||
'Permissions-5ee8405eaaa16', // Permissions
|
'Permissions-5ee8405eaaa16', // Permissions
|
||||||
'Scheduler-5ee8405eaaa16', // Permissions
|
'Scheduler-5ee8405eaaa16', // Permissions
|
||||||
|
'UserNotifications-5ee8405eaaa16', // Permissions
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
echo '<!-- '.basename(__FILE__).' -->';
|
||||||
include $global['systemRootPath'] . 'plugin/Gallery/view/modeGalleryCategoryLive.php';
|
include $global['systemRootPath'] . 'plugin/Gallery/view/modeGalleryCategoryLive.php';
|
||||||
$ob = _ob_get_clean();
|
$ob = _ob_get_clean();
|
||||||
_ob_start();
|
_ob_start();
|
||||||
|
|
|
@ -39,6 +39,7 @@ $_REQUEST['rowCount'] = $obj->CategoriesRowCount;
|
||||||
$_GET['catName'] = $_cat['clean_name'];
|
$_GET['catName'] = $_cat['clean_name'];
|
||||||
if (!empty($liveobj) && empty($liveobj->doNotShowLiveOnCategoryList)) {
|
if (!empty($liveobj) && empty($liveobj->doNotShowLiveOnCategoryList)) {
|
||||||
$currentCat = $_cat;
|
$currentCat = $_cat;
|
||||||
|
echo '<!-- '.basename(__FILE__).' -->';
|
||||||
include $global['systemRootPath'] . 'plugin/Gallery/view/modeGalleryCategoryLive.php';
|
include $global['systemRootPath'] . 'plugin/Gallery/view/modeGalleryCategoryLive.php';
|
||||||
}
|
}
|
||||||
unset($_POST['sort']);
|
unset($_POST['sort']);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/Live/Objects/LiveTransmition.php';
|
require_once $global['systemRootPath'] . 'plugin/Live/Objects/LiveTransmition.php';
|
||||||
|
@ -23,9 +22,9 @@ class Live extends PluginAbstract {
|
||||||
public static $posterType_regular = 0;
|
public static $posterType_regular = 0;
|
||||||
public static $posterType_preroll = 1;
|
public static $posterType_preroll = 1;
|
||||||
public static $posterType_postroll = 2;
|
public static $posterType_postroll = 2;
|
||||||
|
|
||||||
const PERMISSION_CAN_RESTREAM= 0;
|
const PERMISSION_CAN_RESTREAM = 0;
|
||||||
const CAN_RESTREAM_All_USERS= 0;
|
const CAN_RESTREAM_All_USERS = 0;
|
||||||
const CAN_RESTREAM_ONLY_SELECTED_USERGROUPS = 1;
|
const CAN_RESTREAM_ONLY_SELECTED_USERGROUPS = 1;
|
||||||
|
|
||||||
public function getTags() {
|
public function getTags() {
|
||||||
|
@ -487,14 +486,13 @@ class Live extends PluginAbstract {
|
||||||
self::addDataObjectHelper('controlServer', 'Control Server');
|
self::addDataObjectHelper('controlServer', 'Control Server');
|
||||||
$obj->disableRestream = false;
|
$obj->disableRestream = false;
|
||||||
self::addDataObjectHelper('disableRestream', 'Disable Restream', 'If you check this, we will not send requests to your Restreamer URL');
|
self::addDataObjectHelper('disableRestream', 'Disable Restream', 'If you check this, we will not send requests to your Restreamer URL');
|
||||||
|
|
||||||
$o = new stdClass();
|
$o = new stdClass();
|
||||||
$o->type = array(self::CAN_RESTREAM_All_USERS=>('All Users'), self::CAN_RESTREAM_ONLY_SELECTED_USERGROUPS=>('Selected user groups'));
|
$o->type = array(self::CAN_RESTREAM_All_USERS => ('All Users'), self::CAN_RESTREAM_ONLY_SELECTED_USERGROUPS => ('Selected user groups'));
|
||||||
$o->value = self::CAN_RESTREAM_All_USERS;
|
$o->value = self::CAN_RESTREAM_All_USERS;
|
||||||
$obj->whoCanRestream = $o;
|
$obj->whoCanRestream = $o;
|
||||||
self::addDataObjectHelper('whoCanRestream', 'Who can Restream');
|
self::addDataObjectHelper('whoCanRestream', 'Who can Restream');
|
||||||
|
|
||||||
|
|
||||||
$obj->disableDVR = false;
|
$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');
|
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;
|
$obj->disableGifThumbs = false;
|
||||||
|
@ -2901,13 +2899,13 @@ Click <a href=\"{link}\">here</a> to join our live.";
|
||||||
return self::sendRestream($obj);
|
return self::sendRestream($obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function restream($liveTransmitionHistory_id, $live_restreams_id=0, $test=false) {
|
public static function restream($liveTransmitionHistory_id, $live_restreams_id = 0, $test = false) {
|
||||||
if(empty($test)){
|
if (empty($test)) {
|
||||||
outputAndContinueInBackground();
|
outputAndContinueInBackground();
|
||||||
}
|
}
|
||||||
$obj = self::getRestreamObject($liveTransmitionHistory_id);
|
$obj = self::getRestreamObject($liveTransmitionHistory_id);
|
||||||
$obj->live_restreams_id = $live_restreams_id;
|
$obj->live_restreams_id = $live_restreams_id;
|
||||||
if($test){
|
if ($test) {
|
||||||
$obj->test = 1;
|
$obj->test = 1;
|
||||||
}
|
}
|
||||||
return self::sendRestream($obj);
|
return self::sendRestream($obj);
|
||||||
|
@ -2921,14 +2919,14 @@ Click <a href=\"{link}\">here</a> to join our live.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
set_time_limit(30);
|
set_time_limit(30);
|
||||||
|
|
||||||
$obj->responseToken = encryptString(array('users_id'=>$obj->users_id,'time'=>time(), 'liveTransmitionHistory_id'=>$obj->liveTransmitionHistory_id));
|
$obj->responseToken = encryptString(array('users_id' => $obj->users_id, 'time' => time(), 'liveTransmitionHistory_id' => $obj->liveTransmitionHistory_id));
|
||||||
|
|
||||||
$data_string = json_encode($obj);
|
$data_string = json_encode($obj);
|
||||||
_error_log("Live:sendRestream ({$obj->restreamerURL}) {$data_string} " . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5)));
|
_error_log("Live:sendRestream ({$obj->restreamerURL}) {$data_string} " . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5)));
|
||||||
//open connection
|
//open connection
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
|
||||||
//set the url, number of POST vars, POST data
|
//set the url, number of POST vars, POST data
|
||||||
curl_setopt($ch, CURLOPT_URL, $obj->restreamerURL);
|
curl_setopt($ch, CURLOPT_URL, $obj->restreamerURL);
|
||||||
|
@ -2941,8 +2939,8 @@ Click <a href=\"{link}\">here</a> to join our live.";
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
||||||
curl_setopt(
|
curl_setopt(
|
||||||
$ch,
|
$ch,
|
||||||
|
@ -3597,7 +3595,7 @@ Click <a href=\"{link}\">here</a> to join our live.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getProcess($key) {
|
private static function getProcess($key) {
|
||||||
if(empty($key)){
|
if (empty($key)) {
|
||||||
error_log("Live:getProcess key is empty");
|
error_log("Live:getProcess key is empty");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3629,40 +3627,60 @@ Click <a href=\"{link}\">here</a> to join our live.";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPermissionsOptions() {
|
||||||
function getPermissionsOptions(){
|
|
||||||
$permissions = array();
|
$permissions = array();
|
||||||
$permissions[] = new PluginPermissionOption(self::PERMISSION_CAN_RESTREAM, __("Can Restream"), __("Can restream live videos"), 'Live');
|
$permissions[] = new PluginPermissionOption(self::PERMISSION_CAN_RESTREAM, __("Can Restream"), __("Can restream live videos"), 'Live');
|
||||||
return $permissions;
|
return $permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canRestream(){
|
static function canRestream() {
|
||||||
if (!empty($_REQUEST['token'])) {
|
if (!empty($_REQUEST['token'])) {
|
||||||
$live_restreams_id = intval(decryptString($_REQUEST['token']));
|
$live_restreams_id = intval(decryptString($_REQUEST['token']));
|
||||||
if(!empty($live_restreams_id)){
|
if (!empty($live_restreams_id)) {
|
||||||
_error_log('Live::canRestream: canRestream by pass '.$live_restreams_id);
|
_error_log('Live::canRestream: canRestream by pass ' . $live_restreams_id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$canStream = User::canStream();
|
$canStream = User::canStream();
|
||||||
if(empty($canStream)){
|
if (empty($canStream)) {
|
||||||
_error_log('Live::canRestream: user cannot restream');
|
_error_log('Live::canRestream: user cannot restream');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$obj = AVideoPlugin::getDataObject('Live');
|
$obj = AVideoPlugin::getDataObject('Live');
|
||||||
if(!empty($obj->disableRestream)){
|
if (!empty($obj->disableRestream)) {
|
||||||
_error_log('Live::canRestream: disableRestream is active');
|
_error_log('Live::canRestream: disableRestream is active');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($obj->whoCanRestream->value === self::CAN_RESTREAM_All_USERS){
|
if ($obj->whoCanRestream->value === self::CAN_RESTREAM_All_USERS) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$permission = Permissions::hasPermission(self::PERMISSION_CAN_RESTREAM,'Live');
|
$permission = Permissions::hasPermission(self::PERMISSION_CAN_RESTREAM, 'Live');
|
||||||
_error_log('Live::canRestream: permission is '. json_encode($permission));
|
_error_log('Live::canRestream: permission is ' . json_encode($permission));
|
||||||
return $permission;
|
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 {
|
class LiveImageType {
|
||||||
|
|
|
@ -57,75 +57,6 @@ if (User::canStream()) {
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</style>
|
</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>
|
<script>
|
||||||
async function refreshGetLiveImage(selector) {
|
async function refreshGetLiveImage(selector) {
|
||||||
|
@ -360,6 +291,8 @@ if (isVideo()) {
|
||||||
$('#liveVideos .extraVideos').prepend(html);
|
$('#liveVideos .extraVideos').prepend(html);
|
||||||
$('#liveVideos').slideDown();
|
$('#liveVideos').slideDown();
|
||||||
}
|
}
|
||||||
|
processUserNotificationFromApplication(application);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
lazyImage();
|
lazyImage();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -384,6 +317,20 @@ if (!empty($obj->playLiveInFullScreenOnIframe)) {
|
||||||
$('.views_on_total_on_live_' + application.users.transmition_key + '_' + application.users.live_servers_id).text(application.users.views);
|
$('.views_on_total_on_live_' + application.users.transmition_key + '_' + application.users.live_servers_id).text(application.users.views);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function socketLiveONCallback(json) {
|
||||||
//console.log('socketLiveONCallback processLiveStats', json);
|
//console.log('socketLiveONCallback processLiveStats', json);
|
||||||
|
|
|
@ -322,6 +322,9 @@ class PlayerSkins extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$videos_id = getVideos_id();
|
$videos_id = getVideos_id();
|
||||||
|
|
||||||
|
$event = "updateMediaSessionMetadata();";
|
||||||
|
PlayerSkins::getStartPlayerJS($event);
|
||||||
if (!empty($videos_id) && Video::getEPG($videos_id)) {
|
if (!empty($videos_id) && Video::getEPG($videos_id)) {
|
||||||
PlayerSkins::getStartPlayerJS(file_get_contents("{$global['systemRootPath']}plugin/PlayerSkins/epgButton.js"));
|
PlayerSkins::getStartPlayerJS(file_get_contents("{$global['systemRootPath']}plugin/PlayerSkins/epgButton.js"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,17 +73,28 @@ if (empty($MediaMetadata)) {
|
||||||
key = 0;
|
key = 0;
|
||||||
live_servers_id = 0;
|
live_servers_id = 0;
|
||||||
live_schedule_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();
|
index = player.playlist.currentIndex();
|
||||||
if(!empty(playerPlaylist[index])){
|
if (!empty(playerPlaylist[index])) {
|
||||||
videos_id = playerPlaylist[index].videos_id;
|
videos_id = playerPlaylist[index].videos_id;
|
||||||
|
console.log('updateMediaSessionMetadata playerPlaylist[index].videos_id', videos_id);
|
||||||
}
|
}
|
||||||
} else if (mediaId) {
|
} else if (mediaId) {
|
||||||
videos_id = mediaId;
|
videos_id = mediaId;
|
||||||
|
console.log('updateMediaSessionMetadata mediaId', mediaId);
|
||||||
} else if (isLive) {
|
} else if (isLive) {
|
||||||
key = isLive.key;
|
key = isLive.key;
|
||||||
live_servers_id = isLive.live_servers_id;
|
live_servers_id = isLive.live_servers_id;
|
||||||
live_schedule_id = isLive.live_schedule_id;
|
live_schedule_id = isLive.live_schedule_id;
|
||||||
|
console.log('updateMediaSessionMetadata isLive', key);
|
||||||
}
|
}
|
||||||
if (videos_id) {
|
if (videos_id) {
|
||||||
console.log('updateMediaSessionMetadata', videos_id);
|
console.log('updateMediaSessionMetadata', videos_id);
|
||||||
|
@ -97,6 +108,7 @@ if (empty($MediaMetadata)) {
|
||||||
'live_schedule_id': live_schedule_id,
|
'live_schedule_id': live_schedule_id,
|
||||||
},
|
},
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
|
console.log('updateMediaSessionMetadata response', response);
|
||||||
navigator.mediaSession.metadata = new MediaMetadata(response);
|
navigator.mediaSession.metadata = new MediaMetadata(response);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -235,6 +235,14 @@ abstract class PluginAbstract {
|
||||||
return false;
|
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) {
|
public function afterDonation($from_users_id, $how_much, $videos_id, $users_id, $extraParameters) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -298,6 +306,10 @@ abstract class PluginAbstract {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserNotificationButton() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public function getVideoManagerButton() {
|
public function getVideoManagerButton() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TopMenu extends PluginAbstract {
|
||||||
|
|
||||||
public function getHeadCode() {
|
public function getHeadCode() {
|
||||||
global $global;
|
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;
|
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.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/jquery-lazy/jquery.lazy.plugins.min.js'); ?>" type="text/javascript"></script>
|
||||||
<script src="<?php echo getURL('node_modules/moment/min/moment.min.js'); ?>"></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('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>
|
<script src="<?php echo getURL('node_modules/jquery-ui-dist/jquery-ui.min.js'); ?>" type="text/javascript"></script>
|
||||||
<?php
|
<?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) {
|
function countTo(selector, total) {
|
||||||
var text = $(selector).text();
|
var text = $(selector).text();
|
||||||
if (isNaN(text)) {
|
if (isNaN(text)) {
|
||||||
|
@ -1715,6 +1731,31 @@ function countTo(selector, total) {
|
||||||
}, timeout);
|
}, 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') {
|
if (typeof showPleaseWaitTimeOut == 'undefined') {
|
||||||
var showPleaseWaitTimeOut = 0;
|
var showPleaseWaitTimeOut = 0;
|
||||||
}
|
}
|
||||||
|
@ -1938,7 +1979,7 @@ function convertDBDateToLocal(dbDateString) {
|
||||||
//console.log('convertDBDateToLocal format does not match', dbDateString);
|
//console.log('convertDBDateToLocal format does not match', dbDateString);
|
||||||
return dbDateString;
|
return dbDateString;
|
||||||
}
|
}
|
||||||
|
checkMoment();
|
||||||
dbDateString = $.trim(dbDateString.replace(/[^ 0-9:-]/g, ''));
|
dbDateString = $.trim(dbDateString.replace(/[^ 0-9:-]/g, ''));
|
||||||
var m;
|
var m;
|
||||||
if (!_serverDBTimezone) {
|
if (!_serverDBTimezone) {
|
||||||
|
@ -1961,12 +2002,22 @@ function convertDateFromTimezoneToLocal(dbDateString, timezone) {
|
||||||
//console.log('convertDBDateToLocal format does not match', dbDateString);
|
//console.log('convertDBDateToLocal format does not match', dbDateString);
|
||||||
return dbDateString;
|
return dbDateString;
|
||||||
}
|
}
|
||||||
|
checkMoment();
|
||||||
dbDateString = $.trim(dbDateString.replace(/[^ 0-9:-]/g, ''));
|
dbDateString = $.trim(dbDateString.replace(/[^ 0-9:-]/g, ''));
|
||||||
timezone = $.trim(timezone);
|
timezone = $.trim(timezone);
|
||||||
var m = moment.tz(dbDateString, timezone).local();
|
var m = moment.tz(dbDateString, timezone).local();
|
||||||
return m.format("YYYY-MM-DD HH:mm:ss");
|
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) {
|
function addGetParam(_url, _key, _value) {
|
||||||
if (typeof _url !== 'string') {
|
if (typeof _url !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2967,7 +3018,7 @@ function isValidURL(value) {
|
||||||
if (/^(ws|wss):\/\//i.test(value)) {
|
if (/^(ws|wss):\/\//i.test(value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (/^(https?|ftp):\/\/localhost/i.test(value)) {
|
if (/^(https?|ftp):\/\//i.test(value)) {
|
||||||
return true;
|
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);
|
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) {
|
function getCookie(cname) {
|
||||||
return Cookies.get(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