summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/js/js.js32
-rw-r--r--core/js/oc-backbone-webdav.js24
-rw-r--r--core/shipped.json1
-rw-r--r--core/templates/layout.user.php2
-rw-r--r--core/vendor/davclient.js/lib/client.js31
5 files changed, 67 insertions, 23 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))) {
diff --git a/core/shipped.json b/core/shipped.json
index 5dd8700bf1a..5f995326625 100644
--- a/core/shipped.json
+++ b/core/shipped.json
@@ -3,6 +3,7 @@
"activity",
"admin_audit",
"encryption",
+ "comments",
"dav",
"enterprise_key",
"external",
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index 7fe67159bb5..7905f5b7f3a 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -2,7 +2,7 @@
<!--[if lte IE 8]><html class="ng-csp ie ie8 lte9 lte8" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><![endif]-->
<!--[if IE 9]><html class="ng-csp ie ie9 lte9" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="ng-csp" data-placeholder-focus="false" lang="<?php p($_['language']); ?>" ><!--<![endif]-->
- <head data-user="<?php p($_['user_uid']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>"
+ <head data-user="<?php p($_['user_uid']); ?>" data-user-displayname="<?php p($_['user_displayname']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>"
<?php if ($_['updateAvailable']): ?>
data-update-version="<?php p($_['updateVersion']); ?>" data-update-link="<?php p($_['updateLink']); ?>"
<?php endif; ?>
diff --git a/core/vendor/davclient.js/lib/client.js b/core/vendor/davclient.js/lib/client.js
index 1a73c7db020..89c11516a38 100644
--- a/core/vendor/davclient.js/lib/client.js
+++ b/core/vendor/davclient.js/lib/client.js
@@ -1,17 +1,17 @@
if (typeof dav == 'undefined') { dav = {}; };
dav._XML_CHAR_MAP = {
- '<': '&lt;',
- '>': '&gt;',
- '&': '&amp;',
- '"': '&quot;',
- "'": '&apos;'
+ '<': '&lt;',
+ '>': '&gt;',
+ '&': '&amp;',
+ '"': '&quot;',
+ "'": '&apos;'
};
dav._escapeXml = function(s) {
- return s.replace(/[<>&"']/g, function (ch) {
- return dav._XML_CHAR_MAP[ch];
- });
+ return s.replace(/[<>&"']/g, function (ch) {
+ return dav._XML_CHAR_MAP[ch];
+ });
};
dav.Client = function(options) {
@@ -79,17 +79,16 @@ dav.Client.prototype = {
return this.request('PROPFIND', url, headers, body).then(
function(result) {
- var resultBody = this.parseMultiStatus(result.body);
if (depth===0) {
return {
status: result.status,
- body: resultBody[0],
+ body: result.body[0],
xhr: result.xhr
};
} else {
return {
status: result.status,
- body: resultBody,
+ body: result.body,
xhr: result.xhr
};
}
@@ -161,6 +160,7 @@ dav.Client.prototype = {
*/
request : function(method, url, headers, body) {
+ var self = this;
var xhr = this.xhrProvider();
if (this.userName) {
@@ -182,8 +182,13 @@ dav.Client.prototype = {
return;
}
+ var resultBody = xhr.response;
+ if (xhr.status === 207) {
+ resultBody = self.parseMultiStatus(xhr.response);
+ }
+
fulfill({
- body: xhr.response,
+ body: resultBody,
status: xhr.status,
xhr: xhr
});
@@ -238,7 +243,7 @@ dav.Client.prototype = {
}
}
- return content || propNode.textContent || propNode.text;
+ return content || propNode.textContent || propNode.text || '';
},
/**