vbsso_platform_settings = vbsso_get_platform_settings(); $this->vbsso_settings = vbsso_get_dokuwiki_settings(); } /** * Register * * @param object $controller controller * * @return void */ function register(Doku_Event_Handler $controller) { if (vbsso_get_platform_config_property(SHAREDAPI_PLATFORM_DOKUWIKI, VBSSO_CONFIG_PROPERTY_OVERRIDE_LINKS, TRUE)) { if (!empty($this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_LOGIN_URL])) { $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'vbsso_redirect_page_hook'); } if (!empty($this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_LOGIN_VBULLETIN_URL]) and !$this->vbsso_settings[VBSSO_NAMED_EVENT_FIELD_LOGIN_THROUGH_VB_PAGE]) { $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'vbsso_loginform_page_hook'); } } $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'vbsso_add_header'); $extensions = vbsso_verify_loaded_extensions(); if (count($extensions)) { $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'vbsso_show_warnings', $extensions); } } /** * Redirect page hook * * @param object $event event * @param mixed $param param * * @return void * * @codingStandardsIgnoreStart */ function vbsso_redirect_page_hook(&$event, $param) { /** * @codingStandardsIgnoreEnd */ global $INFO; switch ($event->data) { case 'register': $url = $this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_REGISTER_URL]; sharedapi_url_redirect(sharedapi_url_add_destination($url)); break; case 'logout': $url = $this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_LOGOUT_URL]; sharedapi_url_redirect(sharedapi_url_add_destination($url)); exit; case 'login': if ($this->vbsso_settings[VBSSO_NAMED_EVENT_FIELD_LOGIN_THROUGH_VB_PAGE]) { $url = $this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_LOGIN_URL]; sharedapi_url_redirect(sharedapi_url_add_destination($url)); } break; case 'profile': if (isset($INFO['userinfo']) and !in_array('admin', $INFO['userinfo']['grps']) and $this->vbsso_settings[VBSSO_NAMED_EVENT_FIELD_SHOW_VBULLETIN_PROFILE]) { sharedapi_url_redirect($this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_PROFILE_URL]); } break; } } /** * Login form page hook * * @param object $event event * @param mixed $param param * * @return void * * @codingStandardsIgnoreStart */ function vbsso_loginform_page_hook(&$event, $param) { /** * @codingStandardsIgnoreEnd */ global $INPUT; $form = new Doku_Form(array('id' => 'dw__login', 'action' => $this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_LOGIN_VBULLETIN_URL]), TRUE, 'post'); $form->startFieldset($this->getLang('btn_login')); $form->addHidden('do', 'login'); $form->addElement(form_makeTextField('vb_login_username', ((!$INPUT->bool('http_credentials')) ? $INPUT->str('u') : ''), $this->getLang('user'), 'focus__this', 'block')); $form->addElement(form_makePasswordField('vb_login_password', $this->getLang('pass'), '', 'block')); $form->addElement(form_makeCheckboxField('cookieuser', '1', $this->getLang('remember'), 'remember__me', 'simple')); $form->addElement(form_makeButton('submit', '', $this->getLang('btn_login'))); $form->endFieldset(); if (actionOK('register')) { $url = $this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_REGISTER_URL]; $form->addElement('
' . $this->getLang('reghere') . ': ' . tpl_link(sharedapi_url_add_destination($url), $this->getLang('btn_register'), '', TRUE) . '
'); } if (actionOK('resendpwd')) { $url = $this->vbsso_platform_settings[VBSSO_NAMED_EVENT_FIELD_LOSTPASSWORD_URL]; $form->addElement('' . $this->getLang('pwdforget') . ': ' . tpl_link(sharedapi_url_add_destination($url), $this->getLang('btn_resendpwd'), '', TRUE) . '
'); } $event->data = $form; } /** * Add header * * @param object $event event * @param mixed $param param * * @return void * * @codingStandardsIgnoreStart */ function vbsso_add_header(&$event, $param) { /** * @codingStandardsIgnoreEnd */ $event->data["script"][] = array("type" => "text/javascript", "_data" => strip_tags(VBSSO_PLATFORM_FOOTER_GA_HTML(sharedapi_get_platforms(SHAREDAPI_PLATFORM_DOKUWIKI)))); if ($this->vbsso_settings[VBSSO_PLATFORM_FOOTER_LINK_PROPERTY]) { $event->data["script"][] = array("type" => "text/javascript", "_data" => "function vbsso_add_js() { var newDiv = document.createElement('div'); newDiv.innerHTML = '" . VBSSO_PLATFORM_FOOTER_LINK_HTML . "'; document.body.appendChild(newDiv); } window.onload = vbsso_add_js; "); } } /** * Show warnings * * @param object $event event * @param mixed $param param * * @return void * * @codingStandardsIgnoreStart */ function vbsso_show_warnings(&$event, $param) { /** * @codingStandardsIgnoreEnd */ global $INFO; if (isset($INFO['userinfo']) and in_array('admin', $INFO['userinfo']['grps'])) { $tpl = file_get_contents(__DIR__.'/views/action.tpl'); $error_message = implode(', ', $param); $tpl = str_replace('[[content]]', $error_message, $tpl); echo $tpl; } } }