From 729dffed5ec924492962a41b4697ca05ad40da79 Mon Sep 17 00:00:00 2001 From: kondou Date: Sat, 15 Mar 2014 15:27:48 +0100 Subject: [PATCH] Load avatar in header via PHP * fix #7484 * use UID, css, and div instead of span --- core/css/header.css | 2 ++ core/js/avatar.js | 10 ---------- core/templates/layout.user.php | 10 +++++++--- lib/private/helper.php | 15 +++++++++++++++ lib/private/templatelayout.php | 3 ++- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/core/css/header.css b/core/css/header.css index f83ef451ce6..33eb7e25cc6 100644 --- a/core/css/header.css +++ b/core/css/header.css @@ -239,6 +239,8 @@ display: inline-block; margin-right: 5px; cursor: pointer; + height: 32px; + width: 32px; } #header .avatardiv img { opacity: 1; diff --git a/core/js/avatar.js b/core/js/avatar.js index 6835f6ef0ac..8ff136d67ca 100644 --- a/core/js/avatar.js +++ b/core/js/avatar.js @@ -1,15 +1,5 @@ $(document).ready(function(){ if (OC.currentUser) { - var callback = function() { - // do not show display name on mobile when profile picture is present - if($('#header .avatardiv').children().length > 0) { - $('#header .avatardiv').addClass('avatardiv-shown'); - } - }; - - $('#header .avatardiv').avatar( - OC.currentUser, 32, undefined, true, callback - ); // Personal settings $('#avatar .avatardiv').avatar(OC.currentUser, 128); } diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 9445175efcf..09630435b77 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -65,13 +65,17 @@
- +
-
+ - +
    diff --git a/lib/private/helper.php b/lib/private/helper.php index 823e82ceeb1..628af14fa08 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -279,6 +279,21 @@ class OC_Helper { return self::linkToRoute( 'core_ajax_public_preview', array('x' => 36, 'y' => 36, 'file' => $path, 't' => $token)); } + /** + * shows whether the user has an avatar + * @param string $user username + * @return bool avatar set or not + **/ + public static function userAvatarSet($user) { + $avatar = new \OC_Avatar($user); + $image = $avatar->get(1); + if ($image instanceof \OC_Image) { + return true; + } else { + return false; + } + } + /** * Make a human file size * @param int $bytes file size in bytes diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index f5f079c8b2a..cbaadd5768f 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -76,6 +76,7 @@ class OC_TemplateLayout extends OC_Template { $this->assign( 'user_uid', OC_User::getUser() ); $this->assign( 'appsmanagement_active', strpos(OC_Request::requestUri(), OC_Helper::linkToRoute('settings_apps')) === 0 ); $this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true)); + $this->assign('userAvatarSet', \OC_Helper::userAvatarSet(OC_User::getUser())); } else if ($renderAs == 'error') { parent::__construct('core', 'layout.guest', '', false); $this->assign('bodyid', 'body-login'); @@ -89,7 +90,7 @@ class OC_TemplateLayout extends OC_Template { if(empty(self::$versionHash)) { self::$versionHash = md5(implode(',', OC_App::getAppVersions())); } - + $useAssetPipeline = self::isAssetPipelineEnabled(); if ($useAssetPipeline) { $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash))); -- 2.39.5