From d69b0ac71cbbadba90076df15db1a8e3ce0a9516 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 8 Mar 2016 19:35:58 -0500 Subject: [PATCH] CRM-18192 - Remove Sunlight code from core --- CRM/Contact/Page/View/Sunlight.php | 65 ------- CRM/Core/xml/Menu/Contact.xml | 5 - CRM/Utils/Sunlight.php | 185 ------------------- templates/CRM/Contact/Page/View/Sunlight.tpl | 59 ------ 4 files changed, 314 deletions(-) delete mode 100644 CRM/Contact/Page/View/Sunlight.php delete mode 100644 CRM/Utils/Sunlight.php delete mode 100644 templates/CRM/Contact/Page/View/Sunlight.tpl diff --git a/CRM/Contact/Page/View/Sunlight.php b/CRM/Contact/Page/View/Sunlight.php deleted file mode 100644 index add1aa6afc..0000000000 --- a/CRM/Contact/Page/View/Sunlight.php +++ /dev/null @@ -1,65 +0,0 @@ -_contactId); - $locations = CRM_Contact_BAO_Contact_Location::getMapInfo($ids); - - $rows = &CRM_Utils_Sunlight::getInfo($locations[0]['city'], - $locations[0]['state'], - $locations[0]['postal_code'] - ); - $this->assign('rowCount', count($rows)); - $this->assign_by_ref('rows', $rows); - } - - /** - * the main function that is called when the page loads, - * it decides the which action has to be taken for the page. - * - * @return null - */ - public function run() { - $this->preProcess(); - - $this->browse(); - - return parent::run(); - } - -} diff --git a/CRM/Core/xml/Menu/Contact.xml b/CRM/Core/xml/Menu/Contact.xml index 7f1ac88b2a..cee3a1b9c2 100644 --- a/CRM/Core/xml/Menu/Contact.xml +++ b/CRM/Core/xml/Menu/Contact.xml @@ -194,11 +194,6 @@ Smart Groups CRM_Contact_Page_View_ContactSmartGroup - - civicrm/contact/view/sunlight - Sunlight - CRM_Contact_Page_View_Sunlight - civicrm/contact/view/note cid=%%cid%% diff --git a/CRM/Utils/Sunlight.php b/CRM/Utils/Sunlight.php deleted file mode 100644 index bffa1ed972..0000000000 --- a/CRM/Utils/Sunlight.php +++ /dev/null @@ -1,185 +0,0 @@ - HTTP_REQUEST_METHOD_GET, - 'allowRedirects' => FALSE, - ); - - $request = new HTTP_Request(self::$_apiURL . $uri, $params); - $result = $request->sendRequest(); - if (PEAR::isError($result)) { - CRM_Core_Error::fatal($result->getMessage()); - } - if ($request->getResponseCode() != 200) { - CRM_Core_Error::fatal(ts('Invalid response code received from Sunlight servers: %1', - array(1 => $request->getResponseCode()) - )); - } - $string = $request->getResponseBody(); - return simplexml_load_string($string); - } - - /** - * @param $zipcode - * - * @return array - */ - public static function getCityState($zipcode) { - $key = self::$_apiKey; - $uri = "places.getCityStateFromZip.php?zip={$zipcode}&apikey={$key}&output=xml"; - $xml = self::makeAPICall($uri); - - return array($xml->city, $xml->state); - } - - /** - * @param int $peopleID - * - * @return array - */ - public static function getDetailedInfo($peopleID) { - $key = self::$_apiKey; - $uri = "people.getPersonInfo.php?id={$peopleID}&apikey={$key}&output=xml"; - $xml = self::makeAPICall($uri); - - $result = array(); - $fields = array( - 'title' => 'title', - 'firstname' => 'first_name', - 'lastname' => 'last_name', - 'gender' => 'gender', - 'party' => 'party', - 'congress_office' => 'address', - 'phone' => 'phone', - 'email' => 'email', - 'congresspedia' => 'url', - 'photo' => 'image_url', - 'webform' => 'contact_url', - ); - - foreach ($fields as $old => $new) { - $result[$new] = (string ) $xml->$old; - } - - $result['image_url'] = 'http://sunlightlabs.com/widgets/popuppoliticians/resources/images/' . $result['image_url']; - - return $result; - } - - /** - * @param $uri - * - * @return array - */ - public static function getPeopleInfo($uri) { - $xml = self::makeAPICall($uri); - - $result = array(); - foreach ($xml->entity_id_list->entity_id as $key => $value) { - $result[] = self::getDetailedInfo($value); - } - return $result; - } - - /** - * @param $city - * @param $state - * - * @return array|null - */ - public static function getRepresentativeInfo($city, $state) { - if (!$city || - !$state - ) { - return NULL; - } - $key = self::$_apiKey; - $city = urlencode($city); - $uri = "people.reps.getRepsFromCityState.php?city={$city}&state={$state}&apikey={$key}&output=xml"; - return self::getPeopleInfo($uri); - } - - /** - * @param $state - * - * @return array|null - */ - public static function getSenatorInfo($state) { - if (!$state) { - return NULL; - } - - $key = self::$_apiKey; - $uri = "people.sens.getSensFromState.php?state={$state}&apikey={$key}&output=xml"; - return self::getPeopleInfo($uri); - } - - /** - * @param $city - * @param $state - * @param null $zipcode - * - * @return array - */ - public static function getInfo($city, $state, $zipcode = NULL) { - if ($zipcode) { - list($city, $state) = self::getCityState($zipcode); - } - - $reps = self::getRepresentativeInfo($city, $state); - $sens = self::getSenatorInfo($state); - - $result = array(); - if (is_array($reps)) { - $result = array_merge($result, $reps); - } - if (is_array($sens)) { - $result = array_merge($result, $sens); - } - - return $result; - } - -} diff --git a/templates/CRM/Contact/Page/View/Sunlight.tpl b/templates/CRM/Contact/Page/View/Sunlight.tpl deleted file mode 100644 index af049011a3..0000000000 --- a/templates/CRM/Contact/Page/View/Sunlight.tpl +++ /dev/null @@ -1,59 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 4.7 | - +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | - +--------------------------------------------------------------------+ - | This file is a part of CiviCRM. | - | | - | CiviCRM is free software; you can copy, modify, and distribute it | - | under the terms of the GNU Affero General Public License | - | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | - | | - | CiviCRM is distributed in the hope that it will be useful, but | - | WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | - | See the GNU Affero General Public License for more details. | - | | - | You should have received a copy of the GNU Affero General Public | - | License and the CiviCRM Licensing Exception along | - | with this program; if not, contact CiviCRM LLC | - | at info[AT]civicrm[DOT]org. If you have questions about the | - | GNU Affero General Public License or the licensing of CiviCRM, | - | see the CiviCRM license FAQ at http://civicrm.org/licensing | - +--------------------------------------------------------------------+ -*} -
-

-
{ts}Elected Officials:{/ts} {$displayName}
-
- {if $rowCount > 0 } - - - - - - - - - - {foreach from=$rows item=row} - - - - - - - - - {/foreach} -
{ts}Image{/ts}{ts}Name{/ts}{ts}Party{/ts}{ts}Address{/ts}{ts}Phone{/ts}{ts}Email{/ts}
{$row.title} {$row.first_name} {$row.last_name}{$row.party}{$row.address}{$row.phone}{$row.email}
- {else} -
- {ts}status{/ts}   - {ts}No data available for this contact. Please check city/state/zipcode{/ts} -
- {/if} -
-

-
-- 2.25.1