|
30 | 30 |
|
31 | 31 | require_once('../../lib/config.inc.php'); |
32 | 32 | require_once('../../lib/app.inc.php'); |
33 | | -require_once('classes/class.guicontroller.php'); |
| 33 | +$app->load('aps_guicontroller'); |
34 | 34 |
|
35 | 35 | // Check the module permissions |
36 | | -$app->auth->check_module_permissions('aps'); |
| 36 | +$app->auth->check_module_permissions('sites'); |
37 | 37 |
|
38 | 38 | $gui = new ApsGUIController($app); |
39 | 39 |
|
40 | 40 | // An action and ID are required in any case |
41 | | -if(!isset($_GET['action'])) die; |
| 41 | +if(!isset($_GET['action'])) die('No action'); |
42 | 42 |
|
43 | 43 | // List of operations which can be performed |
44 | 44 | if($_GET['action'] == 'change_status') |
45 | 45 | { |
46 | 46 | // Only admins can perform this operation |
47 | | - if($_SESSION['s']['user']['typ'] != 'admin') die; |
| 47 | + if($_SESSION['s']['user']['typ'] != 'admin') die('For admin use only.'); |
48 | 48 |
|
49 | 49 | // Make sure a valid package ID is given |
50 | 50 | if(!$gui->isValidPackageID($_GET['id'], true)) die($app->lng('Invalid ID')); |
51 | 51 |
|
52 | 52 | // Change the existing status to the opposite |
53 | | - $get_status = $app->db->queryOneRecord("SELECT PackageStatus FROM aps_packages WHERE ID = '".intval($_GET['id'])."';"); |
54 | | - if($get_status['PackageStatus'] == strval(PACKAGE_LOCKED)) |
| 53 | + $get_status = $app->db->queryOneRecord("SELECT package_status FROM aps_packages WHERE id = '".intval($_GET['id'])."';"); |
| 54 | + if($get_status['package_status'] == strval(PACKAGE_LOCKED)) |
55 | 55 | { |
56 | | - $app->db->query("UPDATE aps_packages SET PackageStatus = ".PACKAGE_ENABLED." WHERE ID = '".intval($_GET['id'])."';"); |
| 56 | + $app->db->query("UPDATE aps_packages SET package_status = ".PACKAGE_ENABLED." WHERE id = '".intval($_GET['id'])."';"); |
57 | 57 | echo '<div class="swap" id="ir-Yes"><span>'.$app->lng('Yes').'</span></div>'; |
58 | 58 | } |
59 | 59 | else |
60 | 60 | { |
61 | | - $app->db->query("UPDATE aps_packages SET PackageStatus = ".PACKAGE_LOCKED." WHERE ID = '".intval($_GET['id'])."';"); |
| 61 | + $app->db->query("UPDATE aps_packages SET Package_status = ".PACKAGE_LOCKED." WHERE id = '".intval($_GET['id'])."';"); |
62 | 62 | echo '<div class="swap" id="ir-No"><span>'.$app->lng('No').'</span></div>'; |
63 | 63 | } |
64 | 64 | } |
|
76 | 76 | if(!$gui->isValidInstanceID($_GET['id'], $client_id, $is_admin)) die($app->lng('Invalid ID')); |
77 | 77 |
|
78 | 78 | // Only delete the instance if the status is "installed" or "flawed" |
79 | | - $check = $app->db->queryOneRecord("SELECT ID FROM aps_instances |
80 | | - WHERE ID = ".$app->db->quote($_GET['id'])." AND |
81 | | - (InstanceStatus = ".INSTANCE_SUCCESS." OR InstanceStatus = ".INSTANCE_ERROR.");"); |
| 79 | + $check = $app->db->queryOneRecord("SELECT id FROM aps_instances |
| 80 | + WHERE id = ".$app->db->quote($_GET['id'])." AND |
| 81 | + (instance_status = ".INSTANCE_SUCCESS." OR instance_status = ".INSTANCE_ERROR.");"); |
82 | 82 | if(!empty($check)) $gui->deleteInstance($_GET['id']); |
83 | 83 |
|
84 | 84 | echo $app->lng('Installation_remove'); |
|
96 | 96 | // Assume that the given instance belongs to the currently calling client_id. Unimportant if status is admin |
97 | 97 | if(!$gui->isValidInstanceID($_GET['id'], $client_id, $is_admin)) die($app->lng('Invalid ID')); |
98 | 98 |
|
99 | | - // We've an InstanceID, so make sure the package is no enabled and InstanceStatus is still "installed" |
100 | | - $check = $app->db->queryOneRecord("SELECT aps_instances.ID FROM aps_instances, aps_packages |
101 | | - WHERE aps_instances.PackageID = aps_packages.ID |
102 | | - AND aps_instances.InstanceStatus = ".INSTANCE_SUCCESS." |
103 | | - AND aps_packages.PackageStatus = ".PACKAGE_ENABLED." |
104 | | - AND aps_instances.ID = ".$app->db->quote($_GET['id']).";"); |
105 | | - if(!$check) die; // normally this might not happen at all, so just die |
| 99 | + // We've an InstanceID, so make sure the package is not enabled and InstanceStatus is still "installed" |
| 100 | + $check = $app->db->queryOneRecord("SELECT aps_instances.id FROM aps_instances, aps_packages |
| 101 | + WHERE aps_instances.package_id = aps_packages.id |
| 102 | + AND aps_instances.instance_status = ".INSTANCE_SUCCESS." |
| 103 | + AND aps_packages.package_status = ".PACKAGE_ENABLED." |
| 104 | + AND aps_instances.id = ".$app->db->quote($_GET['id']).";"); |
| 105 | + if(!$check) die('Check failed'); // normally this might not happen at all, so just die |
106 | 106 |
|
107 | 107 | $gui->reinstallInstance($_GET['id']); |
108 | 108 | echo $app->lng('Installation_task'); |
|
0 commit comments