summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules-available/locationinfo/api.inc.php6
-rw-r--r--modules-available/locationinfo/inc/coursebackend.inc.php40
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php3
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php2
-rw-r--r--modules-available/locationinfo/lang/en/template-tags.json2
-rw-r--r--modules-available/locationinfo/page.inc.php3
-rw-r--r--modules-available/locationinfo/templates/page-locations.html2
7 files changed, 38 insertions, 20 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index a89f16ed..ceaf04c0 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -175,10 +175,10 @@ function getCalendar($idList)
foreach ($serverList as $serverid => $server) {
$serverInstance = CourseBackend::getInstance($server['type']);
if ($serverInstance === false) {
- EventLog::warning('Cannot fetch schedule for locationid ' . $server['locationid']
+ EventLog::warning('Cannot fetch schedule for location (' . implode(', ', $server['idlist']) . ')'
. ': Backend type ' . $server['type'] . ' unknown. Disabling location.');
- Database::exec("UPDATE locationinfo_locationconfig SET serverid = 0 WHERE locationid = :lid",
- array('lid' => $server['locationid']));
+ Database::exec("UPDATE locationinfo_locationconfig SET serverid = NULL WHERE locationid IN (:lid)",
+ array('lid' => $server['idlist']));
continue;
}
$credentialsOk = $serverInstance->setCredentials($serverid, $server['credentials']);
diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php
index bf3e2e1f..7162c885 100644
--- a/modules-available/locationinfo/inc/coursebackend.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend.inc.php
@@ -47,17 +47,20 @@ abstract class CourseBackend
foreach (glob(dirname(__FILE__) . '/coursebackend/coursebackend_*.inc.php', GLOB_NOSORT) as $file) {
require_once $file;
preg_match('#coursebackend_([^/\.]+)\.inc\.php$#i', $file, $out);
- if (!class_exists('coursebackend_' . $out[1])) {
- trigger_error("Backend type source unit $file doesn't seem to define class CourseBackend_{$out[1]}", E_USER_ERROR);
+ $className = 'CourseBackend_' . $out[1];
+ if (!class_exists($className)) {
+ trigger_error("Backend type source unit $file doesn't seem to define class $className", E_USER_ERROR);
}
+ if (!CONFIG_DEBUG && defined("$className::DEBUG") && constant("$className::DEBUG"))
+ continue;
self::$backendTypes[$out[1]] = true;
}
}
/**
- * Get all known config module types.
+ * Get all known backend types.
*
- * @return array list of modules
+ * @return array list of backends
*/
public static function getList()
{
@@ -65,24 +68,30 @@ abstract class CourseBackend
return array_keys(self::$backendTypes);
}
+ public static function exists($backendType)
+ {
+ self::loadDb();
+ return isset(self::$backendTypes[$backendType]);
+ }
+
/**
- * Get fresh instance of ConfigModule subclass for given module type.
+ * Get fresh instance of CourseBackend subclass for given backend type.
*
- * @param string $moduleType name of module type
- * @return \CourseBackend module instance
+ * @param string $backendType name of module type
+ * @return \CourseBackend|false module instance
*/
- public static function getInstance($moduleType)
+ public static function getInstance($backendType)
{
self::loadDb();
- if (!isset(self::$backendTypes[$moduleType])) {
- error_log('Unknown module type: ' . $moduleType);
+ if (!isset(self::$backendTypes[$backendType])) {
+ error_log('Unknown module type: ' . $backendType);
return false;
}
- if (!is_object(self::$backendTypes[$moduleType])) {
- $class = "coursebackend_$moduleType";
- self::$backendTypes[$moduleType] = new $class;
+ if (!is_object(self::$backendTypes[$backendType])) {
+ $class = "coursebackend_$backendType";
+ self::$backendTypes[$backendType] = new $class;
}
- return self::$backendTypes[$moduleType];
+ return self::$backendTypes[$backendType];
}
/**
@@ -328,6 +337,9 @@ abstract class CourseBackend
$xml = new SimpleXMLElement($cleanresponse);
} catch (Exception $e) {
$this->error = 'Could not parse reply as XML, got ' . get_class($e) . ': ' . $e->getMessage();
+ if (CONFIG_DEBUG) {
+ error_log($cleanresponse);
+ }
return false;
}
$array = json_decode(json_encode((array)$xml), true);
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
index fac3f296..8843e372 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
@@ -106,6 +106,9 @@ class CourseBackend_Davinci extends CourseBackend
}
$return = $this->xmlStringToArray($return);
if ($return === false) {
+ if (CONFIG_DEBUG) {
+ error_log('Room was ' . $roomId);
+ }
continue;
}
$lessons = $this->getArrayPath($return, '/Lessons/Lesson');
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
index 24e01070..adff8b1b 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
@@ -4,6 +4,8 @@ class CourseBackend_Dummy extends CourseBackend
{
private $pw;
+ const DEBUG = true;
+
/**
* uses json to setCredentials, the json must follow the form given in
* getCredentials
diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json
index 0d2b42a3..be927ee4 100644
--- a/modules-available/locationinfo/lang/en/template-tags.json
+++ b/modules-available/locationinfo/lang/en/template-tags.json
@@ -39,7 +39,7 @@
"lang_language": "Language",
"lang_languageTooltip": "The language the frontend uses",
"lang_locationName": "Name",
- "lang_locationSettings": "Settings",
+ "lang_locationSettings": "Location specific settings",
"lang_locations": "Locations",
"lang_locationsTable": "Rooms \/ Locations",
"lang_locationsTableHints": "Here you can define opening times for your locations and link the location ID to a configured backend (e.g. HISinOne) to show calendar events.",
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index d6035869..c6aa0860 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -449,7 +449,7 @@ class Page_LocationInfo extends Page
$locations = Location::getLocations(0, 0, false, true);
// Get hidden state of all locations
- $dbquery = Database::simpleQuery("SELECT li.locationid, li.serverid, li.serverlocationid, li.openingtime, li.lastcalendarupdate, cb.servername
+ $dbquery = Database::simpleQuery("SELECT li.locationid, li.serverid, li.serverlocationid, li.openingtime, li.lastcalendarupdate, cb.servertype, cb.servername
FROM `locationinfo_locationconfig` AS li
LEFT JOIN `locationinfo_coursebackend` AS cb USING (serverid)");
@@ -466,6 +466,7 @@ class Page_LocationInfo extends Page
'openingGlyph' => $glyph,
'backend' => $backend,
'lastCalendarUpdate' => $row['lastcalendarupdate'], // TODO
+ 'backendMissing' => !CourseBackend::exists($row['servertype']),
);
}
diff --git a/modules-available/locationinfo/templates/page-locations.html b/modules-available/locationinfo/templates/page-locations.html
index 3eafa7bf..de8dab7e 100644
--- a/modules-available/locationinfo/templates/page-locations.html
+++ b/modules-available/locationinfo/templates/page-locations.html
@@ -21,7 +21,7 @@
<span class="glyphicon glyphicon-edit"></span>
</a>
</td>
- <td>
+ <td {{#backendMissing}}class="text-danger"{{/backendMissing}}>
{{backend}}
</td>
<td>