<?php
/**
 * -----------------------------------------------------------------------
 * vBSSO is a solution which helps you connect to different software platforms
 * via secure Single Sign-On.
 *
 * Copyright (c) 2011-2017 vBSSO. All Rights Reserved.
 * This software is the proprietary information of vBSSO.
 *
 * Author URI: http://www.vbsso.com
 * License: GPL version 2 or later -
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * -----------------------------------------------------------------------
 */

if (!defined('DIR')) {
    define('DIR', dirname(__FILE__) . '/');
}

if (!defined('VBSSO_PLATFORM_CONFIG_FILE')) {
    define('VBSSO_PLATFORM_CONFIG_FILE', DIR . 'platform.conf');
}

if (!defined('VBSSO_VBSSO_CONFIG_FILE')) {
    define('VBSSO_VBSSO_CONFIG_FILE', DIR . 'vbsso.conf');
}
define('VBSSO_DOKUWIKI_PLUGIN_VERSION', '1.1.0');

require_once(DIR . '../../../inc/init.php');
require_once(DIR . 'vendor/com.extremeidea.vbsso/vbsso-connect-shared/vbsso_shared.php');
require_once(DIR . 'includes/api.php');

if (file_exists(DIR . 'config.custom.php')) {
    require_once(DIR . 'config.custom.php');
}

global $vbsso_platform_settings, $vbsso_settings;
$vbsso_platform_settings = ($vbsso_platform_settings) ? $vbsso_platform_settings : vbsso_get_platform_settings();
$vbsso_settings = ($vbsso_settings) ? $vbsso_settings : vbsso_get_dokuwiki_settings();

$vbsso = new action_plugin_vbsso();
sharedapi_data_handler(SHAREDAPI_PLATFORM_DOKUWIKI, getVersion(),
    VBSSO_DOKUWIKI_PLUGIN_VERSION,
    $vbsso_settings[VBSSO_NAMED_EVENT_FIELD_API_KEY],
    (!$plugin_controller->isdisabled('vbsso')) ? array(
        SHAREDAPI_EVENT_VERIFY => 'vbsso_listener_verify',
        SHAREDAPI_EVENT_LOGIN => 'vbsso_listener_register',
        SHAREDAPI_EVENT_AUTHENTICATION => 'vbsso_listener_authentication',
        SHAREDAPI_EVENT_LOGOUT => 'vbsso_listener_logout',
        SHAREDAPI_EVENT_REGISTER => 'vbsso_listener_register',
        SHAREDAPI_EVENT_CREDENTIALS => 'vbsso_listener_credentials',
    ) : array()
);