/** * Sends fax (using the myfax.com service) to a target determined by the participant\'s information. */ function connect_action_myfax_lookup(&$parent, &$child, $op = '', $target = 'child') { switch ($op) { case 'requires': require_once drupal_get_path('module', 'connect') . '/connect_lookup.php'; $return = array(); $default = connect_node_options($parent->nid, 'is_live'); $default = $default ? $default : 'no'; $options = connect_get_lookup_types(TRUE); $base['variables'] = array('is_live' => array('#type' => 'radios', '#title' => t('Is this campaign ready to go live?'), '#description' => t('\'No\' means that no emails, faxes, etc. will not be sent; you will instead see a display of the message(s) that would have been sent.'), '#options' => array('yes' => 'Yes', 'no' => 'No'), '#default_value' => $default, '#required' => TRUE), 'myfax_lookup_type' => array('#type' => 'select', '#title' => 'MyFax target lookup', '#options' => $options, '#default_value' => connect_node_options($parent->nid, 'myfax_lookup_type'), '#required' => TRUE), 'myfax_email' => array('#type' => 'textfield', '#title' => 'MyFax account \'from\' email address', '#default_value' => connect_node_options($parent->nid, 'myfax_email'), '#required' => TRUE), 'myfax_password' => array('#type' => 'textfield', '#title' => 'MyFax password', '#default_value' => connect_node_options($parent->nid, 'myfax_password'))); $base['parent'] = array('fax_subject' => 'Fax subject', 'fax_body' => 'Fax body'); $base['child'] = array('fax_lookup_result' => 'MyFax (lookup) success/failure message', 'fax_from' => 'Fax \'from\' name'); // add requirements from lookup type $lookup = connect_target_lookup($parent, $child, 'requires', 'myfax'); if (is_array($lookup)) { foreach (array('variables', 'parent', 'child') as $key) { if (isset($lookup[$key])) { $return[$key] = $base[$key] + $lookup[$key]; } else { $return[$key] = $base[$key]; } } } else { $return = $base; drupal_set_message('You have not selected a lookup type. Please do so and then adjust any new settings that are required.'); } return $return; break; case 'validate': if ($target != 'child') { return; } $name = connect_value('fax_from', $parent, $child, 'child'); if (empty($name)) { form_set_error('', 'Please enter your name.'); } // call validation from lookup type connect_target_lookup($parent, $child, 'validate', 'myfax'); break; case 'insert': if ($target != 'child') { return; } require_once drupal_get_path('module', 'connect') . '/connect_lookup.php'; $target = connect_target_lookup($parent, $child, 'lookup', 'myfax'); if ($target && isset($target['fax']) && strlen($target['fax']) >= 10) { $fax = array(); $fax['from_name'] = connect_value('fax_from', $parent, $child, 'child'); $fax['from_mail'] = connect_node_options($parent->nid, 'myfax_email'); $fax['to_fax'] = $target['fax']; $fax['to_name'] = $target['name']; $fax['body'] = connect_value('fax_body', $parent, $child, 'parent'); $fax['password'] = connect_node_options($parent->nid, 'myfax_password'); $fax['subject'] = connect_value('fax_subject', $parent, $child, 'parent'); $message = connect_myfax_prepare($fax); $active = connect_node_options($parent->nid, 'is_live') == 'yes'; $result = _connect_send_email($message, FALSE, $active); } else { $result = FALSE; } // save result $_SESSION['connect_' . $parent->nid . '_myfax_lookup_sent'] = $result ? $target['name'] : FALSE; $result = $result ? "Success" : "Failed"; connect_value('fax_lookup_result', $parent, $child, 'child', $result); node_save($child); break; case 'status': $message = ''; if (isset($_SESSION['connect_' . $parent->nid . '_myfax_lookup_sent'])) { $message = $_SESSION['connect_' . $parent->nid . '_myfax_lookup_sent'] ? 'Your fax message was sent to ' . $_SESSION['connect_' . $parent->nid . '_myfax_lookup_sent'] : 'Sorry, but there was a problem sending the message. The problem will be investigated, and your message will be sent when the problem is resolved.'; unset($_SESSION['connect_' . $parent->nid . '_myfax_lookup_sent']); } return array('status' => $message); break; break; } }
function _connect_get_cache_names() { $cache_names = array(); $lookup_types = connect_get_lookup_types(TRUE); unset($lookup_types[0]); $empty = array(); foreach ($lookup_types as $key => $title) { if (function_exists($key)) { eval('$temp = ' . $key . '(\'cache\', $empty, $empty);'); $cache_names = array_merge($cache_names, $temp); } } return array_unique($cache_names); }