Browse Source

- Add a isEmpty() method on the Contact model

- Use it in the Contact widget
pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
a7d592372d
  1. 13
      app/models/contact/Contact.php
  2. 21
      app/widgets/Chat/Chat.php
  3. 1
      app/widgets/Chats/Chats.php
  4. 2
      app/widgets/Contact/Contact.php

13
app/models/contact/Contact.php

@ -398,6 +398,19 @@ class Contact extends Model {
'value' => $this->value
);
}
function isEmpty() {
if($this->fn == null
&& $this->name == null
&& $this->date == null
&& $this->url == null
&& $this->email == null
&& $this->description == null) {
return true;
} else {
return false;
}
}
}
class PresenceContact extends Contact {

21
app/widgets/Chat/Chat.php

@ -16,8 +16,29 @@ class Chat extends WidgetCommon
$this->registerEvent('composing', 'onComposing');
$this->registerEvent('paused', 'onPaused');
$this->registerEvent('gone', 'onGone');
//$this->registerEvent('presence', 'onPresence');
}
/*
* Disabled for the moment, it SPAM a bit too much the user
function onPresence($packet)
{
$contacts = $packet->content;
if($contacts != null){
$contact = $contacts[0];
if($contact->value < 5) {
$avatar = $contact->getPhoto('s');
if($avatar == false) $avatar = null;
$presences = getPresences();
$presence = $presences[$contact->value];
Notification::append('presence', $contact->getTrueName(), $presence, $avatar, 4);
}
}
}*/
function onMessage($packet, $mine = false)
{
$message = $packet->content;

1
app/widgets/Chats/Chats.php

@ -11,7 +11,6 @@ class Chats extends WidgetCommon
$this->addjs('chats.js');
$this->registerEvent('carbons', 'onMessage');
$this->registerEvent('message', 'onMessage');
//$this->registerEvent('bookmark_set_handle', 'onBookmark');
$this->registerEvent('presence', 'onPresence', 'chat');
}

2
app/widgets/Contact/Contact.php

@ -147,7 +147,7 @@ class Contact extends WidgetCommon
$cd = new \Modl\ContactDAO;
$c = $cd->get($jid, true);
if($c == null || $c->created == null) {
if($c == null || $c->created == null || $c->isEmpty()) {
$c = new \Modl\Contact;
$c->jid = $jid;

Loading…
Cancel
Save