Skip to content

Commit

Permalink
Add the option for is a rebroadcast on livelinks
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Jan 18, 2025
1 parent bacce95 commit 4d35800
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 17 deletions.
4 changes: 3 additions & 1 deletion plugin/LiveLinks/LiveLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function getEmptyDataObject() {
$obj->doNotShowLiveLinksLabel = false;
$obj->disableProxy = false;
$obj->hideTopButton = true;
$obj->hideIsRebroadcastOption = true;
self::addDataObjectHelper('hideTopButton', 'Hide Top Button', 'This will hide the button on the top menu bar');
return $obj;
}
Expand All @@ -46,7 +47,7 @@ public function getUUID() {
}

public function getPluginVersion() {
return "4.2";
return "4.3";
}

public function canAddLinks() {
Expand Down Expand Up @@ -191,6 +192,7 @@ public function getLiveApplicationArray() {
$row['end_date'] = $value['end_date'];
$row['end_date_my_timezone'] = date('Y-m-d H:i:s', $value['end_php_time']);
$row['expires'] = strtotime($row['end_date_my_timezone']);
$row['isRebroadcast'] = !empty($value['isRebroadcast']);
$array[] = $row;

}
Expand Down
12 changes: 11 additions & 1 deletion plugin/LiveLinks/Objects/LiveLinksTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

class LiveLinksTable extends ObjectYPT {

protected $id, $title, $description, $link, $start_date, $end_date, $type, $status, $users_id, $categories_id, $timezone, $start_php_time, $end_php_time;
protected $id, $title, $description, $link, $start_date, $end_date, $type, $status, $users_id, $categories_id, $timezone, $start_php_time, $end_php_time;
protected $isRebroadcast;

static function getSearchFieldsNames() {
return array('title', 'description');
Expand Down Expand Up @@ -117,6 +118,14 @@ function setCategories_id($categories_id) {
$this->categories_id = intval($categories_id);
}

public function getIsRebroadcast() {
return !empty($this->isRebroadcast);
}

public function setIsRebroadcast($isRebroadcast): void {
$this->isRebroadcast = !_empty($isRebroadcast)?1:0;
}

public static function getAll($users_id = 0) {
global $global;
if (!static::isTableInstalled()) {
Expand All @@ -132,6 +141,7 @@ public static function getAll($users_id = 0) {
$sql .= self::getSqlFromPost();
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
//var_dump($sql, $fullData);
sqlDAL::close($res);
$rows = array();
if ($res != false) {
Expand Down
Binary file removed plugin/LiveLinks/Objects/livelinks.mwb
Binary file not shown.
1 change: 1 addition & 0 deletions plugin/LiveLinks/install/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CREATE TABLE IF NOT EXISTS `LiveLinks` (
`timezone` VARCHAR(255) NULL,
`start_php_time` BIGINT NULL,
`end_php_time` BIGINT NULL,
`isRebroadcast` TINYINT(1) NULL DEFAULT 0,
PRIMARY KEY (`id`),
INDEX `fk_LiveLinks_users_idx` (`users_id` ASC),
CONSTRAINT `fk_LiveLinks_users2`
Expand Down
1 change: 1 addition & 0 deletions plugin/LiveLinks/install/updateV4.3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `LiveLinks` ADD COLUMN `isRebroadcast` TINYINT(1) NULL DEFAULT 0;
1 change: 1 addition & 0 deletions plugin/LiveLinks/view/addLiveLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$o->setStatus($_POST['status']);
$o->setTitle($_POST['title']);
$o->setType($_POST['type']);
$o->setIsRebroadcast($_POST['isRebroadcast']);

if(User::isAdmin()){
if(!empty($_REQUEST['users_id'])){
Expand Down
53 changes: 38 additions & 15 deletions plugin/LiveLinks/view/panel.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<link rel="stylesheet" type="text/css" href="<?php echo getCDN(); ?>view/css/DataTables/datatables.min.css" />
<link href="<?php echo getCDN(); ?>js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
<?php
$obj = AVideoPlugin::getDataObject("LiveLinks");
?>
<link rel="stylesheet" type="text/css" href="<?php echo getURL('view/css/DataTables/datatables.min.css'); ?>" />
<link href="<?php echo getURL('js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css'); ?>" rel="stylesheet" type="text/css" />
<div class="panel panel-default">
<div class="panel-heading">
<i class="fas fa-link"></i> <?php echo __("Add an external Live Link"); ?>
Expand Down Expand Up @@ -49,21 +52,39 @@
<label for="inputLinkEnd"><?php echo __("End on"); ?>:</label>
<input type="text" id="inputLinkEnd" name="end_date" class="form-control datepickerLink input-sm" placeholder="<?php echo __("End on"); ?>" required>
</div>
<?php

if (!empty($obj->hideIsRebroadcastOption)) {
?>
<input id="isRebroadcast" name="isRebroadcast" type="hidden" value="0" />
<?php
} else {
?>
<div class="form-group col-sm-12" id="publiclyListed">
<i class="fas fa-retweet"></i> <?php echo __("Mark this stream as a Rebroadcast"); ?>
<div class="material-switch pull-right">
<input id="isRebroadcast" name="isRebroadcast" type="checkbox" value="1" <?php echo !empty($trasnmition['isRebroadcast']) ? "checked" : ""; ?> />
<label for="isRebroadcast" class="label-success"></label>
</div>
</div>
<?php
}
?>
<div class="form-group col-sm-12">
<label for="title"><?php echo __("Category"); ?>:</label>
<?php
echo Layout::getCategorySelect('categories_id');
?>
</div>
<?php
if(User::isAdmin()){
if (User::isAdmin()) {
?>
<div class="form-group col-sm-12">
<label for="title"><?php echo __("User"); ?>:</label>
<?php
$updateUserAutocomplete = Layout::getUserAutocomplete(User::getId(), 'users_id');
?>
</div>
<div class="form-group col-sm-12">
<label for="title"><?php echo __("User"); ?>:</label>
<?php
$updateUserAutocomplete = Layout::getUserAutocomplete(User::getId(), 'users_id');
?>
</div>
<?php
}
?>
Expand Down Expand Up @@ -207,6 +228,7 @@
$('#linkId').val('');
$('select[name="categories_id"]').val('');
$('select[name="categories_id"]').trigger('change');
$("#isRebroadcast").prop("checked", false);
var imageURL = webSiteRootURL + 'plugin/Live/view/OnAir.jpg';
<?php
echo $croppie1["restartCroppie"] . "(imageURL)";
Expand Down Expand Up @@ -264,10 +286,11 @@
$('select[name="categories_id"]').trigger('change');
$('#linkStatus').val(data.status);
$(".userGroups").prop("checked", false);
$("#isRebroadcast").prop("checked", !empty(data.isRebroadcast));
$('#users_id').val(data.users_id);
<?php
if(!empty($updateUserAutocomplete)){
echo $updateUserAutocomplete;
<?php
if (!empty($updateUserAutocomplete)) {
echo $updateUserAutocomplete;
}
?>
for (const index in data.user_groups) {
Expand Down Expand Up @@ -304,9 +327,9 @@ function submitLiveLinks(image) {
} else {
avideoToastSuccess(__("Your link has been saved!"));
$("#liveLinksForm").trigger("reset");
<?php
if(!empty($updateUserAutocomplete)){
echo $updateUserAutocomplete;
<?php
if (!empty($updateUserAutocomplete)) {
echo $updateUserAutocomplete;
}
?>
}
Expand Down

0 comments on commit 4d35800

Please sign in to comment.