コード例 #1
0
ファイル: modules_shipping.php プロジェクト: gblok/rsc
 {
     return strcmp($a->title, $b->title);
 }
 usort($shipping_modules, "cmpShObjs");
 if (isset($_GET["install"])) {
     if (CONF_BACKEND_SAFEMODE) {
         Redirect(ADMIN_FILE . "?dpt=modules&sub=shipping&safemode=yes");
     }
     $shipping_modules[(int) $_GET["install"]]->install();
     Redirect(ADMIN_FILE . "?dpt=modules&sub=shipping");
 }
 if (isset($_GET["uninstall"])) {
     if (CONF_BACKEND_SAFEMODE) {
         Redirect(ADMIN_FILE . "?dpt=modules&sub=shipping&safemode=yes");
     }
     $ModuleConfig = modGetModuleConfig($_GET["uninstall"]);
     if ($ModuleConfig['ModuleClassName']) {
         modUninstallModuleConfig($_GET["uninstall"]);
     } else {
         foreach ($shipping_configs as $_tModConf) {
             if ($_tModConf['ConfigID'] == (int) $_GET["uninstall"]) {
                 eval('$_tModConf = new ' . $_tModConf['ConfigClassName'] . '();');
                 $_tModConf->uninstall();
                 break;
             }
         }
     }
     Redirect(ADMIN_FILE . "?dpt=modules&sub=shipping");
 }
 $smarty->assign("shipping_modules", $shipping_modules);
 $smarty->assign("shipping_methods_by_modules", $shipping_methods_by_modules);
