1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
Daniel Neto 2023-06-27 10:51:07 -03:00
parent 4e075a8674
commit 37e14a8982
30 changed files with 1745 additions and 1293 deletions

File diff suppressed because it is too large Load diff

View file

@ -28,13 +28,19 @@ if (!PlayLists::canAddVideoOnPlaylist($_POST['videos_id'])) {
} }
$playList = new PlayList($_POST['playlists_id']); $playList = new PlayList($_POST['playlists_id']);
if (empty($playList) || User::getId() !== $playList->getUsers_id() || empty($_POST['videos_id'])) { if (empty($playList) || empty($_POST['videos_id'])) {
$obj->msg = __("Permission denied"); $obj->msg = __("Permission denied");
die(json_encode($obj)); die(json_encode($obj));
} }
if(!PlayLists::canManageAllPlaylists() && User::getId() !== $playList->getUsers_id() ){
$obj->msg = __("This is not your playlist");
die(json_encode($obj));
}
$obj->error = false; $obj->error = false;
$obj->status = $playList->addVideo($_POST['videos_id'], $_POST['add']); $obj->status = $playList->addVideo($_POST['videos_id'], $_POST['add']);
$obj->users_id = $playList->getUsers_id();
//log_error("videos id: ".$_POST['videos_id']." playlist_id: ".$_POST['playlists_id']); //log_error("videos id: ".$_POST['videos_id']." playlist_id: ".$_POST['playlists_id']);
die(json_encode($obj)); die(json_encode($obj));

View file

