? nodeprofile.info
? nodeprofile_47_to_50.patch
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodeprofile/README.txt,v
retrieving revision 1.21
diff -u -r1.21 README.txt
--- README.txt	2 Sep 2006 20:32:42 -0000	1.21
+++ README.txt	29 Jan 2007 17:14:41 -0000
@@ -12,8 +12,8 @@
 ---------------------
 nodeprofile.module - Marks content types as profiles
 
-usernode.module - Automatically creation of usernodes
-nodefamily.module - Builds nodefamilies based on content types and author information
+usernode.module - Automatic creation of usernodes
+nodefamily.module - Builds node families based on content types and author information
 pageroute.module - Allows the creation of pageroutes.
 views_fusion.module - Provides fusing of multiple views.
 
@@ -22,8 +22,8 @@
 nodeprofile.module
 -----------------
 This module allows you to mark content types as user profiles, do this
-at 'admin/settings/content-types'. 
-It uses the nodefamily module to restrict the node population and it to set 
+at 'admin/content/types'.
+It uses the nodefamily module to restrict the node population and it to set
 a relation between the content type of usernodes and a user profile, so that
 it is possible to easily get all profile nodes and display them at the usernode.
 
@@ -32,27 +32,27 @@
 ---------------
 http://drupal.org/project/usernode
 
-This module tries to make users nodes. It cares for automatically creation and 
+This module tries to make users nodes. It cares for automatic creation and
 deletion of a node for each user, the so called usernode.
 
-You need not use this module if you want to build nodeprofiles, however it is 
-suggested to do so.
+You don't need to use the usernode module if you want to build nodeprofiles,
+however it is suggested to do so.
 
 It allows you to
-    * Use views to build user listings or even searches. Usernode provides an 
+    * Use views to build user listings or even searches. Usernode provides an
       easy customizeable default view.
-    * Makes building of nodeprofiles easier. You may use it to present the users
-      nodeprofile to the public.
+    * Makes building of nodeprofiles easier. You may use it to present the
+      user's nodeprofile to the public.
     * Use features, which other modules provide for nodes, with users. Think of
       comments, taxonomy...
 
 
 How do usernodes interact with nodeprofiles?
 ----------------------------------------------
-The default display of the usernode shows links to all child nodes of any existing
-nodefamily relation. This will list nodes with a content type marked as 
-nodeprofile.
-So you can use the usernode for viewing all profiles of an user.
+The default display of the usernode shows links to all child nodes of
+any existing nodefamily relation. This will list nodes with a content type
+marked as nodeprofile.
+So you can use the usernode for viewing all profile pages of a user.
 
 By using the nodefamily relations you are able to theme the display of the usernode
 to display the whole content of a nodeprofile or to use the information from multiple
@@ -68,7 +68,7 @@
 http://drupal.org/project/views_fusion
 
 
