diff options
author | kondou <kondou@ts.unde.re> | 2013-08-02 08:03:51 +0200 |
---|---|---|
committer | kondou <kondou@ts.unde.re> | 2013-08-25 21:04:45 +0200 |
commit | 252548c62cf099e5186ffc323e3cf9494fae3768 (patch) | |
tree | 9336f2a84a7059e98385e13080485d43fe46f461 /settings | |
parent | a58d270684110334aab1b296b69e98def6cc6558 (diff) | |
download | nextcloud-server-252548c62cf099e5186ffc323e3cf9494fae3768.tar.gz nextcloud-server-252548c62cf099e5186ffc323e3cf9494fae3768.zip |
Improve styling & enable avatar-upload at personal page
Diffstat (limited to 'settings')
-rw-r--r-- | settings/ajax/newavatar.php | 15 | ||||
-rw-r--r-- | settings/css/settings.css | 3 | ||||
-rw-r--r-- | settings/js/personal.js | 8 | ||||
-rw-r--r-- | settings/personal.php | 3 | ||||
-rw-r--r-- | settings/templates/admin.php | 21 | ||||
-rw-r--r-- | settings/templates/personal.php | 2 |
6 files changed, 34 insertions, 18 deletions
diff --git a/settings/ajax/newavatar.php b/settings/ajax/newavatar.php index 4c8ff0c4169..bede15e499d 100644 --- a/settings/ajax/newavatar.php +++ b/settings/ajax/newavatar.php @@ -13,12 +13,19 @@ if(isset($_POST['path'])) { \OC_Avatar::setLocalAvatar($user, $path); OC_JSON::success(); } catch (Exception $e) { - OC_JSON::error(); + OC_JSON::error(array("msg" => $e->getMessage())); } } -} elseif (isset($_POST['image'])) { // upload a new image - \OC_Avatar::setLocalAvatar($user, $_POST['image']); - OC_JSON::success(); +} elseif (!empty($_FILES)) { // upload a new image + $files = $_FILES['files']; + if ($files['error'][0] === 0) { + $data = file_get_contents($files['tmp_name'][0]); + \OC_Avatar::setLocalAvatar($user, $data); + unlink($files['tmp_name'][0]); + OC_JSON::success(); + } else { + OC_JSON::error(); + } } else { OC_JSON::error(); } diff --git a/settings/css/settings.css b/settings/css/settings.css index d5ffe448482..e6ced0e375a 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -35,6 +35,9 @@ td.name, td.password { padding-left:.8em; } 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>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; } tr:hover>td.password>span, tr:hover>td.displayName>span { margin:0; cursor:pointer; } diff --git a/settings/js/personal.js b/settings/js/personal.js index fdaca07e98d..71b4785bbf2 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -144,6 +144,14 @@ $(document).ready(function(){ updateAvatar(); }); + var uploadparms = { + done: function(e) { + updateAvatar(); + } + }; + + $('#uploadavatar').fileupload(uploadparms); + $('#selectavatar').click(function(){ OC.dialogs.filepicker(t('settings', "Select an avatar"), selectAvatar, false, "image"); }); diff --git a/settings/personal.php b/settings/personal.php index 4bec21d58c8..233b1440eb2 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -15,6 +15,9 @@ OC_Util::addScript( 'settings', 'personal' ); OC_Util::addStyle( 'settings', 'settings' ); OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' ); OC_Util::addStyle( '3rdparty', 'chosen' ); +if (OC_Config::getValue('avatar', 'local') === 'local') { + \OC_Util::addScript('files', 'jquery.fileupload'); +} OC_App::setActiveNavigationEntry( 'personal' ); $storageInfo=OC_Helper::getStorageInfo(); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index e5b941f2b2f..f7d6a576d9e 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -121,10 +121,9 @@ if (!$_['internetconnectionworking']) { <table class="nostyle"> <tr> <td> - <input type="radio" name="avatarmode" value="gravatar" - id="avatar_gravatar" <?php if ($_['avatar'] === "gravatar") { - print_unescaped('checked="checked"'); - } ?>> + <input type="radio" name="avatarmode" value="gravatar" id="avatar_gravatar" + <?php if ($_['avatar'] === "gravatar") { p('checked'); } ?> + <?php if (!$_['internetconnectionworking']) { p('disabled'); } ?>> <label for="avatar_gravatar">Gravatar</label><br> <em><?php print_unescaped($l->t('Use <a href="http://gravatar.com/">gravatar</a> for avatars')); ?></em><br> <em><?php p($l->t('This sends data to gravatar')); ?></em> @@ -135,22 +134,18 @@ if (!$_['internetconnectionworking']) { </tr> <tr> <td> - <input type="radio" name="avatarmode" value="local" - id="avatar_local" <?php if ($_['avatar'] === "local") { - print_unescaped('checked="checked"'); - } ?>> + <input type="radio" name="avatarmode" value="local" id="avatar_local" + <?php if ($_['avatar'] === "local") { p('checked'); } ?>> <label for="avatar_local"><?php p($l->t('Local avatars')); ?></label><br> <em><?php p($l->t('Use local avatars, which each user has to upload themselves')); ?></em> </td> </tr> <tr> <td> - <input type="radio" name="avatarmode" value="none" - id="avatar_none" <?php if ($_['avatar'] === "none") { - print_unescaped('checked="checked"'); - } ?>> + <input type="radio" name="avatarmode" value="none" id="avatar_none" + <?php if ($_['avatar'] === "none") { p('checked'); } ?>> <label for="avatar_none"><?php p($l->t('No avatars')); ?></label><br> - <em><?php print_unescaped($l->t('Do not provide avatars')); ?></em> + <em><?php p($l->t('Do not provide avatars')); ?></em> </td> </tr> </table> diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 01415a6f9a1..e0e91cb7de4 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -87,7 +87,7 @@ if($_['passwordChangeSupported']) { <form id="avatar"> <fieldset class="personalblock"> <legend><strong><?php p($l->t('Avatar')); ?></strong></legend> - <img src="<?php print_unescaped(\OC_Avatar::get(\OC_User::getUser(), 128)); ?>"><br> + <img src="<?php print_unescaped(link_to('', 'avatar.php').'?user='.OC_User::getUser().'&size=128'); ?>"><br> <em><?php p($l->t('Your avatar has to be a square and either a PNG or JPG image')); ?></em><br> <div class="inlineblock button" id="uploadavatar"><?php p($l->t('Upload a new avatar')); ?></div> <div class="inlineblock button" id="selectavatar"><?php p($l->t('Select a new avatar from your files')); ?></div> |