@ -724,8 +724,10 @@ class PlayList extends ObjectYPT {
return false; return false;
} }
$this->clearEmptyLists(); $this->clearEmptyLists();
if(empty($this->getUsers_id()) || !PlayLists::canManageAllPlaylists()){
$users_id = User::getId(); $users_id = User::getId();
$this->setUsers_id($users_id); $this->setUsers_id($users_id);
}
$this->showOnTV = intval($this->showOnTV); $this->showOnTV = intval($this->showOnTV);
$playlists_id = parent::save(); $playlists_id = parent::save();
if (!empty($playlists_id)) { if (!empty($playlists_id)) {

View file

@ -20,10 +20,15 @@ if (empty($_POST['name'])) {
} }
$obj = new PlayList(@$_POST['id']); $obj = new PlayList(@$_POST['id']);
if (PlayLists::canManageAllPlaylists()) {
if(!empty($_REQUEST['users_id'])){
$obj->setUsers_id($_REQUEST['users_id']);
}
}else{
if(!empty($obj->getUsers_id())){ if(!empty($obj->getUsers_id())){
forbidIfItIsNotMyUsersId($obj->getUsers_id()); forbidIfItIsNotMyUsersId($obj->getUsers_id());
} }
}
$obj->setName($_POST['name']); $obj->setName($_POST['name']);
$obj->setStatus($_POST['status']); $obj->setStatus($_POST['status']);
echo '{"status":"'.$obj->save().'"}'; echo '{"status":"'.$obj->save().'", "users_id":"'.$obj->getUsers_id().'"}';

View file

@ -29,27 +29,6 @@ class AVideoPlugin
} }
} }
public static function addRoutes()
{
global $global;
if (empty($global)) {
$global = [];
}
$plugins = Plugin::getAllEnabled();
foreach ($plugins as $value) {
if (in_array($value['dirName'], $global['skippPlugins'])) {
continue;
}
self::YPTstart();
$p = static::loadPlugin($value['dirName']);
if (is_object($p)) {
$p->addRoutes();
}
self::YPTend("{$value['dirName']}::" . __FUNCTION__);
}
return false;
}
public static function addView($videos_id, $total) public static function addView($videos_id, $total)
{ {
global $global; global $global;

View file

@ -2,8 +2,6 @@
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php'; require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
use Pecee\SimpleRouter\SimpleRouter; //required if we want to define routes on our plugin.
class OptionsTest extends PluginAbstract { class OptionsTest extends PluginAbstract {
public function getTags() { public function getTags() {
@ -51,15 +49,6 @@ class OptionsTest extends PluginAbstract {
public function getHeadCode() { public function getHeadCode() {
} }
public function addRoutes()
{
global $basePath;
SimpleRouter::get($basePath."OptionsTest/home", function() {
require_once "plugin/OptionsTest/home.php"; exit;
});
return false;
}
public function getCustomizeAdvancedOptions() public function getCustomizeAdvancedOptions()
{ {
$options["optionsTestVariable"]=false; $options["optionsTestVariable"]=false;

View file

@ -437,7 +437,8 @@ TimeLogEnd($timeName, __LINE__);
method: 'POST', method: 'POST',
data: { data: {
'status': "public", 'status': "public",
'name': inputValue 'name': inputValue,
'user': '<?php echo $users_id; ?>'
}, },
success: function(response) { success: function(response) {
if (response.status > 0) { if (response.status > 0) {

View file

@ -368,10 +368,6 @@ abstract class PluginAbstract {
return array(); return array();
} }
public function addRoutes() {
return false;
}
public function addView($videos_id, $total) { public function addView($videos_id, $total) {
return false; return false;
} }

View file

@ -0,0 +1,138 @@
<?php
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
class Email_to_user extends ObjectYPT {
protected $id, $sent_at, $timezone, $emails_messages_id, $users_id;
static function getSearchFieldsNames() {
return array('timezone');
}
static function getTableName() {
return 'email_to_user';
}
static function getAllEmails_messages() {
global $global;
$table = "emails_messages";
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
$sql .= self::getSqlFromPost();
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = array();
if ($res != false) {
foreach ($fullData as $row) {
$rows[] = $row;
}
} else {
/**
*
* @var array $global
* @var object $global['mysqli']
*/
_error_log($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
static function setSent($email_to_user_id){
global $global;
if(!is_array($email_to_user_id)){
$email_to_user_id = array($email_to_user_id);
}
$sql = "UPDATE email_to_user SET sent_at = NOW(), timezone = ? WHERE id IN (". implode(', ', $email_to_user_id).")";
return sqlDAL::writeSql($sql, 's', [date_default_timezone_get()]);
}
static function alreadyHasMessageSet($users_id, $emails_messages_id){
global $global;
$sql = "SELECT * FROM email_to_user WHERE sent_at is NULL AND users_id = ? AND emails_messages_id = ?";
$res = sqlDAL::readSql($sql, 'ii', [$users_id, $emails_messages_id], true);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
//var_dump($sql, [$users_id, $emails_messages_id], $fullData);
return !empty($fullData);
}
static function getAllToSend(){
global $global;
$sql = "SELECT * FROM email_to_user WHERE sent_at is NULL ";
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
return $fullData;
}
static function getAllEmailsToSend(){
global $global;
$emails = new stdClass();
$sql = "SELECT message, subject, GROUP_CONCAT(u.email) as emails, GROUP_CONCAT(etu.id) as ids
FROM email_to_user etu
LEFT JOIN users u ON users_id = u.id
LEFT JOIN emails_messages em ON emails_messages_id = em.id
WHERE sent_at IS NULL
GROUP BY emails_messages_id";
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
return $fullData;
}
function setId($id) {
$this->id = intval($id);
}
function setSent_at($sent_at) {
$this->sent_at = $sent_at;
}
function setTimezone($timezone) {
$this->timezone = $timezone;
}
function setEmails_messages_id($emails_messages_id) {
$this->emails_messages_id = intval($emails_messages_id);
}
function setUsers_id($users_id) {
$this->users_id = intval($users_id);
}
function getId() {
return intval($this->id);
}
function getSent_at() {
return $this->sent_at;
}
function getTimezone() {
return $this->timezone;
}
function getEmails_messages_id() {
return intval($this->emails_messages_id);
}
function getUsers_id() {
return intval($this->users_id);
}
public function save() {
if(self::alreadyHasMessageSet($this->users_id, $this->emails_messages_id)){
return false;
}
if(empty($this->sent_at)){
$this->sent_at = 'NULL';
}
return parent::save();
}
}

View file

@ -0,0 +1,58 @@
<?php
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
class Emails_messages extends ObjectYPT {
protected $id,$message,$subject;
static function getSearchFieldsNames() {
return array('message','subject');
}
static function getTableName() {
return 'emails_messages';
}
function setId($id) {
$this->id = intval($id);
}
function setMessage($message) {
$this->message = $message;
}
function setSubject($subject) {
$this->subject = $subject;
}
function getId() {
return intval($this->id);
}
function getMessage() {
return $this->message;
}
function getSubject() {
return $this->subject;
}
static function setOrCreate($message, $subject): Emails_messages {
global $global;
$sql = "SELECT id FROM emails_messages WHERE message = ? ";
$res = sqlDAL::readSql($sql, 's', [$message], true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if(empty($data)){
$obj = new Emails_messages(0);
$obj->setMessage($message);
$obj->setSubject($subject);
}else{
$obj = new Emails_messages($data['id']);
}
return $obj;
}
}

View file

@ -5,6 +5,8 @@ require_once $global['systemRootPath'] . 'objects/ICS.php';
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php'; require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Scheduler_commands.php'; require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Scheduler_commands.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Emails_messages.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Email_to_user.php';
class Scheduler extends PluginAbstract class Scheduler extends PluginAbstract
{ {
@ -43,7 +45,7 @@ class Scheduler extends PluginAbstract
public function getPluginVersion() public function getPluginVersion()
{ {
return "4.3"; return "4.4";
} }
public function updateScript() public function updateScript()
@ -84,6 +86,13 @@ class Scheduler extends PluginAbstract
sqlDal::writeSqlTry(trim($value)); sqlDal::writeSqlTry(trim($value));
} }
} }
if (AVideoPlugin::compareVersion($this->getName(), "4.4") < 0) {
$sqls = file_get_contents($global['systemRootPath'] . 'plugin/Scheduler/install/updateV4.4.sql');
$sqlParts = explode(";", $sqls);
foreach ($sqlParts as $value) {
sqlDal::writeSqlTry(trim($value));
}
}
return true; return true;
} }
@ -94,6 +103,7 @@ class Scheduler extends PluginAbstract
$obj->watchDogSocket = true; $obj->watchDogSocket = true;
$obj->watchDogLiveServer = true; $obj->watchDogLiveServer = true;
$obj->watchDogLiveServerSSL = true; $obj->watchDogLiveServerSSL = true;
$obj->sendEmails = true;
/* /*
$obj->textSample = "text"; $obj->textSample = "text";
$obj->checkboxSample = true; $obj->checkboxSample = true;
@ -112,6 +122,27 @@ class Scheduler extends PluginAbstract
return $obj; return $obj;
} }
static function sendEmails(){
$obj = AVideoPlugin::getDataObjectIfEnabled('Scheduler');
if($obj->sendEmails){
$messages = Email_to_user::getAllEmailsToSend();
echo 'Scheduler::sendEmails found '.count($messages).PHP_EOL;
foreach ($messages as $value) {
$to = explode(',', $value['emails']);
// Make sure the emails in $to are unique
$to = array_unique($to);
$subject = $value['subject'];
$message = $value['message'];
echo "Scheduler::sendEmails [{$subject}] found emails ".count($to).PHP_EOL;
//var_dump($to);
sendSiteEmailAsync($to, $subject, $message);
$ids = explode(',', $value['ids']);
Email_to_user::setSent($ids);
}
}
}
public function getPluginMenu() public function getPluginMenu()
{ {
global $global; global $global;

View file

@ -0,0 +1,27 @@
<?php
header('Content-Type: application/json');
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Email_to_user.php';
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
$plugin = AVideoPlugin::loadPluginIfEnabled('Scheduler');
if(!User::isAdmin()){
$obj->msg = "You cant do this";
die(json_encode($obj));
}
$o = new Email_to_user(@$_POST['id']);
$o->setSent_at($_POST['sent_at']);
$o->setTimezone($_POST['timezone']);
$o->setEmails_messages_id($_POST['emails_messages_id']);
$o->setUsers_id($_POST['users_id']);
if($id = $o->save()){
$obj->error = false;
}
echo json_encode($obj);

View file

@ -0,0 +1,20 @@
<?php
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Email_to_user.php';
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
$plugin = AVideoPlugin::loadPluginIfEnabled('Scheduler');
if(!User::isAdmin()){
$obj->msg = "You cant do this";
die(json_encode($obj));
}
$id = intval($_POST['id']);
$row = new Email_to_user($id);
$obj->error = !$row->delete();
die(json_encode($obj));
?>

View 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 getLanguage(); ?>">
<head>
<title><?php echo $config->getWebSiteTitle(); ?> :: Scheduler</title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
include $global['systemRootPath'] . 'plugin/Scheduler/View/{$classname}/index_head.php';
?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
include $global['systemRootPath'] . 'plugin/Scheduler/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>

View file

@ -0,0 +1,228 @@
<?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-4">
<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="panelEmail_to_userForm">
<div class="row">
<input type="hidden" name="id" id="Email_to_userid" value="">
<div class="form-group col-sm-12">
<label for="Email_to_usersent_at"><?php echo __("Sent At"); ?>:</label>
<input type="text" id="Email_to_usersent_at" name="sent_at" class="form-control input-sm" placeholder="<?php echo __("Sent At"); ?>" autocomplete="off">
</div>
<div class="form-group col-sm-12">
<label for="Email_to_usertimezone"><?php echo __("Timezone"); ?>:</label>
<input type="text" id="Email_to_usertimezone" name="timezone" class="form-control input-sm" placeholder="<?php echo __("Timezone"); ?>">
</div>
<div class="form-group col-sm-12">
<label for="Email_to_useremails_messages_id"><?php echo __("Emails Messages Id"); ?>:</label>
<select class="form-control input-sm" name="emails_messages_id" id="Email_to_useremails_messages_id">
<?php
$options = Email_to_user::getAllEmails_messages();
foreach ($options as $value) {
echo '<option value="' . $value['id'] . '">' . $value['id'] . '</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-12">
<label for="Email_to_userusers_id"><?php echo __("Users Id"); ?>:</label>
<select class="form-control input-sm" name="users_id" id="Email_to_userusers_id">
<?php
$options = User::getAllUsers();
foreach ($options as $value) {
echo '<option value="' . $value['id'] . '">' . $value['id'] . '</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-12">
<div class="btn-group pull-right">
<span class="btn btn-success" id="newEmail_to_userLink" onclick="clearEmail_to_userForm()"><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-8">
<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="Email_to_userTable" class="display table table-bordered table-responsive table-striped table-hover table-condensed" width="100%" cellspacing="0">
<thead>
<tr>
<th>#</th>
<th><?php echo __("Sent At"); ?></th>
<th><?php echo __("Timezone"); ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>#</th>
<th><?php echo __("Sent At"); ?></th>
<th><?php echo __("Timezone"); ?></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="Email_to_userbtnModelLinks" style="display: none;">
<div class="btn-group pull-right">
<button href="" class="edit_Email_to_user btn btn-default btn-xs">
<i class="fa fa-edit"></i>
</button>
<button href="" class="delete_Email_to_user btn btn-danger btn-xs">
<i class="fa fa-trash"></i>
</button>
</div>
</div>
<script type="text/javascript">
function clearEmail_to_userForm() {
$('#Email_to_userid').val('');
$('#Email_to_usersent_at').val('');
$('#Email_to_usertimezone').val('');
$('#Email_to_useremails_messages_id').val('');
$('#Email_to_userusers_id').val('');
}
$(document).ready(function() {
$('#addEmail_to_userBtn').click(function() {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Scheduler/View/addEmail_to_userVideo.php',
data: $('#panelEmail_to_userForm').serialize(),
type: 'post',
success: function(response) {
if (response.error) {
avideoAlertError(response.msg);
} else {
avideoToast("<?php echo __("Your register has been saved!"); ?>");
$("#panelEmail_to_userForm").trigger("reset");
}
clearEmail_to_userForm();
tableVideos.ajax.reload();
modal.hidePleaseWait();
}
});
});
var Email_to_usertableVar = $('#Email_to_userTable').DataTable({
serverSide: true,
"ajax": "<?php echo $global['webSiteRootURL']; ?>plugin/Scheduler/View/Email_to_user/list.json.php",
"columns": [{
"data": "id"
},
{
"data": "sent_at"
},
{
"data": "timezone"
},
{
sortable: false,
data: null,
defaultContent: $('#Email_to_userbtnModelLinks').html()
}
],
select: true,
});
$('#newEmail_to_user').on('click', function(e) {
e.preventDefault();
$('#panelEmail_to_userForm').trigger("reset");
$('#Email_to_userid').val('');
});
$('#panelEmail_to_userForm').on('submit', function(e) {
e.preventDefault();
modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Scheduler/View/Email_to_user/add.json.php',
data: $('#panelEmail_to_userForm').serialize(),
type: 'post',
success: function(response) {
if (response.error) {
avideoAlertError(response.msg);
} else {
avideoToast("<?php echo __("Your register has been saved!"); ?>");
$("#panelEmail_to_userForm").trigger("reset");
}
Email_to_usertableVar.ajax.reload();
$('#Email_to_userid').val('');
modal.hidePleaseWait();
}
});
});
$('#Email_to_userTable').on('click', 'button.delete_Email_to_user', function(e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Email_to_usertableVar.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/Scheduler/View/Email_to_user/delete.json.php",
data: data
}).done(function(resposta) {
if (resposta.error) {
avideoAlertError(resposta.msg);
}
Email_to_usertableVar.ajax.reload();
modal.hidePleaseWait();
});
} else {
}
});
});
$('#Email_to_userTable').on('click', 'button.edit_Email_to_user', function(e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Email_to_usertableVar.row(tr).data();
$('#Email_to_userid').val(data.id);
$('#Email_to_usersent_at').val(data.sent_at);
$('#Email_to_usertimezone').val(data.timezone);
$('#Email_to_useremails_messages_id').val(data.emails_messages_id);
$('#Email_to_userusers_id').val(data.users_id);
});
});
</script>
<script>
$(document).ready(function() {
$('#Email_to_usersent_at').datetimepicker({
format: 'yyyy-mm-dd hh:ii',
autoclose: true
});
});
</script>

View file

@ -0,0 +1,5 @@
<?php
$plugin = AVideoPlugin::loadPluginIfEnabled('Scheduler');
?>
<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"/>

View file

@ -0,0 +1,10 @@
<?php
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Email_to_user.php';
header('Content-Type: application/json');
$rows = Email_to_user::getAll();
$total = Email_to_user::getTotal();
?>
{"data": <?php echo json_encode($rows); ?>, "draw": <?php echo intval(@$_REQUEST['draw']); ?>, "recordsTotal":<?php echo $total; ?>, "recordsFiltered":<?php echo $total; ?>}

View file

@ -0,0 +1,25 @@
<?php
header('Content-Type: application/json');
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Emails_messages.php';
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
$plugin = AVideoPlugin::loadPluginIfEnabled('Scheduler');
if(!User::isAdmin()){
$obj->msg = "You cant do this";
die(json_encode($obj));
}
$o = new Emails_messages(@$_POST['id']);
$o->setMessage($_POST['message']);
$o->setSubject($_POST['subject']);
if($id = $o->save()){
$obj->error = false;
}
echo json_encode($obj);

View file

@ -0,0 +1,20 @@
<?php
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Emails_messages.php';
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
$plugin = AVideoPlugin::loadPluginIfEnabled('Scheduler');
if(!User::isAdmin()){
$obj->msg = "You cant do this";
die(json_encode($obj));
}
$id = intval($_POST['id']);
$row = new Emails_messages($id);
$obj->error = !$row->delete();
die(json_encode($obj));
?>

View 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 getLanguage(); ?>">
<head>
<title><?php echo $config->getWebSiteTitle(); ?> :: Scheduler</title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
include $global['systemRootPath'] . 'plugin/Scheduler/View/{$classname}/index_head.php';
?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
include $global['systemRootPath'] . 'plugin/Scheduler/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>

View file

@ -0,0 +1,194 @@
<?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-4">
<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="panelEmails_messagesForm">
<div class="row">
<input type="hidden" name="id" id="Emails_messagesid" value="">
<div class="form-group col-sm-12">
<label for="Emails_messagesmessage"><?php echo __("Message"); ?>:</label>
<textarea id="Emails_messagesmessage" name="message" class="form-control input-sm" placeholder="<?php echo __("Message"); ?>" required="true"></textarea>
</div>
<div class="form-group col-sm-12">
<label for="Emails_messagessubject"><?php echo __("Subject"); ?>:</label>
<input type="text" id="Emails_messagessubject" name="subject" class="form-control input-sm" placeholder="<?php echo __("Subject"); ?>" required="true">
</div>
<div class="form-group col-sm-12">
<div class="btn-group pull-right">
<span class="btn btn-success" id="newEmails_messagesLink" onclick="clearEmails_messagesForm()"><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-8">
<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="Emails_messagesTable" class="display table table-bordered table-responsive table-striped table-hover table-condensed" width="100%" cellspacing="0">
<thead>
<tr>
<th>#</th>
<th><?php echo __("Message"); ?></th>
<th><?php echo __("Subject"); ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>#</th>
<th><?php echo __("Message"); ?></th>
<th><?php echo __("Subject"); ?></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="Emails_messagesbtnModelLinks" style="display: none;">
<div class="btn-group pull-right">
<button href="" class="edit_Emails_messages btn btn-default btn-xs">
<i class="fa fa-edit"></i>
</button>
<button href="" class="delete_Emails_messages btn btn-danger btn-xs">
<i class="fa fa-trash"></i>
</button>
</div>
</div>
<script type="text/javascript">
function clearEmails_messagesForm() {
$('#Emails_messagesid').val('');
$('#Emails_messagesmessage').val('');
$('#Emails_messagessubject').val('');
}
$(document).ready(function() {
$('#addEmails_messagesBtn').click(function() {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Scheduler/View/addEmails_messagesVideo.php',
data: $('#panelEmails_messagesForm').serialize(),
type: 'post',
success: function(response) {
if (response.error) {
avideoAlertError(response.msg);
} else {
avideoToast("<?php echo __("Your register has been saved!"); ?>");
$("#panelEmails_messagesForm").trigger("reset");
}
clearEmails_messagesForm();
tableVideos.ajax.reload();
modal.hidePleaseWait();
}
});
});
var Emails_messagestableVar = $('#Emails_messagesTable').DataTable({
serverSide: true,
"ajax": "<?php echo $global['webSiteRootURL']; ?>plugin/Scheduler/View/Emails_messages/list.json.php",
"columns": [{
"data": "id"
},
{
"data": "message"
},
{
"data": "subject"
},
{
sortable: false,
data: null,
defaultContent: $('#Emails_messagesbtnModelLinks').html()
}
],
select: true,
});
$('#newEmails_messages').on('click', function(e) {
e.preventDefault();
$('#panelEmails_messagesForm').trigger("reset");
$('#Emails_messagesid').val('');
});
$('#panelEmails_messagesForm').on('submit', function(e) {
e.preventDefault();
modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Scheduler/View/Emails_messages/add.json.php',
data: $('#panelEmails_messagesForm').serialize(),
type: 'post',
success: function(response) {
if (response.error) {
avideoAlertError(response.msg);
} else {
avideoToast("<?php echo __("Your register has been saved!"); ?>");
$("#panelEmails_messagesForm").trigger("reset");
}
Emails_messagestableVar.ajax.reload();
$('#Emails_messagesid').val('');
modal.hidePleaseWait();
}
});
});
$('#Emails_messagesTable').on('click', 'button.delete_Emails_messages', function(e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Emails_messagestableVar.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/Scheduler/View/Emails_messages/delete.json.php",
data: data
}).done(function(resposta) {
if (resposta.error) {
avideoAlertError(resposta.msg);
}
Emails_messagestableVar.ajax.reload();
modal.hidePleaseWait();
});
} else {
}
});
});
$('#Emails_messagesTable').on('click', 'button.edit_Emails_messages', function(e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Emails_messagestableVar.row(tr).data();
$('#Emails_messagesid').val(data.id);
$('#Emails_messagesmessage').val(data.message);
$('#Emails_messagessubject').val(data.subject);
});
});
</script>

View file

@ -0,0 +1,5 @@
<?php
$plugin = AVideoPlugin::loadPluginIfEnabled('Scheduler');
?>
<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"/>

View file

@ -0,0 +1,10 @@
<?php
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/Scheduler/Objects/Emails_messages.php';
header('Content-Type: application/json');
$rows = Emails_messages::getAll();
$total = Emails_messages::getTotal();
?>
{"data": <?php echo json_encode($rows); ?>, "draw": <?php echo intval(@$_REQUEST['draw']); ?>, "recordsTotal":<?php echo $total; ?>, "recordsFiltered":<?php echo $total; ?>}

View file

@ -186,18 +186,39 @@ if (!User::isAdmin()) {
var Scheduler_commandstableVar = $('#Scheduler_commandsTable').DataTable({ var Scheduler_commandstableVar = $('#Scheduler_commandsTable').DataTable({
serverSide: true, serverSide: true,
"ajax": "<?php echo $global['webSiteRootURL']; ?>plugin/Scheduler/View/Scheduler_commands/list.json.php", "ajax": "<?php echo $global['webSiteRootURL']; ?>plugin/Scheduler/View/Scheduler_commands/list.json.php",
"columns": [ "columns": [{
{"data": "id"}, "data": "id"
{"data": "parameters"}, },
{"data": "date_to_execute"}, {
{"data": "executed_in"}, "data": "parameters"
{"data": "status"}, },
{"data": "repeat_minute"}, {
{"data": "repeat_hour"}, "data": "date_to_execute"
{"data": "repeat_day_of_month"}, },
{"data": "repeat_month"}, {
{"data": "repeat_day_of_week"}, "data": "executed_in"
{"data": "type"}, },
{
"data": "status"
},
{
"data": "repeat_minute"
},
{
"data": "repeat_hour"
},
{
"data": "repeat_day_of_month"
},
{
"data": "repeat_month"
},
{
"data": "repeat_day_of_week"
},
{
"data": "type"
},
{ {
sortable: false, sortable: false,
data: null, data: null,
@ -283,9 +304,19 @@ if (!User::isAdmin()) {
}); });
}); });
</script> </script>
<script> $(document).ready(function () { <script>
$('#Scheduler_commandsdate_to_execute').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose: true}); $(document).ready(function() {
});</script> $('#Scheduler_commandsdate_to_execute').datetimepicker({
<script> $(document).ready(function () { format: 'yyyy-mm-dd hh:ii',
$('#Scheduler_commandsexecuted_in').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose: true}); autoclose: true
});</script> });
});
</script>
<script>
$(document).ready(function() {
$('#Scheduler_commandsexecuted_in').datetimepicker({
format: 'yyyy-mm-dd hh:ii',
autoclose: true
});
});
</script>

View file

@ -26,6 +26,8 @@ AVideoPlugin::loadPlugin("Scheduler");
<div class="panel-body"> <div class="panel-body">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Scheduler_commands"><?php echo __("Scheduler Commands"); ?></a></li> <li class="active"><a data-toggle="tab" href="#Scheduler_commands"><?php echo __("Scheduler Commands"); ?></a></li>
<li class=""><a data-toggle="tab" href="#Emails_messages"><?php echo __("Emails Messages"); ?></a></li>
<li class=""><a data-toggle="tab" href="#Email_to_user"><?php echo __("Email To User"); ?></a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div id="Scheduler_commands" class="tab-pane fade in active" style="padding: 10px;"> <div id="Scheduler_commands" class="tab-pane fade in active" style="padding: 10px;">
@ -33,6 +35,16 @@ AVideoPlugin::loadPlugin("Scheduler");
include $global['systemRootPath'] . 'plugin/Scheduler/View/Scheduler_commands/index_body.php'; include $global['systemRootPath'] . 'plugin/Scheduler/View/Scheduler_commands/index_body.php';
?> ?>
</div> </div>
<div id="Emails_messages" class="tab-pane fade " style="padding: 10px;">
<?php
include $global['systemRootPath'] . 'plugin/Scheduler/View/Emails_messages/index_body.php';
?>
</div>
<div id="Email_to_user" class="tab-pane fade " style="padding: 10px;">
<?php
include $global['systemRootPath'] . 'plugin/Scheduler/View/Email_to_user/index_body.php';
?>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -25,3 +25,36 @@ CREATE TABLE IF NOT EXISTS `scheduler_commands` (
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE) ON UPDATE CASCADE)
ENGINE = InnoDB; ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `emails_messages` (
`id` INT NOT NULL AUTO_INCREMENT,
`message` TEXT NOT NULL,
`subject` VARCHAR(255) NOT NULL,
`created` DATETIME NULL,
`modified` DATETIME NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `unique_msg` (`message` ASC))
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `email_to_user` (
`id` INT NOT NULL AUTO_INCREMENT,
`sent_at` DATETIME NULL,
`timezone` VARCHAR(255) NULL,
`created` DATETIME NULL,
`modified` DATETIME NULL,
`emails_messages_id` INT NOT NULL,
`users_id` INT(11) NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_email_to_user_emails_messages1_idx` (`emails_messages_id` ASC),
INDEX `fk_email_to_user_users1_idx` (`users_id` ASC),
CONSTRAINT `fk_email_to_user_emails_messages1`
FOREIGN KEY (`emails_messages_id`)
REFERENCES `emails_messages` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_email_to_user_users1`
FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

View file

@ -0,0 +1,32 @@
CREATE TABLE IF NOT EXISTS `emails_messages` (
`id` INT NOT NULL AUTO_INCREMENT,
`message` TEXT NOT NULL,
`subject` VARCHAR(255) NOT NULL,
`created` DATETIME NULL,
`modified` DATETIME NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `unique_msg` (`message` ASC))
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `email_to_user` (
`id` INT NOT NULL AUTO_INCREMENT,
`sent_at` DATETIME NULL,
`timezone` VARCHAR(255) NULL,
`created` DATETIME NULL,
`modified` DATETIME NULL,
`emails_messages_id` INT NOT NULL,
`users_id` INT(11) NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_email_to_user_emails_messages1_idx` (`emails_messages_id` ASC),
INDEX `fk_email_to_user_users1_idx` (`users_id` ASC),
CONSTRAINT `fk_email_to_user_emails_messages1`
FOREIGN KEY (`emails_messages_id`)
REFERENCES `emails_messages` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_email_to_user_users1`
FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

View file

@ -53,3 +53,5 @@ function _log($msg){
} }
include $global['systemRootPath'] . 'plugin/Scheduler/watchDog.php'; include $global['systemRootPath'] . 'plugin/Scheduler/watchDog.php';
Scheduler::sendEmails();

View file

@ -5,9 +5,6 @@ require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php'; require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/Menu.php';
require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php'; require_once $global['systemRootPath'] . 'plugin/TopMenu/Objects/MenuItem.php';
use Pecee\SimpleRouter\SimpleRouter; //required if we want to define routes on our plugin.
class TopMenu extends PluginAbstract { class TopMenu extends PluginAbstract {
const PERMISSION_CAN_EDIT = 0; const PERMISSION_CAN_EDIT = 0;
@ -56,16 +53,6 @@ class TopMenu extends PluginAbstract {
return true; return true;
} }
public function addRoutes()
{
global $basePath;
SimpleRouter::get($basePath."/menu/{menuSeoUrlItem}", function($menuSeoUrlItem) {
$_GET['menuSeoUrlItem']=$menuSeoUrlItem;
require_once "plugin/TopMenu/seo.php";
},['defaultParameterRegex' => '.*']);
return false;
}
public function getHeadCode() { public function getHeadCode() {
global $global; global $global;
$css = '<link href="' .getURL('plugin/TopMenu/style.css') . '" rel="stylesheet" type="text/css"/>'; $css = '<link href="' .getURL('plugin/TopMenu/style.css') . '" rel="stylesheet" type="text/css"/>';

View file

@ -45,6 +45,7 @@ time.duration {
border-radius: 5px; border-radius: 5px;
opacity: 0.8; opacity: 0.8;
text-shadow: 1px 1px 4px #000; text-shadow: 1px 1px 4px #000;
z-index: 10;
} }
.thumbsImageContainer { .thumbsImageContainer {