Completed
Branch master (9d5b94)
by Seth
10:18
created
classes/CanvasAPIviaLTI_Installer.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	/**
21 21
 	 * Generate a SECRETS_FILE from user input.
22 22
 	 *
23
-	 * @param scalar $step optional Where are we in the SECRETS_FILE creation workflow? (defaults to SECRETS_NEEDED_STEP -- the beginning)
23
+	 * @param integer $step optional Where are we in the SECRETS_FILE creation workflow? (defaults to SECRETS_NEEDED_STEP -- the beginning)
24 24
 	 *
25 25
 	 * @throws CanvasAPIviaLTI_Installer_Exception If form submission does not contain all required MySQL credentals (host, username, password and database)
26 26
 	 * @throws CanvasAPIviaLTI_Installer_Exception If SECRETS_FILE cannot be created
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	/**
262 262
 	 * Obtain a Canvas API token, if needed.
263 263
 	 *
264
-	 * @param scalar $step optional Where are we in the API token negotiation workflow? (defaults to API_DECISION_NEEDED_STEP -- the beginning)
264
+	 * @param integer $step optional Where are we in the API token negotiation workflow? (defaults to API_DECISION_NEEDED_STEP -- the beginning)
265 265
 	 * @param boolean $skip optional Skip this step (defaults to FALSE)
266 266
 	 *
267 267
 	 * @throws CanvasAPIviaLTI_Installer_Exception If $step is not a pre-defined *_STEP constant
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 						}
97 97
 						
98 98
 						$htaccessFile = __DIR__ . '/.htaccess';
99
-						if(!file_put_contents($htaccessFile, "AuthType Basic\nAuthName \"{$secrets->app->name} Admin\"\nAuthUserFile $htpasswdFile\nRequire valid-user\n")) {
99
+						if (!file_put_contents($htaccessFile, "AuthType Basic\nAuthName \"{$secrets->app->name} Admin\"\nAuthUserFile $htpasswdFile\nRequire valid-user\n")) {
100 100
 							throw new CanvasAPIviaLTI_Installer_Exception(
101 101
 								"Failed to create $htaccessFile",
102 102
 								CanvasAPIviaLTI_Installer_Exception::HTACCESS_FILE
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		} elseif (file_exists($ltiSchema)) {
155 155
 			$queries = explode(";", file_get_contents($ltiSchema));
156 156
 			$created = true;
157
-			foreach($queries as $query) {
157
+			foreach ($queries as $query) {
158 158
 				if (!empty(trim($query))) {
159 159
 					if (!$sql->query($query)) {
160 160
 						throw new CanvasAPIviaLTI_Installer_Exception(
Please login to merge, or discard this patch.
classes/CanvasHack.php 2 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -26,6 +26,9 @@  discard block
 block discarded – undo
26 26
 	private $abstract = null;
27 27
 	private $description = null;
28 28
 	
29
+	/**
30
+	 * @param \mysqli $sql
31
+	 */
29 32
 	public function __construct($sql, $path) {
30 33
 
31 34
 		if ($sql instanceof \mysqli) {
@@ -98,6 +101,9 @@  discard block
 block discarded – undo
98 101
 		}
99 102
 	}
100 103
 	
