diff -urp contact_importer.orig/contact_importer.info contact_importer/contact_importer.info --- contact_importer.orig/contact_importer.info 2008-09-22 06:04:13.000000000 -0600 +++ contact_importer/contact_importer.info 2008-12-12 15:13:40.000000000 -0700 @@ -2,8 +2,4 @@ name = Contact Importer description = Enables other modules to allow users to import email addresses from their address book. package = Contact Importer -; Information added by drupal.org packaging script on 2008-09-22 -version = "5.x-1.x-dev" -project = "contact_importer" -datestamp = "1222085053" - +core = 6.x \ No newline at end of file diff -urp contact_importer.orig/contact_importer.module contact_importer/contact_importer.module --- contact_importer.orig/contact_importer.module 2008-09-21 22:57:09.000000000 -0600 +++ contact_importer/contact_importer.module 2009-01-06 19:54:22.000000000 -0700 @@ -16,51 +16,45 @@ * Implementation of hook_perm. */ function contact_importer_perm() { - return array('access contact importer'); + return array('access contact importer', 'admin contact importer'); } /** * Implementation of hook_menu. */ -function contact_importer_menu($may_cache) { +function contact_importer_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/contact_importer', - 'title' => 'Contact Importer', - 'callback' => 'drupal_get_form', - 'callback arguments' => 'contact_importer_settings', - ); - $items[] = array( - 'path' => 'contact_importer', - 'title' => 'Import your contacts', - 'callback' => 'drupal_get_form', - 'callback arguments' => 'contact_importer_form', - 'access' => user_access('access contact importer'), - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'contact_importer_js', - 'title' => 'Import your contacts', - 'callback' => 'contact_importer_js', - 'access' => user_access('access contact importer'), - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'contact_importer_js_submit', - 'title' => 'Import your contacts', - 'callback' => 'contact_importer_js_submit', - 'access' => user_access('access contact importer'), - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'contact_importer/engine_help', - 'title' => 'Contact Importer Help', - 'callback' => 'contact_importer_engine_help', - 'access' => user_access('access contact importer'), - 'type' => MENU_CALLBACK, - ); - } + $items['admin/contact_importer'] = array( + 'title' => 'Contact Importer', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('contact_importer_settings'), + 'access arguments' => array('administer contact importer'), + ); + $items['contact_importer'] = array( + 'title' => 'Import your contacts', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('contact_importer_form'), + 'access arguments' => array('access contact importer'), + 'type' => MENU_CALLBACK, + ); + $items['contact_importer_js'] = array( + 'title' => 'Import your contacts', + 'page callback' => 'contact_importer_js', + 'access arguments' => array('access contact importer'), + 'type' => MENU_CALLBACK, + ); + $items['contact_importer_js_submit'] = array( + 'title' => 'Import your contacts', + 'page callback' => 'contact_importer_js_submit', + 'access arguments' => array('access contact importer'), + 'type' => MENU_CALLBACK, + ); + $items['contact_importer/engine_help'] = array( + 'title' => 'Contact Importer Help', + 'page callback' => 'contact_importer_engine_help', + 'access arguments' => array('access contact importer'), + 'type' => MENU_CALLBACK, + ); return $items; } @@ -135,7 +129,6 @@ function contact_importer_requirements($ * @return FAPI array. */ function contact_importer_settings() { - // Check for Lightbox2. if (!module_exists('lightbox2')) { drupal_set_message( @@ -196,6 +189,13 @@ function contact_importer_settings() { ); } + + $form['separator'] = array( + '#type' => 'textfield', + '#title' => t('Separate Character'), + '#description' => t('Character that will be used to separate email addresses'), + '#default_value' => variable_get('contact_importer_separator', '//n'), + ); // TODO: Maybe have a list of options for what seperator to use for the // final email list (newline, comma, semi-colon). @@ -207,8 +207,9 @@ function contact_importer_settings() { return $form; } -function contact_importer_settings_submit($form_id, $form_values) { - variable_set('contact_importer_engine', $form_values['engines']); +function contact_importer_settings_submit($form, $form_state) { + variable_set('contact_importer_engine', $form_state['values']['engines']); + variable_set('contact_importer_separator', $form_state['values']['separator']); } /** @@ -218,7 +219,7 @@ function contact_importer_settings_submi * Is the form being used as a javascript modal popup? * @return FAPI array. */ -function contact_importer_form($js_modal = FALSE) { +function contact_importer_form($form_state, $js_modal = FALSE) { // Sanity checking. $requirements = contact_importer_requirements('runtime'); @@ -232,10 +233,45 @@ function contact_importer_form($js_modal } // Remove any emails stored from a previous attempt. - contact_importer_set_contacts(NULL); + if(empty($form_state['values'])) { + contact_importer_set_contacts(NULL); + + // Build the form. { + $form = $engine_form_function(); + } else { + $email_list = array(); + $email_list['selectAll'] = 'Select/Deselect All'; + foreach ($form_state['values']['contacts'] as $contact) { + $name = $contact['name']; + $email = $contact['email']; + $email_list[htmlentities($email)] = htmlentities($name).' <'.htmlentities($email).'>'; + + } + + $form['contacts']['list'] = array( + '#type' => 'checkboxes', + '#options' => $email_list, + '#required' => TRUE, + + ); + $form['addContact'] = array( + '#type' => 'button', + '#id' => 'submit-contacts', + '#value' => 'Add Contacts', + ); + + //select/deselect all js + $js = << 'value', '#value' => $js_modal, @@ -244,22 +280,29 @@ function contact_importer_form($js_modal '#type' => 'value', '#value' => $current_engine, ); + + + return $form; } /** * Validation handler. * - * @param string $form_id - * @param array $form_values * @param array $form + * @param array $form_state * @return NULL */ -function contact_importer_form_validate($form_id, $form_values, $form) { - $engine_validation_function = $form_values['current_engine'] .'_form_validate'; - if (function_exists($engine_validation_function)) { - $engine_validation_function($form_id, $form_values, $form); - } +function contact_importer_form_validate($form, &$form_state) { + if(empty($form_state['values']['list'])) { + $form_state['rebuild'] = TRUE; + $engine_validation_function = $form_state['values']['current_engine'] .'_form_validate'; + if (function_exists($engine_validation_function)) { + $engine_validation_function($form, $form_state); + } + } else { + $form_state['submitted'] = TRUE; + } } /** @@ -269,14 +312,20 @@ function contact_importer_form_validate( * @param array $form_values * @return NULL */ -function contact_importer_form_submit($form_id, $form_values) { - $engine_submit_function = $form_values['current_engine'] .'_form_submit'; +function contact_importer_form_submit($form, &$form_state) { + + $engine_submit_function = $form_state['values']['current_engine'] .'_form_submit'; if (function_exists($engine_submit_function)) { - $engine_submit_function($form_id, $form_values); - } + $engine_submit_function($form, $form_state); + } + //remove selectall if it is set + $list = $form_state['values']['list']; + if(isset($list['selectAll'])) { + unset($list['selectAll']); + } // Add the results to the session. - contact_importer_set_contacts($form_values['contacts']); + contact_importer_set_contacts(array_filter($list)); // If we are on the non-JS form, return to the calling form. // Otherwise don't do anything and contact_importer_js() will take care of things. @@ -285,9 +334,10 @@ function contact_importer_form_submit($f // Do not unset($_SESSION['contact_importer_destination']) since this is used on subsequent // forms for sanity checking. $destination = $_SESSION['contact_importer_destination']; - if (!$form_values['js_modal']) { + if (!$form_state['values']['js_modal']) { return $destination; } + } /** @@ -318,12 +368,11 @@ function contact_importer_js() { // If the form has just been sucessfully submitted, // move our contact details to the textfield in the parent window. - if ($emails = contact_importer_get_contacts('string_emails', "\\n")) { - + $separator = variable_get('contact_importer_separator', '\n'); + if ($emails = contact_importer_get_contacts($separator)) { // Clear the stored contacts so that the user can do the whole thing again to retrieve from a // different provider. contact_importer_set_contacts(NULL); - $js = 'window.parent.Drupal.contactImporterFillEmails("'. $emails .'");'. 'window.parent.Lightbox.end("forceClose");'. 'window.parent.jQuery(".contact-importer-review-message").show(1000);'; @@ -352,7 +401,7 @@ function contact_importer_add_js() { // This is the page that we will return to when the form is submitted. // Used only for our non JS form. $_SESSION['contact_importer_destination'] = $_GET['q']; - + $separator = variable_get('contact_importer_separator', '\n'); // Unset any previous lookups. contact_importer_set_contacts(NULL); @@ -366,9 +415,8 @@ function contact_importer_add_js() { // Don't use jQuery(document).ready() so that lightbox code does its binding // after we have assigned the rel attr. jQuery('a.contact-importer-link').attr('href', jQuery('a.contact-importer-link').attr('href') + '_js'); - jQuery('a.contact-importer-link').attr('rel', 'lightframe[|width:500px; height:500px;]'); - jQuery('.contact-importer-review-message').hide('fast'); - + jQuery('a.contact-importer-link').attr('rel', 'lightframe[|width:550px; height:450px;]'); + jQuery('.contact-importer-review-message').hide('fast'); /** * Fills the textfield with our addresses. * @@ -378,10 +426,11 @@ function contact_importer_add_js() { Drupal.contactImporterFillEmails = function(emails) { jQuery('.contact-importer-destination').each(function(){ var text = jQuery(this).val(); - jQuery(this).val(text + (text ? "\\n" : '') + emails); + jQuery(this).val(text + (text ? "$separator" : '') + emails); }); }; EOD; + drupal_add_js($js, 'inline', 'footer'); } @@ -394,7 +443,7 @@ EOD; * @return NULL */ function contact_importer_set_contacts($contacts = array()) { - + // Do we need to reset? if ($contacts === NULL || !is_array($contacts)) { unset($_SESSION['contact_importer_contacts']); @@ -407,10 +456,7 @@ function contact_importer_set_contacts($ /** * Return the contacts. - * - * @param string $format - * What format do you want the contacts returned as: - * 'array', 'string_emails', 'string_names' + * * @param string $separator * Only used for formats other than 'array'. What do you want to separate the elements? * @return mixed @@ -420,9 +466,8 @@ function contact_importer_set_contacts($ * and has keys for email and name. * Otherwise a string. */ -function contact_importer_get_contacts($format = 'string_emails', $separator = "\n") { +function contact_importer_get_contacts($separator = "\n") { $contacts = (array)$_SESSION['contact_importer_contacts']; - // Are we on the same form as the original process, or is this a new form? $q = $_GET['q']; if ( @@ -435,20 +480,8 @@ function contact_importer_get_contacts($ } $elements = array(); - switch ($format) { - case 'array': - return $contacts; - case 'string_names': - foreach ($contacts as $contact) { - $elements[] = $contact['name']; - } - break; - case 'string_emails': - default: - foreach ($contacts as $contact) { - $elements[] = $contact['email']; - } - break; + foreach ($contacts as $contact) { + $elements[] = $contact; } return implode($separator, $elements); } @@ -500,3 +533,14 @@ function _contact_importer_engines() { } return $engines; } + +/** + * Implementation of hook_theme() + */ +function contact_importer_theme() { + return array( + 'contact_importer_js' => array( + 'arguments' => array('content'), + ), + ); +} Only in contact_importer/: CVS Only in contact_importer.orig/: LICENSE.txt Only in contact_importer/octazen_engine: abimporter Only in contact_importer/octazen_engine: CVS diff -urp contact_importer.orig/octazen_engine/octazen_engine.info contact_importer/octazen_engine/octazen_engine.info --- contact_importer.orig/octazen_engine/octazen_engine.info 2008-09-22 06:04:13.000000000 -0600 +++ contact_importer/octazen_engine/octazen_engine.info 2008-12-12 15:13:40.000000000 -0700 @@ -1,10 +1,6 @@ ; $Id: octazen_engine.info,v 1.1.2.1 2008/08/18 05:23:32 dalin Exp $ name = Octazen Retrieval Engine description = Integrates Contact Importer with the Octazen Retrieval Service -dependencies = contact_importer +dependencies[] = contact_importer package = Contact Importer -; Information added by drupal.org packaging script on 2008-09-22 -version = "5.x-1.x-dev" -project = "contact_importer" -datestamp = "1222085053" - +core = 6.x \ No newline at end of file diff -urp contact_importer.orig/octazen_engine/octazen_engine.module contact_importer/octazen_engine/octazen_engine.module --- contact_importer.orig/octazen_engine/octazen_engine.module 2008-09-10 21:24:52.000000000 -0600 +++ contact_importer/octazen_engine/octazen_engine.module 2008-12-12 15:13:40.000000000 -0700 @@ -18,7 +18,7 @@ function octazen_engine_retrieval_engine return array( 'name' => 'Octazen', 'url' => 'http://octazen.com/product_abimporter.php', - 'inc' => 'abimporter/abi.php', + 'inc' => 'abimporter/abimporter/abi.php', ); } @@ -121,28 +121,29 @@ EOD; * we do the heavy lifting here instead of in the submit handler. * * @param string $form_id - * @param array $form_values + * @param array $form_state * @param array $form * @return null */ -function octazen_engine_form_validate($form_id, $form_values, $form) { +function octazen_engine_form_validate($form, &$form_state) { // Load the library. $engines = _contact_importer_engines(); - require_once(dirname(__FILE__) . '/'. $engines['octazen_engine']['inc']); + $filename = substr($engines['octazen_engine']['inc'], 0, -4); + module_load_include('php', 'octazen_engine', $filename); - $file = file_check_upload(); + // $file = file_check_upload(); // Webmail scenario. - if ($form_values['email'] || $form_values['password']) { + if ($form_state['values']['email'] || $form_state['values']['password']) { $scenario = 'webmail'; // Validate form fields. - if (!$form_values['email']) { + if (!$form_state['values']['email']) { form_set_error('email', t('Please enter your email address.')); return; } - elseif (!$form_values['password']) { + elseif (!$form_state['values']['password']) { form_set_error('password', t('Please enter your password.')); return; } @@ -150,7 +151,7 @@ function octazen_engine_form_validate($f // Fetch the contacts. $importer = new AddressBookImporter; - $contacts = $importer->fetchContacts($form_values['email'], $form_values['password']); + $contacts = $importer->fetchContacts($form_state['values']['email'], $form_state['values']['password']); $result = abi_get_errorcode(); if ($result != _ABI_SUCCESS || !is_array($contacts)) { @@ -187,7 +188,9 @@ function octazen_engine_form_validate($f // IMPORTANT: Add the contacts to the form so that they are available in // the submit stage. Contacts must be an array of arrays. - form_set_value($form['contacts'], _octazen_engine_contacts_as_arrays($contacts)); + + $contactArray = _octazen_engine_contacts_as_arrays($contacts); + form_set_value($form['contacts'], $contactArray, $form_state); return; } } @@ -195,11 +198,11 @@ function octazen_engine_form_validate($f } // Upload scenario. - elseif ($form_values['format'] || $file) { + elseif ($form_state['values']['format']){// || $file) { $scenario = 'upload'; // Validate form fields. - if (!$form_values['format']) { + if (!$form_state['values']['format']) { form_set_error('format', t('Please choose a file format.')); return; } @@ -215,7 +218,7 @@ function octazen_engine_form_validate($f $error = t('Empty CSV file'); } else { - switch ($form_values['format']) { + switch ($form_state['values']['format']) { case "o": $result = abi_extractContactsFromCsv($csv); break; @@ -234,7 +237,7 @@ function octazen_engine_form_validate($f // IMPORTANT: Add the contacts to the form so that they are available in // the submit stage. Contacts must be an array of arrays. - form_set_value($form['contacts'], _octazen_engine_contacts_as_arrays($result)); + form_set_value($form['contacts'], _octazen_engine_contacts_as_arrays($result), $form_state); return; } } @@ -266,10 +269,10 @@ function octazen_engine_form_validate($f * Submit handler * * @param string $form_id - * @param array $form_values + * @param array $form_state * @return null */ -function octazen_engine_form_submit($form_id, $form_values) { +function octazen_engine_form_submit($form, &$form_state) { // There's noting to do here since due to the architecture of the octazen library // we are forced to do all processing in the validation handler. } @@ -821,3 +824,14 @@ function _ocatazen_engine_email_domains( $list[] = '@t-online.de'; return $list; } + + +/** + * Implementation of hook_theme() + */ +function octazen_engine_theme() { + return array( + 'theme_octazen_engine_file_help' => array(), + 'theme_octazen_engine_webmail_help' => array(), + ); +} \ No newline at end of file Only in contact_importer/octazen_engine: .svn Only in contact_importer/: .svn