1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-06 03:50:04 +02:00
Oinktube/plugin/UserNotifications/View/User_notifications/delete.json.php
DanieL 2f2fdc4923 Add a notification central plugin UserNotification
this will be responsible to handle all the top bar bell button
2022-08-18 10:25:19 -03:00

37 lines
No EOL
1 KiB
PHP

<?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));
?>