public function calibrate() { //specific instruction for PS 1.5 and greater if (_PS_VERSION_ >= '1.5') { $link = new Link(); //sets the redirection according to the action switch (Tools::getValue('action')) { //if checkoutScore, redirection to the admin order page case 'checkoutScore': $this->redirect_after = $link->getAdminLink('AdminOrders') . "&id_order=" . Tools::getValue('id_order') . '&vieworder'; break; //if sendOrder, redirection to the admin order page //if sendOrder, redirection to the admin order page case 'sendOrder': $this->redirect_after = $link->getAdminLink('AdminOrders') . "&id_order=" . Tools::getValue('id_order') . '&vieworder'; break; //if getAllWaitingScore, redirection to the admin orders list //if getAllWaitingScore, redirection to the admin orders list case 'getAllWaitingScores': $this->redirect_after = $link->getAdminLink('AdminCertissim'); break; //if getReevaluations, redirection to the admin orders list //if getReevaluations, redirection to the admin orders list case 'getReevaluations': $this->redirect_after = $link->getAdminLink('AdminCertissim'); break; //if unknown action //if unknown action default: break; } } $this->_select .= ', IF( (SELECT cs.label FROM `' . _DB_PREFIX_ . 'certissim_order` c LEFT JOIN `' . _DB_PREFIX_ . 'certissim_state` cs ON c.id_certissim_state = cs.id_certissim_state WHERE c.id_order = a.id_order) = "scored", (SELECT c2.score FROM `' . _DB_PREFIX_ . 'certissim_order` c2 WHERE c2.id_order = a.id_order LIMIT 1), ( IF( (SELECT count(c3.id_order) FROM `' . _DB_PREFIX_ . 'certissim_order` c3 WHERE c3.id_order=a.id_order) > 0, (SELECT cs2.label FROM `' . _DB_PREFIX_ . 'certissim_order` c3 LEFT JOIN `' . _DB_PREFIX_ . 'certissim_state` cs2 ON c3.id_certissim_state = cs2.id_certissim_state WHERE c3.id_order = a.id_order), ("not concerned") ) ) ) as score'; $this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'certissim_order` cert ON (cert.`id_order` = a.`id_order`)'; if (_PS_VERSION_ >= '1.5') { $column_description = array('title' => $this->l('Certissim Eval'), 'width' => 50, 'search' => true, 'icon' => array('0' => array('src' => "../../modules/fianetfraud/img/0.gif", 'alt' => 'Risque détecté'), '-1' => array('src' => "../../modules/fianetfraud/img/-1.gif", 'alt' => 'Pas de risque détecté'), '100' => array('src' => "../../modules/fianetfraud/img/100.gif", 'alt' => 'Certifiée sans risque'), 'error' => array('src' => "../../modules/fianetfraud/img/error.gif", 'alt' => 'Erreur'), 'sent' => array('src' => "../../modules/fianetfraud/img/sent.gif", 'alt' => 'Calcul du risque en cours'), 'ready to send' => array('src' => "../../modules/fianetfraud/img/ready-to-send.gif", 'alt' => 'En attente du paiement'), 'not concerned' => array('src' => "../../modules/fianetfraud/img/not-concerned.gif", 'alt' => 'Non concernée'))); $this->fields_list['score'] = $column_description; } else { $column_description = array('title' => $this->l('Certissim Eval'), 'width' => 50, 'search' => true, 'icon' => array('0' => "../../modules/fianetfraud/img/0.gif", '-1' => "../../modules/fianetfraud/img/-1.gif", '100' => "../../modules/fianetfraud/img/100.gif", 'error' => "../../modules/fianetfraud/img/error.gif", 'sent' => "../../modules/fianetfraud/img/sent.gif", 'ready to send' => "../../modules/fianetfraud/img/ready-to-send.gif", 'default' => "../../modules/fianetfraud/img/not-concerned.gif")); $this->fieldsDisplay['score'] = $column_description; } }
function upgrade_addquickaccess() { $link = new Link(); $qa = new QuickAccess(); $qa->link = $link->getAdminLink('AdminModules') . '&configure=smartblog'; $languages = Language::getLanguages(false); foreach ($languages as $language) { $qa->name[$language['id_lang']] = 'Smart Blog Setting'; } $qa->new_window = '0'; if ($qa->save()) { Configuration::updateValue('smartblog_quick_access', $qa->id); } return true; }
public function __construct() { parent::__construct(); //specific instruction for PS 1.5 and greater if (_PS_VERSION_ >= '1.5') { $this->tpl_folder = AdminModulesController::getController('AdminOrdersController')->tpl_folder; $this->override_folder = AdminModulesController::getController('AdminOrdersController')->override_folder; $link = new Link(); //sets the redirection according to the action switch (Tools::getValue('action')) { //if sendOrder, redirection to the admin order page case 'ResendOrder': $this->redirect_after = $link->getAdminLink('AdminSceau') . "&id_order=" . Tools::getValue('id_order') . '&vieworder'; break; //if unknown action //if unknown action default: break; } } //build sql query which added to sql query of AdminOrders class $this->_select .= ', fs.`label` as `fs_label`'; $this->_join .= 'LEFT JOIN `' . _DB_PREFIX_ . 'fianetsceau_order` fo ON a.`id_order` = fo.`id_order`'; $this->_join .= 'LEFT JOIN `' . _DB_PREFIX_ . 'fianetsceau_state` fs ON fo.`id_fianetsceau_state` = fs.`id_fianetsceau_state`'; //icons management if (_PS_VERSION_ >= '1.5') { $icons = array('sent' => array('src' => "../../modules/fianetsceau/img/sent.gif", 'alt' => 'Commande envoyée'), 'waiting payment' => array('src' => "../../modules/fianetsceau/img/waiting.gif", 'alt' => 'Commande en attente de paiement'), 'error' => array('src' => "../../modules/fianetsceau/img/not_concerned.png", 'alt' => 'Commande en erreur'), 'default' => "../../modules/fianetsceau/img/error.gif"); } else { $icons = array('sent' => '../../modules/fianetsceau/img/sent.gif', 'waiting payment' => '../../modules/fianetsceau/img/waiting.gif', 'error' => '../../modules/fianetsceau/img/not_concerned.png', 'default' => "../../modules/fianetsceau/img/error.gif"); } //personalize new column added in new order tab $column_definition = array('title' => $this->l('Sceau state'), 'width' => 50, 'icon' => $icons); if (_PS_VERSION_ >= '1.5') { $this->fields_list['fs_label'] = $column_definition; } else { $this->fieldsDisplay['fs_label'] = $column_definition; } $this->module = Module::getInstanceByName('fianetsceau'); }
protected function toggleWebservice($force_webservice = false, $active = true) { if ($force_webservice !== false) { $cron_mode = 'webservice'; } else { $cron_mode = Tools::getValue('cron_mode', 'webservice'); $active = $cron_mode == 'advanced' ? false : true; } $link = new Link(); Configuration::updateValue('CRONJOBS_MODE', $cron_mode); $admin_folder = str_replace(_PS_ROOT_DIR_ . '/', null, _PS_ADMIN_DIR_); $path = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . $admin_folder; $cron_url = $path . '/' . $link->getAdminLink('AdminCronJobs', false); $webservice_id = Configuration::get('CRONJOBS_WEBSERVICE_ID') ? '/' . Configuration::get('CRONJOBS_WEBSERVICE_ID') : null; $data = array('callback' => $link->getModuleLink($this->name, 'callback'), 'cronjob' => $cron_url . '&token=' . Configuration::get('CRONJOBS_EXECUTION_TOKEN', null, 0, 0), 'cron_token' => Configuration::get('CRONJOBS_EXECUTION_TOKEN', null, 0, 0), 'active' => (int) $active); $context_options = array('http' => array('method' => is_null($webservice_id) == true ? 'POST' : 'PUT', 'content' => http_build_query($data))); $context = stream_context_create($context_options); $result = Tools::file_get_contents($this->webservice_url . $webservice_id, false, $context); Configuration::updateValue('CRONJOBS_WEBSERVICE_ID', (int) $result); if ($this->isLocalEnvironment() == true) { return true; } elseif ((Tools::isSubmit('install') == false || Tools::isSubmit('reset') == false) && (bool) $result == false) { return $this->setErrorMessage('An error occurred while trying to contact PrestaShop\'s cron tasks webservice.'); } elseif ((Tools::isSubmit('install') == true || Tools::isSubmit('reset') == true) && (bool) $result == false) { return true; } Configuration::updateValue('CRONJOBS_MODE', $cron_mode); switch ($cron_mode) { case 'advanced': return $this->setSuccessMessage('Your cron tasks have been successfully registered using the Advanced mode.'); case 'webservice': return $this->setSuccessMessage('Your cron tasks have been successfully added to PrestaShop\'s cron tasks webservice.'); default: return; } return true; }
public function processBooking($param) { if (Tools::isSubmit('submitAddproductAndStay')) { $checkTabClick = Tools::getValue('checkTabClick'); $date_from = Tools::getValue('from_date'); $date_to = Tools::getValue('to_date'); $num_rooms = Tools::getValue('num_rooms'); $id_product = Tools::getValue('id_product'); $link = new Link(); if ($checkTabClick) { Tools::redirectAdmin($link->getAdminLink('AdminProducts') . '&id_product=' . $id_product . '&updateproduct&key_tab=Booking&date_from=' . $date_from . '&date_to=' . $date_to); } } }
protected function updateWebservice($use_webservice) { $link = new Link(); $admin_folder = $this->getAdminDir(); $path = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . $admin_folder; $cron_url = $path . '/' . $link->getAdminLink('AdminCronJobs', false); $webservice_id = Configuration::get('CRONJOBS_WEBSERVICE_ID') ? '/' . Configuration::get('CRONJOBS_WEBSERVICE_ID') : null; $data = array('callback' => $link->getModuleLink($this->name, 'callback'), 'domain' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__, 'cronjob' => $cron_url . '&token=' . Configuration::getGlobalValue('CRONJOBS_EXECUTION_TOKEN'), 'cron_token' => Configuration::getGlobalValue('CRONJOBS_EXECUTION_TOKEN'), 'active' => (bool) $use_webservice); $context_options = array('http' => array('method' => is_null($webservice_id) == true ? 'POST' : 'PUT', 'content' => http_build_query($data))); $result = Tools::file_get_contents($this->webservice_url . $webservice_id, false, stream_context_create($context_options)); if ($result != false) { Configuration::updateValue('CRONJOBS_WEBSERVICE_ID', (int) $result); } if ((Tools::isSubmit('install') == true || Tools::isSubmit('reset') == true) && (bool) $result == false) { return true; } elseif ((Tools::isSubmit('install') == false || Tools::isSubmit('reset') == false) && (bool) $result == false) { return $this->setErrorMessage('An error occurred while trying to contact PrestaShop\'s cron tasks webservice.'); } elseif ($this->isLocalEnvironment() == true) { return true; } if ((bool) $use_webservice == true) { return $this->setSuccessMessage('Your cron tasks have been successfully added to PrestaShop\'s cron tasks webservice.'); } return $this->setSuccessMessage('Your cron tasks have been successfully registered using the Advanced mode.'); }
public function postProcess() { $modif = false; // Res is here to test page the time to wait the functional application if (($res = Tools::getValue('mj_check_hosting')) && !$this->isAccountSet()) { $this->page_name = $res ? 'SETUP_STEP_1' : 'SETUP_STEP_0'; } else { if (Tools::isSubmit('MJ_set_connect')) { $this->checkAuthentication(); } else { if (Tools::isSubmit('MJ_set_login')) { $this->checkAuthentication(); } else { if ($events_list = Tools::getValue('events')) { $mj_event = new MailJetEvents(); foreach ($events_list as $key => $id_mf_events) { $mj_event->id = $id_mf_events; if ($mj_event->delete()) { unset($events_list[$key]); } } $this->context->smarty->assign('MJ_events_form_success', $events_list); } } } } // All emails sending by Mailjet ? if (Tools::isSubmit('MJ_set_allemails')) { $triggers = ($triggers = Tools::jsonDecode(Configuration::get('MJ_TRIGGERS'), true)) ? $triggers : $this->triggers; Configuration::updateValue('MJ_TRIGGERS', Tools::jsonEncode($triggers)); if (Tools::getValue('MJ_allemails_active')) { $this->activateAllEmailMailjet(); $triggers['active'] = 1; } else { Configuration::updateValue('PS_MAIL_METHOD', 1); /* * deactivate triggers if Mailjet emails are disabled */ $triggers['active'] = 0; } Configuration::updateValue('MJ_ALLEMAILS', Tools::getValue('MJ_allemails_active')); $this->context->smarty->assign(array('MJ_allemails_active' => Configuration::get('MJ_ALLEMAILS'), 'AllMailsActiveMessage' => Tools::getValue('MJ_allemails_active') ? 1 : 2)); } // Campaign if (Tools::isSubmit('MJ_submitCampaign')) { $this->page_name = 'NEWSLETTER'; } if (Tools::isSubmit('MJ_submitCampaign2')) { $this->page_name = 'CAMPAIGN3'; } // Activation root file Creation if (Tools::isSubmit('submitCreateRootFile')) { $api = MailjetTemplate::getApi(); $domains = $api->getTrustDomains(); foreach ($domains->domains as $domain) { if ($domain->domain == Configuration::get('PS_SHOP_DOMAIN') || $domain->domain == Configuration::get('PS_SHOP_DOMAIN_SSL')) { $fp = fopen(_PS_ROOT_DIR_ . $domain->file_name, 'w'); fclose($fp); } } } // Account settings : details if (Tools::isSubmit('MJ_set_account_details')) { $api = MailjetTemplate::getApi(); $api->updateUser(Tools::getValue('MJ_account_address_city'), Tools::getValue('MJ_account_address_country'), Tools::getValue('MJ_account_address_postal_code'), Tools::getValue('MJ_account_address_street'), Tools::getValue('MJ_account_company_name'), null, Tools::getValue('MJ_account_firstname'), Tools::getValue('MJ_account_lastname'), null); /* $locale = NULL */ $modif = true; } // Account settings : tracking if (Tools::isSubmit('MJ_set_account_tracking')) { $api = MailjetTemplate::getApi(); if (Tools::getValue('MJ_account_tracking_clicks') == '1') { $tracking_clicks = true; } else { $tracking_clicks = false; } if (Tools::getValue('MJ_account_tracking_openers') == '1') { $tracking_openers = true; } else { $tracking_openers = false; } $api->updateTracking($tracking_clicks, $tracking_openers); $modif = true; } // Account settings : senders if (Tools::isSubmit('MJ_set_account_senders')) { $api = MailjetTemplate::getApi(); $address = Tools::getValue('MJ_account_senders_new'); $api->createSender($address); $modif = true; } // Triggers if (Tools::isSubmit('MJ_set_triggers')) { $this->triggers['active'] = Tools::getValue('MJ_triggers_active'); for ($sel = 1; $sel <= 9; $sel++) { $this->triggers['trigger'][$sel]['active'] = Tools::getValue('MJ_triggers_trigger_' . $sel . '_active'); if ($sel != 5 && $sel != 6) { $this->triggers['trigger'][$sel]['period'] = (double) Tools::getValue('MJ_triggers_trigger_' . $sel . '_period'); $this->triggers['trigger'][$sel]['periodType'] = (int) Tools::getValue('MJ_triggers_trigger_' . $sel . '_periodType'); } else { $this->triggers['trigger'][$sel]['discount'] = (double) Tools::getValue('MJ_triggers_trigger_' . $sel . '_discount'); $this->triggers['trigger'][$sel]['discountType'] = (int) Tools::getValue('MJ_triggers_trigger_' . $sel . '_discountType'); } $languages = Language::getLanguages(); foreach ($languages as $l) { $this->triggers['trigger'][$sel]['subject'][$l['id_lang']] = Tools::getValue('MJ_triggers_trigger_' . $sel . '_subject_' . $l['id_lang']); $this->triggers['trigger'][$sel]['mail'][$l['id_lang']] = Tools::getValue('MJ_triggers_trigger_' . $sel . '_mail_' . $l['id_lang']); } } $this->updateTriggers(); $modif = true; } if (Tools::isSubmit('MJ_triggers_import_submit')) { if (isset($_FILES['MJ_triggers_import_file']['tmp_name']) && !empty($_FILES['MJ_triggers_import_file']['tmp_name'])) { $file = new SplFileObject($_FILES['MJ_triggers_import_file']['tmp_name']); while (!$file->eof()) { $triggers .= $file->fgets(); } Configuration::updateValue('MJ_TRIGGERS', $triggers); $modif = true; } } if (Tools::isSubmit('MJ_triggers_export_submit')) { $triggers = ($triggers = Configuration::get('MJ_TRIGGERS')) ? $triggers : Tools::jsonEncode($this->triggers); header("Content-Type: plain/text"); header("Content-Disposition: Attachment; filename=Mailjet_Trigger_Templates.txt"); header("Pragma: no-cache"); echo "{$triggers}"; die; } if ($modif) { $link = new Link(); Tools::redirectAdmin($link->getAdminLink('AdminModules') . '&configure=mailjet&module_name=mailjet&MJ_request_page=' . Tools::getValue('MJ_request_page') . '&conf=4'); } }
public function hookAdminOrder($params) { $link = new Link(); $html = '<div class="panel"><div class="clear"> </div> <form action="' . $link->getAdminLink('AdminOrders') . '&vieworder&id_order=' . $params['id_order'] . '" method="post"> <input type="hidden" value="1" name="export_csv"> <input class="btn btn-primary" type="submit" value="' . $this->l('Export this order by email') . '" name="submitExportCSV" /> </form></div>'; if (Tools::isSubmit('submitExportCSV')) { if ((int) Tools::getValue('export_csv')) { $this->sendExportByEmail($params); $html .= '<div class="panel"><div class="clear"> </div> <div class="conf"> <img alt="" src="../img/admin/ok2.png"> ' . $this->l('Order was exported with success.') . ' </div></div>'; } } return $html; }
public function getPreform() { $link = new Link(); $redir_admin_link = $link->getAdminLink('AdminRedirect'); $this->context->smarty->assign(array('displayName' => $this->displayName, 'description' => $this->description, 'redir_admin_link' => $redir_admin_link, 'logo_img' => __PS_BASE_URI__ . 'modules/' . $this->name . '/logo.png')); return $this->display(__FILE__, 'preform.tpl'); }