| 1 |
<?php |
<?php |
| 2 |
// $Id: foaf.module,v 1.5 2004/11/04 14:58:30 walkah Exp $ |
// $Id: foaf.module,v 1.4.2.2 2004/11/04 15:02:00 walkah Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implements hook_help |
* Implements hook_help |
| 85 |
} |
} |
| 86 |
|
|
| 87 |
function foaf_xmlrpc() { |
function foaf_xmlrpc() { |
| 88 |
return array('foaf.getUrl' => array('function' => 'foaf_get_url')); |
return array( |
| 89 |
|
array('foaf.getUrl', |
| 90 |
|
'foaf_get_url', |
| 91 |
|
array('string', 'string'), |
| 92 |
|
t('returns the FOAF url for a user'))); |
| 93 |
} |
} |
| 94 |
|
|
| 95 |
function foaf_export($uid = null) { |
function foaf_export($uid = null) { |
| 287 |
if (!$user->foaf_url) { |
if (!$user->foaf_url) { |
| 288 |
if ($server = strrchr($user->name, '@')) { |
if ($server = strrchr($user->name, '@')) { |
| 289 |
$name = substr($user->name, 0, strlen($user->name) - strlen($server)); |
$name = substr($user->name, 0, strlen($user->name) - strlen($server)); |
| 290 |
$server = substr($server, 1); |
$server = substr($server, 1); |
| 291 |
} |
} |
| 292 |
else { |
else { |
| 293 |
return; |
return; |
| 294 |
} |
} |
| 295 |
|
|
| 296 |
// send an xmlrpc message to the server to get a full foaf url |
// send an xmlrpc message to the server to get a full foaf url |
| 297 |
$message = new xmlrpcmsg('foaf.getUrl', array(new xmlrpcval($name, 'string'))); |
$result = xmlrpc($server, 'foaf.getUrl', $user->name); |
| 298 |
$client = new xmlrpc_client('/xmlrpc.php', $server, 80); |
if ($result !== FALSE) { |
| 299 |
$result = $client->send($message, 5); |
$user->foaf_url = $result; |
|
if ($result && !$result->faultCode()) { |
|
|
$value = $result->value(); |
|
|
$user->foaf_url = $value->scalarval(); |
|
| 300 |
} |
} |
| 301 |
} |
} |
| 302 |
|
|
| 306 |
/** |
/** |
| 307 |
* XML-RPC function to return the FOAF url for a user |
* XML-RPC function to return the FOAF url for a user |
| 308 |
*/ |
*/ |
| 309 |
function foaf_get_url($params) { |
function foaf_get_url($username) { |
|
$param = $params->getparam(0); |
|
|
$username = $param->scalarval(); |
|
|
|
|
| 310 |
if ($user = user_load(array('name' => $username, 'status' => 1))) { |
if ($user = user_load(array('name' => $username, 'status' => 1))) { |
| 311 |
return new xmlrpcresp(new xmlrpcval(url('foaf/'.$user->uid, null,null, true))); |
return url('foaf/'.$user->uid, null,null, true); |
| 312 |
} |
} |
| 313 |
} |
} |
| 314 |
|
|