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

Diff of /contributions/modules/nodeprofile/nodeprofile.module

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

revision 1.7.2.35, Sun Apr 20 20:57:14 2008 UTC revision 1.7.2.36, Fri Jan 9 15:40:16 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: nodeprofile.module,v 1.7.2.34 2008/04/07 18:17:39 fago Exp $  // $Id: nodeprofile.module,v 1.7.2.35 2008/04/20 20:57:14 fago Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 77  function nodeprofile_admin_settings($typ Line 77  function nodeprofile_admin_settings($typ
77      '#type' => 'checkbox',      '#type' => 'checkbox',
78      '#title' => t("Show this node profile during user registration."),      '#title' => t("Show this node profile during user registration."),
79      '#default_value' => nodeprofile_get_settings('register', $type),      '#default_value' => nodeprofile_get_settings('register', $type),
80      '#description' => t('If selected this node profile\'s form will be shown on the user register page. ') .      '#description' => t('If selected this node profile\'s form will be shown on the user register page. ') .
81        t('Note that this will bypass the node creation permission settings, so this will work for your users regardless if they have access to edit or create their nodeprofile later!'),        t('Note that this will bypass the node creation permission settings, so this will work for your users regardless if they have access to edit or create their nodeprofile later!'),
82    );    );
83    if (module_exists('rolesignup')) {    if (module_exists('rolesignup')) {
# Line 163  function nodeprofile_keep_relation() { Line 163  function nodeprofile_keep_relation() {
163    
164    if (is_nodeprofile(arg(4))) {    if (is_nodeprofile(arg(4))) {
165      drupal_set_message(t('You may not delete this relation manually. To remove it unmark the '.      drupal_set_message(t('You may not delete this relation manually. To remove it unmark the '.
166                           'content type "%type" as nodeprofile.',        'content type "%type" as nodeprofile.',
167                           array('%type' => node_get_types('name', arg(4)))), 'error');        array('%type' => node_get_types('name', arg(4)))), 'error');
168      drupal_goto('admin/content/nodefamily');      drupal_goto('admin/content/nodefamily');
169    }    }
170    else {    else {
# Line 351  function nodeprofile_user($op, &$edit, & Line 351  function nodeprofile_user($op, &$edit, &
351          }          }
352          $fields[$category] = array(          $fields[$category] = array(
353            '#type' => 'subform',            '#type' => 'subform',
354            '#id' => $node->type. '_node_form',            '#id' => $node->type .'_node_form',
355            '#arguments' => array($node),            '#arguments' => array($node),
356            '#data_separation' => ($category == 'account'),            '#data_separation' => ($category == 'account'),
357            '#subform_after_build' => array('nodeprofile_integration_adapt_node_form'),            '#subform_after_build' => array('nodeprofile_integration_adapt_node_form'),
# Line 363  function nodeprofile_user($op, &$edit, & Line 363  function nodeprofile_user($op, &$edit, &
363      case 'update':      case 'update':
364        if (nodeprofile_get_settings('user_edit', $category) && node_access('create', $category)) {        if (nodeprofile_get_settings('user_edit', $category) && node_access('create', $category)) {
365          subform_element_submit();          subform_element_submit();
366          unset($edit[$category. '_node_form']);          unset($edit[$category .'_node_form']);
367        }        }
368        break;        break;
369    
# Line 506  function _nodeprofile_node_delete($node) Line 506  function _nodeprofile_node_delete($node)
506    watchdog('content', t('@type: deleted %title.', array('@type' => node_get_types('name', $node->type), '%title' => $node->title)));    watchdog('content', t('@type: deleted %title.', array('@type' => node_get_types('name', $node->type), '%title' => $node->title)));
507  }  }
508    
509  /*  /**
510   * Returns a form, that will be added to the registration form   * Returns a form, that will be added to the registration form
511   */   */
512  function nodeprofile_get_register_form() {  function nodeprofile_get_register_form() {
# Line 532  function nodeprofile_get_register_form() Line 532  function nodeprofile_get_register_form()
532        $node = (object)array('uid' => 0, 'name' => '', 'type' => $type);        $node = (object)array('uid' => 0, 'name' => '', 'type' => $type);
533        $form[$type]['form'] = array(        $form[$type]['form'] = array(
534          '#type' => 'subform',          '#type' => 'subform',
535          '#id' => $type. '_node_form',          '#id' => $type .'_node_form',
536          //data separation should be set to FALSE, so that imagefield works (see #201804)          //data separation should be set to FALSE, so that imagefield works (see #201804)
537          '#data_separation' => FALSE,          '#data_separation' => FALSE,
538          '#arguments' => array($node),          '#arguments' => array($node),
# Line 546  function nodeprofile_get_register_form() Line 546  function nodeprofile_get_register_form()
546    }    }
547  }  }
548    
549  /*  /**
550   * Implementation of hook_nodeapi   * Implementation of hook_nodeapi().
551   */   */
552  function nodeprofile_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {  function nodeprofile_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
553    global $new_account, $last_nid;    global $new_account, $last_nid;
554    
555    //Set the correct author for new nodes created during registration    //Set the correct author for new nodes created during registration
556    if ($op == 'submit' && is_nodeprofile($node->type) && isset($new_account)) {    if ($op == 'submit' && is_nodeprofile($node->type) && isset($new_account)) {
557      $node->uid = $new_account->uid;      $node->uid = $new_account->uid;
558      $node->name = $new_account->name;      $node->name = $new_account->name;
559    }    }
560    
561    //index themed node    //index themed node
562    if ($op == 'alter' && is_nodeprofile($node->type) && isset($last_nid)) {    if ($op == 'alter' && is_nodeprofile($node->type) && isset($last_nid)) {
563      $node->body = theme('node', $node, FALSE, TRUE);      $node->body = theme('node', $node, FALSE, TRUE);
564    }    }
565  }  }
566    
567  /*  /**
568   * Returns the nodeprofiles' settings   * Returns the nodeprofiles' settings
569   * @param $return One of the nodeprofile_available_settings(), e.g. user_edit, register or weight   * @param $return One of the nodeprofile_available_settings(), e.g. user_edit, register or weight
570   * @param $type If not all, return the setting for the specified type   * @param $type If not all, return the setting for the specified type
# Line 584  function nodeprofile_get_settings($retur Line 584  function nodeprofile_get_settings($retur
584    return array();    return array();
585  }  }
586    
587  /*  /**
588   * Returns all settings with the applied defaults   * Returns all settings with the applied defaults
589   */   */
590  function nodeprofile_get_all_settings() {  function nodeprofile_get_all_settings() {
# Line 600  function nodeprofile_get_all_settings() Line 600  function nodeprofile_get_all_settings()
600    return $settings;    return $settings;
601  }  }
602    
603  /*  /**
604   * Defines default values for the settings   * Defines default values for the settings
605   */   */
606  function nodeprofile_get_setting_defaults($setting, $type) {  function nodeprofile_get_setting_defaults($setting, $type) {
# Line 620  function nodeprofile_get_setting_default Line 620  function nodeprofile_get_setting_default
620  }  }
621    
622    
623  /*  /**
624   * Saves the nodeprofile settings - needs the complete settings array   * Saves the nodeprofile settings - needs the complete settings array
625   */   */
626  function nodeprofile_set_settings($settings) {  function nodeprofile_set_settings($settings) {
# Line 638  function nodeprofile_set_settings($setti Line 638  function nodeprofile_set_settings($setti
638    variable_set('nodeprofile_settings', $settings);    variable_set('nodeprofile_settings', $settings);
639  }  }
640    
641  /*  /**
642   * returns an array containing all available nodeprofile settings   * returns an array containing all available nodeprofile settings
643   */   */
644  function nodeprofile_available_settings() {  function nodeprofile_available_settings() {
645    return array('weight', 'user_edit', 'register', 'register_roles', 'user_display', 'edit_link', 'add_link');    return array('weight', 'user_edit', 'register', 'register_roles', 'user_display', 'edit_link', 'add_link');
646  }  }
647    
648  /*  /**
649   * Deactivates some unwanted fields for integrated node forms   * Deactivates some unwanted fields for integrated node forms
650   * This is invoked through #after_build on the subform elment   * This is invoked through #after_build on the subform elment
651   */   */
# Line 656  function nodeprofile_integration_adapt_n Line 656  function nodeprofile_integration_adapt_n
656    return $form_element;    return $form_element;
657  }  }
658    
659  /*  /**
660   * Loads the node, like node_load but caches the results   * Loads the node, like node_load but caches the results
661   */   */
662  function nodeprofile_load($type, $uid) {  function nodeprofile_load($type, $uid) {
# Line 668  function nodeprofile_load($type, $uid) { Line 668  function nodeprofile_load($type, $uid) {
668    return $cache[$type][$uid];    return $cache[$type][$uid];
669  }  }
670    
671  /*  /**
672   * Theme function for the nodeprofile display as teaser   * Theme function for the nodeprofile display as teaser
673   */   */
674  function theme_nodeprofile_display_teaser(&$element) {  function theme_nodeprofile_display_teaser(&$element) {
675    if ($node = nodeprofile_load($element['#content_type'], $element['#uid'])) {    if ($node = nodeprofile_load($element['#content_type'], $element['#uid'])) {
676      if (node_access('view', $node)) {      if (node_access('view', $node)) {
677        $element['#node'] = $node;        $element['#node'] = $node;
678        return theme('nodeprofile_display_box', $element, node_view($node, TRUE, TRUE, FALSE));        return theme('nodeprofile_display_box', $element, node_view($node, TRUE, TRUE, FALSE));
679      }      }
680    }    }
681  }  }
682    
683  /*  /**
684   * Theme function for the nodeprofile display as full node   * Theme function for the nodeprofile display as full node
685   */   */
686  function theme_nodeprofile_display_full(&$element) {  function theme_nodeprofile_display_full(&$element) {
# Line 692  function theme_nodeprofile_display_full( Line 692  function theme_nodeprofile_display_full(
692    }    }
693  }  }
694    
695  /*  /**
696   * Theme function for the nodeprofile display as link   * Theme function for the nodeprofile display as link
697   */   */
698  function theme_nodeprofile_display_link(&$element) {  function theme_nodeprofile_display_link(&$element) {
# Line 707  function theme_nodeprofile_display_link( Line 707  function theme_nodeprofile_display_link(
707    }    }
708  }  }
709    
710  /*  /**
711   * Displays the given content in a nodeprofile box, which may have some tabs, that allow   * Displays the given content in a nodeprofile box, which may have some tabs, that allow
712   * users to perform some actions on the node   * users to perform some actions on the node
713   */   */
# Line 726  function theme_nodeprofile_display_box($ Line 726  function theme_nodeprofile_display_box($
726      }      }
727      $output .= "</ul>\n";      $output .= "</ul>\n";
728    }    }
729    return $head .'<div class="nodeprofile-display">'. $output . $content. '</div>';    return $head .'<div class="nodeprofile-display">'. $output . $content .'</div>';
730  }  }
731    
732  /**  /**
# Line 736  function theme_nodeprofile_display_add_l Line 736  function theme_nodeprofile_display_add_l
736    return l(t("Create your @profile_node.", array('@profile_node' => $type_name)), nodeprofile_get_add_path($type), array(), drupal_get_destination());    return l(t("Create your @profile_node.", array('@profile_node' => $type_name)), nodeprofile_get_add_path($type), array(), drupal_get_destination());
737  }  }
738    
739  /*  /**
740   * Themes the view tab   * Themes the view tab
741   */   */
742  function theme_nodeprofile_display_tab_view($node) {  function theme_nodeprofile_display_tab_view($node) {
743    return l(t('View'), 'node/'. $node->nid);    return l(t('View'), 'node/'. $node->nid);
744  }  }
745    
746  /*  /**
747   * Themes the edit tab   * Themes the edit tab
748   */   */
749  function theme_nodeprofile_display_tab_edit($node) {  function theme_nodeprofile_display_tab_edit($node) {
# Line 752  function theme_nodeprofile_display_tab_e Line 752  function theme_nodeprofile_display_tab_e
752    }    }
753  }  }
754    
755  /*  /**
756   * Gets the edit path for a nodeprofile   * Gets the edit path for a nodeprofile
757   */   */
758  function nodeprofile_get_edit_path($node) {  function nodeprofile_get_edit_path($node) {
# Line 762  function nodeprofile_get_edit_path($node Line 762  function nodeprofile_get_edit_path($node
762    return 'node/'. $node->nid .'/edit';    return 'node/'. $node->nid .'/edit';
763  }  }
764    
765  /*  /**
766   * Gets the add path for a nodeprofile of the active user   * Gets the add path for a nodeprofile of the active user
767   */   */
768  function nodeprofile_get_add_path($type) {  function nodeprofile_get_add_path($type) {
# Line 773  function nodeprofile_get_add_path($type) Line 773  function nodeprofile_get_add_path($type)
773    return 'node/add/'. $type;    return 'node/add/'. $type;
774  }  }
775    
776  /*  /**
777   * Returns an array suitable for use with drupal_render,   * Returns an array suitable for use with drupal_render,
778   * that shows all nodperofiles as configured by the admin   * that shows all nodperofiles as configured by the admin
779   */   */
# Line 784  function nodeprofile_show_profiles($uid) Line 784  function nodeprofile_show_profiles($uid)
784        $fields[$type] = array(        $fields[$type] = array(
785          '#type' => 'nodeprofile_display_'. $style,          '#type' => 'nodeprofile_display_'. $style,
786          '#tabs' => nodeprofile_get_settings('edit_link', $type) ? array('view', 'edit') : ($style == 'teaser' ? array('view') : array()),          '#tabs' => nodeprofile_get_settings('edit_link', $type) ? array('view', 'edit') : ($style == 'teaser' ? array('view') : array()),
787          '#title' => $type_name,          '#title' => $type_name,
788          '#uid' => $uid,          '#uid' => $uid,
789          '#content_type' => $type,          '#content_type' => $type,
790          '#weight' => nodeprofile_get_settings('weight', $type),          '#weight' => nodeprofile_get_settings('weight', $type),

Legend:
Removed from v.1.7.2.35  
changed lines
  Added in v.1.7.2.36

  ViewVC Help
Powered by ViewVC 1.1.2