@@ -13,8 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | /* store any requested actions for future handling */ |
15 | 15 | $action = (empty($_REQUEST['action']) ? |
16 | - ACTION_UNSPECIFIED : |
|
17 | - strtolower($_REQUEST['action']) |
|
16 | + ACTION_UNSPECIFIED : strtolower($_REQUEST['action']) |
|
18 | 17 | ); |
19 | 18 | |
20 | 19 | /* action requests only come from outside the LTI! */ |
@@ -49,8 +48,7 @@ discard block |
||
49 | 48 | /* if not authenticated, default to showing credentials */ |
50 | 49 | } else { |
51 | 50 | $action = (empty($action) ? |
52 | - ACTION_CONFIG : |
|
53 | - $action |
|
51 | + ACTION_CONFIG : $action |
|
54 | 52 | ); |
55 | 53 | } |
56 | 54 | |
@@ -59,7 +57,7 @@ discard block |
||
59 | 57 | /* reset cached install data from config file */ |
60 | 58 | case ACTION_INSTALL: |
61 | 59 | $_SESSION['toolbox'] = Toolbox::fromConfiguration(CONFIG_FILE, true); |
62 | - $toolbox =& $_SESSION['toolbox']; |
|
60 | + $toolbox = & $_SESSION['toolbox']; |
|
63 | 61 | |
64 | 62 | /* test to see if we can connect to the API */ |
65 | 63 | try { |
@@ -3,30 +3,30 @@ |
||
3 | 3 | require_once('common.inc.php'); |
4 | 4 | |
5 | 5 | if (isset($_REQUEST['course_url'])) { |
6 | - $eventsApi = new CanvasPest($_SESSION['apiUrl'], $_SESSION['apiToken']); |
|
6 | + $eventsApi = new CanvasPest($_SESSION['apiUrl'], $_SESSION['apiToken']); |
|
7 | 7 | |
8 | - // TODO work nicely with the cache (purge uncached events, or only cached events, etc.) |
|
8 | + // TODO work nicely with the cache (purge uncached events, or only cached events, etc.) |
|
9 | 9 | |
10 | - $events = $eventsApi->get('calendar_events', |
|
11 | - array( |
|
12 | - 'type' => 'event', |
|
13 | - 'all_events' => true, |
|
14 | - 'context_codes[]' => preg_replace('|.*/courses/(\d+)/?.*|', "course_$1", $_REQUEST['course_url']) |
|
15 | - ) |
|
16 | - ); |
|
17 | - do { |
|
18 | - foreach($events as $event) { |
|
19 | - $api->delete("calendar_events/{$event['id']}", |
|
20 | - array( |
|
21 | - 'cancel_reason' => $metadata['APP_NAME'] . " course_url={$_REQUEST['course_url']}" |
|
22 | - ) |
|
23 | - ); |
|
24 | - } |
|
25 | - } while($events = $eventsApi->nextPage()); |
|
10 | + $events = $eventsApi->get('calendar_events', |
|
11 | + array( |
|
12 | + 'type' => 'event', |
|
13 | + 'all_events' => true, |
|
14 | + 'context_codes[]' => preg_replace('|.*/courses/(\d+)/?.*|', "course_$1", $_REQUEST['course_url']) |
|
15 | + ) |
|
16 | + ); |
|
17 | + do { |
|
18 | + foreach($events as $event) { |
|
19 | + $api->delete("calendar_events/{$event['id']}", |
|
20 | + array( |
|
21 | + 'cancel_reason' => $metadata['APP_NAME'] . " course_url={$_REQUEST['course_url']}" |
|
22 | + ) |
|
23 | + ); |
|
24 | + } |
|
25 | + } while($events = $eventsApi->nextPage()); |
|
26 | 26 | |
27 | - $smarty->assign('content', 'Calendar purged.'); |
|
27 | + $smarty->assign('content', 'Calendar purged.'); |
|
28 | 28 | } else { |
29 | - $smarty->assign('content', '<form action="' . $_SERVER['PHP_SELF'] . '" method="post"><label for="course_url">Course URL <input id="course_url" name="course_url" type="text" /><input type="submit" value="Purge All Calendar Events" /></form>'); |
|
29 | + $smarty->assign('content', '<form action="' . $_SERVER['PHP_SELF'] . '" method="post"><label for="course_url">Course URL <input id="course_url" name="course_url" type="text" /><input type="submit" value="Purge All Calendar Events" /></form>'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $smarty->display(); |
@@ -15,14 +15,14 @@ |
||
15 | 15 | ) |
16 | 16 | ); |
17 | 17 | do { |
18 | - foreach($events as $event) { |
|
18 | + foreach ($events as $event) { |
|
19 | 19 | $api->delete("calendar_events/{$event['id']}", |
20 | 20 | array( |
21 | 21 | 'cancel_reason' => $metadata['APP_NAME'] . " course_url={$_REQUEST['course_url']}" |
22 | 22 | ) |
23 | 23 | ); |
24 | 24 | } |
25 | - } while($events = $eventsApi->nextPage()); |
|
25 | + } while ($events = $eventsApi->nextPage()); |
|
26 | 26 | |
27 | 27 | $smarty->assign('content', 'Calendar purged.'); |
28 | 28 | } else { |
@@ -3,27 +3,27 @@ |
||
3 | 3 | require_once('common.inc.php'); |
4 | 4 | |
5 | 5 | if (isset($_REQUEST['course_url'])) { |
6 | - $courseId = preg_replace('|.*/courses/(\d+)/?.*|', '$1', parse_url($_REQUEST['course_url'], PHP_URL_PATH)); |
|
7 | - $course = $api->get("/courses/$courseId"); |
|
8 | - if ($course) { |
|
9 | - $webcalFeed = str_replace('https://', 'webcal://', $course['calendar']['ics']); |
|
10 | - $smarty->assign('content', ' |
|
6 | + $courseId = preg_replace('|.*/courses/(\d+)/?.*|', '$1', parse_url($_REQUEST['course_url'], PHP_URL_PATH)); |
|
7 | + $course = $api->get("/courses/$courseId"); |
|
8 | + if ($course) { |
|
9 | + $webcalFeed = str_replace('https://', 'webcal://', $course['calendar']['ics']); |
|
10 | + $smarty->assign('content', ' |
|
11 | 11 | <h3>Course Calendar ICS Feed</h3> |
12 | 12 | <p>You can subscribe to the calendar for <a href="https://' . |
13 | - parse_url(CANVAS_API_URL, PHP_URL_HOST) . '/courses/' . $courseId . |
|
14 | - '">' . $course['name'] . '</a> at <a href="' . |
|
15 | - $webcalFeed . '">' . $webcalFeed . |
|
16 | - '</a> in any calendar application that supports external ICS feeds.</p>' |
|
17 | - ); |
|
18 | - } else { |
|
19 | - $messages[] = array( |
|
20 | - 'class' => 'error', |
|
21 | - 'title' => 'Canvas API Error', |
|
22 | - 'content' => 'The course you requested could not be accessed.<pre>' . print_r($json, false) . '</pre>' |
|
23 | - ); |
|
24 | - } |
|
13 | + parse_url(CANVAS_API_URL, PHP_URL_HOST) . '/courses/' . $courseId . |
|
14 | + '">' . $course['name'] . '</a> at <a href="' . |
|
15 | + $webcalFeed . '">' . $webcalFeed . |
|
16 | + '</a> in any calendar application that supports external ICS feeds.</p>' |
|
17 | + ); |
|
18 | + } else { |
|
19 | + $messages[] = array( |
|
20 | + 'class' => 'error', |
|
21 | + 'title' => 'Canvas API Error', |
|
22 | + 'content' => 'The course you requested could not be accessed.<pre>' . print_r($json, false) . '</pre>' |
|
23 | + ); |
|
24 | + } |
|
25 | 25 | } else { |
26 | - $smarty->assign('content', ' |
|
26 | + $smarty->assign('content', ' |
|
27 | 27 | <form method="post" action="' . $_SERVER['PHP_SELF'] . '"> |
28 | 28 | <label for="course_url">Course URL <span class="comment">The URL to the course whose calendar you would like to export as an ICS feed</span></label> |
29 | 29 | <input id="course_url" name="course_url" type="text" /> |
@@ -11,7 +11,6 @@ |
||
11 | 11 | |
12 | 12 | require_once 'common.inc.php'; |
13 | 13 | |
14 | -use smtech\CanvasPest\CanvasPest; |
|
15 | 14 | use smtech\ReflexiveCanvasLTI\LTI\ToolProvider; |
16 | 15 | use Battis\Educoder\Pest_Unauthorized; |
17 | 16 | use Battis\Educoder\Pest_ClientError; |
@@ -122,12 +122,10 @@ discard block |
||
122 | 122 | '" . getSyncTimestamp() . "', |
123 | 123 | '" . ($_REQUEST['enable_regexp_filter'] == VALUE_ENABLE_REGEXP_FILTER) . "', |
124 | 124 | " . ($_REQUEST['enable_regexp_filter'] == VALUE_ENABLE_REGEXP_FILTER ? |
125 | - "'" . $toolbox->getMySQL()->escape_string($_REQUEST['include_regexp']) . "'" : |
|
126 | - 'NULL' |
|
125 | + "'" . $toolbox->getMySQL()->escape_string($_REQUEST['include_regexp']) . "'" : 'NULL' |
|
127 | 126 | ) . ", |
128 | 127 | " . ($_REQUEST['enable_regexp_filter'] == VALUE_ENABLE_REGEXP_FILTER ? |
129 | - "'" . $toolbox->getMySQL()->escape_string($_REQUEST['exclude_regexp']) . "'" : |
|
130 | - 'NULL' |
|
128 | + "'" . $toolbox->getMySQL()->escape_string($_REQUEST['exclude_regexp']) . "'" : 'NULL' |
|
131 | 129 | ) . " |
132 | 130 | ) |
133 | 131 | "); |
@@ -159,10 +157,10 @@ discard block |
||
159 | 157 | * side of today's date, probably a better system? |
160 | 158 | */ |
161 | 159 | foreach ($ics->selectComponents( |
162 | - date('Y')-1, // startYear |
|
160 | + date('Y') - 1, // startYear |
|
163 | 161 | date('m'), // startMonth |
164 | 162 | date('d'), // startDay |
165 | - date('Y')+1, // endYEar |
|
163 | + date('Y') + 1, // endYEar |
|
166 | 164 | date('m'), // endMonth |
167 | 165 | date('d'), // endDay |
168 | 166 | 'vevent', // cType |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | /* prepare the toolbox */ |
15 | 15 | if (empty($_SESSION[Toolbox::class])) { |
16 | - $_SESSION[Toolbox::class] =& Toolbox::fromConfiguration(CONFIG_FILE); |
|
16 | + $_SESSION[Toolbox::class] = & Toolbox::fromConfiguration(CONFIG_FILE); |
|
17 | 17 | } |
18 | -$toolbox =& $_SESSION[Toolbox::class]; |
|
18 | +$toolbox = & $_SESSION[Toolbox::class]; |
|
19 | 19 | $toolbox->smarty_prependTemplateDir(__DIR__ . '/templates', basename(__DIR__)); |
20 | 20 | $toolbox->smarty_assign([ |
21 | 21 | 'category' => DataUtilities::titleCase(preg_replace('/[\-_]+/', ' ', basename(__DIR__))) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $FIELD_MAP = array( |
95 | 95 | 'calendar_event[title]' => 'SUMMARY', |
96 | 96 | 'calendar_event[description]' => 'DESCRIPTION', |
97 | - 'calendar_event[start_at]' => array ( |
|
97 | + 'calendar_event[start_at]' => array( |
|
98 | 98 | 0 => 'X-CURRENT-DTSTART', |
99 | 99 | 1 => 'DTSTART' |
100 | 100 | ), |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | **/ |
126 | 126 | public function filterEvent($event, $calendarCache) |
127 | 127 | { |
128 | - return ( |
|
128 | + return ( |
|
129 | 129 | ( |
130 | 130 | // TODO actual multi-day events would be nice |
131 | 131 | // only include first day of multi-day events |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ) && |
135 | 135 | ( |
136 | 136 | // include this event if filtering is off... |
137 | - $calendarCache['enable_regexp_filter'] == false || |
|
137 | + $calendarCache['enable_regexp_filter'] == false || |
|
138 | 138 | ( |
139 | 139 | ( |
140 | 140 | ( // if filtering is on, and there's an include pattern test that pattern... |