Project

General

Profile

« Previous | Next » 

Revision c7e36592

Added by Andreas Kohlbecker about 14 years ago

fixing cdm nodetype comment settings

View differences:

.gitattributes
17 17
modules/cdm_dataportal/cdm_api/xml2json.php -text
18 18
modules/cdm_dataportal/cdm_dataportal.css -text
19 19
modules/cdm_dataportal/cdm_dataportal.info -text
20
modules/cdm_dataportal/cdm_dataportal.install -text
20 21
modules/cdm_dataportal/cdm_dataportal.module -text
21 22
modules/cdm_dataportal/cdm_dataportal_print.css -text
22 23
modules/cdm_dataportal/cdm_dataportal_screen.css -text
modules/cdm_dataportal/cdm_api/cdm_node.php
21 21
    $messages = drupal_set_message();
22 22

  
23 23
    $result = drupal_execute($node->type.'_node_form', $values, $node);
24
    
25 24
    // restore the messages
26
    if(isset($messages)){
27
      $_SESSION['messages'] = $messages;
28
    }
25
    $_SESSION['messages'] = $messages;
29 26
    
30 27
    if(!is_array($result)){
31 28
      // result should contain the path the newly created node; e.g.: node/32
modules/cdm_dataportal/cdm_dataportal.install
1
<?php
2
// $Id$
3

  
4
/**
5
 * Implementation of hook_install().
6
 */
7
function cdm_dataportal_install(){
8
   update_sql(_get_sql_fix_module_weight());
9
}
10

  
11

  
12
/**
13
 * Implementation of hook_api_update_N().
14
 * 
15
 * Update 1 for version 5.x-1.0
16
 */
17
function cdm_dataportal_update_5101() {
18
  $items = array();
19
  $items[] = update_sql(_get_sql_fix_module_weight());
20
  return $items;
21
}
22

  
23
// ------------------------- SQL  Scripts ------------------------ // 
24

  
25

  
26
function _get_sql_fix_module_weight() {
27
  return  "UPDATE {system} SET weight = 20 WHERE name = 'cdm_dataportal'";
28
}
modules/cdm_dataportal/cdm_dataportal.module
704 704
	return system_settings_form($form);
705 705
}
706 706

  
707
function cdm_dataportal_form_alter($form_id, &$form) {
708
    
709
static $comment_node_disabled =  0;
710
static $comment_node_read_only =  1;
711
static $comment_node_read_write =  2;
712
   
713
    
714
  if ($form_id == 'node_type_form' 
715
    && isset($form['identity']['type']) 
716
    && array_key_exists($form['#node_type']->type, cdm_dataportal_get_nodetypes()) 
717
    ) {
718
    $form['workflow']['comment'] = array(
719
      '#type' => 'radios',
720
      '#title' => t('Default comment setting'),
721
      '#default_value' => variable_get('comment_'. $form['#node_type']->type, $comment_node_disabled),
722
      '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
723
      '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'),
724
    );
725
  }
726
}
727

  
707 728
/**
708 729
 * LAYOUT settings
709 730
 * @return unknown_type
modules/cdm_dataportal/node_types.php
5 5
define(NODETYPE_REFERENCE, 'reference');
6 6
define(NODETYPE_NAME, 'name');
7 7

  
8
function cdm_dataportal_get_nodetypes(){
9
	static $nodetypes;
10
	  if(!$nodetypes){
11
	    $nodetypes = array('cdm_'.NODETYPE_REFERENCE => NODETYPE_REFERENCE, 'cdm_'.NODETYPE_TAXON => NODETYPE_TAXON, 'cdm_'.NODETYPE_MEDIA => NODETYPE_MEDIA, 'cdm_'.NODETYPE_NAME => NODETYPE_NAME); 
12
	  }
13
	  return $nodetypes; 
14
}
15

  
8 16
/**
9 17
 * Implementation of hook_node_info().
10 18
 */
11 19
function cdm_dataportal_node_info() {
12
  
13
  static $nodetypes;
14
  if(!$nodetype){
15
    $nodetypes = array(NODETYPE_REFERENCE, NODETYPE_TAXON, NODETYPE_MEDIA, NODETYPE_NAME); 
16
  }
17
  
20
	
18 21
  $nodeinfo = array();
19
  foreach( $nodetypes as $type){
20
    $nodeinfo['cdm_'.$type] = array(
22
  foreach( cdm_dataportal_get_nodetypes() as $nodeType=>$type){
23
    $nodeinfo[$nodeType] = array(
21 24
      'name' => t(ucfirst($type)),
22 25
      'has_title' => TRUE,
23 26
      'module' => 'cdm_dataportal',
......
28 31
  return $nodeinfo;
29 32
}
30 33

  
34

  
31 35
/**
32 36
 *  Implementation of hook_form()
33 37
 */

Also available in: Unified diff