Sfoglia il codice sorgente

Generate the profile edition link

Angel Fernando Quiroz Campos 10 anni fa
parent
commit
8a43ed1cb4

+ 1 - 18
main/admin/user_list.php

@@ -577,24 +577,7 @@ function modify_filter($user_id, $url_params, $row) {
 	}
 
 	if (api_is_platform_admin(true)) {
-        $editProfileUrl = api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=$user_id";
-
-        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($user_id, true);
-        }
+        $editProfileUrl = Display::getProfileEditionLink($user_id, true);
 
         if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) {
             $result .= '<a href="' . $editProfileUrl . '">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';

+ 35 - 0
main/inc/lib/display.lib.php

@@ -1986,4 +1986,39 @@ class Display
     {
         Session::erase('flash_messages');
     }
+
+    /**
+     * Get the profile edition link for a user
+     * @param int $userId The user id
+     * @param boolean $asAdmin Optional. Whether get the URL for the platform admin
+     * @return string The link
+     */
+    public static function getProfileEditionLink($userId, $asAdmin = false)
+    {
+        $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+
+        if ($asAdmin) {
+            $editProfileUrl = api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=" . intval($userId);
+        }
+
+        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($userId, $asAdmin);
+        }
+
+        return $editProfileUrl;
+    }
+
 }

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

@@ -891,23 +891,7 @@ class IndexManager
             }
         }
 
-        $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();
-        }
+        $editProfileUrl = Display::getProfileEditionLink($user_id);
 
         $profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">'.Display::return_icon('edit-profile.png',get_lang('EditProfile'),null,ICON_SIZE_SMALL).get_lang('EditProfile').'</a></li>';
         $profile_content .= '</ul>';

+ 1 - 16
main/messages/inbox.php

@@ -144,23 +144,8 @@ if (api_get_setting('allow_social_tool') == 'true') {
         $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
     }
 
-    $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+    $editProfileUrl = Display::getProfileEditionLink($user_id);
 
-    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();
-    }
     $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 1 - 16
main/messages/new_message.php

@@ -324,23 +324,8 @@ if (api_get_setting('allow_social_tool') == 'true') {
         $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
     }
 
-    $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+    $editProfileUrl = Display::getProfileEditionLink($user_id);
 
-    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();
-    }
     $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 1 - 16
main/messages/outbox.php

@@ -123,23 +123,8 @@ if (api_get_setting('allow_social_tool') == 'true') {
         $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
     }
 
-    $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+    $editProfielUrl = Display::getProfileEditionLink($user_id);
 
-    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();
-    }
     $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 1 - 16
main/messages/view_message.php

@@ -68,23 +68,8 @@ if (api_get_setting('allow_social_tool') == 'true') {
         $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
     }
 
-    $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+    $editProfileUrl = Display::getProfileEditionLink($user_id);
 
-    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();
-    }
     $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 1 - 16
main/social/friends.php

@@ -95,23 +95,8 @@ if(!empty($chat_status['user_chat_status'])){
     $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
 }
 
-$editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+$editProfileUrl = Display::getProfileEditionLink($user_id);
 
-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();
-}
 $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 2 - 30
main/social/groups.php

@@ -235,23 +235,9 @@ if ($group_id != 0) {
     }else{
         $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
     }
-    $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;
+    $editProfileUrl = Display::getProfileEditionLink($user_id);
 
-        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();
-    }
     $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';
@@ -276,23 +262,9 @@ if ($group_id != 0) {
     }else{
         $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
     }
-    $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;
+    $editProfileUrl = Display::getProfileEditionLink($user_id);
 
-        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();
-    }
     $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 1 - 16
main/social/home.php

@@ -97,23 +97,8 @@ $chat_status = $userInfo['extra'];
      $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
  }
 
-    $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+$editProfileUrl = Display::getProfileEditionLink(api_get_user_id());
 
-    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();
-    }
 $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 1 - 16
main/social/invitations.php

@@ -106,23 +106,8 @@ if(!empty($chat_status['user_chat_status'])){
     $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
 }
 
-$editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+$editProfileUrl = Display::getProfileEditionLink($user_id);
 
-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();
-}
 $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 1 - 16
main/social/myfiles.php

@@ -144,23 +144,8 @@ if(!empty($chat_status['user_chat_status'])){
     $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
 }
 
-$editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+$editProfileUrl = Display::getProfileEditionLink($user_id);
 
-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();
-}
 $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';

+ 1 - 16
main/social/profile.php

@@ -389,23 +389,8 @@ if(!empty($chat_status['user_chat_status'])){
 }
 
 if (api_get_user_id() === $friendId) {
-    $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+    $editProfileUrl = Display::getProfileEditionLink(api_get_user_id());
 
-    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();
-    }
     $social_avatar_block .= '<div class="edit-profile">
                                 <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                              </div>';

+ 1 - 16
main/social/search.php

@@ -161,23 +161,8 @@ if(!empty($chat_status['user_chat_status'])){
     $social_avatar_block.= '<div class="status">'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')</div>';
 }
 
-$editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
+$editProfileUrl = Display::getProfileEditionLink($user_id);
 
-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();
-}
 $social_avatar_block .= '<div class="edit-profile">
                             <a class="btn" href="' . $editProfileUrl . '">' . get_lang('EditProfile') . '</a>
                          </div>';