| 1 |
<?php |
<?php |
| 2 |
// $Id: foaf.module,v 1.6.2.1 2005/06/13 10:42:03 walkah Exp $ |
// $Id: foaf.module,v 1.6.2.2 2005/06/14 22:36:17 walkah Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implements hook_help |
* Implements hook_help |
| 100 |
} |
} |
| 101 |
|
|
| 102 |
function foaf_xmlrpc() { |
function foaf_xmlrpc() { |
| 103 |
return array('foaf.getUrl' => array('function' => 'foaf_get_url')); |
return array( |
| 104 |
|
array('foaf.getUrl', |
| 105 |
|
'foaf_get_url', |
| 106 |
|
array('string', 'string'), |
| 107 |
|
t('returns the FOAF url for a user'))); |
| 108 |
} |
} |
| 109 |
|
|
| 110 |
function foaf_export($uid = null) { |
function foaf_export($uid = null) { |
| 305 |
if (!$user->foaf_url) { |
if (!$user->foaf_url) { |
| 306 |
if ($server = strrchr($user->name, '@')) { |
if ($server = strrchr($user->name, '@')) { |
| 307 |
$name = substr($user->name, 0, strlen($user->name) - strlen($server)); |
$name = substr($user->name, 0, strlen($user->name) - strlen($server)); |
| 308 |
$server = substr($server, 1); |
$server = substr($server, 1); |
| 309 |
} |
} |
| 310 |
else { |
else { |
| 311 |
return; |
return; |
| 312 |
} |
} |
| 313 |
|
|
| 314 |
// 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 |
| 315 |
$message = new xmlrpcmsg('foaf.getUrl', array(new xmlrpcval($name, 'string'))); |
$result = xmlrpc($server, 'foaf.getUrl', $user->name); |
| 316 |
$client = new xmlrpc_client('/xmlrpc.php', $server, 80); |
if ($result !== FALSE) { |
| 317 |
$result = $client->send($message, 5); |
$user->foaf_url = $result; |
|
if ($result && !$result->faultCode()) { |
|
|
$value = $result->value(); |
|
|
$user->foaf_url = $value->scalarval(); |
|
| 318 |
} |
} |
| 319 |
} |
} |
| 320 |
|
|
| 324 |
/** |
/** |
| 325 |
* XML-RPC function to return the FOAF url for a user |
* XML-RPC function to return the FOAF url for a user |
| 326 |
*/ |
*/ |
| 327 |
function foaf_get_url($params) { |
function foaf_get_url($username) { |
|
$param = $params->getparam(0); |
|
|
$username = $param->scalarval(); |
|
|
|
|
| 328 |
if ($user = user_load(array('name' => $username, 'status' => 1))) { |
if ($user = user_load(array('name' => $username, 'status' => 1))) { |
| 329 |
return new xmlrpcresp(new xmlrpcval(url('foaf/'.$user->uid, null,null, true))); |
return url('foaf/'.$user->uid, null,null, true); |
| 330 |
} |
} |
| 331 |
} |
} |
| 332 |
|
|