function onAction()
 {
     global $application;
     if (modApiFunc('Session', 'is_Set', 'SessionPost')) {
         _fatal(array("CODE" => "CORE_050"), __CLASS__, __FUNCTION__);
     }
     $SessionPost = $_POST;
     $SessionPost["ViewState"]["ErrorsArray"] = array();
     $fsr_id = $SessionPost["FsRule_id"] = intval($SessionPost["FsRule_id"]);
     $SessionPost["FsRuleName"] = trim($SessionPost["FsRuleName"]);
     $SessionPost["FsRuleMinSubtotal"] = floatval($SessionPost["FsRuleMinSubtotal"]);
     $SessionPost["FsRuleStrictCart"] = intval($SessionPost["StrictCart"]);
     if ($SessionPost["FsRuleName"] == "") {
         $SessionPost["ViewState"]["ErrorsArray"][] = "ERROR_EMPTY_RULE_NAME";
     }
     $is_unique = modApiFunc("Shipping_Cost_Calculator", "checkIfFsRuleIsUnique", $SessionPost["FsRuleName"], $fsr_id);
     if (!$is_unique) {
         $SessionPost["ViewState"]["ErrorsArray"][] = "ERROR_NOT_UNIQUE_RULE_NAME";
     }
     if ($SessionPost["FormSubmitValue"] == "Save") {
         if (count($SessionPost["ViewState"]["ErrorsArray"]) == 0) {
             unset($SessionPost["ViewState"]["ErrorsArray"]);
             $this->saveSettings($SessionPost);
             $SessionPost["ViewState"]["hasCloseScript"] = "true";
         }
     }
     modApiFunc('Session', 'set', 'SessionPost', $SessionPost);
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setKey('FsRule_id', $fsr_id);
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     $SessionPost = array();
     if (modApiFunc('Session', 'is_Set', 'SessionPost')) {
         _fatal(array("CODE" => "CORE_050"), __CLASS__, __FUNCTION__);
     }
     $SessionPost = $_POST;
     $nErrors = 0;
     $this->getEmails();
     if ($this->_valid_emails_count == 0) {
         $SessionPost['ViewState']['ErrorsArray'][] = 'ALERT_FILL_EMAILS_TO_SUBSCRIBE';
         // @                       -               ?
         $SessionPost['ViewState']['ErrorFields'][] = 'emails_subscribe';
         $nErrors++;
     } else {
         $SessionPost['action_key'] = $this->_action_key;
         $SessionPost['ViewState']['stage'] = 'confirm';
     }
     modApiFunc('Session', 'set', 'SessionPost', $SessionPost);
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setKey('topics', modApiFunc('Request', 'getValueByKey', 'topics'));
     if (isset($this->_action_key)) {
         $request->setKey('action_key', $this->_action_key);
         $request->setKey('stage', 'confirm');
     }
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $data = array("parent_entity" => $_POST["parent_entity"], "entity_id" => intval($_POST["entity_id"]), "option_id" => intval($_POST["option_id"]));
     $check_result = modApiFunc("Product_Options", "checkDataFor", "delOptionFromEntity", $data);
     if (!empty($check_result)) {
         modApiFunc("Session", "set", "Errors", $check_result);
         $request = new Request();
         $request->setKey("parent_entity", $data["parent_entity"]);
         $request->setKey("entity_id", $data["entity_id"]);
         $request->setView('PO_OptionsList');
         $application->redirect($request);
     } else {
         $del_result = modApiFunc("Product_Options", "delOptionFromEntity", $data);
         if ($del_result == true) {
             modApiFunc("Session", "set", "ResultMessage", "MSG_OPTION_DELETED");
         } else {
             modApiFunc("Session", "set", "ResultMessage", "MSG_OPTION_NOT_DELETED");
         }
         $request = new Request();
         $request->setView('PO_OptionsList');
         $request->setKey('parent_entity', $data["parent_entity"]);
         $request->setKey('entity_id', $data["entity_id"]);
         $application->redirect($request);
     }
 }
 function onAction()
 {
     global $application;
     $emails_keys = modApiFunc('Request', 'getValueByKey', 'emails');
     $emails_topics = modApiFunc('Request', 'getValueByKey', 'topic');
     $customer_id = modApiFunc('Request', 'getValueByKey', 'customer_id');
     if (!is_array($emails_topics)) {
         $emails_topics = array();
     }
     foreach (array_keys($emails_keys) as $email) {
         $topics = @$emails_topics[$email];
         if (!is_array($topics)) {
             $topics = array();
         }
         modApiFunc('Subscriptions', 'changeSubscriptions', $email, $topics);
         $params = array('customer_id' => $customer_id, 'email' => $email);
         execQuery('SUBSCR_LINK_SUBSCRIPTION_TO_CUSTOMER', $params);
     }
     $messages['MESSAGES'][] = getMsg('SYS', 'SUBSCRIPTIONS_UPDATED');
     modApiFunc('Session', 'set', 'AplicationSettingsMessages', $messages);
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setKey('page_view', modApiFunc('Request', 'getValueByKey', 'page_view'));
     $request->setKey('customer_id', $customer_id);
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $request = new Request();
     $category_id = $request->getValueByKey('category_id');
     $tree_id = $request->getValueByKey('tree_id');
     $fp_ids = $request->getValueByKey('to_save');
     modApiFunc('Featured_Products', 'deleteAllFPLinksFromCategory', $category_id);
     $errors = array();
     if ($fp_ids != null) {
         if (!modApiFunc('Featured_Products', 'addFPLinksToCategory', $category_id, $fp_ids)) {
             $errors[] = 'E_FP_NOT_SAVED';
         }
     }
     if (empty($errors)) {
         modApiFunc('Session', 'set', 'ResultMessage', 'MSG_FP_SAVED');
     } else {
         modApiFunc('Session', 'set', 'Errors', $errors);
     }
     $request->setView('PopupWindow');
     $request->setKey('page_view', 'FP_LinksList');
     $request->setKey('category_id', $category_id);
     $request->setKey('tree_id', $tree_id);
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $request = new Request();
     $category_id = $request->getValueByKey('category_id');
     $tree_id = $request->getValueByKey('tree_id');
     $bs_ids = $request->getValueByKey('to_save');
     modApiFunc('Bestsellers_API', 'deleteAllBSLinksFromCategory', $category_id);
     $errors = array();
     if ($bs_ids != null) {
         if (!modApiFunc('Bestsellers_API', 'addBSLinksToCategory', $category_id, $bs_ids)) {
             $errors[] = 'E_BS_NOT_SAVED';
         }
     }
     if (empty($errors)) {
         $sets = $request->getValueByKey('sets');
         $sets['BS_FROM_STAT_PERIOD'] = $sets['BS_FROM_STAT_PERIOD']['count'] * $sets['BS_FROM_STAT_PERIOD']['type'];
         modApiFunc('Bestsellers_API', 'updateSettings', $category_id, $sets);
     }
     if (empty($errors)) {
         modApiFunc('Session', 'set', 'ResultMessage', 'MSG_BS_SAVED');
     } else {
         modApiFunc('Session', 'set', 'Errors', $errors);
     }
     $request->setView('PopupWindow');
     // $request->setView('BS_LinksList');
     $request->setKey('page_view', 'BS_LinksList');
     $request->setKey('category_id', $category_id);
     $request->setKey('tree_id', $tree_id);
     $application->redirect($request);
 }
 /**
  *
  *
  * @
  * @param
  * @return
  */
 function outputAdminList()
 {
     global $application;
     $retval = "";
     $admin_members = modApiFunc("Users", "getAdminMembersList");
     $i = 0;
     //$min_list_size = 10;
     foreach ($admin_members as $member) {
         $current_admin = modApiFunc("Users", "getCurrentUserID") == $member["id"] ? true : false;
         $request = new Request();
         $request->setView('AdminMemberInfo');
         $request->setAction('SetSelectedUser');
         $request->setKey('uid', $member["id"]);
         $request->setKey('edit', true);
         $link = $request->getURL();
         $template_contents = array("AdminMemberInfoLink" => $link, "AdminId" => $member["id"], "Style" => "visible", "AdminCheckBox" => $current_admin ? "" : "select_" . $i, "AdminCheckBoxName" => $current_admin ? "" : "selected_admins[" . ($i + 1) . "]", "AdminName" => prepareHTMLDisplay($member["firstname"] . " " . $member["lastname"]), "CurrentAdmin" => $current_admin ? "<span class=\"font-red\">*</span>" : "", "Email" => $member["email"], "LogNum" => $member["lognum"], "LoggedIn" => $member["logdate"] && $member["logdate"] != "0000-00-00" ? modApiFunc("Localization", "SQL_date_format", $member["logdate"]) : $this->MessageResources->getMessage("ADMIN_MEMBERS_LABEL_001"), "Created" => modApiFunc("Localization", "SQL_date_format", $member["created"]), "Modified" => $member["modified"] && $member["modified"] != "0000-00-00" ? modApiFunc("Localization", "SQL_date_format", $member["modified"]) : $this->MessageResources->getMessage("ADMIN_MEMBERS_LABEL_002"), "Enabled" => $current_admin ? " DISABLED" : "");
         $this->_Template_Contents = $template_contents;
         $application->registerAttributes($this->_Template_Contents);
         $retval .= modApiFunc('TmplFiller', 'fill', "users/admin_members/", "item.tpl.html", array());
         if (!$current_admin) {
             $i++;
         }
     }
     for (; $i < $min_list_size; $i++) {
         $retval .= modApiFunc('TmplFiller', 'fill', "users/admin_members/", "item_empty.tpl.html", array());
     }
     return $retval;
 }
 /**
  * Deletes tax rate by zip set.
  */
 function onAction()
 {
     global $application;
     $SessionPost = array();
     $SessionPost = $_POST;
     $Errors = array();
     $Result = array();
     $request = new Request();
     $request->setView("PopupWindow");
     $updateSid = $request->getValueByKey("updateSid", 0);
     if ($updateSid) {
         $request->setKey("updateSid", $updateSid);
     }
     $description = '';
     if (isset($_POST['file_description'])) {
         $description = prepareHTMLDisplay(trim($_POST['file_description']));
     }
     if ($description == '') {
         $SessionPost['Errors'][] = getMsg("TAX_ZIP", "ADD_NEW_SET_EMPTY_FILE_DESCRIPTION_ERROR");
         modApiFunc('Session', 'set', 'SessionPost', $SessionPost);
         $request->setKey("page_view", "TaxRateByZip_AddNewSet");
         $application->redirect($request);
         return;
     }
     modApiFunc('Session', 'set', 'SessionPost', $SessionPost);
     $sid = modApiFunc("TaxRateByZip", "addSetToDB", $description, $_POST["csv_file_name"]);
     $request->setKey("page_view", "TaxRatesImportView");
     $request->setKey("sid", $sid);
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     $attr_id = $request->getValueByKey("customFieldsList");
     if (!isset($_POST['customFieldVisible'])) {
         $_POST['customFieldVisible'] = 0;
     }
     if (!isset($_POST['customFieldRequired'])) {
         $_POST['customFieldRequired'] = 0;
     }
     if ($_POST['customFieldRequired'] == 1) {
         $_POST['customFieldVisible'] = 1;
     }
     if ($_POST['customFieldVisible'] == 0) {
         $_POST['customFieldRequired'] = 0;
     }
     #validation
     if (isset($_POST['params'])) {
         foreach ($_POST['params'] as $name => $v) {
             if (!preg_match("/^\\d+\$/", $v)) {
                 $_data = $_POST;
                 $_data['invalid_params'] = $_POST['customFieldType'];
                 modApiFunc("Session", "set", "FormData", $_data);
                 modApiFunc("Session", "set", "ResultMessage", 'MSG_INVALID_DATA');
                 $request = new Request();
                 $request->setView(CURRENT_REQUEST_URL);
                 $request->setKey('page_view', 'ManageCustomFields');
                 $request->setKey('variant_id', $_POST['variant_id']);
                 $request->setKey('attribute_id', $attr_id);
                 $request->setKey('mode', 'edit');
                 $application->redirect($request);
                 return;
             }
         }
     }
     $params = null;
     if (isset($_POST['params'])) {
         $params = serialize($_POST['params']);
     }
     $values = array();
     if (isset($_POST['customFieldValues'])) {
         $values = explode("\n", $_POST['customFieldValues']);
         foreach ($values as $i => $v) {
             $values[$i] = trim($v);
         }
     }
     $r = modApiFunc('Checkout', 'updateCustomField', $_POST['variant_id'], $attr_id, $_POST['customFieldVisibleName'], $_POST['customFieldDescription'], $_POST['customFieldVisible'], $_POST['customFieldRequired'], $_POST['customFieldType'], $values, $params);
     modApiFunc('Checkout', 'updateCheckoutFormHash');
     modApiFunc("Session", "set", "UpdateParent", true);
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setKey('page_view', 'ManageCustomFields');
     $request->setKey('variant_id', $_POST['variant_id']);
     $request->setKey('attribute_id', $attr_id);
     $request->setKey('mode', 'edit');
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $request =& $application->getInstance('Request');
     modApiFunc('Product_Files', 'zeroHotlinkTries', $request->getValueByKey('opid'), $request->getValueByKey('hl_id'));
     $r = new Request();
     $r->setView(CURRENT_REQUEST_URL);
     $r->setKey('page_view', 'PF_OrderHotlinks');
     $r->setKey('opid', $request->getValueByKey('opid'));
     $application->redirect($r);
 }
 function output($report_settings)
 {
     //        $res =  modApiFunc( "Charts",
     //        "getStockChartAmchart",
     //        'http://localhost/~af/trunk/avactis-system/admin/amcharts/stock/examples/data_at_irregular_intervals/data.csv',
     //        array('title 1', 'title 2'),
     //        460 // width
     //            );
     // $this->__render_settings->getReportID();
     // http://localhost/~af/trunk/avactis-system/admin/reports.php?asc_action=getReportContent&type=Excel&reportName=ChartOrdersByDay&format=csv
     global $application;
     $this->__report_settings = $report_settings;
     //                 ,                ,      -
     $report_rows = $this->__report_settings->getReportData();
     //                            ,
     $report_columns = $this->__report_settings->getColumnList();
     //                     ,          -                             ,          -                           .
     $report_column_headers = $this->__report_settings->getColumnHeaders();
     $report_column_units = $this->__report_settings->getColumnUnits();
     if (count($report_columns) < 2) {
         return "<br><br><br><br>" . getMsg('RPTS', 'CHART_ERROR') . "<br><br><br><br>";
     }
     if (empty($report_rows)) {
         return "<br><br><br><br>" . getMsg('RPTS', 'EMPTY_REPORT') . "<br><br><br><br>";
     }
     $report_id = $this->__report_settings->getReportID();
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setKey('asc_action', 'getReportContent');
     $request->setKey('type', 'Excel');
     $request->setKey('format', 'csv');
     $request->setKey('csv-header', 'false');
     $request->setKey('reportName', $report_id);
     $url_csv = $request->getURL();
     $chart_width = $this->__report_settings->getReportPlaceholderWidth() - 20;
     $series = array();
     $units = array();
     //                             ,              ,
     for ($i = 1; $i < count($report_columns); $i++) {
         $series[] = $report_column_headers[$report_columns[$i]];
         $units[] = isset($report_column_units[$report_columns[$i]]) ? $report_column_units[$report_columns[$i]] : '';
     }
     $res = modApiFunc("Charts", "getStockChartAmchart", $url_csv, $series, $chart_width, 450, $units);
     return $res['html'];
     //        echo $url_csv;
     //        echo "<br>";
     //        _print($series);
     //        echo $chart_width;
     //        return '';
 }
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     $attr_id = $request->getValueByKey("customFieldsList");
     modApiFunc('Checkout', 'removeCustomField', $_POST['variant_id'], $attr_id);
     modApiFunc('Checkout', 'updateCheckoutFormHash');
     modApiFunc("Session", "set", "UpdateParent", true);
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setKey('page_view', 'ManageCustomFields');
     $request->setKey('variant_id', $_POST['variant_id']);
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $sort_array = explode("|", $_POST["optionsSortOrder_hidden"]);
     if (modApiFunc("Product_Options", "updateOptionsSortOrder", $sort_array)) {
         modApiFunc("Session", "set", "ResultMessage", "MSG_OPTIONS_SORT_ORDER_UPDATED");
     } else {
         modApiFunc("Session", "set", "ResultMessage", "MSG_OPTIONS_SORT_ORDER_NOT_UPDATED");
     }
     $request = new Request();
     $request->setView('PO_OptionsList');
     $request->setKey('parent_entity', $_POST["parent_entity"]);
     $request->setKey('entity_id', $_POST["entity_id"]);
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $request =& $application->getInstance('Request');
     $hl_id = $request->getValueByKey('hl_id');
     $opid = $request->getValueByKey('opid');
     $edate = explode("/", $request->getValueByKey('edate'));
     $ts = mktime($edate[3], $edate[4], 0, $edate[1], $edate[2], $edate[0]);
     modApiFunc('Product_Files', 'updateHotlinkExpireDate', $opid, $hl_id, $ts);
     $r = new Request();
     $r->setView(CURRENT_REQUEST_URL);
     $r->setKey('page_view', 'PF_OrderHotlinks');
     $r->setKey('opid', $request->getValueByKey('opid'));
     $application->redirect($r);
 }
 function onAction()
 {
     global $application;
     $request =& $application->getInstance('Request');
     // getting posted review data
     $review_data = $request->getValueByKey('review_data');
     // getting mode
     $mode = $request->getValueByKey('mode');
     if ($mode == 'product_changed') {
         $review_data['datetime'] = $review_data['year'] . '-' . $review_data['month'] . '-' . $review_data['day'] . ' ' . $review_data['hour'] . ':' . $review_data['minute'] . ':' . $review_data['second'];
         // product has been changed, continue...
         modApiFunc('Session', 'set', 'SavedReviewData', $review_data);
         $req_to_redirect = new Request();
         $req_to_redirect->setView(CURRENT_REQUEST_URL);
         $req_to_redirect->setKey('page_view', 'CR_Review_Data');
         $req_to_redirect->setKey('cr_id', $review_data['cr_id']);
         $application->redirect($req_to_redirect);
         return;
     }
     // validating data
     $error = $this->validatePostedData($review_data);
     if ($error) {
         // if there is an error save the data and reload the page
         modApiFunc('Session', 'set', 'SavedReviewData', $review_data);
         $req_to_redirect = new Request();
         $req_to_redirect->setView(CURRENT_REQUEST_URL);
         $req_to_redirect->setKey('page_view', 'CR_Review_Data');
         $req_to_redirect->setKey('cr_id', $review_data['cr_id']);
         $application->redirect($req_to_redirect);
     } else {
         // no errors... ready to save the data
         $cr_id = $this->savePostedData($review_data);
         // reload the parent window while reloading
         modApiFunc('Session', 'set', 'CR_ReloadParentWindow', 1);
         // setting ResultMessage
         if (@$review_data['cr_id'] <= 0) {
             modApiFunc('Session', 'set', 'ResultMessage', 'CR_MSG_CUSTOMER_REVIEW_ADDED');
         } else {
             modApiFunc('Session', 'set', 'ResultMessage', 'CR_MSG_CUSTOMER_REVIEW_UPDATED');
         }
         // prepare the redirect
         $req_to_redirect = new Request();
         $req_to_redirect->setView(CURRENT_REQUEST_URL);
         $req_to_redirect->setKey('page_view', 'CR_Review_Data');
         $req_to_redirect->setKey('cr_id', $cr_id);
         $application->redirect($req_to_redirect);
     }
 }
 function onAction()
 {
     global $application;
     $request =& $application->getInstance('Request');
     $layout_path = $request->getValueByKey('layout_path');
     $mr_act = $request->getValueByKey('mr_act');
     if ($mr_act == 'on') {
         $hta_content = modApiFunc('Mod_Rewrite', 'genRewriteBlock', $layout_path);
         $res = modApiFunc('Mod_Rewrite', 'saveHTAcontent', $hta_content, $layout_path);
         if (empty($res)) {
             modApiFunc('Session', 'set', 'ResultMessage', 'MSG_MR_ENABLED');
             modApiFunc('Mod_Rewrite', 'enableMRforLayout', $layout_path);
         } else {
             modApiFunc('Session', 'set', 'Errors', $res);
         }
     }
     if ($mr_act == 'off') {
         modApiFunc('Mod_Rewrite', 'disableMRforLayout', $layout_path);
         modApiFunc('Session', 'set', 'ResultMessage', 'MSG_MR_DISABLED');
     }
     $r = new Request();
     $r->setView(CURRENT_REQUEST_URL);
     $r->setKey('page_view', 'MR_Settings');
     $application->redirect($r);
 }
 function onAction()
 {
     $r = new Request();
     $to_cc = $r->getValueByKey('to_currency_code');
     $from_cc = $r->getValueByKey('from_currency_code');
     $base = $r->getValueByKey('base_rate');
     $rate = trim($base);
     $errors = array();
     if (modApiFunc('Currency_Converter', 'doesManRateExists', $from_cc, $to_cc)) {
         $errors[] = 'E_MAN_RATE_EXISTS';
     }
     #
     # base rate validation. should be integer or decimal value
     #
     if ($this->validateDecimal($rate) != true) {
         $errors[] = 'E_MAN_INVALID_RATE';
     }
     if (empty($errors)) {
         if (!modApiFunc('Currency_Converter', 'addManualRate', $from_cc, $to_cc, $rate)) {
             $errors[] = 'E_MAN_RATE_NOT_ADDED';
         }
     }
     if (empty($errors)) {
         modApiFunc('Session', 'set', 'ResultMessage', 'MSG_MAN_RATE_ADDED');
     } else {
         modApiFunc('Session', 'set', 'Errors', $errors);
     }
     $r->setView('PopupWindow');
     $r->setKey('page_view', 'CurrencyRateEditor');
     global $application;
     $application->redirect($r);
 }
 function onAction()
 {
     global $application;
     $oid = $_POST["option_id"];
     unset($_POST["option_id"]);
     $data = array("value_name" => $_POST["NewValue"]["Name"], "is_default" => isset($_POST["NewValue"]["IsDefault"]) ? 'Y' : 'N');
     foreach ($_POST["NewValue"] as $key => $value) {
         if (preg_match("/_modifier\$/", $key)) {
             $data[$key] = floatval(str_replace(",", ".", trim($value)));
         }
     }
     $check_result = modApiFunc("Product_Options", "checkDataFor", "addValueToOption", $data);
     if (!empty($check_result)) {
         modApiFunc("Session", "set", "Errors", $check_result);
         modApiFunc("Session", "set", "SessionPost", $_POST);
         $request = new Request();
         $request->setKey("option_id", $oid);
         $request->setView('PO_EditOption');
         $application->redirect($request);
     } else {
         $data["option_id"] = $oid;
         $add_result = modApiFunc("Product_Options", "addValueToOption", $data);
         if ($add_result == false) {
             modApiFunc("Session", "set", "SessionPost", $_POST);
             modApiFunc("Session", "set", "ResultMessage", "MSG_VALUE_NOT_ADDED");
         } else {
             modApiFunc("Session", "un_set", "SessionPost");
             modApiFunc("Session", "set", "ResultMessage", "MSG_VALUE_ADDED");
         }
         $request = new Request();
         $request->setView('PO_EditOption');
         $request->setKey("option_id", $oid);
         $application->redirect($request);
     }
 }
 /**
  *
  */
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     $cc_id = $request->getValueByKey("cc_id");
     $attrs = $request->getValueByKey("attrs");
     $post_visible = $request->getValueByKey("visible");
     $post_required = $request->getValueByKey("required");
     $SessionPost = $_POST;
     $visible = array();
     $required = array();
     foreach ($attrs as $id) {
         if (isset($post_visible[$id]) && $post_visible[$id] == 'on') {
             $visible[$id] = 1;
         } else {
             $visible[$id] = 0;
         }
         if (isset($post_required[$id]) && $post_required[$id] == 'on') {
             $required[$id] = 1;
         } else {
             $required[$id] = 0;
         }
     }
     $params = array('type' => $cc_id, 'visible' => $visible, 'required' => $required);
     modApiFunc('Configuration', 'clearAttributesForCardType', $cc_id);
     modApiFunc('Configuration', 'addAttributesForCardType', $params);
     //        modApiFunc('Session', 'set', 'ResultMessage', $messages);
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $request->setKey('cc_id', $cc_id);
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $request =& $application->getInstance('Request');
     $mode = $request->getValueByKey('mode');
     switch ($mode) {
         case 'sort':
             $sort_array = explode('|', $request->getValueByKey('cr_rates_sort_order_hidden'));
             modApiFunc('Customer_Reviews', 'updateRateSortOrder', $sort_array);
             modApiFunc('Session', 'set', 'ResultMessage', 'CR_MSG_RATES_SORTED');
             break;
         case 'add':
             $rate_new = $request->getValueByKey('rate_new');
             $result = modApiFunc('Customer_Reviews', 'insertNewRate', $rate_new['rate_label'], $rate_new['visible']);
             if ($result) {
                 modApiFunc('Session', 'set', 'ResultMessage', 'CR_MSG_RATE_ADDED');
             } else {
                 modApiFunc('Session', 'set', 'ResultMessage', 'CR_MSG_EMPTY_RATE_CANNOT_BE_ADDED');
             }
             break;
         case 'update':
             modApiFunc('Customer_Reviews', 'updateRates', $request->getValueByKey('rates'));
             modApiFunc('Session', 'set', 'ResultMessage', 'CR_MSG_RATES_SETTINGS_UPDATED');
             break;
         case 'delete':
             modApiFunc('Customer_Reviews', 'deleteRates', $request->getValueByKey('selected_rates'));
             modApiFunc('Session', 'set', 'ResultMessage', 'CR_MSG_RATES_DELETED');
             break;
     }
     $req_to_redirect = new Request();
     $req_to_redirect->setView(CURRENT_REQUEST_URL);
     $req_to_redirect->setKey('page_view', 'CR_Rates_Settings');
     $application->redirect($req_to_redirect);
 }
 /**
  * @ describe the function ->getTag.
  */
 function getTag($tag)
 {
     global $application;
     $value = null;
     switch ($tag) {
         case 'EditLink':
             $request = new Request();
             $request->setAction('SetCurrentProductType');
             $request->setView('EditProductType');
             $request->setKey('type_id', $this->_type['id']);
             $value = $request->getURL();
             break;
         case 'TypeName':
             $value = $this->_type['name'];
             break;
         case 'TypeDescription':
             $value = '';
             if ($this->_type['description'] != '') {
                 $value = '&nbsp;-&nbsp;' . $this->_type['description'];
             }
             break;
         case 'ProductTypes':
             $value = $this->outputProductTypes();
             break;
         default:
             break;
     }
     return $value;
 }
 function output($group_id_range_from = 0, $group_id_range_to = 999999, $group_title)
 {
     $groups = modApiFunc('Reports', 'getReportGroups');
     $current_group_id = (int) modApiFunc('Request', 'getValueByKey', 'report_group_id');
     if ($current_group_id !== null and isset($groups[$current_group_id])) {
         $current_group_id = (int) $current_group_id;
     } else {
         reset($groups);
         $current_group_id = array_keys($groups);
         $current_group_id = $current_group_id[0];
     }
     $links = '';
     foreach ($groups as $grp_id => $grp) {
         if ($grp_id < $group_id_range_from or $grp_id > $group_id_range_to) {
             continue;
         }
         $data = array();
         $data['LinkName'] = $grp['GROUP_NAME'];
         $data['LinkDescription'] = $grp['GROUP_DESCRIPTION'];
         $request = new Request();
         $request->setView(CURRENT_REQUEST_URL);
         $request->setKey('report_group_id', $grp_id);
         $data['LinkHref'] = $request->getURL();
         if ($current_group_id === $grp_id and $current_group_id >= $group_id_range_from and $current_group_id <= $group_id_range_to) {
             $links .= $this->_TmplFiller->fill("", "group-link-selected.tpl.html", $data);
         } else {
             $links .= $this->_TmplFiller->fill("", "group-link.tpl.html", $data);
         }
     }
     return $this->_TmplFiller->fill("", "container.tpl.html", array('ReportGroupLinks' => $links, 'Title' => getMsg('RPTS', $group_title)));
 }
 function onAction()
 {
     global $application;
     $oid = $_POST["option_id"];
     unset($_POST["option_id"]);
     $data = array("option_id" => $oid, "values_ids" => array_keys($_POST["toDeleteValues"]));
     $check_result = modApiFunc("Product_Options", "checkDataFor", "delValuesFromOption", $data);
     if (!empty($check_result)) {
         modApiFunc("Session", "set", "Errors", $check_result);
         $request = new Request();
         $request->setKey("option_id", $oid);
         $request->setView('PO_EditOption');
         $application->redirect($request);
     } else {
         $del_result = modApiFunc("Product_Options", "delValuesFromOption", $data);
         if ($del_result == false) {
             modApiFunc("Session", "set", "ResultMessage", "MSG_VALUES_NOT_DELETED");
         } else {
             modApiFunc("Session", "set", "ResultMessage", "MSG_VALUES_DELETED");
         }
         $request = new Request();
         $request->setView('PO_EditOption');
         $request->setKey('option_id', $oid);
         $application->redirect($request);
     }
 }
 function onAction()
 {
     loadClass('GiftCertificateCreator');
     $cr = new GiftCertificateCreator();
     //                                    ,                .             ,
     //         $map                 $_POST          .
     //                              ,                     .
     $cr->initByMap($_POST);
     //                     .
     $cr->save();
     if ($cr->isError()) {
         modApiFunc('Session', 'set', 'gc_update_action_result', 'failed');
         modApiFunc('Session', 'set', 'gc_update_action_errors', $cr->errors);
         modApiFunc('Session', 'set', 'SessionPost', $_POST);
     } else {
         modApiFunc('Session', 'set', 'gc_update_action_result', 'created');
         if ($cr->sendtype === GC_SENDTYPE_EMAIL && $cr->status === GC_STATUS_ACTIVE) {
             modApiFunc('EventsManager', 'throwEvent', 'GiftCertificateCreated', $cr);
         }
         $request = new Request();
         $request->setView('GiftCertificateEditView');
         $request->setKey('gc_code', $cr->code);
         global $application;
         $application->redirect($request);
     }
 }
 /**
  * Returns Review info tag value
  */
 function getReviewTagValue($tag)
 {
     $output = '';
     // if productid is incorrect returns '' in any case
     if ($this->_productid_invalid) {
         return '';
     }
     switch ($tag) {
         case 'number':
             $output = modApiFunc('Customer_Reviews', 'getProductCustomerReviewNumber', $this->_productid);
             if (!$this->checkReviewAvail(6, 7)) {
                 $output = 0;
             }
             break;
         case 'averagerating':
             $output = modApiFunc('Customer_Reviews', 'getTotalProductRating', $this->_productid);
             $output = $output['total_rating'];
             if (!$this->checkReviewAvail(7)) {
                 $output = 0;
             }
             break;
         case 'link':
             $cid = modApiFunc('CProductListFilter', 'getCurrentCategoryId');
             $r = new Request();
             $r->setView('ProductInfo');
             $r->setAction('SetCurrentProduct');
             $r->setKey('prod_id', $this->_productid);
             $r->setProductID($this->_productid);
             $r->setCategoryID($cid);
             $r->setAnchor('customer_reviews_' . $this->_productid);
             return $r->getURL();
     }
     return $output;
 }
 function getTag($tag)
 {
     $value = null;
     switch ($tag) {
         case 'Local_SetCurrencyLink':
             $r = new Request();
             $r->setView(CURRENT_REQUEST_URL);
             $r->setAction('SetDisplayCurrency');
             $r->setKey('currency_id', '%currency_id_value%');
             $value = $r->getURL();
             break;
         case 'Local_CurrencyName':
             $value = $this->_Currency['name'];
             break;
         case 'Local_CurrencySelected':
             $b = $this->_Currency['id'] == modApiFunc("Localization", "getSessionDisplayCurrency");
             $value = $b ? 'selected="selected"' : "";
             break;
         case 'Local_CurrencyId':
             $value = $this->_Currency['id'];
             break;
         case 'Local_Items':
             $value = $this->outputItems();
             break;
         case 'Local_CurrentCurrency':
             $value = modApiFunc("Localization", "getCurrencyCodeById", modApiFunc("Localization", "getSessionDisplayCurrency"));
             break;
         case 'Local_CurrencyCode':
             $value = $this->_Currency['code'];
             break;
     }
     return $value;
 }
 function onAction()
 {
     global $application;
     $request =& $application->getInstance('Request');
     $product_id = $request->getValueByKey('product_id');
     $cats_ids = array_keys($request->getValueByKey('product_cats'));
     $prodObj =& $application->getInstance('CProductInfo', $product_id);
     $cur_cats = $prodObj->getCategoriesIDs();
     $cats_to_del = array_diff($cur_cats, $cats_ids);
     $cats_to_add = array_diff($cats_ids, $cur_cats);
     if (!empty($cats_to_del)) {
         modApiFunc('Catalog', 'delProductLinksFromCategories', $product_id, $cats_to_del);
     }
     if (!empty($cats_to_add)) {
         foreach ($cats_to_add as $category_id) {
             modApiFunc('Catalog', 'addProductLinkToCategory', $product_id, $category_id);
         }
     }
     modApiFunc('Session', 'set', 'mustReloadParent', true);
     modApiFunc('Session', 'set', 'ResultMessage', 'MSG_PROD_CATS_UPDATED');
     $r = new Request();
     $r->setView('MngProductCats');
     $r->setKey('product_id', $product_id);
     $application->redirect($r);
 }
 function onAction()
 {
     global $application;
     $request = new Request();
     $key = $request->getValueByKey('key');
     $passwd = array('passwd' => $request->getValueByKey('new_password'), 're-type' => $request->getValueByKey('retype_password'));
     $account_name = modApiFunc('Customer_Account', 'getAccountByActivationKey', $key);
     $errors = array();
     if ($account_name != null) {
         $validator =& $application->getInstance('CAValidator');
         if (!$validator->isValid('passwd', $passwd)) {
             $errors[] = 'E_INVALID_PASSWD';
         }
     }
     if (!empty($errors)) {
         modApiFunc('Session', 'set', 'RegisterErrors', $errors);
         $request->setView('CustomerNewPassword');
         $request->setKey('key', $key);
     } else {
         modApiFunc('Session', 'set', 'ResultMessage', 'MSG_PASSWD_UPDATED');
         modApiFunc('Customer_Account', 'dropActivationKey', $account_name, 'customer_account');
         $obj =& $application->getInstance('CCustomerInfo', $account_name);
         $obj->setPersonInfo(array(array('Status', 'A', 'base')));
         $obj->changePassword($passwd['passwd']);
         $obj->SignIn();
         $request->setView('CustomerAccountHome');
     }
     $application->redirect($request);
 }
 function onAction()
 {
     global $application;
     $request =& $application->getInstance('Request');
     $product_id = $request->getValueByKey('product_id');
     $file_descr = $request->getValueByKey('new_file_descr');
     if ($file_descr == null) {
         $file_descr = '';
     }
     $file_path = $request->getValueByKey('new_file_name_hidden');
     if (preg_match("/^__shell_upload_\\d+\$/", basename(dirname($file_path)))) {
         $result = modApiFunc('Product_Files', 'moveFileToPFDir', $product_id, $file_path);
         $is_uploaded = true;
         modApiFunc('Shell', 'removeDirectory', dirname($file_path));
     } else {
         $result = array('error' => UPLOAD_ERR_OK, 'full_path' => $file_path, 'base_name' => basename($file_path), 'file_size' => filesize($file_path));
         $is_uploaded = false;
     }
     if ($result['error'] == UPLOAD_ERR_OK) {
         modApiFunc('Product_Files', 'addFileToProduct', $product_id, $result['base_name'], $result['full_path'], $file_descr, $is_uploaded);
         modApiFunc('Session', 'set', 'ResultMessage', 'MSG_FILE_ADDED');
     } else {
         modApiFunc('Session', 'set', 'Errors', array($result['error']));
     }
     $r = new Request();
     $r->setView('PF_FilesList');
     $r->setKey('product_id', $product_id);
     $application->redirect($r);
 }
 /**
  * Redirects after action.
  */
 function redirect()
 {
     global $application;
     $request = new Request();
     $request->setView('EditCategory');
     $request->setKey('tree_id', modApiFunc('Request', 'getValueByKey', 'tree_id'));
     // getting the category name for category tree
     // Note: assume the data language for the tree page is not changed
     //       otherwise the data language for that page should be set below
     // Note: Since the redirect is taken place we do not worry about
     //       restoring the language
     modApiFunc('MultiLang', 'setLanguage', modApiFunc('MultiLang', 'getResourceLanguage'));
     $catInfo = new CCategoryInfo($this->old_id);
     $request->setKey('new_name', urlencode($catInfo->getCategoryTagValue('name')));
     $request->setKey('old_id', $this->old_id);
     $application->redirect($request);
 }