104
+	/**
105
+	 * @param string $manifest
106
+	 */
101 107
 	private function parseManifest($manifest) {
102 108
 		$xml = simplexml_load_string(file_get_contents($manifest));
103 109
 		if ($xml === false) {
@@ -111,6 +117,9 @@  discard block
 block discarded – undo
111 117
 		$this->parseManifestComponents($xml->components);
112 118
 	}
113 119
 	
120
+	/**
121
+	 * @param \SimpleXMLElement $xml
122
+	 */
114 123
 	private function parseManifestMetadata($xml) {
115 124
 		$this->required('id', $this->sql->real_escape_string($xml->id));
116 125
 		$this->required('name', $xml->name);
@@ -247,6 +256,9 @@  discard block
 block discarded – undo
247 256
 		$this->parseManifestCanvas($components->canvas);
248 257
 	}
249 258
 	
259
+	/**
260
+	 * @param string $field
261
+	 */
250 262
 	private function required($field, $value) {
251 263
 		if (!empty($value)) {
252 264
 			$this->$field = (string) $value;
@@ -258,6 +270,9 @@  discard block
 block discarded – undo
258 270
 		}
259 271
 	}
260 272
 	
273
+	/**
274
+	 * @param string $field
275
+	 */
261 276
 	private function optional($field, $value) {
262 277
 		if (isset($value)) {
263 278
 			$this->$field = (string) $value;
@@ -360,6 +375,9 @@  discard block
 block discarded – undo
360 375
 		}
361 376
 	}
362 377
 	
378
+	/**
379
+	 * @param string $table
380
+	 */
363 381
 	private function clearDb($table, $id, $idKey = 'canvashack') {
364 382
 		if (!$this->sql->query("
365 383
 			DELETE FROM `$table`
Please login to merge, or discard this patch.
Spacing   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -128,13 +128,11 @@  discard block
 block discarded – undo
128 128
 		$_name = $this->sql->real_escape_string($this->name);
129 129
 		$_abstract = (
130 130
 			isset($this->abstract) ?
131
-				$this->sql->real_escape_string($this->abstract) :
132
-				$this->sql->real_escape_string($this->description)
131
+				$this->sql->real_escape_string($this->abstract) : $this->sql->real_escape_string($this->description)
133 132
 		);
134 133
 		$_description = (
135 134
 			isset($this->description) ?
136
-				$this->sql->real_escape_string($this->description) :
137
-				$this->sql->real_escape_string($this->abstract)
135
+				$this->sql->real_escape_string($this->description) : $this->sql->real_escape_string($this->abstract)
138 136
 		);
139 137
 		$_path = $this->sql->real_escape_string($this->path);
140 138
 		
@@ -160,7 +158,7 @@  discard block
 block discarded – undo
160 158
 	private function parseManifestCanvasPages($pages) {
161 159
 		$this->clearDb($this->pages, $this->id);
162 160
 		if (!empty($pages->include)) {
163
-			foreach($pages->include->children() as $page) {
161
+			foreach ($pages->include->children() as $page) {
164 162
 				if (!$this->sql->query("
165 163
 					INSERT INTO `{$this->pages}`
166 164
 					(
@@ -183,7 +181,7 @@  discard block
 block discarded – undo
183 181
 			}
184 182
 		}
185 183
 		if (!empty($pages->exclude)) {
186
-			foreach($pages->exclude->children() as $page) {
184
+			foreach ($pages->exclude->children() as $page) {
187 185
 				if (!$this->sql->query("
188 186
 					INSERT INTO `{$this->pages}`
189 187
 					(
@@ -211,7 +209,7 @@  discard block
 block discarded – undo
211 209
 	private function parseManifestCanvasDOM($dom) {
212 210
 		$this->clearDb($this->dom, $this->id);
213 211
 		if (!empty($dom)) {
214
-			foreach($dom->children() as $bundle) {
212
+			foreach ($dom->children() as $bundle) {
215 213
 				if (!$this->sql->query("
216 214
 					INSERT INTO `{$this->dom}`
217 215
 					(
@@ -327,7 +325,7 @@  discard block
 block discarded – undo
327 325
 		");
328 326
 		
329 327
 		$params = array();
330
-		foreach($fields as $field => $value) {
328
+		foreach ($fields as $field => $value) {
331 329
 			$params[] = "`$field` = '$value'";
332 330
 		}
333 331
 		
Please login to merge, or discard this patch.
classes/UserAPIToken.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	}
92 92
 	
93 93
 	/**
94
-	 * @return string|boolean The API access token for this user, or FALSE if no token has been acquired
94
+	 * @return string|false The API access token for this user, or FALSE if no token has been acquired
95 95
 	 **/
96 96
 	public function getToken() {
97 97
 		if ($this->token) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 	
135 135
 	/**
136
-	 * @return string|boolean The URL of the API for which the user's API token is valid, or FALSE if no token has been acquired
136
+	 * @return string|false The URL of the API for which the user's API token is valid, or FALSE if no token has been acquired
137 137
 	 **/
138 138
 	function getAPIUrl() {
139 139
 		if ($this->apiUrl) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
 				UserAPIToken_Exception::TOKEN_REQUIRED
117 117
 			);
118 118
 		}
119
-		if($this->consumerKey && $this->id && $this->sql) {
119
+		if ($this->consumerKey && $this->id && $this->sql) {
120 120
 			$_token = $this->sql->real_escape_string($token);
121 121
 			if (!$this->sql->query("UPDATE `" . self::USER_TOKENS_TABLE . "` set `token` = '$_token' WHERE `consumer_key` = '{$this->consumerKey}' AND `id` = '{$this->id}'")) {
122 122
 				throw new UserAPIToken_Exception(
Please login to merge, or discard this patch.
app.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 if (isset($_REQUEST['hack'])) {
10 10
 	while (list($id, $setting) = each($_REQUEST['hack'])) {
11
-		try{
11
+		try {
12 12
 
13 13
 			$hack = CanvasHack::getCanvasHackById($sql, $id);
14 14
 			if ($setting === 'enable') {
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
 
25 25
 $hacksContents = scandir(realpath(__DIR__ . '/hacks'), SCANDIR_SORT_ASCENDING);
26 26
 $hacks = array();
27
-foreach($hacksContents as $item) {
27
+foreach ($hacksContents as $item) {
28 28
 	if (is_dir($path = realpath(__DIR__ . "/hacks/$item")) && file_exists($manifest = "$path/manifest.xml")) {
29 29
 		try {
30 30
 			$hacks[$item] = new CanvasHack($sql, $path);
31 31
 		} catch (CanvasHack_Exception $e) {
32 32
 			$smarty->addMessage(
33
-				'CanvasHack Manifest Error ['. $e->getCode() . ']',
33
+				'CanvasHack Manifest Error [' . $e->getCode() . ']',
34 34
 				$e->getMessage(),
35 35
 				NotificationMessage::ERROR
36 36
 			);
Please login to merge, or discard this patch.
admin/install.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 	
16 16
 /* ...otherwise, let's start with the SECRETS_FILE */
17 17
 } else {
18
-	if(!file_exists(SECRETS_FILE)) {
18
+	if (!file_exists(SECRETS_FILE)) {
19 19
 		if (isset($_REQUEST['step']) && $_REQUEST['step'] == CanvasAPIviaLTI_Installer::SECRETS_ENTERED_STEP) {
20 20
 			CanvasAPIviaLTI_Installer::createSecretsFile(CanvasAPIviaLTI_Installer::SECRETS_ENTERED_STEP);
21 21
 		} else {
Please login to merge, or discard this patch.
admin/consumers.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,10 +47,11 @@
 block discarded – undo
47 47
 /* look up consumer to edit, if requested */
48 48
 } elseif (isset($_REQUEST['consumer_key'])) {
49 49
 	$consumer = new LTI_Tool_Consumer($_REQUEST['consumer_key'], LTI_Data_Connector::getDataConnector($sql));
50
-	if (isset($_REQUEST['action']))
51
-		switch ($_REQUEST['action']) {
50
+	if (isset($_REQUEST['action'])) {
51
+			switch ($_REQUEST['action']) {
52 52
 			case 'delete': {
53 53
 				$consumer->delete();
54
+	}
54 55
 				break;
55 56
 			}
56 57
 			case 'select': {
Please login to merge, or discard this patch.
canvashack-loader.js.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 header('Content-Type: application/javascript');
6 6
 
7 7
 if (!empty($_REQUEST['download'])) {
8
-    header("Content-Disposition: attachment; filename=canvashack-loader.js");
8
+	header("Content-Disposition: attachment; filename=canvashack-loader.js");
9 9
 }
10 10
 
11 11
 ?>
Please login to merge, or discard this patch.
hacks/common.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-define ('IGNORE_LTI', true);
3
+define('IGNORE_LTI', true);
4 4
 
5 5
 require_once(__DIR__ . '/../common.inc.php');
6 6
 
Please login to merge, or discard this patch.
classes/CanvasAPIviaLTI.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 		if ($this->user->isAdmin()) {
19 19
 			
20 20
 			/* set up any needed session variables */
21
-	        $_SESSION['consumer_key'] = $this->consumer->getKey();
22
-	        $_SESSION['resource_id'] = $this->resource_link->getId();
23
-	        $_SESSION['user_consumer_key'] = $this->user->getResourceLink()->getConsumer()->getKey();
24
-	        $_SESSION['user_id'] = $this->user->getId();
25
-	        $_SESSION['isStudent'] = $this->user->isLearner();
26
-	        $_SESSION['isContentItem'] = FALSE;	   
21
+			$_SESSION['consumer_key'] = $this->consumer->getKey();
22
+			$_SESSION['resource_id'] = $this->resource_link->getId();
23
+			$_SESSION['user_consumer_key'] = $this->user->getResourceLink()->getConsumer()->getKey();
24
+			$_SESSION['user_id'] = $this->user->getId();
25
+			$_SESSION['isStudent'] = $this->user->isLearner();
26
+			$_SESSION['isContentItem'] = FALSE;	   
27 27
 			
28 28
 			/* do we have an admin API access token? */
29 29
 			$haveToken = true;
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 			}
53 53
 			$_SESSION['apiUrl'] = 'https://' . $this->user->getResourceLink()->settings['custom_canvas_api_domain'] . '/api/v1';
54 54
 			
55
-	        /* pass control off to the app */
56
-	        if ($haveToken) {
57
-		        $this->redirectURL = "{$metadata['APP_URL']}/app.php?lti-request=launch";
58
-	        }
55
+			/* pass control off to the app */
56
+			if ($haveToken) {
57
+				$this->redirectURL = "{$metadata['APP_URL']}/app.php?lti-request=launch";
58
+			}
59 59
 
60 60
 		/* ...otherwise set an appropriate error message and fail */
61 61
 		} else {
Please login to merge, or discard this patch.