Add content selection before removing content
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / WoltLabSuite / Core / User.js
index bd05d8d87a9c54eed703d4d6f39230209c0db40d..4e9d2e5be30d3294f7be912582050cc89e0df34c 100644 (file)
@@ -2,7 +2,7 @@
  * Provides data of the active user.
  * 
  * @author     Matthias Schmidt
- * @copyright  2001-2017 WoltLab GmbH
+ * @copyright  2001-2018 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLabSuite/Core/User
  */
@@ -10,18 +10,30 @@ define([], function() {
        "use strict";
        
        var _didInit = false;
+       var _link;
        
        /**
         * @exports     WoltLabSuite/Core/User
         */
        return {
+               /**
+                * Returns the link to the active user's profile or an empty string
+                * if the active user is a guest.
+                * 
+                * @return      {string}
+                */
+               getLink: function() {
+                       return _link;
+               },
+               
                /**
                 * Initializes the user object.
                 * 
                 * @param       {int}           userId          id of the user, `0` for guests
                 * @param       {string}        username        name of the user, empty for guests
+                * @param       {string}        userLink        link to the user's profile, empty for guests
                 */
-               init: function(userId, username) {
+               init: function(userId, username, userLink) {
                        if (_didInit) {
                                throw new Error('User has already been initialized.');
                        }
@@ -36,6 +48,8 @@ define([], function() {
                                writable: false
                        });
                        
+                       _link = userLink;
+                       
                        _didInit = true;
                }
        };