-Installation 
+Installation
 ------------
  * Download and install the nodefamily module. (http://drupal.org/project/nodefamily)
  * Copy the nodeprofile module to your modules directory and activate it.
@@ -85,21 +85,21 @@
 can be built:
 
  * Create your content type you want to use for your profile, e.g. with the CCK.
- * Mark your content type as user profile at 'admin/settings/content-types'
- * If you don't like the usual node forms for editing the profile remove the usual 
-   'create content' link using the menu module. Use a new link pointing at 
+ * Mark your content type as user profile at 'admin/content/types'
+ * If you don't like the usual node forms for editing the profile remove the usual
+   'create content' link using the menu module. Use a new link pointing at
    'nodefamily/CONTENT_TYPE' or an url alias of it.
  * For building user listings and user searches use the views module together with the
    usernode module. If the view should also contain profile information use the views
    fusion module.
 
 
-To build a more advanced user profile, which consists of several node types:
+To build a more advanced user profile which consists of several node types:
 
- * Create your content types you want to use for your profiles, e.g. with the CCK.
+ * Create the content types that you want to use for your profiles, e.g. with the CCK.
 
- * Mark a content type as user profile at 'admin/settings/content-types' and set
-   appropriate relations between the content types at 'admin/settings/nodefamily'.
+ * Mark a content type as user profile at 'admin/content/types' and set
+   appropriate relations between the content types at 'admin/content/nodefamily'.
 
    To achieve greatest flexibility it is suggested to mark only one content type
    as user profile. Set nodefamily relations between this type and the other content
@@ -107,27 +107,27 @@
    using the nodefamily relations (instructions are provided in the nodefamily readme).
 
  * Theme your usernodes
- 
+
    If you have only one nodeprofile, just load the node view of your parent content
    type of your nodeprofile, e.g. use this in your theme:
    <?php $children = nodefamily_relation_load($nid);
          print node_view($children[0]);
    ?>
-   
+
    So you can easily change this later, if you decide to create another nodeprofile for
    your users.
-   
+
    If there might be more than one nodeprofile per user you may use the usernode to provide
    links to your nodeprofiles as it is per default.
 
- * Use the pageroute module to provide an userfriendly way for filling out the nodeprofile.
+ * Use the pageroute module to provide an user-friendly way for filling out the nodeprofile.
    Note: Use the node management page type for adding/editing a nodeprofile content type.
 
  * For building user listings and user searches use the views module together with the
    usernode module. If the view should also contain profile information use the views
    fusion module.
-   Create a view for each content type of your nodeprofile, which contains information you
-   need. Fuse the parent nodeprofile content type with this views using the views fusion
+   Create a view for each content type of your nodeprofile which contains information you
+   need. Fuse the parent nodeprofile content type with these views using the views fusion
    module and fuse the usernode content type with this type.
    (You have to fuse the content types the same way as there are nodefamily relations.)
 
Index: nodeprofile.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodeprofile/nodeprofile.module,v
retrieving revision 1.6
diff -u -r1.6 nodeprofile.module
--- nodeprofile.module	9 Aug 2006 08:18:22 -0000	1.6
+++ nodeprofile.module	29 Jan 2007 17:14:41 -0000
@@ -8,49 +8,48 @@
 
 
 /**
- * Implementation of hook_help().
- */
-function nodeprofile_help($section) {
-  switch ($section) {
-    case 'admin/modules#description':
-      return t('Marks content types as profiles.');
-  }
-}
-
-/**
  * Implementation of hook_menu().
  */
 function nodeprofile_menu($may_cache) {
-    
-  if ($may_cache && module_exist('usernode') && module_exist('nodefamily')) {
-    //prevent the deletion of the usernode-ct - nodeprofile-ct relation
-    $items[] = array('path' => 'admin/settings/nodefamily/' . USERNODE_CONTENT_TYPE, 
-        'title' => t('delete relation'),
-        'callback' => 'nodeprofile_keep_relation',
-        'access' => user_access('administer nodes'),
-        'type' => MENU_CALLBACK);
-    return $items;
+  $items = array();
+
+  if ($may_cache && module_exists('usernode')) {
+    // prevent the deletion of the usernode-ct - nodeprofile-ct relation
+    $items[] = array(
+      'path' => 'admin/content/nodefamily/'. USERNODE_CONTENT_TYPE,
+      'title' => t('delete relation'),
+      'callback' => 'nodeprofile_keep_relation',
+      'access' => user_access('administer nodes'),
+      'type' => MENU_CALLBACK,
+    );
   }
+  return $items;
 }
 
+/**
+ * Menu callback.
+ * Hooks into admin/content/nodefamily/usernode which is normally handled by
+ * the usernode module, but gets special handling here for relations that
+ * may not be deleted.
+ */
 function nodeprofile_keep_relation() {
 
   if (is_nodeprofile(arg(4))) {
     drupal_set_message(t('You may not delete this relation manually. To remove it unmark the '.
-                          'content type "%type" as nodeprofile.', 
-                          array('%type' => node_get_name(arg(4)))), 'error');
-    drupal_goto('admin/settings/nodefamily');
+                         'content type "%type" as nodeprofile.',
+                         array('%type' => node_get_types('name', arg(4)))), 'error');
+    drupal_goto('admin/content/nodefamily');
   }
   else {
-    //proceed with deletion
-    nodefamily_admin();  
-  }  
+    // proceed with deletion
+    return nodefamily_admin_page();
+  }
 }
 
 
