Index: resource_conflict.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/resource_conflict/resource_conflict.module,v retrieving revision 1.1.2.5.2.1 diff -u -p -r1.1.2.5.2.1 resource_conflict.module --- resource_conflict.module 31 Jul 2008 03:44:08 -0000 1.1.2.5.2.1 +++ resource_conflict.module 13 Aug 2008 01:08:56 -0000 @@ -11,14 +11,14 @@ function resource_conflict_nodeapi(&$nod switch ($op) { case 'validate': $type = $node->type; - if (! variable_get('resource_conflict_type_' . $type, FALSE)) { - //conflict handling is not enabled for this node + if (!variable_get('resource_conflict_type_' . $type, FALSE)) { + // Conflict handling is not enabled for this node. break; } require_once(drupal_get_path('module', 'date_api') .'/date.inc'); - // Find the date field to use for time overlapping_node_ids detection + // Find the date field to use for time overlapping_node_ids detection. $date_field = variable_get('resource_conflict_date_field_' . $type, FALSE); $overlapping_node_ids = array(); @@ -47,7 +47,7 @@ function resource_conflict_nodeapi(&$nod // Display conflict errors _resource_conflict_display_conflict_errors($node, $conflicting_nodes); - break; + break; } } @@ -93,7 +93,7 @@ function resource_conflict_form_alter($f $form['resource_conflict_set'] = array( '#type' => 'fieldset', '#title' => t('Resource Conflict'), - '#collapsible' => 1, + '#collapsible' => TRUE, ); $form['resource_conflict_set']['resource_conflict_type'] = array( @@ -104,7 +104,7 @@ function resource_conflict_form_alter($f ); if ($type != NULL) { - $type_info = content_types($type); + $type_info = content_types($type); $fields = $type_info['fields']; foreach ($fields as $field) { @@ -119,7 +119,7 @@ function resource_conflict_form_alter($f if (empty($nodereference_fields)) { $form['resource_conflict_set']['no_nodreference_fields'] = array( - '#value' => t('Please create some nodereference fields for this content type.') + '#value' => t('Please create some nodereference fields for this content type.'), ); } else { @@ -129,12 +129,12 @@ function resource_conflict_form_alter($f '#options' => $nodereference_fields, '#multiple' => TRUE, '#default_value' => variable_get('resource_conflict_reference_fields_'.$type, FALSE), - '#description' => t("Select the node reference resources which can't be booked at the same time.") + '#description' => t("Select the node reference resources which can't be booked at the same time."), ); } if (empty($date_fields)) { $form['resource_conflict_set']['no_date_fields'] = array( - '#value' => t('Please create some CCK Date fields for this content type OR enable the event module on it.') + '#value' => t('Please create some CCK Date fields for this content type OR enable the event module on it.'), ); } else { @@ -143,8 +143,8 @@ function resource_conflict_form_alter($f '#title' => t('Fields to use as date for conflict checks'), '#options' => $date_fields, '#multiple' => FALSE, - '#default_value' => variable_get('resource_conflict_date_field_'.$type, FALSE), - '#description' => t("Select the date field when other resources can't be booked.") + '#default_value' => variable_get('resource_conflict_date_field_' . $type, FALSE), + '#description' => t("Select the date field when other resources can't be booked."), ); } //set custom validation and submit callbacks @@ -160,12 +160,12 @@ function resource_conflict_form_validate if ($form_id == 'node_type_form') { if ($form_values['resource_conflict_type']) { if (empty($form_values['resource_conflict_reference_fields'])) { - form_set_error('resource_conflict_reference_fields', t("Reference field must be set if conflict handling is enabled.")); + form_set_error('resource_conflict_reference_fields', t("Reference field must be set if conflict handling is enabled.")); } if (empty($form_values['resource_conflict_date_field']) && (empty($form_values['event_nodeapi']) || $form_values['event_nodeapi'] == 'never') ) { - form_set_error('resource_conflict_reference_fields', t("CCK Date field must be set (or event module must be enabled on this content type) if conflict handling is enabled.")); + form_set_error('resource_conflict_reference_fields', t("CCK Date field must be set (or event module must be enabled on this content type) if conflict handling is enabled.")); } } } @@ -201,7 +201,7 @@ function resource_conflict_form_submit($ */ function _resource_conflict_get_conflict_enabled_types() { $conflict_types = variable_get("resource_conflict_types", array()); - return $conflict_types; + return $conflict_types; } /** @@ -213,17 +213,17 @@ function _resource_conflict_get_conflict * An array with keys of the node ID's, values of true */ function _resource_conflict_get_node_resource_demand($node) { - $type = $node->type; - $reference_fields = variable_get('resource_conflict_reference_fields_' . $type, array()); + $type = $node->type; + $reference_fields = variable_get('resource_conflict_reference_fields_' . $type, array()); - $demand = array(); - foreach ($reference_fields as $reference_field) { - $references = $node-> {$reference_field}; - foreach ($references as $reference) { - $demand[$reference['nid']] = true; - } - } - return $demand; + $demand = array(); + foreach ($reference_fields as $reference_field) { + $references = $node-> {$reference_field}; + foreach ($references as $reference) { + $demand[$reference['nid']] = TRUE; + } + } + return $demand; } /** @@ -281,7 +281,7 @@ function _resource_conflict_get_overlaps $rows = array(); $conflict_types = _resource_conflict_get_conflict_enabled_types(); - foreach ($conflict_types as $type) { + foreach ($conflict_types as $type) { $date_field = variable_get('resource_conflict_date_field_' . $type, FALSE); if($date_field) { @@ -309,6 +309,6 @@ function _resource_conflict_get_overlaps $rows[] = $row['nid']; } } - } - return $rows; + } + return $rows; }