}
/**
+ * Returns a list of available drivers for a library that are available
+ * in an application.
+ *
+ * @param string $app The application name.
+ * @param string $prefix The library prefix.
+ *
+ * @return array The list of available class names.
+ */
+ public function getAppDrivers($app, $prefix)
+ {
+ $classes = array();
+ $fileprefix = strtr($prefix, '_', '/');
+ $fileroot = $this->get('fileroot', $app);
+
+ if (!is_null($fileroot) &&
+ is_dir($fileroot . '/lib/' . $fileprefix)) {
+ foreach (scandir($fileroot . '/lib/' . $fileprefix) as $file) {
+ $classname = $app . '_' . $prefix . '_' . basename($file, '.php');
+ if (class_exists($classname)) {
+ $classes[] = $classname;
+ }
+ }
+ }
+
+ return $classes;
+ }
+
+ /**
* Function to work out an application's graphics URI, optionally taking
* into account any themes directories that may be set up.
*
$tasks = array();
foreach ($app_list as $app) {
- $fileroot = $GLOBALS['registry']->get('fileroot', $app);
- if (!is_null($fileroot)) {
- foreach (array('SystemTask', 'Task') as $val) {
- if (is_dir($fileroot . '/lib/LoginTasks/' . $val)) {
- foreach (scandir($fileroot . '/lib/LoginTasks/' . $val) as $file) {
- $classname = $app . '_LoginTasks_' . $val . '_' . basename($file, '.php');
- if (class_exists($classname)) {
- $tasks[$classname] = $app;
- }
- }
- }
- }
+ foreach (array_merge($GLOBALS['registry']->getAppDrivers($app, 'LoginTasks_SystemTask'), $GLOBALS['registry']->getAppDrivers($app, 'LoginTasks_Task')) as $val) {
+ $tasks[$val] = $app;
}
}