forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pluginSwitch.json.php
44 lines (35 loc) · 1.24 KB
/
pluginSwitch.json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
header('Content-Type: application/json');
global $global, $config;
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/plugin.php';
if (!User::isAdmin()) {
die('{"error":"'.__("Permission denied").'"}');
}
if(empty($_POST['name'])){
die('{"error":"'.__("Name can't be blank").'"}');
}
if(empty($_POST['uuid'])){
die('{"error":"'.__("UUID can't be blank").'"}');
}
$obj = new Plugin(0);
$obj->loadFromUUID($_POST['uuid']);
$obj->setName($_POST['name']);
$obj->setDirName($_POST['dir']);
if(empty($_POST['enable']) || $_POST['enable']==="false"){
$_POST['status'] = "inactive";
}else{
$_POST['status'] = "active";
}
$obj->setStatus($_POST['status']);
if(empty($obj->pluginversion)||is_null($obj->pluginversion)){
require_once $global['systemRootPath'] . 'plugin/AVideoPlugin.php';
$p=AVideoPlugin::loadPlugin($_POST['dir']);
$currentVersion=$p->getPluginVersion();
$obj->setPluginversion($currentVersion);
Plugin::setCurrentVersionByUuid($_POST['uuid'], $currentVersion);
}
echo '{"status":"'.$obj->save().'"}';