/** * _updateBasic() method update basic settings * * @param array $aPost * @return array */ private function _updateBasic(array $aPost) { // clean headers @ob_end_clean(); // set $aUpdate = array(); try { // use case - check display fancy popin for asking to associate FB account with PS $bDisplayAskFbPopin = Tools::getIsset(strtolower(_FPC_MODULE_NAME) . 'DisplayFbPopin') && Tools::getValue(strtolower(_FPC_MODULE_NAME) . 'DisplayFbPopin') == 'true' ? true : false; if (!Configuration::updateValue(_FPC_MODULE_NAME . '_DISPLAY_FB_POPIN', $bDisplayAskFbPopin)) { throw new Exception(FacebookPsConnect::$oModule->l('An error occurred during FB association popin update', 'admin-update_class') . '.', 110); } // use case - check display block $bDisplayBlock = Tools::getIsset(strtolower(_FPC_MODULE_NAME) . 'DisplayBlock') && Tools::getValue(strtolower(_FPC_MODULE_NAME) . 'DisplayBlock') == 'true' ? true : false; if (!Configuration::updateValue(_FPC_MODULE_NAME . '_DISPLAY_BLOCK', $bDisplayBlock)) { throw new Exception(FacebookPsConnect::$oModule->l('An error occurred during block display update', 'admin-update_class') . '.', 111); } // use case - check display account information block $bDisplayBlockInfoAccount = Tools::getIsset(strtolower(_FPC_MODULE_NAME) . 'DisplayBlockInfoAccount') && Tools::getValue(strtolower(_FPC_MODULE_NAME) . 'DisplayBlockInfoAccount') == 'true' ? true : false; if (!Configuration::updateValue(_FPC_MODULE_NAME . '_DISPLAY_BLOCK_INFO_ACCOUNT', $bDisplayBlockInfoAccount)) { throw new Exception(FacebookPsConnect::$oModule->l('An error occurred during block display update', 'admin-update_class') . '.', 112); } // use case - check display cart information block $bDisplayBlockInfoCart = Tools::getIsset(strtolower(_FPC_MODULE_NAME) . 'DisplayBlockInfoCart') && Tools::getValue(strtolower(_FPC_MODULE_NAME) . 'DisplayBlockInfoCart') == 'true' ? true : false; if (!Configuration::updateValue(_FPC_MODULE_NAME . '_DISPLAY_BLOCK_INFO_CART', $bDisplayBlockInfoCart)) { throw new Exception(FacebookPsConnect::$oModule->l('An error occurred during block display update', 'admin-update_class') . '.', 113); } // use case - set default customer group if (Tools::getIsset(strtolower(_FPC_MODULE_NAME) . 'DefaultGroup')) { $iDefaultCustGroup = Tools::getValue(strtolower(_FPC_MODULE_NAME) . 'DefaultGroup'); if (is_numeric($iDefaultCustGroup)) { if (!Configuration::updateValue(_FPC_MODULE_NAME . '_DEFAULT_CUSTOMER_GROUP', $iDefaultCustGroup)) { throw new Exception(FacebookPsConnect::$oModule->l('An error occurred during default customer group update', 'admin-update_class') . '.', 114); } } else { throw new Exception(FacebookPsConnect::$oModule->l('Default customer group is not a numeric', 'admin-update_class') . '.', 115); } } // use case - set default API request method if (Tools::getIsset(strtolower(_FPC_MODULE_NAME) . 'ApiRequestType')) { $iDefaultApiMethod = Tools::getValue(strtolower(_FPC_MODULE_NAME) . 'ApiRequestType'); if (!empty($iDefaultApiMethod)) { if (!Configuration::updateValue(_FPC_MODULE_NAME . '_API_REQUEST_METHOD', $iDefaultApiMethod)) { throw new Exception(FacebookPsConnect::$oModule->l('An error occurred during default API request method update', 'admin-update_class') . '.', 116); } } } // use case - if OPC activate, update block's text below connectors' button if (Tools::getIsset(strtolower(_FPC_MODULE_NAME) . 'DisplayBlockInfoCart')) { $bDisplayBlockOpc = Tools::getValue(strtolower(_FPC_MODULE_NAME) . 'DisplayBlockInfoCart') == 'true' ? true : false; if (!Configuration::updateValue(_FPC_MODULE_NAME . '_DISPLAY_BLOCK_INFO_CART', $bDisplayBlockOpc)) { throw new Exception(FacebookPsConnect::$oModule->l('An error occurred during display block cart update', 'admin-update_class') . '.', 117); } } } catch (Exception $e) { $aUpdate['aErrors'][] = array('msg' => $e->getMessage(), 'code' => $e->getCode()); } // get configuration options BT_FPCModuleTools::getConfiguration(); // require admin configure class - to factorise require_once _FPC_PATH_LIB_ADMIN . 'admin-display_class.php'; // get run of admin display in order to display first page of admin with basic settings updated $aData = BT_AdminDisplay::create()->run(array('sType' => 'basic')); // use case - empty error and updating status $aData['assign'] = array_merge($aData['assign'], array('iActiveTab' => 1, 'bUpdate' => empty($aUpdate['aErrors']) ? true : false), $aUpdate); // destruct unset($aUpdate); return $aData; }
/** * getContent() method manages all data in Back Office * * @return string */ public function getContent() { require_once _FPC_PATH_CONF . 'admin.conf.php'; require_once _FPC_PATH_LIB_ADMIN . 'admin-ctrl_class.php'; // set $aUpdateModule = array(); try { // update new module keys BT_FPCModuleTools::updateConfiguration(); // get configuration options BT_FPCModuleTools::getConfiguration(); // set js msg translation BT_FPCModuleTools::translateJsMsg(); // instantiate admin controller object $oAdmin = new BT_AdminCtrl(); // defines type to execute // use case : no key sAction sent in POST mode (no form has been posted => first page is displayed with admin-display.class.php) // use case : key sAction sent in POST mode (form or ajax query posted ). $sAction = !Tools::getIsset('sAction') || Tools::getIsset('sAction') && 'display' == Tools::getValue('sAction') ? Tools::getIsset('sAction') ? Tools::getValue('sAction') : 'display' : Tools::getValue('sAction'); // make module update only in case of display general admin page if ($sAction == 'display' && !Tools::getIsset('sType')) { // update module if necessary $aUpdateModule = $this->_updateModule(); } //execute good action in admin // only displayed with key : tpl and assign in order to display good smarty template $aDisplay = $oAdmin->run($sAction, array_merge($_GET, $_POST)); // free memory unset($oAdmin); if (!empty($aDisplay)) { $aDisplay['assign'] = array_merge($aDisplay['assign'], array('aUpdateErrors' => $aUpdateModule, 'oJsTranslatedMsg' => BT_FPCModuleTools::jsonEncode($GLOBALS[_FPC_MODULE_NAME . '_JS_MSG']), 'bAddJsCss' => true)); // get content $sContent = $this->displayModule($aDisplay['tpl'], $aDisplay['assign']); if (!empty(self::$sQueryMode)) { echo $sContent; } else { return $sContent; } } else { throw new Exception('action returns empty content', 110); } } catch (Exception $e) { $this->aErrors[] = array('msg' => $e->getMessage(), 'code' => $e->getCode()); // get content $sContent = $this->displayErrorModule(); if (!empty(self::$sQueryMode)) { echo $sContent; } else { return $sContent; } } // exit clean with XHR mode if (!empty(self::$sQueryMode)) { exit(0); } }