Skip to content
Snippets Groups Projects
Commit aa88eea9 authored by Christopher Schäpers's avatar Christopher Schäpers
Browse files

Sanitize displayname, respect data @ $element, fix routename, clean after...

Sanitize displayname, respect data @ $element, fix routename, clean after cropping, updateAvatar with displayname
parent 5d653753
No related branches found
No related tags found
No related merge requests found
...@@ -25,8 +25,8 @@ class OC_Core_Avatar_Controller { ...@@ -25,8 +25,8 @@ class OC_Core_Avatar_Controller {
$size = 64; $size = 64;
} }
$ava = new \OC_Avatar(); $avatar = new \OC_Avatar();
$image = $ava->get($user, $size); $image = $avatar->get($user, $size);
if ($image instanceof \OC_Image) { if ($image instanceof \OC_Image) {
$image->show(); $image->show();
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
if (typeof(size) === 'undefined') { if (typeof(size) === 'undefined') {
if (this.height() > 0) { if (this.height() > 0) {
size = this.height(); size = this.height();
} else if (this.data('size') > 0) {
size = this.data('size');
} else { } else {
size = 64; size = 64;
} }
...@@ -19,10 +21,17 @@ ...@@ -19,10 +21,17 @@
this.width(size); this.width(size);
if (typeof(user) === 'undefined') { if (typeof(user) === 'undefined') {
this.placeholder('x'); if (typeof(this.data('user')) !== 'undefined') {
return; user = this.data('user');
} else {
this.placeholder('x');
return;
}
} }
// sanitize
user = user.replace(/\//g,'');
var $div = this; var $div = this;
//$.get(OC.Router.generate('core_avatar_get', {user: user, size: size}), function(result) { // TODO does not work "Uncaught TypeError: Cannot use 'in' operator to search for 'core_avatar_get' in undefined" router.js L22 //$.get(OC.Router.generate('core_avatar_get', {user: user, size: size}), function(result) { // TODO does not work "Uncaught TypeError: Cannot use 'in' operator to search for 'core_avatar_get' in undefined" router.js L22
......
...@@ -59,8 +59,10 @@ $this->create('core_lostpassword_reset_password', '/lostpassword/reset/{token}/{ ...@@ -59,8 +59,10 @@ $this->create('core_lostpassword_reset_password', '/lostpassword/reset/{token}/{
->action('OC_Core_LostPassword_Controller', 'resetPassword'); ->action('OC_Core_LostPassword_Controller', 'resetPassword');
// Avatar routes // Avatar routes
$this->create('core_avatar_get_tmp', '/avatar/tmp')
->get()
->action('OC_Core_Avatar_Controller', 'getTmpAvatar');
$this->create('core_avatar_get', '/avatar/{user}/{size}') $this->create('core_avatar_get', '/avatar/{user}/{size}')
->defaults(array('user' => '', 'size' => 64))
->get() ->get()
->action('OC_Core_Avatar_Controller', 'getAvatar'); ->action('OC_Core_Avatar_Controller', 'getAvatar');
$this->create('core_avatar_post', '/avatar/') $this->create('core_avatar_post', '/avatar/')
...@@ -69,9 +71,6 @@ $this->create('core_avatar_post', '/avatar/') ...@@ -69,9 +71,6 @@ $this->create('core_avatar_post', '/avatar/')
$this->create('core_avatar_delete', '/avatar/') $this->create('core_avatar_delete', '/avatar/')
->delete() ->delete()
->action('OC_Core_Avatar_Controller', 'deleteAvatar'); ->action('OC_Core_Avatar_Controller', 'deleteAvatar');
$this->create('core_avatar_get_tmp', '/avatartmp/') //TODO better naming, so it doesn't conflict with core_avatar_get
->get()
->action('OC_Core_Avatar_Controller', 'getTmpAvatar');
$this->create('core_avatar_post_cropped', '/avatar/cropped') $this->create('core_avatar_post_cropped', '/avatar/cropped')
->post() ->post()
->action('OC_Core_Avatar_Controller', 'postCroppedAvatar'); ->action('OC_Core_Avatar_Controller', 'postCroppedAvatar');
......
...@@ -37,9 +37,6 @@ td.name, td.password { padding-left:.8em; } ...@@ -37,9 +37,6 @@ td.name, td.password { padding-left:.8em; }
td.password>img,td.displayName>img, td.remove>a, td.quota>img { visibility:hidden; } td.password>img,td.displayName>img, td.remove>a, td.quota>img { visibility:hidden; }
td.password, td.quota, td.displayName { width:12em; cursor:pointer; } td.password, td.quota, td.displayName { width:12em; cursor:pointer; }
td.password>span, td.quota>span, rd.displayName>span { margin-right: 1.2em; color: #C7C7C7; } td.password>span, td.quota>span, rd.displayName>span { margin-right: 1.2em; color: #C7C7C7; }
td.avatar img {
margin-top: 6px;
}
td.remove { width:1em; padding-right:1em; } td.remove { width:1em; padding-right:1em; }
tr:hover>td.password>span, tr:hover>td.displayName>span { margin:0; cursor:pointer; } tr:hover>td.password>span, tr:hover>td.displayName>span { margin:0; cursor:pointer; }
......
...@@ -34,6 +34,7 @@ function changeDisplayName(){ ...@@ -34,6 +34,7 @@ function changeDisplayName(){
$('#oldDisplayName').text($('#displayName').val()); $('#oldDisplayName').text($('#displayName').val());
// update displayName on the top right expand button // update displayName on the top right expand button
$('#expandDisplayName').text($('#displayName').val()); $('#expandDisplayName').text($('#displayName').val());
updateAvatar();
} }
else{ else{
$('#newdisplayname').val(data.data.displayName); $('#newdisplayname').val(data.data.displayName);
...@@ -82,7 +83,6 @@ function showAvatarCropper() { ...@@ -82,7 +83,6 @@ function showAvatarCropper() {
} }
function sendCropData() { function sendCropData() {
$('#cropperbox').ocdialog('close');
var cropperdata = $('#cropper').data(); var cropperdata = $('#cropper').data();
var data = { var data = {
x: cropperdata.x, x: cropperdata.x,
...@@ -90,6 +90,7 @@ function sendCropData() { ...@@ -90,6 +90,7 @@ function sendCropData() {
w: cropperdata.w, w: cropperdata.w,
h: cropperdata.h h: cropperdata.h
}; };
$('#cropperbox').remove();
$.post(OC.Router.generate('core_avatar_post_cropped'), {crop: data}, avatarResponseHandler); $.post(OC.Router.generate('core_avatar_post_cropped'), {crop: data}, avatarResponseHandler);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment