requirePermission();
global $rServers;
$rCategories = getCategories('live');
$rTranscodeProfiles = getTranscodeProfiles();
if (!isset(CoreUtilities::$rRequest['id'])) {
$rChannel = null;
} else {
$rChannel = getStream(CoreUtilities::$rRequest['id']);
if (!$rChannel || $rChannel['type'] != 3) {
goHome();
}
}
$rOnDemand = [];
$rServerTree = [
[
'id' => 'source',
'parent' => '#',
'text' => "Online",
'icon' => 'mdi mdi-play',
'state' => ['opened' => true]
],
[
'id' => 'offline',
'parent' => '#',
'text' => "Offline",
'icon' => 'mdi mdi-stop',
'state' => ['opened' => true]
]
];
if (isset($rChannel)) {
$rProperties = json_decode($rChannel['movie_properties'], true);
if (!$rProperties) {
$rProperties = ['type' => $rChannel['series_no'] > 0 ? 0 : 1];
}
$rChannelSys = getStreamSys(CoreUtilities::$rRequest['id']);
foreach ($rServers as $rServer) {
if (isset($rChannelSys[intval($rServer['id'])])) {
$rParent = $rChannelSys[intval($rServer['id'])]['parent_id'] != 0
? intval($rChannelSys[intval($rServer['id'])]['parent_id'])
: (!$rChannelSys[intval($rServer['id'])]['on_demand'] ? 'source' : null);
} else {
$rParent = 'offline';
}
if ($rParent !== null) {
$rServerTree[] = [
'id' => $rServer['id'],
'parent' => $rParent,
'text' => $rServer['server_name'],
'icon' => 'mdi mdi-server-network',
'state' => ['opened' => true]
];
}
}
} else {
foreach ($rServers as $rServer) {
$rServerTree[] = [
'id' => $rServer['id'],
'parent' => 'offline',
'text' => $rServer['server_name'],
'icon' => 'mdi mdi-server-network',
'state' => ['opened' => true]
];
}
}
$this->setTitle('Created Channel');
$this->render('created_channel', compact(
'rCategories', 'rTranscodeProfiles', 'rChannel', 'rOnDemand',
'rServerTree', 'rProperties', 'rChannelSys'
));
}
}