From 0449a4fad8c841dfe0df657c13d886b7ade7b21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaussoin=20Timoth=C3=A9e?= Date: Wed, 28 Mar 2012 23:14:50 +0200 Subject: [PATCH] - Fix a little CSS bug on the logout button - Clean Jabber - Save the status/show in the cache to handle it, reload them on the reconnection --- system/Jabber.php | 58 +++++------------------ system/Widget/widgets/Feed/Feed.php | 1 - system/Widget/widgets/Logout/Logout.php | 35 +++++++++++--- system/Widget/widgets/Logout/logout.css | 2 +- system/Widget/widgets/Profile/Profile.php | 24 ++++++++-- system/Widget/widgets/Profile/profile.css | 1 + themes/movim/css/style2.css | 2 +- 7 files changed, 66 insertions(+), 57 deletions(-) diff --git a/system/Jabber.php b/system/Jabber.php index b98df0697..74c4fcec7 100644 --- a/system/Jabber.php +++ b/system/Jabber.php @@ -146,25 +146,7 @@ class Jabber $this->jaxl->startCore('bosh'); } - - - /*if($presence != false && $presence['presence'] != null && $presence['presence'] != '') { - movim_log($presence); - $show = $presence['status']; - } else { - $show = 'Online using Movim'; - }*/ - - self::setStatus('Online using Movim', false, false, true); - - $presence = Cache::c('presence'.$this->getCleanJid()); - $status = $presence['status']; - movim_log($presence); - /*if($presence != false && $presence['presence'] != null && $presence['presence'] != '') { - movim_log($presence); - self::setStatus($presence['status'], false, false, true); - }*/ - self::setStatus($status, false, false, true); + self::setStatus(t('Connecting...'), false, false, true); } /** @@ -471,23 +453,24 @@ class Jabber $evt = new Event(); foreach($payloads as $payload) { - if($payload['movim']['@attributes']['type'] == 'subscribe') { + $payload = $payload['movim']; + if($payload['@attributes']['type'] == 'subscribe') { $evt->runEvent('subscribe', $payload); - } elseif($payload['movim']['@attributes']['type'] == 'result') { + } elseif($payload['@attributes']['type'] == 'result') { - } elseif(in_array($payload['movim']['@attributes']['type'], array('available', 'unavailable', '', 'error'))) { + } elseif(in_array($payload['@attributes']['type'], array('available', 'unavailable', '', 'error'))) { // We update the presences - list($jid, $ressource) = explode('/',$payload['movim']['@attributes']['from']); + list($jid, $ressource) = explode('/',$payload['@attributes']['from']); // We ask for the entity-capabilities - if(isset($payload['movim']['c'])) { + if(isset($payload['c'])) { $this->jaxl->JAXL0030( 'discoInfo', - $payload['movim']['@attributes']['from'], + $payload['@attributes']['from'], $this->jaxl->jid, false, - $payload['movim']['c']['@attributes']['node'].'#'.$payload['movim']['c']['@attributes']['ver'] + $payload['c']['@attributes']['node'].'#'.$payload['c']['@attributes']['ver'] ); } @@ -498,7 +481,7 @@ class Jabber )); if($presence == false) { $presence = new Presence(); - $presence->setPresence($payload['movim']); + $presence->setPresence($payload); $sdb->save($presence); } else { $presence = new Presence(); @@ -507,28 +490,13 @@ class Jabber 'jid' => $jid, 'ressource' => $ressource )); - $presence->setPresence($payload['movim']); + $presence->setPresence($payload); $sdb->save($presence); } - if($payload['movim']['@attributes']['from'] == $payload['movim']['@attributes']['to']) { - // We update the cache with our status and presence - if( - isset($payload['movim']['show']) && - isset($payload['movim']['status']) && - $payload['movim']['show'] != null - //in_array($payload['movim']['show'], array('away','dnd','xa', 'chat')) - ) { - Cache::c( - 'presence'.$this->getCleanJid(), - array( - 'presence' => $payload['movim']['show'], - 'status' => $payload['movim']['status'] - ) - ); - } + if($payload['@attributes']['from'] == $payload['@attributes']['to']) $evt->runEvent('mypresence', $presence); - } + $evt->runEvent('presence', $presence); } } diff --git a/system/Widget/widgets/Feed/Feed.php b/system/Widget/widgets/Feed/Feed.php index 86c385c6b..c9cb13bd2 100644 --- a/system/Widget/widgets/Feed/Feed.php +++ b/system/Widget/widgets/Feed/Feed.php @@ -164,7 +164,6 @@ class Feed extends WidgetBase {
user->getLogin())); $query = ConfVar::query() ->where(array('login' => $this->user->getLogin())); $conf = ConfVar::run_query($query); diff --git a/system/Widget/widgets/Logout/Logout.php b/system/Widget/widgets/Logout/Logout.php index e49a87844..021e24b9b 100644 --- a/system/Widget/widgets/Logout/Logout.php +++ b/system/Widget/widgets/Logout/Logout.php @@ -45,12 +45,32 @@ class Logout extends WidgetBase function ajaxLogout() { + $presence = Cache::c('presence'); + Cache::c( + 'presence', + array( + 'status' => $presence['status'], + 'show' => $presence['show'], + 'boot' => true + ) + ); $this->xmpp->logout(); } - function ajaxSetStatus($statustext, $status) + function ajaxSetStatus($show) { - $this->xmpp->setStatus($statustext, $status); + // We update the cache with our status and presence + $presence = Cache::c('presence'); + if($show == "boot") $show = $presence['show']; + Cache::c( + 'presence', + array( + 'status' => $presence['status'], + 'show' => $show, + 'boot' => false + ) + ); + $this->xmpp->setStatus($presence['status'], $show); } function preparePresence() @@ -72,13 +92,16 @@ class Logout extends WidgetBase $html .= ' '; + $presence = Cache::c('presence'); + if($presence['boot']) + $html .= ''; return $html; } diff --git a/system/Widget/widgets/Logout/logout.css b/system/Widget/widgets/Logout/logout.css index 5ed9631e0..704439f8a 100644 --- a/system/Widget/widgets/Logout/logout.css +++ b/system/Widget/widgets/Logout/logout.css @@ -18,7 +18,7 @@ } #logouttab:hover { - background-color: #6F6F6F; + background-color: rgba(255, 255, 255, 0.3); } #logouttab.online { background-image: url(img/online.png); } diff --git a/system/Widget/widgets/Profile/Profile.php b/system/Widget/widgets/Profile/Profile.php index 3aa1b6644..865efb868 100644 --- a/system/Widget/widgets/Profile/Profile.php +++ b/system/Widget/widgets/Profile/Profile.php @@ -36,9 +36,19 @@ class Profile extends WidgetBase RPC::call('movim_fill', 'profile', RPC::cdata($html)); } - function ajaxSetStatus($statustext, $status) + function ajaxSetStatus($status) { - $this->xmpp->setStatus($statustext, $status); + // We update the cache with our status and presence + $presence = Cache::c('presence'); + Cache::c( + 'presence', + array( + 'status' => $status, + 'show' => $presence['show'], + 'boot' => false + ) + ); + $this->xmpp->setStatus($status, $presence['show']); } function prepareVcard($vcard = false) @@ -62,7 +72,15 @@ class Profile extends WidgetBase '; - $html .= '
'; + $html .= ' + +
+ '; } return $html; diff --git a/system/Widget/widgets/Profile/profile.css b/system/Widget/widgets/Profile/profile.css index 2aac36538..82b554188 100644 --- a/system/Widget/widgets/Profile/profile.css +++ b/system/Widget/widgets/Profile/profile.css @@ -26,6 +26,7 @@ margin-bottom: 10px; border: 1px solid transparent; text-align: center; + width: 80%; } #profile #status:hover { diff --git a/themes/movim/css/style2.css b/themes/movim/css/style2.css index 4accd2094..4ef277eb5 100644 --- a/themes/movim/css/style2.css +++ b/themes/movim/css/style2.css @@ -289,7 +289,7 @@ label { margin-top: 1px; } #nav .menu li:hover a { - background-color: #6F6F6F; + background-color: rgba(255, 255, 255, 0.3); } /* Warning */