From 617c5251b6af8f91268f279914fb13835fe3c21e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 30 Apr 2013 17:12:18 -0700 Subject: [PATCH] Remove van module CRM-9794 ---------------------------------------- * CRM-9794: Remove API v2 http://issues.civicrm.org/jira/browse/CRM-9794 --- tools/drupal/modules/civicrm_van/VAN/Auth.php | 79 ----- .../modules/civicrm_van/VAN/Contact.php | 198 ------------ .../drupal/modules/civicrm_van/VAN/Person.php | 142 --------- .../modules/civicrm_van/VAN/apiKey.php.txt | 3 - .../modules/civicrm_van/civicrm_van.info | 7 - .../modules/civicrm_van/civicrm_van.module | 34 --- tools/drupal/modules/civicrm_van/run.php | 11 - .../civicrm_van/xml/CustomGroupData.xml | 281 ------------------ 8 files changed, 755 deletions(-) delete mode 100644 tools/drupal/modules/civicrm_van/VAN/Auth.php delete mode 100644 tools/drupal/modules/civicrm_van/VAN/Contact.php delete mode 100644 tools/drupal/modules/civicrm_van/VAN/Person.php delete mode 100644 tools/drupal/modules/civicrm_van/VAN/apiKey.php.txt delete mode 100644 tools/drupal/modules/civicrm_van/civicrm_van.info delete mode 100644 tools/drupal/modules/civicrm_van/civicrm_van.module delete mode 100644 tools/drupal/modules/civicrm_van/run.php delete mode 100644 tools/drupal/modules/civicrm_van/xml/CustomGroupData.xml diff --git a/tools/drupal/modules/civicrm_van/VAN/Auth.php b/tools/drupal/modules/civicrm_van/VAN/Auth.php deleted file mode 100644 index 09be71ca0c..0000000000 --- a/tools/drupal/modules/civicrm_van/VAN/Auth.php +++ /dev/null @@ -1,79 +0,0 @@ - new SOAPVar(VAN_API_KEY, - XSD_STRING, NULL, NULL, NULL, - self::VAN_NS - ), - 'DatabaseMode' => new SOAPVar(self::DATABASE_NODE, - XSD_STRING, NULL, NULL, NULL, - self::VAN_NS - ), - ); - self::$_header = new SOAPHeader(self::VAN_NS, - 'Header', - new SOAPVar($headerParams, - SOAP_ENC_OBJECT - ) - ); - - self::$_client = new SOAPClient(self::WSDL_URL, - array('trace' => TRUE) - ); - self::$_client->__setSoapHeaders(array(self::$_header)); - } - - static - function invoke($method, &$params) { - self::initialize(); - return self::$_client->$method($params); - } -} - diff --git a/tools/drupal/modules/civicrm_van/VAN/Contact.php b/tools/drupal/modules/civicrm_van/VAN/Contact.php deleted file mode 100644 index b940671824..0000000000 --- a/tools/drupal/modules/civicrm_van/VAN/Contact.php +++ /dev/null @@ -1,198 +0,0 @@ - array($person['custom']['van_id'], 'Integer')); - $cid = CRM_Core_DAO::singleValueQuery($sql, $params); - if ($cid) { - return array($cid); - } - - // ok, how about we search on - // first_name AND last_name AND street_address AND zip_code - $sql = " -SELECT contact_id -FROM civicrm_contact c, - civicrm_address a -WHERE a.contact_id = c.id -AND c.first_name = %1 -AND c.last_name = %2 -AND a.postal_code = %3 -AND a.street_address = %4 -"; - $params = array(1 => array($person['first_name'], 'String'), - 2 => array($person['last_name'], 'String'), - 3 => array($person['address'][0]['street_address'], 'String'), - 4 => array($person['address'][0]['postal_code'], 'String'), - ); - $dao = CRM_Core_DAO::executeQuery($sql, $params); - if ($dao->N == 1) { - $dao->fetch(); - return array($dao->contact_id); - } - elseif ($dao->N > 1) { - $cids = array(); - while ($dao->fetch()) { - $cids[] = $dao->contact_id; - } - return $cids; - } - - // ok did not find it - // run a simpler query - // first_name AND last_name AND street_address AND zip_code - $sql = " -SELECT contact_id -FROM civicrm_contact c, - civicrm_address a -WHERE a.contact_id = c.id -AND c.first_name = %1 -AND c.last_name = %2 -AND a.postal_code = %3 -"; - $dao = CRM_Core_DAO::executeQuery($sql, $params); - if ($dao->N == 1) { - $dao->fetch(); - return array($dao->contact_id); - } - elseif ($dao->N > 1) { - $cids = array(); - while ($dao->fetch()) { - $cids[] = $dao->contact_id; - } - return $cids; - } - - return NULL; - } - - function createOrUpdateContact(&$person, $cid = NULL) { - if (!$cid) { - $cids = self::findContact($person); - if (is_array($cids) && - count($cids) == 1 - ) { - $cid = $cids[0]; - } - // did not find a contact or too many matching contacts - // lets create a new one :) - } - - $person['contact_type'] = 'Individual'; - - // format address params - if (isset($person['address'])) { - $locationTypes = CRM_Core_PseudoConstant::locationType(); - foreach ($person['address'] as $key => $value) { - $person['address'][$key]['location_type_id'] = array_search($person['address'][$key]['location_type'], $locationTypes); - unset($person['address'][$key]['location_type']); - if ($cid) { - $person['address'][$key]['contact_id'] = $cid; - } - } - } - - // format phone params - if (isset($person['phone'])) { - $phoneTypes = CRM_Core_PseudoConstant::phoneType(); - foreach ($person['phone'] as $key => $value) { - $person['phone'][$key]['phone'] = $person['phone'][$key]['phone_number']; - unset($person['phone'][$key]['phone_number']); - $person['phone'][$key]['location_type_id'] = $person['address'][0]['location_type_id']; - $person['phone'][$key]['phone_type_id'] = array_search($person['phone'][$key]['phone_type'], $phoneTypes); - unset($person['phone'][$key]['phone_type']); - if ($cid) { - $person['phone'][$key]['contact_id'] = $cid; - } - } - } - - require_once 'api/v2/Contact.php'; - if (!$cid) { - $params = $person; - $contact = civicrm_contact_create($params); - if ($contact['is_error']) { - CRM_Core_Error::fatal(); - } - - $cid = $contact['contact_id']; - } - else { - $person['contact_id'] = $cid; - $params = $person; - $contact = civicrm_contact_update($params); - if ($contact['is_error']) { - CRM_Core_Error::fatal(); - } - } - - // now add all the custom fields - $sql = " -REPLACE INTO civicrm_value_van - ( entity_id, van_id, party, county, precinct, congressional, - assembly, state_senate, municipality, ward, supervisor_dist, - portion, zip5 ) -VALUES - ( %1, %2, %3, %4, %5, %6, - %7, %8, %9, %10, %11, - %12, %13 ) -"; - - $custom = &$person['custom']; - $params = array(1 => array($cid, 'Integer'), - 2 => array($custom['van_id'], 'Integer'), - 3 => array($custom['party'], 'String'), - 4 => array($custom['county'], 'String'), - 5 => array($custom['precinct'], 'Integer'), - 6 => array($custom['congressional'], 'Integer'), - 7 => array($custom['assembly'], 'Integer'), - 8 => array($custom['state_senate'], 'Integer'), - 9 => array($custom['municipality'], 'String'), - 10 => array($custom['ward'], 'Integer'), - 11 => array($custom['supervisor_dist'], 'Integer'), - 12 => array($custom['portion'], 'String'), - 13 => array($custom['zip5'], 'String'), - ); - $dao = CRM_Core_DAO::executeQuery($sql, $params); - } -} - diff --git a/tools/drupal/modules/civicrm_van/VAN/Person.php b/tools/drupal/modules/civicrm_van/VAN/Person.php deleted file mode 100644 index 77f17a86f6..0000000000 --- a/tools/drupal/modules/civicrm_van/VAN/Person.php +++ /dev/null @@ -1,142 +0,0 @@ - $vanID, - 'PersonIDType' => 'VANID', - 'options' => array('ReturnSections' => 'Address,Phone,District'), - ); - - require_once 'van/Auth.php'; - $details = van_Auth::invoke('GetPerson', $params); - - return self::formatPersonDetails($details->GetPersonResult); - } - - static - function &formatPersonDetails(&$person) { - $map = array('FirstName' => 'first_name', - 'LastName' => 'last_name', - 'Sex' => 'Gender', - 'Email' => 'email', - 'Party' => 'custom_party', - 'VANID' => 'custom_van_id', - 'DateOfBirth' => 'birth_date', - ); - $values = self::mapInfo($map, $person); - - $map = array('StreetAddress' => 'street_address', - 'City' => 'city', - 'State' => 'state_province', - 'Zip5' => 'postal_code', - 'Zip4' => 'postal_code_suffix', - 'AddressType' => 'location_type', - 'IsPreferred' => 'is_primary', - ); - self::extractInfo('Addresses', 'Address', $person, $values, $map, 'address'); - - $map = array('Number' => 'phone_number', - 'PhoneType' => 'phone_type', - 'IsPreferred' => 'is_primary', - ); - self::extractInfo('Phones', 'Phone', $person, $values, $map, 'phone'); - - /*** - $map = array( 'Email' => 'email', - 'IsPreferred' => 'is_primary' ); - self::extractInfo( 'Emails', 'Email', $person, $values, $map, 'email' ); - ***/ - - self::extractDistricts($person, $values); - - return $values; - } - - function mapInfo(&$map, &$object) { - $value = array(); - foreach ($map as $k => $v) { - if (isset($object->$k)) { - $value[$map[$k]] = $object->$k; - } - } - return $value; - } - - function extractInfo($primary, $secondary, &$object, &$values, &$map, $key) { - if (isset($object->$primary) && - isset($object->$primary->$secondary) - ) { - $values[$key] = array(); - $actual = $object->$primary->$secondary; - if (is_array($actual)) { - foreach ($actual as $a) { - self::extractInfoSingle($map, $a, $values[$key]); - } - } - else { - self::extractInfoSingle($map, $actual, $values[$key]); - } - if (empty($values[$key])) { - unset($values[$key]); - } - } - } - - function extractInfoSingle(&$map, &$object, &$values) { - $value = self::mapInfo($map, $object); - if (!empty($value)) { - $values[] = $value; - } - } - - function extractDistricts(&$person, &$values) { - $values['custom'] = array('van_id' => $values['custom_van_id'], - 'party' => $values['custom_party'], - ); - unset($values['custom_van_id']); - unset($values['custom_party']); - - if (isset($person->Districts) && - isset($person->Districts->District) - ) { - foreach ($person->Districts->District as $district) { - $values['custom'][preg_replace('/\s+|\W+/', '_', - strtolower($district->DistrictType) - )] = $district->Name; - } - } - } -} - diff --git a/tools/drupal/modules/civicrm_van/VAN/apiKey.php.txt b/tools/drupal/modules/civicrm_van/VAN/apiKey.php.txt deleted file mode 100644 index fd3e14e30c..0000000000 --- a/tools/drupal/modules/civicrm_van/VAN/apiKey.php.txt +++ /dev/null @@ -1,3 +0,0 @@ - VAN Integration -description = CiviCRM <-> VAN Integration -version = 3.4 -dependencies[] = civicrm -package = CiviCRM -core = 6.x -php = 5.2 diff --git a/tools/drupal/modules/civicrm_van/civicrm_van.module b/tools/drupal/modules/civicrm_van/civicrm_van.module deleted file mode 100644 index 33485a39fd..0000000000 --- a/tools/drupal/modules/civicrm_van/civicrm_van.module +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - VAN - VAN - Individual - - 0 - - - 2 - 1 - civicrm_value_van - 0 - 1 - 2009-09-18 10:15:04 - - - - - - Int - Text - 1 - 1 - 1 - 1 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - van_id - VAN - - - - String - Select - 0 - 1 - 0 - 2 - 1 - 0 - 4 - M:;:;:;d:;:;:;Y - 60 - 4 - party - Party - VAN - - - - String - Text - 0 - 0 - 0 - 3 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - county - VAN - - - - Int - Text - 0 - 1 - 1 - 4 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - precinct - VAN - - - - Int - Text - 0 - 1 - 1 - 5 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - congressional - VAN - - - - Int - Text - 0 - 1 - 1 - 6 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - assembly - VAN - - - - Int - Text - 0 - 1 - 1 - 7 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - state_senate - VAN - - - - String - Text - 0 - 1 - 0 - 8 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - municipality - VAN - - - - Int - Text - 0 - 1 - 1 - 9 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - ward - VAN - - - - Int - Text - 0 - 1 - 1 - 10 - 1 - 0 - 255 - M:;:;:;d:;:;:;Y - 60 - 4 - supervisor_dist - VAN - - - - String - Text - 0 - 0 - 0 - 11 - 1 - 0 - 8 - M:;:;:;d:;:;:;Y - 60 - 4 - portion - VAN - - - - String - Text - 0 - 1 - 0 - 12 - 1 - 0 - 10 - M:;:;:;d:;:;:;Y - 60 - 4 - zip5 - VAN - - - - - party_20090918102033 - - 1 - - - - - - DS - Declined - 0 - 3 - 0 - 0 - 1 - Party - - - - D - Democrat - 0 - 1 - 0 - 0 - 1 - Party - - - - G - Green - 0 - 4 - 0 - 0 - 1 - Party - - - - R - Republican - 0 - 2 - 0 - 0 - 1 - Party - - - -- 2.25.1