Exemplo n.º 1
0
 /**
  * run() method execute abstract derived admin object
  *
  * @param string $sAdminType : type of interface to display
  * @param array $aRequest : request
  * @return array $aDisplay : empty => false / not empty => true
  */
 public function run($sAdminType, $aRequest)
 {
     // set
     $aDisplay = array();
     // include interface
     require_once _FPC_PATH_LIB_ADMIN . 'i-admin.php';
     switch ($sAdminType) {
         case 'display':
             // include matched admin object
             require_once _FPC_PATH_LIB_ADMIN . 'admin-display_class.php';
             $oAdminType = BT_AdminDisplay::create();
             break;
         case 'update':
             // update basic settings /
             // include matched admin object
             require_once _FPC_PATH_LIB_ADMIN . 'admin-update_class.php';
             $oAdminType = BT_AdminUpdate::create();
             break;
         default:
             $oAdminType = false;
             break;
     }
     // process data to use in view (tpl)
     if (!empty($oAdminType)) {
         $aDisplay = $oAdminType->run($aRequest);
         // destruct
         unset($oAdminType);
     }
     return $aDisplay;
 }
Exemplo n.º 2
0
 /**
  * _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;
 }