| 1 |
<?php |
<?php |
| 2 |
// $Id: xmpp_roster.module,v 1.2 2008/09/25 08:23:38 t0talmeltd0wn Exp $ |
// $Id: xmpp_roster.module,v 1.3 2008/09/25 21:55:22 t0talmeltd0wn Exp $ |
| 3 |
|
|
| 4 |
define("XMPP_ROSTER_NONE", 0); |
define("XMPP_ROSTER_NONE", 0); |
| 5 |
define("XMPP_ROSTER_SUBSCRIBED", 1); |
define("XMPP_ROSTER_SUBSCRIBED", 1); |
| 7 |
|
|
| 8 |
/* ==== Below are hook implementations ==== */ |
/* ==== Below are hook implementations ==== */ |
| 9 |
|
|
| 10 |
|
/* |
| 11 |
|
* Implementation of hook_views_api(). |
| 12 |
|
* Maybe will be implemented someday when views makes sense to me. |
| 13 |
|
*/ |
| 14 |
|
/*function xmpp_roster_views_api() { |
| 15 |
|
return array( |
| 16 |
|
'api' => 2.0, |
| 17 |
|
); |
| 18 |
|
}*/ |
| 19 |
|
|
| 20 |
/** |
/** |
| 21 |
* Implementation of hook_xmpp_disco_features(). |
* Implementation of hook_xmpp_disco_features(). |
| 22 |
*/ |
*/ |
| 53 |
_xmpp_send_to_subscribers($session, $node); |
_xmpp_send_to_subscribers($session, $node); |
| 54 |
} |
} |
| 55 |
|
|
| 56 |
function xmpp_roster_xmpp_client_close($client) { |
function xmpp_roster_xmpp_server_client_close($client) { |
| 57 |
$session = xmpp_server_get_session($client); |
$session = xmpp_server_get_session($client); |
| 58 |
|
|
| 59 |
$presence = new XmlNode(); |
$presence = new XmlNode(); |
| 459 |
$i->options['subscription'] = $f->subscription; |
$i->options['subscription'] = $f->subscription; |
| 460 |
} |
} |
| 461 |
|
|
| 462 |
if (_xmpp_roster_fetch_subscription_state($f->uid, $f->fid)) { |
if (_xmpp_roster_fetch_subscription_state($f->uid, $f->fid) == XMPP_ROSTER_SUBSCRIPTION_PENDING) { |
| 463 |
$i->options['ask'] = 'subscribe'; |
$i->options['ask'] = 'subscribe'; |
| 464 |
} |
} |
| 465 |
|
|
| 477 |
} |
} |
| 478 |
|
|
| 479 |
function _xmpp_send_to_subscribers(&$session, $node) { |
function _xmpp_send_to_subscribers(&$session, $node) { |
| 480 |
if (is_object($node)) { |
if (!is_object($node)) { |
| 481 |
$node = (object)$node; |
$node = (object)$node; |
| 482 |
} |
} |
| 483 |
|
|
| 484 |
$res = db_query("SELECT uid FROM {xmpp_roster_presence |
$res = db_query("SELECT uid FROM {xmpp_roster_presence} |
| 485 |
WHERE fid=%d AND state=%d", |
WHERE fid=%d AND state=%d", |
| 486 |
$session['uid'], XMPP_ROSTER_SUBSCRIBED); |
$session['uid'], XMPP_ROSTER_SUBSCRIBED); |
| 487 |
while($row = db_fetch_object($res)) { |
while($row = db_fetch_object($res)) { |