예제 #1
0
 /**
  *
  */
 public function __construct()
 {
     global $order;
     $this->version = $this->getModuleDefineValue('_VNO');
     $this->title = $this->getModuleDefineValue('_CATALOG_TEXT_TITLE');
     $this->description = '';
     if (defined('IS_ADMIN_FLAG') && IS_ADMIN_FLAG === true || (!isset($_GET['main_page']) || $_GET['main_page'] == '')) {
         $this->title = sprintf($this->getModuleDefineValue('_ADMIN_TEXT_TITLE'), $this->version);
         $this->description = $this->getModuleDefineValue('_ADMIN_TEXT_DESCRIPTION');
     }
     $this->enabled = $this->getModuleDefineValue('_STATUS') == 'True' ? true : false;
     $this->sort_order = $this->getModuleDefineValue('_SORT_ORDER');
     if ((int) $this->getModuleDefineValue('_ORDER_STATUS_ID') > 0) {
         $this->order_status = $this->getModuleDefineValue('_ORDER_STATUS_ID');
     }
     if (is_object($order)) {
         $this->update_status();
     }
     $new_version_details = plugin_version_check_for_updates(2049, '1.00');
     if ($new_version_details !== FALSE) {
         $this->title .= '<span class="alert">' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>' . '</span>';
     }
 }
