Completed
Push — master ( 39e171...7a90d2 )
by Seth
02:58
created

control-panel.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
require_once 'common.inc.php';
4
5
use smtech\CanvasHack\CanvasHack;
6
use smtech\CanvasHack\CanvasHack_Exception;
7
use Battis\BootstrapSmarty\NotificationMessage;
8
9
if (isset($_REQUEST['hack'])) {
10
    while (list($id, $setting) = each($_REQUEST['hack'])) {
11
        try {
12
            $hack = CanvasHack::getCanvasHackById($toolbox->getMySQL(), $id);
13
            if ($setting === 'enable') {
14
                $hack->enable();
15
            } else {
16
                $hack->disable();
17
            }
18
        } catch (CanvasHack_Exception $e) {
19
            $smarty->addMessage('Exception ' . $e->getCode(), $e->getMessage(), NotificationMessage::ERROR);
0 ignored issues
show
Deprecated Code introduced by
The constant Battis\BootstrapSmarty\NotificationMessage::ERROR has been deprecated with message: Use `DANGER` instead for consistency with Bootstrap

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
20
        }
21
    }
22
}
23
24
$hacksContents = scandir(realpath(__DIR__ . '/hacks'), SCANDIR_SORT_ASCENDING);
25
$hacks = array();
26
foreach ($hacksContents as $item) {
27
    if (is_dir($path = realpath(__DIR__ . "/hacks/$item")) && file_exists($manifest = "$path/manifest.xml")) {
28
        try {
29
            $hacks[$item] = new CanvasHack($toolbox->getMySQL(), $path);
30
        } catch (CanvasHack_Exception $e) {
31
            $smarty->addMessage(
32
                'CanvasHack Manifest Error [' . $e->getCode() . ']',
33
                $e->getMessage(),
34
                NotificationMessage::ERROR
0 ignored issues
show
Deprecated Code introduced by
The constant Battis\BootstrapSmarty\NotificationMessage::ERROR has been deprecated with message: Use `DANGER` instead for consistency with Bootstrap

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
35
            );
36
        }
37
    }
38
}
39
40
$smarty->assign([
41
    'appURL' => $toolbox->config('APP_URL'),
42
    'hacks' => $hacks,
43
    'name' => 'CanvasHack',
44
    'category' => 'Control Panel'
45
]);
46
$smarty->display('control-panel.tpl');
47