| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: utility.php,v 1.1 2008/09/25 06:45:42 t0talmeltd0wn Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Loops through an array of objects or arrays looking for a match |
* Loops through an array of objects or arrays looking for a match |
| 59 |
* The JID object, consisting of 'name', 'domain' and, optionally, 'resource' |
* The JID object, consisting of 'name', 'domain' and, optionally, 'resource' |
| 60 |
* fields. |
* fields. |
| 61 |
* @param $bare |
* @param $bare |
| 62 |
* If true, do not append the resource to the JID. |
* If false, render the full JID. If true, do not append the resource to the |
| 63 |
|
* JID. Otherwise, append a wildcard resource identifier. |
| 64 |
* @return |
* @return |
| 65 |
* The JID, serialized into a string. |
* The JID, serialized into a string. |
| 66 |
*/ |
*/ |
| 67 |
function xmpp_serialize_jid($jid, $bare = false) { |
function xmpp_serialize_jid($jid, $bare = false) { |
| 68 |
if ($jid['resource'] && !$bare) { |
if ($jid['resource'] && $bare === false) { |
| 69 |
return "{$jid['name']}@{$jid['domain']}/{$jid['resource']}"; |
return "{$jid['name']}@{$jid['domain']}/{$jid['resource']}"; |
| 70 |
} |
} |
| 71 |
else { |
elseif ($bare === true) { |
| 72 |
return "{$jid['name']}@{$jid['domain']}"; |
return "{$jid['name']}@{$jid['domain']}"; |
| 73 |
|
} else { |
| 74 |
|
return "{$jid['name']}@{$jid['domain']}/*"; |
| 75 |
} |
} |
| 76 |
} |
} |
| 77 |
|
|