Bladeren bron

Merge pull request #437 from AngelFQC/9021

Allow SSO profile editing - refs BT#9021
Yannick Warnier 10 jaren geleden
bovenliggende
commit
a459cdec33
2 gewijzigde bestanden met toevoegingen van 21 en 5 verwijderingen
  1. 1 4
      main/auth/sso/sso.Drupal.class.php
  2. 20 1
      main/inc/lib/userportal.lib.php

+ 1 - 4
main/auth/sso/sso.Drupal.class.php

@@ -228,14 +228,11 @@ class ssoDrupal {
 
     /**
      * Generate the URL for profile editing
-     * @global array $_user
      * @return string If the URL is obtained return the drupal_user_id. Otherwise return false 
      */
     public function generateProfileEditingURL()
     {
-        global $_user;
-
-        $userId = $_user['user_id'];
+        $userId = api_get_user_id();
 
         $userExtraFieldValue = new ExtraFieldValue('user');
         $drupalUserIdData = $userExtraFieldValue->get_values_by_handler_and_field_variable($userId, 'drupal_user_id');

+ 20 - 1
main/inc/lib/userportal.lib.php

@@ -848,7 +848,26 @@ class IndexManager
                 $profile_content .= '<li class="myfiles-social"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.get_lang('MyFiles').'</a></li>';
             }
         }
-        $profile_content .= '<li class="profile-social"><a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">'.get_lang('EditProfile').'</a></li>';
+
+        $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+
+        if (api_get_setting('sso_authentication') === 'true') {
+            $subSSOClass = api_get_setting('sso_authentication_subclass');
+            $objSSO = null;
+
+            if (!empty($subSSOClass)) {
+                require_once api_get_path(SYS_CODE_PATH) . 'auth/sso/sso.' . $subSSOClass . '.class.php';
+
+                $subSSOClass = 'sso' . $subSSOClass;
+                $objSSO = new $subSSOClass();
+            } else {
+                $objSSO = new sso();
+            }
+
+            $editProfileUrl = $objSSO->generateProfileEditingURL();
+        }
+
+        $profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">'.get_lang('EditProfile').'</a></li>';
         $profile_content .= '</ul>';
         $html = self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block');
         return $html;