コード例 #2
0
function settingCONF_BYCOUNTRY_BYZONE_PERCENT_FORM()
{
    $curr_country = isset($_POST["shipping_module_bycountry_byzone_country"]) ? $_POST["shipping_module_bycountry_byzone_country"] : 0;
    $curr_country = (int) $curr_country;
    if (!$curr_country) {
        $curr_country = xGetData('SXshipping_module_bycountry_byzone_countryPERC');
    }
    xSaveData('SXshipping_module_bycountry_byzone_countryPERC', $curr_country);
    $module_id = isset($_GET['setting_up']) ? $_GET['setting_up'] : 0;
    $ModuleConfig = modGetModuleConfig($module_id);
    if (!$ModuleConfig['ModuleClassName']) {
        $module_id = 0;
    }
    if (isset($_POST["save"])) {
        $radiotoggle = isset($_POST["shipping_module_bycountry_byzone_radiotoggle"]) ? $_POST["shipping_module_bycountry_byzone_radiotoggle"] : 0;
        if ($radiotoggle == 0) {
            $rate = (double) $_POST["shipping_module_bycountry_byzone_zone_rate_0"];
            $sql = '
                                DELETE FROM ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                WHERE module_id="' . $module_id . '" AND countryID=' . $curr_country . ' and zoneID=0
                        ';
            db_query($sql);
            $sql = '
                                INSERT INTO ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                (module_id, countryID, zoneID, shipping_rate)
                                VALUES (' . $module_id . ', ' . $curr_country . ', 0, ' . $rate . ')
                        ';
            db_query($sql);
        } else {
            $sql = '
                                DELETE FROM ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                WHERE module_id="' . $module_id . '" AND countryID=' . $curr_country . '
                        ';
            db_query($sql);
            foreach ($_POST as $key => $val) {
                if (strstr($key, "shipping_module_bycountry_byzone_zone_rate_")) {
                    $zone = (int) str_replace("shipping_module_bycountry_byzone_zone_rate_", "", $key);
                    $rate = (double) $val;
                    if ($zone > 0 && $rate != 0) {
                        $sql = '
                                                        INSERT INTO ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                                        (module_id, countryID, zoneID, shipping_rate)
                                                        VALUES (' . $module_id . ', ' . $curr_country . ', ' . $zone . ', ' . $rate . ')
                                                ';
                        db_query($sql);
                    }
                }
            }
        }
    }
    $res = "<table border=0>\n<tr>\n<td>" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_1 . "</td>\n";
    $countries_count = 0;
    $countries = cnGetCountries(null, $countries_count);
    $res .= "<td><select name='shipping_module_bycountry_byzone_country'>\n";
    $res .= "<option value='0'>" . ADMIN_NOT_DEFINED . "</option>\n";
    foreach ($countries as $country) {
        $res .= "<option value='" . $country["countryID"] . "' ";
        if ($curr_country == $country["countryID"]) {
            $res .= " selected ";
        }
        $res .= ">";
        $res .= $country["country_name"];
        $res .= "</option>\n";
    }
    $res .= "</select></td>";
    $res .= "<td><input type=submit name=shipping_module_bycountry_byzone_change_country value=\"" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_2 . "\"></td>\n";
    $res .= "</tr>\n";
    //show toggle + zones
    if ($curr_country > 0) {
        $zones = znGetZonesById($curr_country);
        //toggle
        $res .= "<tr><td colspan=3><hr size=1></td></tr>\n";
        $res .= "<tr><td colspan=3>\n";
        $sql = '
                        SELECT shipping_rate FROM ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                        WHERE module_id="' . $module_id . '" AND countryID=' . $curr_country . ' and zoneID=0
                ';
        $q = db_query($sql);
        $row = db_fetch_row($q);
        if ($row || count($zones) == 0) {
            $radiotoggle = 0;
            //fixed for this country
            $rate = (double) $row[0];
        } else {
            $radiotoggle = 1;
            //by zone definition
            $rate = 0;
        }
        $res .= "<table border=0><tr><td valign=top>\n<input type=radio name=shipping_module_bycountry_byzone_radiotoggle value=0";
        if ($radiotoggle == 0) {
            $res .= " checked";
        }
        $res .= " onclick='JavaScript:shipping_module_bycountry_byzone_toogleClickHandler();'></td>\n";
        $res .= "<td valign=top>" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_7 . "</td>\n";
        $res .= "<td><input type=text name=shipping_module_bycountry_byzone_zone_rate_0 value=\"{$rate}\">" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_3 . "</td></tr>\n";
        $res .= "<tr><td valign=top>\n<input type=radio name=shipping_module_bycountry_byzone_radiotoggle value=1";
        if ($radiotoggle == 1) {
            $res .= " checked";
        }
        $res .= " onclick='JavaScript:shipping_module_bycountry_byzone_toogleClickHandler();'></td>\n";
        $res .= "<td colspan=2>" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_4 . "\n";
        //zones
        if (count($zones) > 0) {
            $res .= "<p><table>\n";
            foreach ($zones as $zone) {
                $zoneID = (int) $zone["zoneID"];
                $sql = '
                                        SELECT shipping_rate FROM ' . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TABLE . '
                                        WHERE module_id="' . $module_id . '" AND countryID=' . $curr_country . ' and zoneID=' . $zoneID . '
                                ';
                $q = db_query($sql);
                $row = db_fetch_row($q);
                $zone_shipping_rate = (double) $row[0];
                $res .= "<tr><td>" . $zone["zone_name"] . ":</td>";
                $res .= "<td><input type=text name=shipping_module_bycountry_byzone_zone_rate_" . $zoneID . " value='" . $zone_shipping_rate . "'>" . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_5 . "</td></tr>";
            }
            $res .= "</table>\n";
        } else {
            $res .= "<p>&lt; " . CSHIPPINGMODULEBYCOUNTRYBYZONEPERCENT_TXT_6 . " &gt;";
        }
        $res .= "</td></tr></table>\n";
        $res .= "</td></tr>\n";
    }
    $res .= "</table>";
    //javascript code
    if ($curr_country > 0) {
        $res .= "\n                                <script language='JavaScript'>\n                                function shipping_module_bycountry_byzone_toogleClickHandler()\n                                {\n\n                                        if ( document.shipping_method_form.shipping_module_bycountry_byzone_radiotoggle[0].checked )\n                                        {\n                                                document.shipping_method_form.shipping_module_bycountry_byzone_zone_rate_0.disabled = false;\n                                                " . _create_JS_zones_handlers_bycountryzone_percent($zones, "true") . "\n                                        }\n                                        else if ( document.shipping_method_form.shipping_module_bycountry_byzone_radiotoggle[1].checked )\n                                        {\n                                                document.shipping_method_form.shipping_module_bycountry_byzone_zone_rate_0.disabled = true;\n                                                " . _create_JS_zones_handlers_bycountryzone_percent($zones, "false") . "\n                                        }\n                                }\n\n                                shipping_module_bycountry_byzone_toogleClickHandler();\n                                </script>\n                ";
    }
    return $res;
}
コード例 #3
0
ファイル: module_function.php プロジェクト: gblok/rsc
function modGetModuleObj($_ID, $_ModuleType = 0)
{
    $ModuleConfig = modGetModuleConfig($_ID);
    $objectModule = null;
    if (!$_ID) {
        return $objectModule;
    }
    if ($ModuleConfig['ModuleClassName']) {
        if (class_exists($ModuleConfig['ModuleClassName'])) {
            eval('$objectModule = new ' . $ModuleConfig['ModuleClassName'] . '(' . $_ID . ');');
            if ($_ModuleType && $objectModule->getModuleType() != $_ModuleType) {
                $objectModule = null;
            }
        } else {
            $moduleFiles = array();
            $IncludeDir = '';
            switch ($_ModuleType) {
                case SHIPPING_RATE_MODULE:
                    $IncludeDir = "core/modules/shipping";
                    break;
                case PAYMENT_MODULE:
                    $IncludeDir = "core/modules/payment";
                    break;
                case SMSMAIL_MODULE:
                    $IncludeDir = "core/modules/smsmail";
                    break;
            }
            $moduleFiles = GetFilesInDirectory($IncludeDir, "php");
            foreach ($moduleFiles as $fileName) {
                $className = GetClassName($fileName);
                if (strtolower($className) != strtolower($ModuleConfig['ModuleClassName'])) {
                    continue;
                }
                require_once $fileName;
                eval('$objectModule = new ' . $className . '(' . $_ID . ');');
                return $objectModule;
            }
        }
    } else {
        $moduleFiles = array();
        switch ($_ModuleType) {
            case SHIPPING_RATE_MODULE:
                $moduleFiles = GetFilesInDirectory("core/modules/shipping", "php");
                break;
            case PAYMENT_MODULE:
                $moduleFiles = GetFilesInDirectory("core/modules/payment", "php");
                break;
            case SMSMAIL_MODULE:
                $IncludeDir = "core/modules/smsmail";
                break;
        }
        foreach ($moduleFiles as $fileName) {
            $className = GetClassName($fileName);
            if (!$className) {
                continue;
            }
            if (!class_exists($className)) {
                require_once $fileName;
            }
            eval('$objectModule = new ' . $className . '();');
            if ($objectModule->get_id() == $_ID && $objectModule->title == $ModuleConfig['module_name']) {
                return $objectModule;
            } else {
                $objectModule = null;
            }
        }
    }
    return $objectModule;
}