From 1e0d5594f88fc2a7d54947151947b5991c80136e Mon Sep 17 00:00:00 2001 From: Nick Freear Date: Wed, 7 Mar 2018 16:50:24 +0000 Subject: [PATCH] Bug #8, fix `survey-end` PHP; Add `base` class [iet:10314222] * [iet:10314221][iet:10314088] --- classes/local/base.php | 23 +++++++++++++++++++ classes/local/conditional_embedded_survey.php | 13 +++-------- classes/local/tesla_consent.php | 7 ++++-- classes/user_event_observer.php | 14 ++++++----- survey-end/index.php | 2 ++ 5 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 classes/local/base.php diff --git a/classes/local/base.php b/classes/local/base.php new file mode 100644 index 0000000..8199834 --- /dev/null +++ b/classes/local/base.php @@ -0,0 +1,23 @@ + true, ], false); - // self::_debug([ __METHOD__, $lastinsertid ]); + self::_debug([ __METHOD__, $lastinsertid ]); + return $lastinsertid; } diff --git a/classes/user_event_observer.php b/classes/user_event_observer.php index 39adb4e..d198c8d 100644 --- a/classes/user_event_observer.php +++ b/classes/user_event_observer.php @@ -10,10 +10,12 @@ namespace auth_ouopenid; require_once __DIR__ . '/../../../vendor/autoload.php'; +require_once __DIR__ . '/local/base.php'; use IET_OU\Moodle\Auth\Ouopenid\Db\User as OuUser; +use auth_ouopenid\local\base; -class user_event_observer { +class user_event_observer extends base { public static function core_user_created($event) { @@ -22,7 +24,7 @@ public static function core_user_created($event) { // Was: self::redirect($user_created = true, __FUNCTION__); - OuUser::debug(__FUNCTION__); + self::debug(__FUNCTION__); } public static function core_user_loggedin($event) { @@ -35,7 +37,7 @@ public static function embed_event_data(\core\event\base $event) { json_encode( $event->get_data() ) . "\n"; } else { - OuUser::debug([ __FUNCTION__, $event->get_data() ]); + self::debug([ __FUNCTION__, $event->get_data() ]); } } @@ -46,15 +48,15 @@ protected static function redirect($user_created, $fn) { $redirects = isset($CFG->auth_ouopenid_redirects) ? $CFG->auth_ouopenid_redirects : null; if (! isset($USER->username)) { - return OuUser::debug([ __FUNCTION__, 'Warning, no username.', $USER ]); + return self::debug([ __FUNCTION__, 'Warning, no username.', $USER ]); } $ou_profile = OuUser::getUser($USER->username); - OuUser::debug([ __FUNCTION__, $fn, $redirects, $ou_profile ]); + self::debug([ __FUNCTION__, $fn, $redirects, $ou_profile ]); if (! $redirects || ! $enabled) { - return OuUser::debug([ __FUNCTION__, 'Warning, redirect is disabled (or missing).', $redirects ]); + return self::debug([ __FUNCTION__, 'Warning, redirect is disabled (or missing).' ]); } $url = OuUser::getRedirectUrl($ou_profile, $user_created ? 'newenrol' : 'return'); diff --git a/survey-end/index.php b/survey-end/index.php index d9a76da..8402e7a 100644 --- a/survey-end/index.php +++ b/survey-end/index.php @@ -9,9 +9,11 @@ // For 'print_string()' language support! require_once __DIR__ . '/../../../config.php'; +require_once __DIR__ . '/../classes/local/base.php'; require_once __DIR__ . '/../classes/local/conditional_embedded_survey.php'; require_once __DIR__ . '/../classes/local/tesla_consent.php'; +use auth_ouopenid\local\conditional_embedded_survey; use auth_ouopenid\local\tesla_consent; define( 'OUOP_STRING', 'auth_ouopenid' );