/[drupal]/contributions/modules/foaf/foaf.module
ViewVC logotype

Diff of /contributions/modules/foaf/foaf.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4.2.2, Thu Nov 4 15:02:00 2004 UTC revision 1.4.2.3, Thu Aug 18 03:17:19 2005 UTC
# Line 1  Line 1 
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
# Line 85  function foaf_settings() { Line 85  function foaf_settings() {
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) {
# Line 283  function foaf_login($user) { Line 287  function foaf_login($user) {
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    
# Line 305  function foaf_login($user) { Line 306  function foaf_login($user) {
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    

Legend:
Removed from v.1.4.2.2  
changed lines
  Added in v.1.4.2.3

  ViewVC Help
Powered by ViewVC 1.1.2