=== modified file 'ca/ca.admin.inc' --- ca/ca.admin.inc 2009-04-07 18:22:28 +0000 +++ ca/ca.admin.inc 2009-06-22 19:19:11 +0000 @@ -8,6 +8,8 @@ // Displays the administration page that lets you add and modify predicates. function ca_admin($groupby = 'trigger') { + $output = ""; + drupal_add_css(drupal_get_path('module', 'ca') .'/ca.css'); // Load all the module defined predicates into a temporary array. @@ -129,6 +131,8 @@ // Form to allow the creation and editing of conditional action predicates. function ca_predicate_meta_form($form_state, $pid) { + $form = array(); + $predicate = ""; // Load the predicate if an ID is passed in. if (!empty($pid) && $pid !== 0) { $predicate = ca_load_predicate($pid); @@ -144,7 +148,7 @@ $form['predicate_pid'] = array( '#type' => 'value', - '#value' => $pid, + '#value' => !empty($pid) ? $pid : null, ); $form['predicate_title'] = array( @@ -158,14 +162,14 @@ // Create an array of triggers for the select box. $triggers = module_invoke_all('ca_trigger'); foreach ($triggers as $key => $value) { - $options[$value['#category']][$key] = $value['#title']; + $options[$value['#category']][$key] = !empty($value['#title']) ? $value['#title'] : null; } $form['predicate_trigger'] = array( '#type' => 'select', '#title' => t('Trigger'), '#description' => t('Select the trigger for this predicate.
Cannot be modified if the predicate has conditions or actions.'), - '#options' => $options, + '#options' => !empty($options) ? $options : null, '#default_value' => $pid ? $predicate['#trigger'] : '', '#disabled' => empty($predicate['#conditions']) && empty($predicate['#actions']) ? FALSE : TRUE, '#required' => TRUE, @@ -179,24 +183,24 @@ ); // Accommodate the mandatory custom prefix for predicate classes. - $class = $predicate['#class']; + $class = !empty($predicate['#class']) ? $predicate['#class']: null ; if (strpos($class, 'custom') === 0) { $class = ltrim(substr($class, 6), ':'); } - if (is_numeric($pid)) { + if (!empty($pid) && is_numeric($pid)) { $form['predicate_class'] = array( '#type' => 'textfield', '#title' => t('Class'), '#description' => t('Classes let you categorize your predicates based on the type of functionality they provide.'), '#field_prefix' => 'custom:', - '#default_value' => $class, + '#default_value' => !empty($class) ? $class : null, ); } else { $form['predicate_class'] = array( '#type' => 'value', - '#value' => $class, + '#value' => !empty($class) ? $class : null, ); } @@ -232,7 +236,7 @@ $save = FALSE; // Load the original predicate. - if ($form_state['values']['pid'] !== 0) { + if (!empty($form_state['values']) && $form_state['values']['pid'] !== 0) { $predicate = ca_load_predicate($form_state['values']['predicate_pid']); $predicate['#pid'] = $form_state['values']['predicate_pid']; } @@ -270,7 +274,8 @@ // Form to reset a modified module defined predicate to its original state. function ca_predicate_delete_form($form_state, $pid) { $predicate = ca_load_predicate($pid); - + $form = array(); + // Fail if we received an invalid predicate ID. if (empty($predicate)) { drupal_set_message(t('That predicate does not exist.'), 'error'); @@ -284,7 +289,7 @@ $form['predicate_title'] = array( '#type' => 'value', - '#value' => $predicate['#title'], + '#value' => !empty($predicate['#title']) ? $predicate['#title'] : null, ); $description = '

