Revision: 43668
Author:   tomasz
Date:     2008-11-18 10:51:44 +0000 (Tue, 18 Nov 2008)

Log Message:
-----------
adding support for ISL exchange rate pull

Modified Paths:
--------------
    civicrm/trunk/sites/all/modules/exchange_rates/exchange_rates.module

Modified: civicrm/trunk/sites/all/modules/exchange_rates/exchange_rates.module
===================================================================
--- civicrm/trunk/sites/all/modules/exchange_rates/exchange_rates.module        
2008-11-18 09:36:19 UTC (rev 43667)
+++ civicrm/trunk/sites/all/modules/exchange_rates/exchange_rates.module        
2008-11-18 10:51:44 UTC (rev 43668)
@@ -122,6 +122,37 @@
       exchange_rates_update_rate($current['attributes']['CURRENCY'], $usd_base 
/ $current['attributes']['RATE'], $bank_update);
     }
   }
+
+  // Secondary lookup for ISL currency
+  $url_isl = variable_get('exchange_rates_url_isl', 
'http://www.bankisrael.gov.il/currency.xml');
+   
+  $result = drupal_http_request($url_isl);
+  $xml = $result->data;
+  
+  $doc = new DOMDocument();
+  $doc->load($xml);
+
+  $date = $doc->getElementsByTagName('LAST_UPDATE')->item(0)->nodeValue;
+  $bank_update = strtotime($date . ' 00:00:00 GMT');
+
+  $currencies = $doc->getElementsByTagName('CURRENCY');
+
+  foreach($currencies as $currency) 
+  { 
+        $currency_name = 
$currency->getElementsByTagName('NAME')->item(0)->nodeValue;
+               
+            // Only pull US Dollar conversion as we already have the rest.
+             if ($currency_name == 'Dollar') 
+            { 
+                 $exchange_rate = 
$currency->getElementsByTagName('RATE')->item(0)->nodeValue;
+                 if ( $date && $exchage_rate ) 
+                 {
+                        exchange_rates_update_rate('ISL', $exchange_rate, 
$bank_update); 
+                        break;
+                 }   
+             }
+  }
+    
 }
 
 function exchange_rates_update_rate($currency, $value_in_usd, $bank_update)



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to