aboutsummaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js32
-rw-r--r--core/js/oc-backbone-webdav.js24
2 files changed, 47 insertions, 9 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 43ea269c203..bc8c51e40d3 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -82,6 +82,12 @@ var OC={
webroot:oc_webroot,
appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
+ /**
+ * Currently logged in user or null if none
+ *
+ * @type String
+ * @deprecated use {@link OC.getCurrentUser} instead
+ */
currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
config: window.oc_config,
appConfig: window.oc_appconfig || {},
@@ -272,6 +278,23 @@ var OC={
},
/**
+ * Returns the currently logged in user or null if there is no logged in
+ * user (public page mode)
+ *
+ * @return {OC.CurrentUser} user spec
+ * @since 9.0.0
+ */
+ getCurrentUser: function() {
+ if (_.isUndefined(this._currentUserDisplayName)) {
+ this._currentUserDisplayName = document.getElementsByTagName('head')[0].getAttribute('data-user-displayname');
+ }
+ return {
+ uid: this.currentUser,
+ displayName: this._currentUserDisplayName
+ };
+ },
+
+ /**
* get the absolute path to an image file
* if no extension is given for the image, it will automatically decide
* between .png and .svg based on what the browser supports
@@ -690,6 +713,15 @@ var OC={
};
/**
+ * Current user attributes
+ *
+ * @typedef {Object} OC.CurrentUser
+ *
+ * @property {String} uid user id
+ * @property {String} displayName display name
+ */
+
+/**
* @namespace OC.Plugins
*/
OC.Plugins = {
diff --git a/core/js/oc-backbone-webdav.js b/core/js/oc-backbone-webdav.js
index 7c32116f011..ba678a32fcf 100644
--- a/core/js/oc-backbone-webdav.js
+++ b/core/js/oc-backbone-webdav.js
@@ -76,6 +76,11 @@
* @param {Object} davProperties properties mapping
*/
function parsePropFindResult(result, davProperties) {
+ if (_.isArray(result)) {
+ return _.map(result, function(subResult) {
+ return parsePropFindResult(subResult, davProperties);
+ });
+ }
var props = {
href: result.href
};
@@ -87,7 +92,7 @@
for (var key in propStat.properties) {
var propKey = key;
- if (davProperties[key]) {
+ if (key in davProperties) {
propKey = davProperties[key];
}
props[propKey] = propStat.properties[key];
@@ -151,15 +156,10 @@
if (isSuccessStatus(response.status)) {
if (_.isFunction(options.success)) {
var propsMapping = _.invert(options.davProperties);
- var results;
+ var results = parsePropFindResult(response.body, propsMapping);
if (options.depth > 0) {
- results = _.map(response.body, function(data) {
- return parsePropFindResult(data, propsMapping);
- });
// discard root entry
results.shift();
- } else {
- results = parsePropFindResult(response.body, propsMapping);
}
options.success(results);
@@ -217,7 +217,13 @@
options.success(responseJson);
return;
}
- options.success(result.body);
+ // if multi-status, parse
+ if (result.status === 207) {
+ var propsMapping = _.invert(options.davProperties);
+ options.success(parsePropFindResult(result.body, propsMapping));
+ } else {
+ options.success(result.body);
+ }
}
});
}
@@ -249,7 +255,7 @@
* DAV transport
*/
function davSync(method, model, options) {
- var params = {type: methodMap[method]};
+ var params = {type: methodMap[method] || method};
var isCollection = (model instanceof Backbone.Collection);
if (method === 'update' && (model.usePUT || (model.collection && model.collection.usePUT))) {