Browse Source

- Display more properly the contacts presence in ther Roster

- Clean the "Discussions" part of the Explore widget
- Clean some old code
pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
f22f8c4187
  1. 88
      app/models/contact/ContactDAO.php
  2. 3
      app/widgets/Chat/Chat.php
  3. 109
      app/widgets/Explore/Explore.php
  4. 32
      app/widgets/Roster/Roster.php
  5. 6
      system/Utils.php
  6. 5
      system/widget/WidgetWrapper.php
  7. 24
      tests/webrtc/script.js

88
app/models/contact/ContactDAO.php

@ -338,7 +338,7 @@ class ContactDAO extends ModlSQL {
left outer join contact
on rosterlink.jid = contact.jid
where rosterlink.session = :session
order by groupname';
order by groupname, rosterlink.jid, presence.value';
$this->prepare(
'RosterLink',
@ -362,7 +362,7 @@ class ContactDAO extends ModlSQL {
on rosterlink.jid = contact.jid
where rosterlink.session = :session
and rosterlink.chaton > 0
order by rosterlink.groupname, presence.value, rosterlink.jid';
order by rosterlink.groupname, rosterlink.jid, presence.value';
$this->prepare(
'RosterLink',
@ -374,22 +374,16 @@ class ContactDAO extends ModlSQL {
return $this->run('RosterContact');
}
function getRosterItem($jid) {
function getRosterItem($jid, $item = false) {
$this->_sql = '
select * from rosterlink
left outer join (
select * from presence
where session = :session
and jid = :jid
order by presence.value
limit 1
) as presence
on rosterlink.jid = presence.jid
left outer join contact
on rosterlink.jid = contact.jid
where rosterlink.session = :session
and rosterlink.jid = :jid
order by rosterlink.groupname, presence.value, rosterlink.jid';
select * from rosterlink
left outer join presence
on rosterlink.jid = presence.jid and rosterlink.session = presence.session
left outer join contact
on rosterlink.jid = contact.jid
where rosterlink.session = :session
and rosterlink.jid = :jid
order by groupname, rosterlink.jid, presence.value';
$this->prepare(
'RosterLink',
@ -399,63 +393,13 @@ class ContactDAO extends ModlSQL {
)
);
return $this->run('RosterContact', 'item');
if($item)
return $this->run('RosterContact');
else
return $this->run('RosterContact', 'item');
}
function getRosterSubscribe() {
/*$sql = '
select
RosterLink.jid,
contact.fn,
contact.nickname,
contact.name,
contact.phototype,
contact.photobin,
contact.loclatitude,
contact.loclongitude,
contact.localtitude,
contact.loccountry,
contact.loccountrycode,
contact.locregion,
contact.locpostalcode,
contact.loclocality,
contact.locstreet,
contact.locbuilding,
contact.loctext,
contact.locuri,
contact.loctimestamp,
contact.mood,
contact.tuneartist,
contact.tunelenght,
contact.tunerating,
contact.tunesource,
contact.tunetitle,
contact.tunetrack,
RosterLink.rostername,
RosterLink.group,
RosterLink.chaton,
Presence.status,
Presence.ressource,
Presence.presence,
Presence.delay,
Presence.last,
Presence.node,
Presence.ver
from RosterLink left outer join
(
select * from Presence
where Presence.key=\''.$this->_user.'\'
group by jid, node, ver
order by presence) as Presence
on Presence.jid = RosterLink.jid
left join contact on RosterLink.jid = contact.jid
where RosterLink.key=\''.$this->_user.'\'
and RosterLink.rosterask = \'subscribe\'
group by RosterLink.jid
order by RosterLink.groupname';
return $this->mapper('RosterContact', $this->_db->query($sql));*/
function getRosterSubscribe() {
return null;
}

3
app/widgets/Chat/Chat.php

@ -431,12 +431,11 @@ class Chat extends WidgetBase
// Zeu messages
$md = new \modl\MessageDAO();
$messages = $md->getContact($jid, 0, 10);
$messages = array_reverse($messages);
$messageshtml = '';
if(!empty($messages)) {
$messages = array_reverse($messages);
$day = '';
foreach($messages as $m) {
if($day != date('d',strtotime($m->published))) {

109
app/widgets/Explore/Explore.php

@ -36,80 +36,61 @@ class Explore extends WidgetCommon {
$html = '<ul class="list">';
$chatrooms = '';
$pubsubs = '';
foreach($servers as $s) {
list($type) = explode('.', $s->server);
switch ($type) {
case 'conference':
$cat = '<span class="tag green">'.t('Chatrooms').'</span>';
$cat = 'chatroom';
break;
case 'muc':
$cat = '<span class="tag green">'.t('Chatrooms').'</span>';
$cat = 'chatroom';
break;
case 'discussion':
$cat = '<span class="tag green">'.t('Chatrooms').'</span>';
$cat = 'chatroom';
break;
case 'pubsub':
$cat = '<span class="tag orange">'.t('Groups').'</span>';
$cat = 'pubsub';
break;
default:
$cat = '';
$cat = null;
break;
}
if(!filter_var($s->server, FILTER_VALIDATE_EMAIL)) {
$html .= '
<li>
<a href="'.Route::urlize('server', $s->server).'">'.
$cat.
$s->server. '
<span class="tag">'.$s->number.'</span>
</a>
</li>';
if(!filter_var($s->server, FILTER_VALIDATE_EMAIL) && isset($cat)) {
if($cat == 'chatroom') {
$chatrooms .= '
<li>
<a href="'.Route::urlize('server', $s->server).'">
<span class="tag green">'.t('Chatrooms').'</span>'.
$s->server. '
<span class="tag">'.$s->number.'</span>
</a>
</li>';
} elseif($cat == 'pubsub') {
$pubsubs .= '
<li>
<a href="'.Route::urlize('server', $s->server).'">
<span class="tag orange">'.t('Groups').'</span>'.
$s->server. '
<span class="tag">'.$s->number.'</span>
</a>
</li>';
}
}
}
$html .= $pubsubs.$chatrooms;
$html .= '</ul>';
return $html;
//var_dump($nd->getServers());
}
function prepareContacts($form = false) {
/*if(!$form){
$where = array('public' => 1);
}
else{
$where = array(
'public' => 1,
array(
'fn%' => '%'.$form['search'].'%',
'|jid%' => '%'.$form['search'].'%',
'|name%' => '%'.$form['search'].'%',
'|email%' => '%'.$form['search'].'%',
'|nickname%' => '%'.$form['search'].'%'
)
);
}
$users_limit = 20;
$gender = getGender();
$marital = getMarital();
$query = Contact::query()->select()
->where($where)
//s->orderby('id', true)
->limit(0, $users_limit);
$users = Contact::run_query($query);
$html = '
<div class="posthead">
<!--<ul class="filters">
<li class="on">'.t('Last registered').'</li>
</ul>-->
<div class="clear"></div>
</div>';*/
$html = '';
$cd = new \modl\ContactDAO();
@ -142,34 +123,4 @@ class Explore extends WidgetCommon {
return $html;
}
/*
function build()
{
?>
<div id="explore">
<!--<form name="searchform" style="margin: 1em 1.5em;" onsubmit="event.preventDefault();">
<div class="element" style="min-height: 0em;">
<input
id="addjid"
class="tiny"
name="search"
placeholder="<?php echo t('Search a contact'); ?>"
onkeypress="if(event.keyCode==13){<?php $this->callAjax("ajaxSearchContacts","movim_parse_form('searchform')"); ?>}"
/>
</div>
<div class="element" style="min-height: 0em; margin-top: 5px;">
<a
class="button icon submit"
href="#"
onclick="<?php $this->callAjax("ajaxSearchContacts","movim_parse_form('searchform')"); ?> "
style="">
<?php echo t('Search'); ?>
</a>
</div>
</form>-->
<?php
}
*/
}

32
app/widgets/Roster/Roster.php

@ -59,23 +59,28 @@ class Roster extends WidgetBase
$arr = $presence->getPresence();
$cd = new \modl\ContactDAO();
$c = $cd->getRosterItem($arr['jid']);
$c = $cd->getRosterItem($arr['jid'], true);
$caps = $this->getCaps();
if($c != null) {
$c->setPresence($presence);
$html = $this->prepareRosterElement($c, $this->getCaps());
if($c->groupname == null)
$group = t('Ungrouped');
else
$group = $c->groupname;
RPC::call(
foreach($c as $item) {
movim_log($item);
RPC::call(
'movim_delete',
'roster'.$arr['jid'].$arr['ressource'],
'roster'.$item->jid.$item->ressource,
$html /* this second parameter is just to bypass the RPC filter*/);
RPC::call('movim_append', 'group'.$group, $html);
$html = $this->prepareRosterElement($item, $caps);
if($item->groupname == null)
$group = t('Ungrouped');
else
$group = $item->groupname;
RPC::call('movim_append', 'group'.$group, $html);
}
RPC::call('sortRoster');
}
}
@ -143,6 +148,7 @@ class Roster extends WidgetBase
$html .= '
id="roster'.$contact->jid.$contact->ressource.'"
data-jid="'.$contact->jid.'"
data-priority="'.$contact->value.'"
>';
$html .= '<div class="chat on" onclick="'.$this->genCallWidget("Chat","ajaxOpenTalk", "'".$contact->jid."'").'"></div>';

6
system/Utils.php

@ -688,12 +688,12 @@ function generateUUID($string = false) {
function movim_log($log) {
//\system\Logs\Logger::log($log);
\system\Logs\Logger::log($log);
openlog('movim', LOG_NDELAY, LOG_USER);
/* openlog('movim', LOG_NDELAY, LOG_USER);
$errlines = explode("\n",$log);
foreach ($errlines as $txt) { syslog(LOG_DEBUG, $txt); }
closelog();
closelog();*/
}
/**

5
system/widget/WidgetWrapper.php

@ -174,7 +174,7 @@ class WidgetWrapper
foreach($widgets as $widget_name) {
$widget = $this->load_widget($widget_name);
// We save the registered events of the widget for the filter
if(isset($widget->events))
if(isset($widget->events)) {
foreach($widget->events as $key => $value) {
if(array_key_exists($key, $this->registered_events)) {
$we = $this->registered_events[$key];
@ -184,7 +184,8 @@ class WidgetWrapper
} else {
$this->registered_events[$key] = array($widget_name);
}
}
}
}
}
return $this->registered_events;

24
tests/webrtc/script.js

@ -40,14 +40,24 @@ function onError(err) {
}
function onOfferCreated(description) {
console.log(description);
offer = description;
pc.setLocalDescription(offer, onPc1LocalDescriptionSet, onError);
console.log(description);
offer = description;
pc.setLocalDescription(offer,onSetSessionDescriptionSuccess, onSetSessionDescriptionError);
sendMessage(offer);
}
function sendMessage(offer) {
var msgString = JSON.stringify(offer);
console.log('C->S: ' + msgString);
}
function onSetSessionDescriptionSuccess() {
console.log('Set session description success.');
}
function onPc1LocalDescriptionSet() {
// after this function returns, pc1 will start firing icecandidate events
//pc2.setRemoteDescription(offer, onPc2RemoteDescriptionSet, onError);
function onSetSessionDescriptionError(error) {
console.log('Failed to set session description: ' + error.toString());
}
function init() {
@ -75,7 +85,7 @@ function init() {
getUserMedia(
// Constraints
{
video: true
video: true, audio: true
},
// Success Callback

Loading…
Cancel
Save