Browse Source

- 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
pull/5/head
Jaussoin Timothée 14 years ago
parent
commit
0449a4fad8
  1. 58
      system/Jabber.php
  2. 1
      system/Widget/widgets/Feed/Feed.php
  3. 35
      system/Widget/widgets/Logout/Logout.php
  4. 2
      system/Widget/widgets/Logout/logout.css
  5. 24
      system/Widget/widgets/Profile/Profile.php
  6. 1
      system/Widget/widgets/Profile/profile.css
  7. 2
      themes/movim/css/style2.css

58
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);
}
}

1
system/Widget/widgets/Feed/Feed.php

@ -164,7 +164,6 @@ class Feed extends WidgetBase {
<div id="feedcontent">
<?php
var_dump(Cache::c('presence'.$this->user->getLogin()));
$query = ConfVar::query()
->where(array('login' => $this->user->getLogin()));
$conf = ConfVar::run_query($query);

35
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 .= '
<div id="logoutlist">
<a onclick="'.$this->genCallAjax('ajaxSetStatus', "':D'", "'online'").'; hideLogoutList();" class="online">'.$txt[1].'</a>
<a onclick="'.$this->genCallAjax('ajaxSetStatus', "':D'", "'away'").'; hideLogoutList();" class="away">'.$txt[2].'</a>
<a onclick="'.$this->genCallAjax('ajaxSetStatus', "':D'", "'dnd'").'; hideLogoutList();" class="dnd">'.$txt[3].'</a>
<a onclick="'.$this->genCallAjax('ajaxSetStatus', "':D'", "'xa'").'; hideLogoutList();" class="xa">'.$txt[4].'</a>
<a onclick="'.$this->genCallAjax('ajaxSetStatus', "'chat'").'; hideLogoutList();" class="online">'.$txt[1].'</a>
<a onclick="'.$this->genCallAjax('ajaxSetStatus', "'away'").'; hideLogoutList();" class="away">'.$txt[2].'</a>
<a onclick="'.$this->genCallAjax('ajaxSetStatus', "'dnd'").'; hideLogoutList();" class="dnd">'.$txt[3].'</a>
<a onclick="'.$this->genCallAjax('ajaxSetStatus', "'xa'").'; hideLogoutList();" class="xa">'.$txt[4].'</a>
<a onclick="'.$this->genCallAjax('ajaxLogout').'">'.$txt[5].'</a>
</div>
';
$presence = Cache::c('presence');
if($presence['boot'])
$html .= '<script type="text/javascript">setTimeout(\''.$this->genCallAjax('ajaxSetStatus', '"boot"').'\', 1500);</script>';
return $html;
}

2
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); }

24
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
</tr>
</table>
';
$html .= '<input type="text" id="status" value="'.$presence['status'].'"><br />';
$html .= '
<input
type="text"
id="status"
value="'.$presence['status'].'"
onkeypress="if(event.keyCode == 13) {'.$this->genCallAjax('ajaxSetStatus', 'this.value').' return false;}"
/>
<br />
';
}
return $html;

1
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 {

2
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 */

Loading…
Cancel
Save