'. check_plain($predicate['#title']) .'
' @@ -316,6 +321,7 @@ * The form array for the actions form. */ function ca_actions_form($form_state, $pid, $title = TRUE) { + $form = array(); // Locate the specified predicate. $predicate = ca_load_predicate($pid); @@ -352,7 +358,7 @@ foreach ($predicate['#actions'] as $key => $action) { // Add it to the form if the action's callback exists. - $callback = $action_data[$action['#name']]['#callback']; + $callback = !empty($action_data[$action['#name']]['#callback']) ? $action_data[$action['#name']]['#callback'] : null; if (function_exists($callback)) { $form['actions'][$i] = array( @@ -365,13 +371,13 @@ $form['actions'][$i]['name'] = array( '#type' => 'value', - '#value' => $action['#name'], + '#value' => !empty($action['#name']) ? $action['#name'] : null, ); $form['actions'][$i]['title'] = array( '#type' => 'textfield', '#title' => t('Title'), - '#default_value' => $action['#title'], + '#default_value' => !empty($action['#title']) ? $action['#name'] : null, ); $form['actions'][$i]['argument_map'] = array( @@ -396,9 +402,9 @@ $form['actions'][$i]['argument_map'][$key] = array( '#type' => 'select', - '#title' => check_plain($value['#title']), + '#title' => !empty($value['#title']) ? check_plain($value['#title']) : null, '#options' => $options, - '#default_value' => $action['#argument_map'][$key], + '#default_value' => !empty($action['#argument_map'][$key]) ? $action['#argument_map'][$key] : null, ); } @@ -498,17 +504,17 @@ */ function ca_actions_form_update_actions($pid, $data) { $actions = array(); - + $predicate = ""; // Unset top level components we don't want to get in the way. unset($data['add_action'], $data['add']); // Loop through the actions from the form and add them to our temporary array. foreach ((array) $data as $key => $value) { $actions[] = array( - '#name' => $value['name'], - '#title' => $value['title'], - '#argument_map' => $value['argument_map'], - '#settings' => empty($value['settings']) ? array() : $value['settings'], + '#name' => !empty($value['name']) ? $value['name'] : null, + '#title' => !empty($value['title']) ? $value['title'] : null, + '#argument_map' => !empty($value['argument_map'] ) ? $value['argument_map'] : null, + '#settings' => !empty($value['settings']) ? $value['settings'] : null, ); } @@ -524,6 +530,7 @@ // Builds a form for adding and editing conditions on a predicate. function ca_conditions_form($form_state, $pid, $title = TRUE) { + $form = array(); // Locate the specified predicate. $predicate = ca_load_predicate($pid); @@ -642,7 +649,7 @@ 'AND' => t('AND. If all of these conditions are TRUE.'), 'OR' => t('OR. If any of these conditions are TRUE.'), ), - '#default_value' => $condition['#operator'], + '#default_value' => !empty($condition['#operator']) ? $condition['#operator'] : null, ); $form[$level]['conditions'] = array(); @@ -702,7 +709,8 @@ // Adds a single condition's fieldset to the conditions form. function _ca_conditions_form_condition($condition, $trigger) { static $identifier = 0; - + $form = array(); + // Load the data for the conditions as defined by modules. $condition_data = ca_load_condition(); @@ -716,7 +724,7 @@ $form['title'] = array( '#type' => 'textfield', '#title' => t('Title'), - '#default_value' => $condition['#title'], + '#default_value' => !empty($condition['#title']) ? $condition['#title'] : null, ); $form['argument_map'] = array( @@ -742,9 +750,9 @@ $form['argument_map'][$key] = array( '#type' => 'select', - '#title' => check_plain($value['#title']), + '#title' => !empty($value['#title']) ? check_plain($value['#title']) : null, '#options' => $options, - '#default_value' => $condition['#argument_map'][$key], + '#default_value' => !empty($condition['#argument_map'][$key]) ? $condition['#argument_map'][$key] : null, ); } @@ -755,7 +763,7 @@ '#type' => 'checkbox', '#title' => t('Negate this condition.'), '#description' => t('Return FALSE if the condition is TRUE and vice versa.'), - '#default_value' => $condition['#settings']['negate'], + '#default_value' => !empty($condition['#settings']['negate']) ? $condition['#settings']['negate']: null, ); // Get the callback for the condition we're displaying. @@ -920,6 +928,7 @@ function ca_conditions_form_update_conditions($pid, $data) { // Build the new conditions array from scratch. $conditions = ca_new_conditions(); + $predicate = ""; // Override the top level operator if need be. if (isset($data['operator'])) { @@ -932,11 +941,11 @@ // Loop through each second level condition group. foreach ($data['conditions'] as $key => $value) { // Save the operator setting. - $conditions['#conditions'][$group]['#operator'] = $value['operator']; + $conditions['#conditions'][$group]['#operator'] = !empty($value['operator']) ? $value['operator'] : null; $conditions['#conditions'][$group]['#conditions'] = array(); // If conditions exist... - if (is_array($value['conditions']) && count($value['conditions']) > 0) { + if (!empty($value['conditions']) && is_array($value['conditions']) && count($value['conditions']) > 0) { // Use a variable to track the condition array key as for groups. $condition = 0; @@ -944,10 +953,10 @@ foreach ($value['conditions'] as $cond_key => $cond_value) { // Save the condition's settings. $conditions['#conditions'][$group]['#conditions'][$condition] = array( - '#name' => $cond_value['name'], - '#title' => $cond_value['title'], - '#argument_map' => $cond_value['argument_map'], - '#settings' => $cond_value['settings'], + '#name' => !empty($cond_value['name']) ? $cond_value['name'] : null, + '#title' => !empty($cond_value['title']) ? $cond_value['title'] : null , + '#argument_map' => !empty($cond_value['argument_map']) ? $cond_value['argument_map'] : array(), + '#settings' => !empty($cond_value['settings']) ? $cond_value['settings'] : array(), ); $condition++; @@ -1027,8 +1036,8 @@ $conditions = array(); $actions = array(); if ($configuration = unserialize($configuration_row->data)) { - $predicate['#class'] = $configuration['#module']; - $predicate['#title'] = $configuration['#label']; + $predicate['#class'] = !empty($configuration['#module'] ) ? $configuration['#module'] : null; + $predicate['#title'] = !empty($configuration['#label'] ) ? $configuration['#label'] : null; // Convert event names to corresponding triggers. switch ($configuration['#event']) { @@ -1042,7 +1051,7 @@ $trigger = 'uc_checkout_complete'; break; default: - $trigger = $configuration['#event']; + $trigger = !empty($configuration['#event']) ? $configuration['#event'] : null; break; } @@ -1055,8 +1064,8 @@ } $predicate['#trigger'] = $trigger; - $predicate['#weight'] = $configuration['#weight']; - $predicate['#status'] = $configuration['#active']; + $predicate['#weight'] = !empty($configuration['#weight']) ? $configuration['#weight'] : null; + $predicate['#status'] = !empty($configuration['#active']) ? $configuration['#active']: null; // Numeric keys in $configuration could be for conditions or actions. // Take each and categorize them to add them to the predicate later. @@ -1145,15 +1154,15 @@ unset($condition_tree['#settings']['operation']); break; default: - $ca_condition['#name'] = $condition_tree['#name']; + $ca_condition['#name'] = !empty($condition_tree['#name']) ? $condition_tree['#name'] : null; break; } if (isset($condition_tree['#label'])) { - $ca_condition['#title'] = $condition_tree['#label']; + $ca_condition['#title'] = !empty($condition_tree['#label']) ? $condition_tree['#label'] : null; } else { - $ca_condition['#title'] = $condition_data[$ca_condition['#name']]['#title']; + $ca_condition['#title'] = !empty($condition_data[$ca_condition['#name']]['#title']) ? $condition_data[$ca_condition['#name']]['#title'] : null ; } $ca_condition['#argument_map'] = $condition_tree['#argument map']; === modified file 'ca/ca.ca.inc' --- ca/ca.ca.inc 2009-06-17 16:45:13 +0000 +++ ca/ca.ca.inc 2009-06-22 18:51:08 +0000 @@ -94,6 +94,7 @@ * and their data types. */ function ca_ca_action() { + $actions = array(); $actions['ca_drupal_set_message'] = array( '#title' => t('Display a message to the user'), '#category' => t('Drupal'), @@ -142,14 +143,14 @@ 'only' => t('Only'), 'after' => t('After'), ), - '#default_value' => $settings['operator'], + '#default_value' => !empty($settings['operator']) ? $settings['operator'] : null, '#description' => t('Example: "The current date is before the date below."'), ); $form['date'] = array( '#type' => 'date', '#title' => t('Date'), - '#default_value' => $settings['date'], + '#default_value' => !empty($settings['date']) ? $settings['date'] : null, '#description' => t('When the predicate is evaluated, the current date is compared to this date.'), ); @@ -164,6 +165,11 @@ // Store the value of the field we're comparing. $field_value = $node_array[$settings['field']]; + //check to see if settings array is set right, if not return false + if(empty($settings['operator']) || empty($settings['value'])) { + return false; + } + // Return the result based on the operator. switch ($settings['operator']) { case 'equal': @@ -238,7 +244,8 @@ function ca_condition_node_field_comparison_form($form_state, $settings = array()) { $form = array(); - + $options = array(); + // Define the fields this works for. $options = array( t('Core node fields') => array( @@ -257,7 +264,7 @@ '#type' => 'select', '#title' => t('Node field'), '#options' => $options, - '#default_value' => $settings['field'], + '#default_value' => !empty($settings['field']) ? $settings['field'] : null, ); // Define the operators for the fields. @@ -286,14 +293,14 @@ '#title' => t('Operator'), '#description' => t('Please note that not every operator makes sense for every field.'), '#options' => $options, - '#default_value' => $settings['operator'], + '#default_value' => !empty($settings['operator']) ? $settings['operator'] : null, ); $form['value'] = array( '#type' => 'textfield', '#title' => t('Comparison value'), '#description' => t('You do not need to specify a value if your operator is in the Yes/No category.'), - '#default_value' => $settings['value'], + '#default_value' => !empty($settings['value']) ? $settings['value'] : null, ); return $form; @@ -303,7 +310,7 @@ function ca_action_drupal_set_message($settings) { // Filter the text using the default format. $message = check_markup($settings['message_text'], FILTER_FORMAT_DEFAULT, FALSE); - + $type = ""; // Return if there's nothing to display. if (empty($message) || empty($settings['message_text'])) { return; @@ -327,7 +334,7 @@ $form['message_text'] = array( '#type' => 'textarea', '#title' => t('Message text'), - '#default_value' => $settings['message_text'], + '#default_value' => !empty($settings['message_text']) ? $settings['message_text'] : null, ); $tips = _filter_tips(variable_get('filter_default_format', 1), FALSE); @@ -343,7 +350,7 @@ 'status' => t('Status'), 'error' => t('Error'), ), - '#default_value' => isset($settings['message_type']) ? $settings['message_type'] : 'status', + '#default_value' => !empty($settings['message_type']) ? $settings['message_type'] : 'status', ); return $form; @@ -355,13 +362,14 @@ } function ca_condition_custom_php_form($form_state, $settings = array(), $arguments = array()) { + $form = array(); $form['variables'] = _ca_custom_php_variables_table($arguments); $form['php'] = array( '#type' => 'textarea', '#title' => t('Custom PHP'), '#description' => t('Enter the custom PHP to be evaluated when this condition is executed. Should not include <?php ?> delimiters.'), - '#default_value' => isset($settings['php']) ? $settings['php'] : '', + '#default_value' => !empty($settings['php']) ? $settings['php'] : null, ); return $form; @@ -381,7 +389,7 @@ } else { foreach ($settings['roles'] as $key) { - if (isset($account->roles[$key])) { + if (!empty($account->roles[$key])) { return TRUE; } } @@ -390,6 +398,7 @@ } function ca_condition_user_roles_form($form_state, $settings = array()) { + $form = array(); $form['operator'] = array( '#type' => 'radios', '#title' => t('Operator'), @@ -398,13 +407,13 @@ 'OR' => t('OR: If the user has any of these roles.'), 'AND' => t('AND: If the user has all of these roles.'), ), - '#default_value' => isset($settings['operator']) ? $settings['operator'] : 'OR', + '#default_value' => !empty($settings['operator']) ? $settings['operator'] : 'OR', ); $form['roles'] = array( '#type' => 'checkboxes', '#title' => t('Roles'), '#options' => user_roles(), - '#default_value' => isset($settings['roles']) ? $settings['roles'] : array(), + '#default_value' => !empty($settings['roles']) ? $settings['roles'] : array(), ); return $form; @@ -416,13 +425,14 @@ } function ca_action_custom_php_form($form_state, $settings = array(), $arguments = array()) { + $form = array(); $form['variables'] = _ca_custom_php_variables_table($arguments); $form['php'] = array( '#type' => 'textarea', '#title' => t('Custom PHP'), '#description' => t('Enter the custom PHP to be evaluated when this action is executed. Should not include <?php ?> delimiters.'), - '#default_value' => isset($settings['php']) ? $settings['php'] : '', + '#default_value' => !empty($settings['php']) ? $settings['php'] : null, ); return $form; @@ -434,7 +444,7 @@ */ function _ca_custom_php_variables_table($arguments) { $rows = array(); - + $fieldset = array(); $header = array(t('Variable'), t('Type'), t('Description')); // Translate the arguments into descriptive rows. === modified file 'ca/ca.module' --- ca/ca.module 2009-04-13 14:26:56 +0000 +++ ca/ca.module 2009-06-22 19:20:57 +0000 @@ -18,28 +18,29 @@ * Implementation of hook_menu(). */ function ca_menu() { + $items = array(); $items[CA_UI_PATH] = array( - 'title' => 'Conditional actions', - 'description' => 'Administer the predicates setup to automate your store.', + 'title' => t('Conditional actions'), + 'description' => t('Administer the predicates setup to automate your store.'), 'page callback' => 'ca_admin', 'access arguments' => array('administer conditional actions'), 'file' => 'ca.admin.inc', 'weight' => 5, ); $items[CA_UI_PATH .'/overview'] = array( - 'title' => 'Overview', + 'title' => t('Overview'), 'weight' => 0, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items[CA_UI_PATH .'/overview/trigger'] = array( - 'title' => 'By trigger', - 'description' => 'Administer the predicates setup to automate your store.', + 'title' => t('By trigger'), + 'description' => t('Administer the predicates setup to automate your store.'), 'weight' => 0, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items[CA_UI_PATH .'/overview/class'] = array( - 'title' => 'By class', - 'description' => 'Administer the predicates setup to automate your store.', + 'title' => t('By class'), + 'description' => t('Administer the predicates setup to automate your store.'), 'page callback' => 'ca_admin', 'page arguments' => array('class'), 'access arguments' => array('administer conditional actions'), @@ -48,8 +49,8 @@ 'file' => 'ca.admin.inc', ); $items[CA_UI_PATH .'/add'] = array( - 'title' => 'Add a predicate', - 'description' => 'Allows an administrator to create a new predicate.', + 'title' => t('Add a predicate'), + 'description' => t('Allows an administrator to create a new predicate.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('ca_predicate_meta_form', '0'), 'access arguments' => array('administer conditional actions'), @@ -58,8 +59,8 @@ 'file' => 'ca.admin.inc', ); $items[CA_UI_PATH .'/convert'] = array( - 'title' => 'Convert configurations', - 'description' => 'Convert Workflow-ng configurations into Conditional Actions predicates.', + 'title' => t('Convert configurations'), + 'description' => t('Convert Workflow-ng configurations into Conditional Actions predicates.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('ca_conversion_form'), 'access callback' => 'ca_convert_configurations_access', @@ -68,8 +69,8 @@ 'file' => 'ca.admin.inc', ); $items[CA_UI_PATH .'/%/edit'] = array( - 'title' => 'Edit predicate', - 'description' => "Edit a predicate's meta data, conditions, and actions.", + 'title' => t('Edit predicate'), + 'description' => t("Edit a predicate's meta data, conditions, and actions."), 'page callback' => 'drupal_get_form', 'page arguments' => array('ca_predicate_meta_form', 3), 'access arguments' => array('administer conditional actions'), @@ -77,8 +78,8 @@ 'type' => MENU_CALLBACK, ); $items[CA_UI_PATH .'/%/edit/meta'] = array( - 'title' => 'Meta data', - 'description' => 'Edit the meta data for a predicate like title, trigger, etc.', + 'title' => t('Meta data'), + 'description' => t('Edit the meta data for a predicate like title, trigger, etc.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('ca_predicate_meta_form', 3), 'access arguments' => array('administer conditional actions'), @@ -87,8 +88,8 @@ 'weight' => -10, ); $items[CA_UI_PATH .'/%/edit/conditions'] = array( - 'title' => 'Conditions', - 'description' => 'Edit the conditions for a predicate.', + 'title' => t('Conditions'), + 'description' => t('Edit the conditions for a predicate.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('ca_conditions_form', 3), 'access arguments' => array('administer conditional actions'), @@ -97,8 +98,8 @@ 'weight' => -5, ); $items[CA_UI_PATH .'/%/edit/actions'] = array( - 'title' => 'Actions', - 'description' => 'Edit the actions for a predicate.', + 'title' => t('Actions'), + 'description' => t('Edit the actions for a predicate.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('ca_actions_form', 3), 'access arguments' => array('administer conditional actions'), @@ -107,7 +108,7 @@ 'weight' => 0, ); $items[CA_UI_PATH .'/%/reset'] = array( - 'title' => 'Reset a predicate', + 'title' => t('Reset a predicate'), 'page callback' => 'drupal_get_form', 'page arguments' => array('ca_predicate_delete_form', 3), 'access arguments' => array('administer conditional actions'), @@ -115,7 +116,7 @@ 'type' => MENU_CALLBACK, ); $items[CA_UI_PATH .'/%/delete'] = array( - 'title' => 'Delete a predicate', + 'title' => t('Delete a predicate'), 'page callback' => 'drupal_get_form', 'page arguments' => array('ca_predicate_delete_form', 3), 'access arguments' => array('administer conditional actions'), @@ -216,6 +217,7 @@ * The array of arguments keyed according to the trigger's argument names. */ function ca_parse_trigger_args($trigger, $args) { + $arguments = array(); // Fail if we didn't receive enough arguments for this trigger. if (count($args) < count($trigger['#arguments'])) { return FALSE; @@ -238,7 +240,7 @@ $arguments[$key] = array( '#entity' => $value['#entity'], '#title' => $value['#title'], - '#data' => $arg, + '#data' => !empty($arg) ? $arg : null, ); } @@ -264,12 +266,12 @@ // inactive predicates if $all == FALSE and adds a default weight if need be. foreach ($predicates as $key => $value) { // Unset the predicate if it doesn't use the specified trigger. - if ($value['#trigger'] != $trigger) { + if (!empty($value['#trigger'] ) && $value['#trigger'] != $trigger) { unset($predicates[$key]); continue; } - if (!$all && $value['#status'] <= 0) { + if (!empty($value['$status']) && !$all && $value['#status'] <= 0) { unset($predicates[$key]); } elseif (!isset($value['#weight'])) { @@ -350,7 +352,7 @@ */ function ca_evaluate_conditions($predicate, $arguments) { // Automatically pass if there are no conditions. - if (count($predicate['#conditions']) == 0) { + if (!empty($predicate['#conditions']) && count($predicate['#conditions']) == 0) { return TRUE; } @@ -439,7 +441,8 @@ $result = call_user_func_array($callback, $args); // If the negate operator is TRUE, then switch the result! - if ($condition['#settings']['negate']) { + //Fix for EALl + if (isset($condition['#settings']['negate']) && $condition['#settings']['negate']) { $result = !$result; } @@ -484,7 +487,7 @@ if (isset($action['#argument_map'][$key])) { // Adding the arguments as references so action functions can update the // arguments here when they make changes to the argument data. - if ($value['#entity'] == 'arguments') { + if (!empty($value['#entity']) && $value['#entity'] == 'arguments') { $args[] = &$arguments; } else { @@ -498,9 +501,9 @@ } // Add the condition settings to the argument list. - $args[] = is_array($action['#settings']) ? $action['#settings'] : array(); - - // Call the action's function with the appropriate arguments. + //EALL FIX + $args[] = (!empty($action['#settings']) && is_array($action['#settings'])) ? $action['#settings'] : array(); + // Call the action's function with the appropriate arguments. $results[$i] = call_user_func_array($callback, $args); } @@ -638,10 +641,10 @@ // Check through each argument needed for the condition. // Cast to an array to accommodate conditions that need no arguments. foreach ((array) $condition['#arguments'] as $argument) { - $entity = $argument['#entity']; + $entity = !empty($argument['#entity']) ? $argument['#entity'] : null; // If the condition requires an entity the trigger doesn't provide, // then skip to the next condition. - if ($entity != 'arguments' && !$trigger_entities[$entity]) { + if ($entity != 'arguments' && !empty($trigger_entities[$entity]) && !$trigger_entities[$entity]) { continue 2; } } @@ -649,7 +652,7 @@ // Getting this far means that all of the condition's arguments have // the same entity types as the trigger's. Add it to the options, // and group them by category for usability. - $options[$condition['#category']][$name] = $condition['#title']; + $options[$condition['#category']][$name] = !empty($condition['#title']) ? $condition['#title'] : null; } // Alphabetically sort the groups and their options. @@ -726,7 +729,7 @@ $entity = $argument['#entity']; // If the action requires an entity the trigger doesn't provide, // then skip to the next action. - if ($entity != 'arguments' && !$trigger_entities[$entity]) { + if ($entity != 'arguments' && !empty($trigger_entities[$entity]) && !$trigger_entities[$entity]) { continue 2; } } @@ -750,7 +753,7 @@ // Returns a default conditions array for use on new predicates or in the UI. function ca_new_conditions() { - return array( + $new_ca = array( '#operator' => 'AND', '#conditions' => array( array( @@ -759,6 +762,7 @@ ), ), ); + return $new_ca; } /** @@ -829,7 +833,7 @@ function ca_add_condition($pid, $name, $group_key, $mark_expanded = TRUE) { // Load the predicate. $predicate = ca_load_predicate($pid); - + // Load the condition we want to add to the predicate. $data = ca_load_condition($name); @@ -838,7 +842,7 @@ // Build the condition array. $condition = array( '#name' => $name, - '#title' => $data['#title'], + '#title' => !empty($data['#title']) ? $data['#title'] : null, '#argument_map' => array(), '#settings' => array(), );