コード例 #1
0
 /**
  * Object constructor
  *
  * @since 0.2.1
  *
  * @param null|AADSSO
  */
 protected function __construct($aadsso = null)
 {
     // Assign properties
     $this->aadsso = is_a($aadsso, 'AADSSO') ? $aadsso : AADSSO::get_instance();
     $this->settings = AADSSO_Settings::get_instance();
     // Add hooks
     add_action('init', array($this, 'init'));
 }
コード例 #2
0
    }
    /**
     * Renders the link used to initiate the login to Azure AD.
     */
    function print_login_link()
    {
        $html = '<p class="aadsso-login-form-text">';
        $html .= '<a href="%s">';
        $html .= sprintf(__('Sign in with your %s account', AADSSO), htmlentities($this->settings->org_display_name));
        $html .= '</a><br /><a class="dim" href="%s">' . __('Sign out', AADSSO) . '</a></p>';
        printf($html, $this->get_login_url(), $this->get_logout_url());
    }
}
// Load settings JSON contents from DB and initialize the plugin
$aadsso_settings_instance = AADSSO_Settings::init();
$aadsso = AADSSO::get_instance($aadsso_settings_instance);
/*** Utility functions ***/
if (!function_exists('com_create_guid')) {
    /**
     * Generates a globally unique identifier ( Guid ).
     *
     * @return string A new random globally unique identifier.
     */
    function com_create_guid()
    {
        mt_srand((double) microtime() * 10000);
        $charid = strtoupper(md5(uniqid(rand(), true)));
        $hyphen = chr(45);
        // "-"
        $uuid = chr(123) . substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12) . chr(125);
        // "}"
コード例 #3
0
    }
    public function printLoginLink()
    {
        echo $this->getLoginLink();
    }
    function getLoginLink()
    {
        $login_url = $this->getLoginUrl();
        $logout_url = $this->getLogoutUrl();
        $org_display_name = $this->settings->org_display_name;
        $html = '
			<p class="aadsso-login-form-text">
				<a href="%s">' . __('Sign in with your %s account', 'aad-sso') . '</a><br />
				<a class="dim" href="%s">' . __('Sign out', 'aad-sso') . '</a>
			</p>
		';
        $html = sprintf($html, $login_url, htmlentities($org_display_name), $logout_url);
        return apply_filters('aad_sso_login_link', $html, $login_url, $logout_url, $org_display_name);
    }
    public static function redirect_uri($context = '')
    {
        return apply_filters('aad_sso_redirect_uri', self::$redirect_uri, $context);
    }
    public static function logout_redirect_uri($context = '')
    {
        return apply_filters('aad_sso_logout_redirect_uri', self::$logout_redirect_uri, $context);
    }
}
// end class
$aadsso = AADSSO::get_instance();