/[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.6.2.2, Tue Jun 14 22:36:17 2005 UTC revision 1.6.2.3, Thu Aug 18 03:17:04 2005 UTC
# Line 1  Line 1 
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
# Line 100  function foaf_settings() { Line 100  function foaf_settings() {
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) {
# Line 301  function foaf_login($user) { Line 305  function foaf_login($user) {
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    
# Line 323  function foaf_login($user) { Line 324  function foaf_login($user) {
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    

Legend:
Removed from v.1.6.2.2  
changed lines
  Added in v.1.6.2.3

  ViewVC Help
Powered by ViewVC 1.1.2