/**
  * Builds a proper login link for the given method object.
  *
  * @param $methodName
  * the method name to use for login
  * @return String
  * properly built login link for the given method
  */
 private function buildLink($methodName)
 {
     $method = $this->multiAuthPlugin->getMethod($methodName);
     $link = $method['login'];
     $link_href = $link['href'];
     if (strstr($link_href, '{RETURN_URL}')) {
         $return_url = $this->buildReturnURL($methodName);
         $link_href = str_replace('{RETURN_URL}', wfUrlencode($return_url), $link_href);
     }
     return $link_href;
 }
 /**
  * Saves the chosen method name in the session and initialises
  * the external login process.
  *
  * @param $methodName
  * Name of the chosen login method
  */
 private function initLogin($methodName)
 {
     $method = $this->multiAuthPlugin->getMethod($methodName);
     if (!empty($method)) {
         // save selected method name
         $_SESSION['MA_methodName'] = $methodName;
         wfDebugLog('MultiAuthPlugin', __METHOD__ . ': ' . ': ' . "SESSION['MA_methodName'] = {$methodName}");
         // init the external login
         $target = $this->buildLink($method);
         wfDebugLog('MultiAuthPlugin', __METHOD__ . ': ' . ': ' . "Redirecting to SSO login process: {$target}");
         header("Location: " . $target);
         exit;
     }
 }
 /**
  * Builds a proper login link for the given method object.
  *
  * @param $methodName
  * the method name to use for login
  * @return String
  * properly built login link for the given method
  */
 private function buildLink($methodName)
 {
     $method = $this->multiAuthPlugin->getMethod($methodName);
     $link = $method['login'];
     $link_href = $link['href'];
     if (strstr($link_href, '{RETURN_URL}')) {
         if ($methodName == 'local') {
             $return_url = isset($_REQUEST['returnto']) ? $_REQUEST['returnto'] : '';
         } else {
             $returnto = isset($_REQUEST['returnto']) ? '?returnto=' . $_REQUEST['returnto'] : '';
             $return_url = SpecialPage::getTitleFor('MultiAuthSpecialLogin')->escapeFullURL() . $returnto;
         }
         $link_href = str_replace('{RETURN_URL}', wfUrlencode($return_url), $link_href);
     }
     return $link_href;
 }