? foaf.d5_port.patch
Index: foaf.info
===================================================================
RCS file: foaf.info
diff -N foaf.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ foaf.info	9 Mar 2008 01:14:15 -0000
@@ -0,0 +1,4 @@
+; $Id$
+name = FOAF
+description = FOAF for Drupal
+dependencies = profile
Index: foaf.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/foaf/foaf.module,v
retrieving revision 1.13
diff -u -p -r1.13 foaf.module
--- foaf.module	12 Jul 2006 17:13:51 -0000	1.13
+++ foaf.module	9 Mar 2008 01:14:15 -0000
@@ -37,6 +37,17 @@ function foaf_menu($may_cache) {
                      'callback' => 'foaf_export',
                      'type' => MENU_CALLBACK);
   }
+  else {
+    $items[] = array(
+      'path' => 'admin/settings/foaf',
+      'title' => t('FOAF'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('foaf_settings'),
+      'access' => user_access('administer foaf'),
+      'type' => MENU_NORMAL_ITEM,
+    );
+    
+  }
   return $items;
 }
 
@@ -57,7 +68,8 @@ function foaf_user($op, &$edit, &$user, 
       drupal_set_html_head("\n".'<link rel="meta" type="application/rdf+xml" title="FOAF" href="'.url('foaf/'.$user->uid, NULL, NULL, TRUE).'" />');
       $output = '';
       if (_foaf_allow_export($user)) {
-          return array(t('Personal Information') => l(t('Download <acronym title="Friend of a Friend">FOAF</acronym>'), 'foaf/'.$user->uid, NULL, NULL, NULL, FALSE, TRUE));
+        //return array(t('Personal Information') => l(t('Download <acronym title="Friend of a Friend">FOAF</acronym>'), 'foaf/'.$user->uid, NULL, NULL, NULL, FALSE, TRUE));
+        return array(t('Personal Information') => array(0 => array(/*'title' => 'FOAF',*/ 'value' => l(t('Download <acronym title="Friend of a Friend">FOAF</acronym>'), 'foaf/'.$user->uid, NULL, NULL, NULL, FALSE, TRUE))));
       }
       break;
     case 'form':
@@ -69,31 +81,149 @@ function foaf_user($op, &$edit, &$user, 
 }
 
 function foaf_settings() {
-  $output = '';
 
-  $output.= form_radios(t('Export <acronym title="Friend of a Friend">FOAF</acronym> for users by default'), 'foaf_export_default', variable_get('foaf_export_default', 0), array(0 => t('no'), 1=> t('yes')), t('This can be overridden by individual users'));
-  
-  $mapping.= form_select(t('Field for foaf:name'), 'foaf_name', variable_get('foaf_name', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:title'), 'foaf_title', variable_get('foaf_title', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:firstName'), 'foaf_firstName', variable_get('foaf_firstName', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:surname'), 'foaf_surname', variable_get('foaf_surname', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:Organization'), 'foaf_Organization', variable_get('foaf_Organization', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:phone'), 'foaf_phone', variable_get('foaf_phone', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:aimChatID'), 'foaf_aimChatID', variable_get('foaf_aimChatID', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:icqChatID'), 'foaf_icqChatID', variable_get('foaf_icqChatID', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:msnChatID'), 'foaf_msnChatID', variable_get('foaf_msnChatID', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:yahooChatID'), 'foaf_yahooChatID', variable_get('foaf_yahooChatID', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:jabberID'), 'foaf_jabberID', variable_get('foaf_jabberID', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for foaf:workplaceHomepage'), 'foaf_workplaceHomepage', variable_get('foaf_workplaceHomepage', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for vCard:Street'), 'foaf_street', variable_get('foaf_street', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for vCard:Locality'), 'foaf_locality', variable_get('foaf_locality', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for vCard:Region'), 'foaf_region', variable_get('foaf_region', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for vCard:Pcode'), 'foaf_pcode', variable_get('foaf_pcode', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for vCard:Country'), 'foaf_country', variable_get('foaf_country', ''), _foaf_profile_fields());
-  $mapping.= form_select(t('Field for bio:keywords'), 'foaf_keywords', variable_get('foaf_keywords', ''), _foaf_profile_fields());
+  $form['foaf_export_default'] = array(
+    '#type' => 'radios',
+    '#title' => t('Export <acronym title="Friend of a Friend">FOAF</acronym> for users by default'),
+    '#default_value' => variable_get('foaf_export_default', 0),
+    '#options' => array(0 => t('no'), 1=> t('yes')),
+    '#description' => t('This can be overridden by individual users'),
+  );
+
+  $mapping = variable_get('mapping', NULL);
+
+  $form['mapping'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Field Mappings'),
+  );
+
+  $form['mapping']['foaf_name'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:name'),
+    '#default_value' => variable_get('foaf_name', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_title'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:title'),
+    '#default_value' => variable_get('foaf_title', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_firstName'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:firstName'),
+    '#default_value' => variable_get('foaf_firstName', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_surname'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:surname'),
+    '#default_value' => variable_get('foaf_surname', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_Organization'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:Organization'),
+    '#default_value' => variable_get('foaf_Organization', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_phone'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:phone'),
+    '#default_value' => variable_get('foaf_phone', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_aimChatID'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:aimChatID'),
+    '#default_value' => variable_get('foaf_aimChatID', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_icqChatID'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:icqChatID'),
+    '#default_value' => variable_get('foaf_icqChatID', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_msnChatID'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:msnChatID'),
+    '#default_value' => variable_get('foaf_msnChatID', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_yahooChatID'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:yahooChatID'),
+    '#default_value' => variable_get('foaf_yahooChatID', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_jabberID'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:jabberID'),
+    '#default_value' => variable_get('foaf_jabberID', ''),
+    '#options' => _foaf_profile_fields(),
+  ); 
+
+  $form['mapping']['foaf_workplaceHomepage'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for foaf:workplaceHomepage'),
+    '#default_value' => variable_get('foaf_workplaceHomepage', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_street'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for vCard:Street'),
+    '#default_value' => variable_get('foaf_street', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_locality'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for vCard:Locality'),
+    '#default_value' => variable_get('foaf_locality', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_region'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for vCard:Region'),
+    '#default_value' => variable_get('foaf_region', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_pcode'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for vCard:Pcode'),
+    '#default_value' => variable_get('foaf_pcode', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_country'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for vCard:Country'),
+    '#default_value' => variable_get('foaf_country', ''),
+    '#options' => _foaf_profile_fields(),
+  );
+
+  $form['mapping']['foaf_keywords'] = array(
+    '#type' => 'select',
+    '#title' => t('Field for bio:keywords'),
+    '#default_value' => variable_get('foaf_keywords', ''),
+    '#options' => _foaf_profile_fields(),
+  );
 
-  $output.= form_group(t('Field Mappings'), $mapping);
-  return $output;
+  return system_settings_form($form);
 }
 
 function foaf_xmlrpc() {
@@ -167,7 +297,7 @@ function foaf_export($uid = null) {
   $output.= '  <foaf:nick>'.$account->name ."</foaf:nick>\n";
 
   // weblog
-  if (module_exist('blog')) {
+  if (module_exists('blog')) {
     $output.= '  <foaf:weblog rdf:resource="'.url('blog/'.$uid, null, null, true) . '" />' . "\n";
   }
 
@@ -326,17 +456,33 @@ function foaf_get_url($username) {
     return url('foaf/'.$user->uid, null,null, true);
   }
 }
-                                 
+
 function foaf_user_form($user) {
-  $data = form_textfield(t('URL for your FOAF file'), 'foaf_url', $user->foaf_url, 64, 255);
-  $data.= form_checkbox(t('Allow FOAF export'), 'foaf_export', 1, _foaf_allow_export($user));
-      
-  $items = array();
-  $items[] = array('title' => t("FOAF Settings"),
-                   'data' => $data,
-                   'weight' => 0);
 
-  return $items;
+  $foafuser = variable_get('foafuser', NULL);
+
+  $form['foafuser'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('FOAF Settings'),
+    '#weight' => 0,
+  );
+
+  $form['foafuser']['foaf_url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('URL for your FOAF file'),
+    '#default_value' => $user->foaf_url,
+    '#size' => 64,
+    '#maxlength' => 255,
+  );
+
+  $form['foafuser']['foaf_export'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Allow FOAF export'),
+    '#return_value' => 1,
+    '#default_value' => _foaf_allow_export($user),
+  );
+
+  return $form;
 }
 
 /**
@@ -499,4 +645,3 @@ function _foaf_allow_export($account) {
     return variable_get('foaf_export_default', 0);
   }
 }
-?>
\ No newline at end of file
