Skip to content

Commit

Permalink
You can now select a next video
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Nov 22, 2017
1 parent ba67112 commit 901c68f
Show file tree
Hide file tree
Showing 15 changed files with 17,720 additions and 766 deletions.
2 changes: 1 addition & 1 deletion install/checkConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$installationVersion = "4.3";
$installationVersion = "4.4";

header('Content-Type: application/json');

Expand Down
23 changes: 19 additions & 4 deletions objects/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Video {
private $zoom;
private $videoDownloadedLink;
private $videoLink;
private $next_videos_id;
static $types = array('webm', 'mp4', 'mp3', 'ogg');
private $videoGroups;
private $videoAdsCount;
Expand Down Expand Up @@ -111,12 +112,12 @@ function save($updateVideoGroups = false) {
}
$sql = "UPDATE videos SET title = '{$this->title}',clean_title = '{$this->clean_title}',"
. " filename = '{$this->filename}', categories_id = '{$this->categories_id}', status = '{$this->status}',"
. " description = '{$this->description}', duration = '{$this->duration}', type = '{$this->type}', videoDownloadedLink = '{$this->videoDownloadedLink}', youtubeId = '{$this->youtubeId}', videoLink = '{$this->videoLink}', modified = now()"
. " description = '{$this->description}', duration = '{$this->duration}', type = '{$this->type}', videoDownloadedLink = '{$this->videoDownloadedLink}', youtubeId = '{$this->youtubeId}', videoLink = '{$this->videoLink}', next_videos_id = {$this->next_videos_id}, modified = now()"
. " WHERE id = {$this->id}";
} else {
$sql = "INSERT INTO videos "
. "(title,clean_title, filename, users_id, categories_id, status, description, duration,type,videoDownloadedLink, created, modified, videoLink) values "
. "('{$this->title}','{$this->clean_title}', '{$this->filename}', {$_SESSION["user"]["id"]},{$this->categories_id}, '{$this->status}', '{$this->description}', '{$this->duration}', '{$this->type}', '{$this->videoDownloadedLink}', now(), now(), '{$this->videoLink}')";
. "(title,clean_title, filename, users_id, categories_id, status, description, duration,type,videoDownloadedLink, created, next_videos_id, modified, videoLink) values "
. "('{$this->title}','{$this->clean_title}', '{$this->filename}', {$_SESSION["user"]["id"]},{$this->categories_id}, '{$this->status}', '{$this->description}', '{$this->duration}', '{$this->type}', '{$this->videoDownloadedLink}', {$this->next_videos_id},now(), now(), '{$this->videoLink}')";
}
$insert_row = $global['mysqli']->query($sql);

Expand Down Expand Up @@ -251,7 +252,12 @@ static function getVideo($id = "", $status = "viewable", $ignoreGroup = false, $
return false;
}

$sql = "SELECT u.*, v.*, c.name as category,c.iconClass, c.clean_name as clean_category, v.created as videoCreation, "
$sql = "SELECT u.*, v.*, "
. " nv.title as next_title,"
. " nv.clean_title as next_clean_title,"
. " nv.filename as next_filename,"
. " nv.id as next_id,"
. " c.name as category,c.iconClass, c.clean_name as clean_category, v.created as videoCreation, "
. " (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes, "
. " (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = -1 ) as dislikes, "
. " (SELECT count(id) FROM video_ads as va where va.videos_id = v.id) as videoAdsCount ";
Expand All @@ -263,6 +269,7 @@ static function getVideo($id = "", $status = "viewable", $ignoreGroup = false, $
$sql .= " FROM videos as v "
. "LEFT JOIN categories c ON categories_id = c.id "
. "LEFT JOIN users u ON v.users_id = u.id "
. "LEFT JOIN videos nv ON v.next_videos_id = nv.id "
. " WHERE 1=1 ";
$sql .= static::getVideoQueryFileter();
if (!$ignoreGroup) {
Expand Down Expand Up @@ -1012,6 +1019,14 @@ function setFilename($filename) {
$this->filename = $filename;
}

function getNext_videos_id() {
return $this->next_videos_id;
}

function setNext_videos_id($next_videos_id) {
$this->next_videos_id = $next_videos_id;
}

function queue($format) {
global $global;
$obj = new stdClass();
Expand Down
1 change: 1 addition & 0 deletions objects/videoAddNew.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
$obj->setType('embed');
$obj->setStatus('a');
}
$obj->setNext_videos_id($_POST['next_videos_id']);
$obj->setDescription($_POST['description']);
$obj->setCategories_id($_POST['categories_id']);
$obj->setVideoGroups(empty($_POST['videoGroups'])?array():$_POST['videoGroups']);
Expand Down
5 changes: 4 additions & 1 deletion objects/videos.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
$name = empty($value['name'])?$value['user']:$value['name'];
//$categories[$key]['comment'] = " <div class=\"commenterName\"><strong>{$name}</strong><div class=\"date sub-text\">{$value['created']}</div></div><div class=\"commentText\">". nl2br($value['comment'])."</div>";
$videos[$key]['creator'] = '<div class="pull-left"><img src="'.User::getPhoto($value['users_id']).'" alt="" class="img img-responsive img-circle" style="max-width: 50px;"/></div><div class="commentDetails"><div class="commenterName"><strong>'.$name.'</strong> <small>'.humanTiming(strtotime($value['videoCreation'])).'</small></div></div>';

$videos[$key]['next_video'] = array();
if(!empty($videos[$key]['next_videos_id'])){
$videos[$key]['next_video'] = Video::getVideo($videos[$key]['next_videos_id']);
}
}

echo '{ "current": '.$_POST['current'].',"rowCount": '.$_POST['rowCount'].', "total": '.$total.', "rows":'. json_encode($videos).'}';
25 changes: 25 additions & 0 deletions update/updateDb.v4.4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- MySQL Workbench Synchronization
-- Generated: 2017-10-05 11:15
-- Model: New Model
-- Version: 1.0
-- Project: Name of the project
-- Author: Daniel

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';


ALTER TABLE `videos`
ADD COLUMN `next_videos_id` INT(11) NOT NULL AFTER `videoLink`,
ADD INDEX `fk_videos_videos1_idx` (`next_videos_id` ASC);

ALTER TABLE `playlists_has_videos`
ADD COLUMN `order` INT(11) NULL DEFAULT NULL AFTER `videos_id`;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;


UPDATE configurations SET version = '4.4', modified = now() WHERE id = 1;
Loading

0 comments on commit 901c68f

Please sign in to comment.