1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace smtech\CanvasHack; |
4
|
|
|
|
5
|
|
|
use mysqli; |
6
|
|
|
use Battis\ConfigXML; |
7
|
|
|
|
8
|
|
|
class Toolbox extends \smtech\StMarksReflexiveCanvasLTI\Toolbox |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Custom Preferences database |
12
|
|
|
* @var mysqli |
13
|
|
|
*/ |
14
|
|
|
protected $customPrefs; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Configure account navigation placement |
18
|
|
|
* |
19
|
|
|
* @return Generator |
20
|
|
|
*/ |
21
|
|
|
public function getGenerator() |
22
|
|
|
{ |
23
|
|
|
parent::getGenerator(); |
24
|
|
|
|
25
|
|
|
$this->generator->setOptionProperty( |
26
|
|
|
Option::COURSE_NAVIGATION(), |
27
|
|
|
'visibility', |
28
|
|
|
'admins' |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
return $this->generator; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Update a Toolbox instance from a configuration file |
36
|
|
|
* |
37
|
|
|
* @see Toolbox::fromConfiguration() Use `Toolbox::fromConfiguration()` |
38
|
|
|
* |
39
|
|
|
* @param string $configFilePath |
40
|
|
|
* @param boolean $forceRecache |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
protected function loadConfiguration($configFilePath, $forceRecache = false) |
44
|
|
|
{ |
45
|
|
|
parent::loadConfiguration($configFilePath, $forceRecache); |
46
|
|
|
|
47
|
|
|
$config = new ConfigXML($configFilePath); |
48
|
|
|
|
49
|
|
|
/* configure database connections */ |
50
|
|
|
$this->setCustomPrefs($config->newInstanceOf(mysqli::class, '/config/mysql/customprefs')); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Set MySQL connection object |
55
|
|
|
* |
56
|
|
|
* @param mysqli $mysql |
57
|
|
|
*/ |
58
|
|
|
public function setCustomPrefs(mysqli $mysql) |
59
|
|
|
{ |
60
|
|
|
$this->customPrefs = $mysql; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Get MySQL connection object |
65
|
|
|
* |
66
|
|
|
* @return mysqli |
67
|
|
|
*/ |
68
|
|
|
public function getCustomPrefs() |
69
|
|
|
{ |
70
|
|
|
return $this->customPrefs; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Make a MySQL query |
75
|
|
|
* |
76
|
|
|
* @link http://php.net/manual/en/mysqli.query.php Pass-through to `mysqli::query()` |
77
|
|
|
* @param string $query |
78
|
|
|
* @param int $resultMode (Optional, defaults to `MYSQLI_STORE_RESULT`) |
79
|
|
|
* @return mixed |
80
|
|
|
*/ |
81
|
|
|
public function customPrefs_query($query, $resultMode = MYSQLI_STORE_RESULT) |
82
|
|
|
{ |
83
|
|
|
return $this->getCustomPrefs()->query($query, $resultMode); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|