@@ -7,38 +7,38 @@ |
||
| 7 | 7 | use Battis\BootstrapSmarty\NotificationMessage; |
| 8 | 8 | |
| 9 | 9 | if (isset($_REQUEST['hack'])) { |
| 10 | - while (list($id, $setting) = each($_REQUEST['hack'])) { |
|
| 11 | - try { |
|
| 12 | - $hack = CanvasHack::getCanvasHackById($sql, $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); |
|
| 20 | - } |
|
| 21 | - } |
|
| 10 | + while (list($id, $setting) = each($_REQUEST['hack'])) { |
|
| 11 | + try { |
|
| 12 | + $hack = CanvasHack::getCanvasHackById($sql, $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); |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $hacksContents = scandir(realpath(__DIR__ . '/hacks'), SCANDIR_SORT_ASCENDING); |
| 25 | 25 | $hacks = array(); |
| 26 | 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($sql, $path); |
|
| 30 | - } catch (CanvasHack_Exception $e) { |
|
| 31 | - $smarty->addMessage( |
|
| 32 | - 'CanvasHack Manifest Error ['. $e->getCode() . ']', |
|
| 33 | - $e->getMessage(), |
|
| 34 | - NotificationMessage::ERROR |
|
| 35 | - ); |
|
| 36 | - } |
|
| 37 | - } |
|
| 27 | + if (is_dir($path = realpath(__DIR__ . "/hacks/$item")) && file_exists($manifest = "$path/manifest.xml")) { |
|
| 28 | + try { |
|
| 29 | + $hacks[$item] = new CanvasHack($sql, $path); |
|
| 30 | + } catch (CanvasHack_Exception $e) { |
|
| 31 | + $smarty->addMessage( |
|
| 32 | + 'CanvasHack Manifest Error ['. $e->getCode() . ']', |
|
| 33 | + $e->getMessage(), |
|
| 34 | + NotificationMessage::ERROR |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $smarty->assign([ |
| 41 | - 'appURL' => $metadata['APP_URL'], |
|
| 42 | - 'hacks' => $hacks |
|
| 41 | + 'appURL' => $metadata['APP_URL'], |
|
| 42 | + 'hacks' => $hacks |
|
| 43 | 43 | ]); |
| 44 | 44 | $smarty->display('control-panel.tpl'); |
@@ -8,79 +8,79 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Toolbox extends \smtech\StMarksReflexiveCanvasLTI\Toolbox |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * Custom Preferences database |
|
| 13 | - * @var mysqli |
|
| 14 | - */ |
|
| 15 | - protected $customPrefs; |
|
| 11 | + /** |
|
| 12 | + * Custom Preferences database |
|
| 13 | + * @var mysqli |
|
| 14 | + */ |
|
| 15 | + protected $customPrefs; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Configure account navigation placement |
|
| 19 | - * |
|
| 20 | - * @return Generator |
|
| 21 | - */ |
|
| 22 | - public function getGenerator() |
|
| 23 | - { |
|
| 24 | - parent::getGenerator(); |
|
| 17 | + /** |
|
| 18 | + * Configure account navigation placement |
|
| 19 | + * |
|
| 20 | + * @return Generator |
|
| 21 | + */ |
|
| 22 | + public function getGenerator() |
|
| 23 | + { |
|
| 24 | + parent::getGenerator(); |
|
| 25 | 25 | |
| 26 | - $this->generator->setOptionProperty( |
|
| 27 | - Option::ACCOUNT_NAVIGATION(), |
|
| 28 | - 'visibility', |
|
| 29 | - 'admins' |
|
| 30 | - ); |
|
| 26 | + $this->generator->setOptionProperty( |
|
| 27 | + Option::ACCOUNT_NAVIGATION(), |
|
| 28 | + 'visibility', |
|
| 29 | + 'admins' |
|
| 30 | + ); |
|
| 31 | 31 | |
| 32 | - return $this->generator; |
|
| 33 | - } |
|
| 32 | + return $this->generator; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Update a Toolbox instance from a configuration file |
|
| 37 | - * |
|
| 38 | - * @see Toolbox::fromConfiguration() Use `Toolbox::fromConfiguration()` |
|
| 39 | - * |
|
| 40 | - * @param string $configFilePath |
|
| 41 | - * @param boolean $forceRecache |
|
| 42 | - * @return void |
|
| 43 | - */ |
|
| 44 | - protected function loadConfiguration($configFilePath, $forceRecache = false) |
|
| 45 | - { |
|
| 46 | - parent::loadConfiguration($configFilePath, $forceRecache); |
|
| 35 | + /** |
|
| 36 | + * Update a Toolbox instance from a configuration file |
|
| 37 | + * |
|
| 38 | + * @see Toolbox::fromConfiguration() Use `Toolbox::fromConfiguration()` |
|
| 39 | + * |
|
| 40 | + * @param string $configFilePath |
|
| 41 | + * @param boolean $forceRecache |
|
| 42 | + * @return void |
|
| 43 | + */ |
|
| 44 | + protected function loadConfiguration($configFilePath, $forceRecache = false) |
|
| 45 | + { |
|
| 46 | + parent::loadConfiguration($configFilePath, $forceRecache); |
|
| 47 | 47 | |
| 48 | - $config = new ConfigXML($configFilePath); |
|
| 48 | + $config = new ConfigXML($configFilePath); |
|
| 49 | 49 | |
| 50 | - /* configure database connections */ |
|
| 51 | - $this->setCustomPrefs($config->newInstanceOf(mysqli::class, '/config/customprefs')); |
|
| 52 | - } |
|
| 50 | + /* configure database connections */ |
|
| 51 | + $this->setCustomPrefs($config->newInstanceOf(mysqli::class, '/config/customprefs')); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Set MySQL connection object |
|
| 56 | - * |
|
| 57 | - * @param mysqli $mysql |
|
| 58 | - */ |
|
| 59 | - public function setCustomPrefs(mysqli $mysql) |
|
| 60 | - { |
|
| 61 | - $this->customPrefs = $mysql; |
|
| 62 | - } |
|
| 54 | + /** |
|
| 55 | + * Set MySQL connection object |
|
| 56 | + * |
|
| 57 | + * @param mysqli $mysql |
|
| 58 | + */ |
|
| 59 | + public function setCustomPrefs(mysqli $mysql) |
|
| 60 | + { |
|
| 61 | + $this->customPrefs = $mysql; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Get MySQL connection object |
|
| 66 | - * |
|
| 67 | - * @return mysqli |
|
| 68 | - */ |
|
| 69 | - public function getCustomPrefs() |
|
| 70 | - { |
|
| 71 | - return $this->customPrefs; |
|
| 72 | - } |
|
| 64 | + /** |
|
| 65 | + * Get MySQL connection object |
|
| 66 | + * |
|
| 67 | + * @return mysqli |
|
| 68 | + */ |
|
| 69 | + public function getCustomPrefs() |
|
| 70 | + { |
|
| 71 | + return $this->customPrefs; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Make a MySQL query |
|
| 76 | - * |
|
| 77 | - * @link http://php.net/manual/en/mysqli.query.php Pass-through to `mysqli::query()` |
|
| 78 | - * @param string $query |
|
| 79 | - * @param int $resultMode (Optional, defaults to `MYSQLI_STORE_RESULT`) |
|
| 80 | - * @return mixed |
|
| 81 | - */ |
|
| 82 | - public function customPrefs_query($query, $resultMode = MYSQLI_STORE_RESULT) |
|
| 83 | - { |
|
| 84 | - return $this->getCustomPrefs()->query($query, $resultMode); |
|
| 85 | - } |
|
| 74 | + /** |
|
| 75 | + * Make a MySQL query |
|
| 76 | + * |
|
| 77 | + * @link http://php.net/manual/en/mysqli.query.php Pass-through to `mysqli::query()` |
|
| 78 | + * @param string $query |
|
| 79 | + * @param int $resultMode (Optional, defaults to `MYSQLI_STORE_RESULT`) |
|
| 80 | + * @return mixed |
|
| 81 | + */ |
|
| 82 | + public function customPrefs_query($query, $resultMode = MYSQLI_STORE_RESULT) |
|
| 83 | + { |
|
| 84 | + return $this->getCustomPrefs()->query($query, $resultMode); |
|
| 85 | + } |
|
| 86 | 86 | } |