Index: content_profile.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_profile/Attic/content_profile.module,v
retrieving revision 1.1.2.21
diff -u -r1.1.2.21 content_profile.module
--- content_profile.module	17 Nov 2008 14:37:54 -0000	1.1.2.21
+++ content_profile.module	17 Nov 2008 20:51:24 -0000
@@ -29,9 +29,43 @@
       'weight' => 1,
     );
   }
+  foreach (content_profile_get_types('names', 'edit_link_sub') as $type => $type_name) {
+    $items['user/%user/edit/'. $type] = array(
+      'title callback' => 'check_plain',
+      'title' => drupal_ucfirst($type_name),
+      'page callback' => 'content_profile_page_edit',
+      'page arguments' => array(1, 3),
+      'access callback' => 'content_profile_page_access',
+      'access arguments' => array(1, 3),
+      'type' => MENU_LOCAL_TASK,
+      'weight' => content_profile_get_settings($type, 'weight'),
+      'tab_parent' => 'user/%/edit',
+      'file' => 'node.pages.inc',
+      'file path' => drupal_get_path('module', 'node'),
+    );
+  }
+
   return $items;
 }
 
+function content_profile_page_access($account, $type) {
+  if ($node = content_profile_load($type, $account->uid)) {
+    return node_access('update', $node);
+  }
+  return node_access('create', $type);
+}
+
+/**
+ * Presents a node editing or adding form for the given content profile.
+ */
+function content_profile_page_edit($account, $type) {
+  if ($node = content_profile_load($type, $account->uid)) {
+    return node_page_edit($node);
+  }
+  return node_add($type);
+}
+
+
 /**
  * Implementation of hook_views_api().
  */
@@ -197,52 +231,6 @@
   global $user;
 
   switch ($op) {
-    case 'categories':
-      foreach (content_profile_get_types() as $type) {
-        // if user can edit their own content or they can administer users
-        if (content_profile_get_settings($type->type, 'edit_link_sub') &&
-            (($user->uid == arg(1) && user_access('edit own '. $type->type .' content')) || user_access('administer users'))) {
-          $data[] = array(
-            'name' => $type->type,
-            'title' => $type->name,
-            'weight' => content_profile_get_settings($type->type, 'weight'),
-          );
-        }
-      }
-      return $data;
-      break;
-    
-    case 'form':
-      if (key_exists($category, content_profile_get_types())) {
-        module_load_include('inc', 'node', 'node.pages');
-        $form_state = array();
-        $node = content_profile_load($category, $account->uid);
-        
-        // create a dummy object if the user has not created this profile type yet
-        if (!$node) {
-          $node = array('uid' => $account->uid, 'name' => $account->name, 'type' => $category);
-        }
-        
-        $form[$category] = drupal_retrieve_form($category .'_node_form', $form_state, $node);
-        unset($form[$category]['author']);  // avoid non-functional form elements for admin
-        unset($form[$category]['buttons']); // avoid duplicate form buttons
-        unset($form[$category]['uid']);     // avoid uid error via user_profile_form_validate() failed validation
-        
-        drupal_prepare_form($category .'_node_form', $form[$category], $form_state);
-
-        $form['#redirect'] = 'user/'. $account->uid;
-        return $form;
-      }
-      break;
-    
-    case 'update':
-      if (key_exists($category, content_profile_get_types())) {
-        $node = (object)$edit;
-        $node->uid = $account->uid;
-        node_save($node);
-      }
-      break;
-
     case 'view':
       $account->content['content_profile'] = content_profile_show_profiles($account->uid);
       break;
