Merge pull request #7947 from colemanw/CRM-18192
authorcolemanw <coleman@civicrm.org>
Wed, 9 Mar 2016 02:00:53 +0000 (21:00 -0500)
committercolemanw <coleman@civicrm.org>
Wed, 9 Mar 2016 02:00:53 +0000 (21:00 -0500)
CRM-18192 - Remove Sunlight code from core

CRM/Contact/Page/View/Sunlight.php [deleted file]
CRM/Core/xml/Menu/Contact.xml
CRM/Utils/Sunlight.php [deleted file]
templates/CRM/Contact/Page/View/Sunlight.tpl [deleted file]

diff --git a/CRM/Contact/Page/View/Sunlight.php b/CRM/Contact/Page/View/Sunlight.php
deleted file mode 100644 (file)
index add1aa6..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | 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        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- */
-class CRM_Contact_Page_View_Sunlight extends CRM_Contact_Page_View {
-
-  /**
-   * Called when action is browse.
-   */
-  public function browse() {
-    // get the primary city, state and zip for the contact
-    $ids = array($this->_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();
-  }
-
-}
index 7f1ac88b2a4110640171edbd880689b1a2b25bfc..cee3a1b9c2ee14bd6306214e1f09988e0ac9c0d4 100644 (file)
     <title>Smart Groups</title>
     <page_callback>CRM_Contact_Page_View_ContactSmartGroup</page_callback>
   </item>
-  <item>
-     <path>civicrm/contact/view/sunlight</path>
-     <title>Sunlight</title>
-     <page_callback>CRM_Contact_Page_View_Sunlight</page_callback>
-  </item>
   <item>
      <path>civicrm/contact/view/note</path>
      <path_arguments>cid=%%cid%%</path_arguments>
diff --git a/CRM/Utils/Sunlight.php b/CRM/Utils/Sunlight.php
deleted file mode 100644 (file)
index bffa1ed..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | 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        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- */
-class CRM_Utils_Sunlight {
-  static $_apiURL = 'http://api.sunlightlabs.com/';
-  static $_apiKey = NULL;
-
-  /**
-   * @param $uri
-   *
-   * @return SimpleXMLElement
-   * @throws Exception
-   */
-  public static function makeAPICall($uri) {
-    require_once 'HTTP/Request.php';
-    $params = array(
-      'method' => 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 (file)
index af04901..0000000
+++ /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        |
- +--------------------------------------------------------------------+
-*}
-<div id="electedOfficals" class="view-content">
-    <p></p>
-    <div class="bold">{ts}Elected Officials:{/ts} {$displayName}</div>
-    <div class="form-item">
-     {if $rowCount > 0 }
-       <table>
-       <tr class="columnheader">
-          <th>{ts}Image{/ts}</th>
-          <th>{ts}Name{/ts}</th>
-          <th>{ts}Party{/ts}</th>
-          <th>{ts}Address{/ts}</th>
-          <th>{ts}Phone{/ts}</th>
-          <th>{ts}Email{/ts}</th>
-       </tr>
-       {foreach from=$rows item=row}
-         <tr class="{cycle values="odd-row,even-row"}">
-            <td><a href="{$row.url}"><img src="{$row.image_url}"></a></td>
-            <td>{$row.title} {$row.first_name} {$row.last_name}</td>
-            <td>{$row.party}</td>
-            <td>{$row.address}</td>
-            <td>{$row.phone}</td>
-            <td>{$row.email}</td>
-         </tr>
-       {/foreach}
-       </table>
-     {else}
-     <div class="messages status no-popup">
-     <img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"> &nbsp;
-      {ts}No data available for this contact. Please check city/state/zipcode{/ts}
-     </div>
-     {/if}
-    </div>
- </p>
-</div>