diff options
-rw-r--r-- | core/css/styles.css | 5 | ||||
-rw-r--r-- | core/templates/layout.user.php | 4 | ||||
-rw-r--r-- | lib/templatelayout.php | 2 | ||||
-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 | ||||
-rw-r--r-- | tests/lib/avatar.php | 2 |
10 files changed, 44 insertions, 21 deletions
diff --git a/core/css/styles.css b/core/css/styles.css index 367f3f7ca41..792ccb08329 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -40,6 +40,11 @@ body { background:#fefefe; font:normal .8em/1.6em "Helvetica Neue",Helvetica,Ari .header-right { float:right; vertical-align:middle; padding:0.5em; } .header-right > * { vertical-align:middle; } +header .avatar { + float:right; + margin-top: 6px; + margin-right: 6px; +} /* INPUTS */ input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="email"], input[type="url"], diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 038264bd064..0ab6a4dc08b 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -45,9 +45,11 @@ <a href="<?php print_unescaped(link_to('', 'index.php')); ?>" title="" id="owncloud"><img class="svg" src="<?php print_unescaped(image_path('', 'logo-wide.svg')); ?>" alt="<?php p($theme->getName()); ?>" /></a> <div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div> + + <?php if (isset($_['avatar'])) { print_unescaped($_['avatar']); } ?> + <ul id="settings" class="svg"> <span id="expand" tabindex="0" role="link"> - <?php if (isset($_['avatar'])) { print_unescaped($_['avatar']); } ?> <span id="expandDisplayName"><?php p(trim($_['user_displayname']) != '' ? $_['user_displayname'] : $_['user_uid']) ?></span> <img class="svg" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /> </span> diff --git a/lib/templatelayout.php b/lib/templatelayout.php index f24cd9cfd9e..c26dff4176c 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -20,7 +20,7 @@ class OC_TemplateLayout extends OC_Template { // display avatars if they are enabled if (OC_Config::getValue('avatar') === 'gravatar' || OC_Config::getValue('avatar', 'local') === 'local') { - $this->assign('avatar', '<img src="'.OC_Avatar::get(OC_User::getUser(), 32).'">'); + $this->assign('avatar', '<img class="avatar" src="'.link_to('', 'avatar.php').'?user='.OC_User::getUser().'&size=32">'); } // Update notification 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> diff --git a/tests/lib/avatar.php b/tests/lib/avatar.php index b1d9f46ed09..551e4e4ec46 100644 --- a/tests/lib/avatar.php +++ b/tests/lib/avatar.php @@ -13,7 +13,7 @@ class Test_Avatar extends PHPUnit_Framework_TestCase { \OC_Config::setValue('avatar', 'local'); $this->assertEquals('local', \OC_Avatar::getMode()); - + \OC_Config::setValue('avatar', 'gravatar'); $this->assertEquals('gravatar', \OC_Avatar::getMode()); |