예제 #2
0
    function plugin_version_check_for_updates($fileid = 0, $version_string_to_check = '')
    {
        if ($fileid == 0) {
            return FALSE;
        }
        $new_version_available = FALSE;
        $lookup_index = 0;
        $url = 'http://www.zen-cart.com/downloads.php?do=versioncheck' . '&id=' . (int) $fileid;
        $data = json_decode(file_get_contents($url), true);
        // compare versions
        if (version_compare($data[$lookup_index]['latest_plugin_version'], $version_string_to_check) > 0) {
            $new_version_available = TRUE;
        }
        // check whether present ZC version is compatible with the latest available plugin version
        if (!in_array('v' . PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR, $data[$lookup_index]['zcversions'])) {
            $new_version_available = FALSE;
        }
        if ($version_string_to_check == true) {
            return $data[$lookup_index];
        } else {
            return FALSE;
        }
    }
}
// Version Checking
if ($zencart_com_plugin_id != 0) {
    $new_version_details = plugin_version_check_for_updates($zencart_com_plugin_id, $current_version);
    if ($_GET['gID'] == $configuration_group_id && $new_version_details != FALSE) {
        $messageStack->add("Version " . $new_version_details['latest_plugin_version'] . " of " . $new_version_details['title'] . ' is available at <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>', 'caution');
    }
}
예제 #3
0
파일: usps.php 프로젝트: bitweaver/commerce
 /**
  * Constructor
  *
  * @return object
  */
 function __construct()
 {
     // for older php < 5.1.0 change to usps() instead of __construct()
     global $db, $template;
     parent::__construct();
     $this->code = 'usps';
     $this->title = 'USPS';
     $this->enabled = CommerceSystem::isConfigActive('MODULE_SHIPPING_USPS_STATUS');
     if ($this->enabled && MODULE_SHIPPING_USPS_DEBUG_MODE != 'Off') {
         $this->title .= '<span class="alert alert-warning"> (Debug is ON: ' . MODULE_SHIPPING_USPS_DEBUG_MODE . ')</span>';
     }
     if ($this->enabled && MODULE_SHIPPING_USPS_SERVER != 'production') {
         $this->title .= '<span class="alert alert-warning"> (USPS Server set to: ' . MODULE_SHIPPING_USPS_SERVER . ')</span>';
     }
     $this->description = 'United States Postal Service';
     $this->icon = 'shipping_usps';
     if ($this->enabled) {
         $this->sort_order = MODULE_SHIPPING_USPS_SORT_ORDER;
         $this->tax_class = MODULE_SHIPPING_USPS_TAX_CLASS;
         $this->tax_basis = MODULE_SHIPPING_USPS_TAX_BASIS;
         $this->typeCheckboxesSelected = explode(', ', MODULE_SHIPPING_USPS_TYPES);
         $this->update_status();
         // check if all keys are in configuration table and correct version
         if (MODULE_SHIPPING_USPS_STATUS == 'True') {
             if (defined('IS_ADMIN_FLAG')) {
                 $chk_keys = $this->keys();
                 $chk_sql = $this->mDb->Execute("select * from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\\_SHIPPING\\_USPS\\_%' ");
                 if (MODULE_SHIPPING_USPS_VERSION != '2014-09-07' || sizeof($chk_keys) != $chk_sql->RecordCount()) {
                     $this->title .= '<span class="alert">' . ' - Missing Keys or Out of date you should reinstall!' . '</span>';
                     $this->enabled = FALSE;
                 }
                 $new_version_details = plugin_version_check_for_updates(1292, '2014-09-07 K5');
                 if ($new_version_details !== FALSE) {
                     $this->title .= '<span class="alert">' . ' - NOTE: A NEW VERSION OF THIS PLUGIN IS AVAILABLE. <a href="' . $new_version_details['link'] . '" target="_blank">[Details]</a>' . '</span>';
                 }
                 if ($this->enabled) {
                     // insert checks here to give warnings if some of the configured selections don't make sense (such as no boxes checked)
                     // And in those cases, set $this->enabled to FALSE so that the amber warning symbol appears. Consider also adding more BRIEF error text to the $this->title.
                     // verify checked boxes
                     $usps_shipping_methods_domestic_cnt = 0;
                     $usps_shipping_methods_international_cnt = 0;
                     foreach ($this->typeCheckboxesSelected as $requested_type) {
                         if (is_numeric($requested_type) || preg_match('#(GXG|International)#i', $requested_type)) {
                             continue;
                         }
                         $usps_shipping_methods_domestic_cnt += 1;
                     }
                     foreach ($this->typeCheckboxesSelected as $requested_type) {
                         if (is_numeric($requested_type) || !preg_match('#(GXG|International)#i', $requested_type)) {
                             continue;
                         }
                         $usps_shipping_methods_international_cnt += 1;
                     }
                     if ($usps_shipping_methods_domestic_cnt + $usps_shipping_methods_international_cnt < 1) {
                         $this->title .= '<span class="alert">' . ' - Nothing has been selected for Quotes.' . '</span>';
                     }
                 }
             }
         }
         $originCountry = zen_get_countries(SHIPPING_ORIGIN_COUNTRY, TRUE);
         if ($originCountry['countries_iso_code_3'] != 'USA') {
             $this->title .= '<span class="alert">' . ' - USPS can only ship from USA. But your store is configured with another origin! See Admin->Configuration->Shipping/Packaging.' . '</span>';
         }
         // prepare list of countries which USPS ships to
         $this->countries = $this->country_list();
         // use USPS translations for US shops (USPS treats certain regions as "US States" instead of as different "countries", so we translate here)
         $this->usps_countries = $this->usps_translation();
         // certain methods don't qualify if declared value is greater than $400
         $this->types_to_skip_over_certain_value = array();
         $this->types_to_skip_over_certain_value['Priority Mail InternationalRM Flat Rate Envelope'] = 400;
         // skip value > $400 Priority Mail International Flat Rate Envelope
         $this->types_to_skip_over_certain_value['Priority Mail InternationalRM Small Flat Rate Envelope'] = 400;
         // skip value > $400 Priority Mail International Small Flat Rate Envelope
         $this->types_to_skip_over_certain_value['Priority Mail InternationalRM Small Flat Rate Box'] = 400;
         // skip value > $400 Priority Mail International Small Flat Rate Box
         $this->types_to_skip_over_certain_value['Priority Mail InternationalRM Legal Flat Rate Envelope'] = 400;
         // skip value > $400 Priority Mail International Legal Flat Rate Envelope
         $this->types_to_skip_over_certain_value['Priority Mail InternationalRM Padded Flat Rate Envelope'] = 400;
         // skip value > $400 Priority Mail International Padded Flat Rate Envelope
         $this->types_to_skip_over_certain_value['Priority Mail InternationalRM Gift Card Flat Rate Envelope'] = 400;
         // skip value > $400 Priority Mail International Gift Card Flat Rate Envelope
         $this->types_to_skip_over_certain_value['Priority Mail InternationalRM Window Flat Rate Envelope'] = 400;
         // skip value > $400 Priority Mail International Window Flat Rate Envelope
         $this->types_to_skip_over_certain_value['First-Class MailRM International Letter'] = 400;
         // skip value > $400 First-Class Mail International Letter
         $this->types_to_skip_over_certain_value['First-Class MailRM International Large Envelope'] = 400;
         // skip value > $400 First-Class Mail International Large Envelope
         $this->types_to_skip_over_certain_value['First-Class Package International ServiceTM'] = 400;
         // skip value > $400 First-Class Package International Service
         $this->getTransitTime = in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS)) ? TRUE : FALSE;
         $this->shipping_cutoff_time = '1400';
         // 1400 = 14:00 = 2pm ---- must be HHMM without punctuation
     }
 }