-/*
- * Determines if a given node is a nodeprofile
- * @param The node object or the node's type
+/**
+ * Determine if a given node is a nodeprofile.
+ * @param $type The node object or the node's type
  */
 function is_nodeprofile($type) {
   if (is_object($type)) {
@@ -59,42 +58,75 @@
   return variable_get('nodeprofile_'. $type, 0);
 }
 
-/*
+/**
+ * Implementation of hook_node_type():
+ * Rename or delete the maximum population variable if a type name changes.
+ */
+function nodeprofile_node_type($op, $info) {
+  switch ($op) {
+    case 'delete':
+      variable_del('nodeprofile_'. $info->type);
+      break;
+    case 'update':
+      if (!empty($info->old_type) && $info->old_type != $info->type) {
+        $is_nodeprofile = variable_get('nodeprofile_'. $info->old_type, -1);
+        if ($is_nodeprofile != -1) {
+          variable_del('nodeprofile_'. $info->old_type);
+          variable_set('nodeprofile_'. $info->type, $is_nodeprofile);
+        }
+      }
+      break;
+  }
+}
+
+/**
  * Implementation of hook_form_alter().
  */
-function nodeprofile_form_alter($form_id, &$form) { 
+function nodeprofile_form_alter($form_id, &$form) {
 
-  if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id &&
-    ( !module_exist('usernode') || $form['type']['#value'] != USERNODE_CONTENT_TYPE )) {
+  if ($form_id == 'node_type_form' &&
+      ( !module_exists('usernode') || $form['#node_type']->type != USERNODE_CONTENT_TYPE )) {
 
-    $form['nodeprofile'] = array('#type' => 'fieldset', '#title' => t('Nodeprofile'));
-    $form['nodeprofile']['nodeprofile_'. $form['type']['#value']] = array(
+    /* The 'nodeprofile_type' field is in the workflow fieldset at the moment,
+     * because the buttons are not properly weighted.
+     * TODO: if node_type_form() in node's content_types.inc fixes this,
+     *       we can think about switching back to our own block.
+     */
+    /*
+    $form['nodeprofile'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Node Profile'),
+      '#collapsible' => 1,
+      '#weight' => 32,
+    );*/
+    $form['workflow']['nodeprofile'] = array(
       '#type' => 'checkbox',
       '#title' => t('Use this content type as a nodeprofile for users'),
-      '#default_value' => variable_get('nodeprofile_'. $form['type']['#value'], 0),
+      '#default_value' => is_nodeprofile($form['#node_type']->type),
       '#return_value' => 1,
     );
-    $form['buttons']['#weight'] = 10;
-    $form['#submit']['nodeprofile_node_settings_submit'] = array(variable_get('nodeprofile_'. $form['type']['#value'], 0));
-    
-    if (module_exist('usernode') && module_exist('nodefamily') && variable_get('nodeprofile_'. $form['type']['#value'], 0)) {
-      $form['nodefamily']['nodefamily_'. $form['type']['#value']. '_max']['#attributes'] = array('disabled' => 'disabled');
+    $form['#submit']['nodeprofile_node_settings_submit'] = array(
+      is_nodeprofile($form['#node_type']->type),
+    );
+
+    if (module_exists('usernode') && is_nodeprofile($form['#node_type']->type)) {
+      $form['workflow']['nodefamily_max']['#disabled'] = TRUE;
     }
   }
 }
 
-function nodeprofile_node_settings_submit($form_id, &$form_values, $old_value) {
+function nodeprofile_node_settings_submit($form_id, $form_values, $old_value) {
   $type = $form_values['type'];
-  if (!$old_value && $form_values['nodeprofile_'. $type ]) {
-    //activated
-    if (module_exist('usernode') && module_exist('nodefamily')) {
+  if (!$old_value && $form_values['nodeprofile']) {
+    // activated
+    if (module_exists('usernode')) {
       nodefamily_ct_relation_add(USERNODE_CONTENT_TYPE, $type);
       nodefamily_content_type_set_max($type, 1);
     }
   }
-  else if ($old_value && !$form_values['nodeprofile_'. $type ]) {
-    //deactivated
-    if (module_exist('usernode') && module_exist('nodefamily')) {
+  else if ($old_value && !$form_values['nodeprofile']) {
+    // deactivated
+    if (module_exists('usernode')) {
       nodefamily_ct_relation_remove(USERNODE_CONTENT_TYPE, $type);
     }
   }
