当前位置: 首页>>代码示例>>PHP>>正文


PHP Configuration::deleteFromContext方法代码示例

本文整理汇总了PHP中Configuration::deleteFromContext方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::deleteFromContext方法的具体用法?PHP Configuration::deleteFromContext怎么用?PHP Configuration::deleteFromContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Configuration的用法示例。


在下文中一共展示了Configuration::deleteFromContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 public function postProcess()
 {
     if (Tools::isSubmit('submitDeleteImgConf')) {
         $this->_deleteCurrentImg();
     }
     $errors = '';
     if (Tools::isSubmit('submitAdvConf')) {
         if (isset($_FILES['adv_img']) && isset($_FILES['adv_img']['tmp_name']) && !empty($_FILES['adv_img']['tmp_name'])) {
             if ($error = ImageManager::validateUpload($_FILES['adv_img'], Tools::convertBytes(ini_get('upload_max_filesize')))) {
                 $errors .= $error;
             } else {
                 Configuration::updateValue('BLOCKADVERT_IMG_EXT', substr($_FILES['adv_img']['name'], strrpos($_FILES['adv_img']['name'], '.') + 1));
                 // Set the image name with a name contextual to the shop context
                 $this->adv_imgname = 'advertising';
                 if (Shop::getContext() == Shop::CONTEXT_GROUP) {
                     $this->adv_imgname = 'advertising-g' . (int) $this->context->shop->getContextShopGroupID();
                 } elseif (Shop::getContext() == Shop::CONTEXT_SHOP) {
                     $this->adv_imgname = 'advertising-s' . (int) $this->context->shop->getContextShopID();
                 }
                 // Copy the image in the module directory with its new name
                 if (!move_uploaded_file($_FILES['adv_img']['tmp_name'], _PS_MODULE_DIR_ . $this->name . '/img/' . $this->adv_imgname . '.' . Configuration::get('BLOCKADVERT_IMG_EXT'))) {
                     $errors .= $this->l('File upload error.');
                 }
             }
         }
         // If the link is not set, then delete it in order to use the next default value (either the global value or the group value)
         if ($link = Tools::getValue('adv_link')) {
             Configuration::updateValue('BLOCKADVERT_LINK', $link);
         } elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP) {
             Configuration::deleteFromContext('BLOCKADVERT_LINK');
         }
         // If the title is not set, then delete it in order to use the next default value (either the global value or the group value)
         if ($title = Tools::getValue('adv_title')) {
             Configuration::updateValue('BLOCKADVERT_TITLE', $title);
         } elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP) {
             Configuration::deleteFromContext('BLOCKADVERT_TITLE');
         }
         // Reset the module properties
         $this->initialize();
         $this->_clearCache('blockadvertising.tpl');
         if (!$errors) {
             Tools::redirectAdmin(AdminController::$currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&conf=6');
         }
         echo $this->displayError($errors);
     }
 }
开发者ID:carloslastresDev,项目名称:HealthyTaiwan_UsingPrestaShop,代码行数:46,代码来源:blockadvertising.php

示例2: deleteFromContext

 public static function deleteFromContext($key)
 {
     ConfigurationKPI::setKpiDefinition();
     $r = parent::deleteFromContext($key);
     ConfigurationKPI::unsetKpiDefinition();
     return $r;
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:7,代码来源:ConfigurationKPI.php

示例3: processUpdateOptions

 /**
  * Update options and preferences
  */
 protected function processUpdateOptions()
 {
     $this->beforeUpdateOptions();
     $languages = Language::getLanguages(false);
     $hide_multishop_checkbox = Shop::getTotalShops(false, null) < 2 ? true : false;
     foreach ($this->fields_options as $category_data) {
         if (!isset($category_data['fields'])) {
             continue;
         }
         $fields = $category_data['fields'];
         foreach ($fields as $field => $values) {
             if (isset($values['type']) && $values['type'] == 'selectLang') {
                 foreach ($languages as $lang) {
                     if (Tools::getValue($field . '_' . strtoupper($lang['iso_code']))) {
                         $fields[$field . '_' . strtoupper($lang['iso_code'])] = array('type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $values['list']);
                     }
                 }
             }
         }
         // Validate fields
         foreach ($fields as $field => $values) {
             // We don't validate fields with no visibility
             if (!$hide_multishop_checkbox && Shop::isFeatureActive() && isset($values['visibility']) && $values['visibility'] > Shop::getContext()) {
                 continue;
             }
             // Check if field is required
             if (!Shop::isFeatureActive() && isset($values['required']) && $values['required'] || Shop::isFeatureActive() && isset($_POST['multishopOverrideOption'][$field]) && isset($values['required']) && $values['required']) {
                 if (isset($values['type']) && $values['type'] == 'textLang') {
                     foreach ($languages as $language) {
                         if (($value = Tools::getValue($field . '_' . $language['id_lang'])) == false && (string) $value != '0') {
                             $this->errors[] = sprintf(Tools::displayError('field %s is required.'), $values['title']);
                         }
                     }
                 } elseif (($value = Tools::getValue($field)) == false && (string) $value != '0') {
                     $this->errors[] = sprintf(Tools::displayError('field %s is required.'), $values['title']);
                 }
             }
             // Check field validator
             if (isset($values['type']) && $values['type'] == 'textLang') {
                 foreach ($languages as $language) {
                     if (Tools::getValue($field . '_' . $language['id_lang']) && isset($values['validation'])) {
                         if (!Validate::$values['validation'](Tools::getValue($field . '_' . $language['id_lang']))) {
                             $this->errors[] = sprintf(Tools::displayError('field %s is invalid.'), $values['title']);
                         }
                     }
                 }
             } elseif (Tools::getValue($field) && isset($values['validation'])) {
                 if (!Validate::$values['validation'](Tools::getValue($field))) {
                     $this->errors[] = sprintf(Tools::displayError('field %s is invalid.'), $values['title']);
                 }
             }
             // Set default value
             if (Tools::getValue($field) === false && isset($values['default'])) {
                 $_POST[$field] = $values['default'];
             }
         }
         if (!count($this->errors)) {
             foreach ($fields as $key => $options) {
                 if (Shop::isFeatureActive() && isset($options['visibility']) && $options['visibility'] > Shop::getContext()) {
                     continue;
                 }
                 if (!$hide_multishop_checkbox && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && empty($options['no_multishop_checkbox']) && empty($_POST['multishopOverrideOption'][$key])) {
                     Configuration::deleteFromContext($key);
                     continue;
                 }
                 // check if a method updateOptionFieldName is available
                 $method_name = 'updateOption' . Tools::toCamelCase($key, true);
                 if (method_exists($this, $method_name)) {
                     $this->{$method_name}(Tools::getValue($key));
                 } elseif (isset($options['type']) && in_array($options['type'], array('textLang', 'textareaLang'))) {
                     $list = array();
                     foreach ($languages as $language) {
                         $key_lang = Tools::getValue($key . '_' . $language['id_lang']);
                         $val = isset($options['cast']) ? $options['cast']($key_lang) : $key_lang;
                         if ($this->validateField($val, $options)) {
                             if (Validate::isCleanHtml($val)) {
                                 $list[$language['id_lang']] = $val;
                             } else {
                                 $this->errors[] = Tools::displayError('Can not add configuration ' . $key . ' for lang ' . Language::getIsoById((int) $language['id_lang']));
                             }
                         }
                     }
                     Configuration::updateValue($key, $list);
                 } else {
                     $val = isset($options['cast']) ? $options['cast'](Tools::getValue($key)) : Tools::getValue($key);
                     if ($this->validateField($val, $options)) {
                         if (Validate::isCleanHtml($val)) {
                             Configuration::updateValue($key, $val);
                         } else {
                             $this->errors[] = Tools::displayError('Can not add configuration ' . $key);
                         }
                     }
                 }
             }
         }
     }
     $this->display = 'list';
//.........这里部分代码省略.........
开发者ID:ramzzes52,项目名称:Uni3,代码行数:101,代码来源:AdminController.php

示例4: updateOptions

 /**
  * Update options and preferences
  *
  * @param string $token
  */
 protected function updateOptions($token)
 {
     if ($this->tabAccess['edit'] === '1') {
         $this->beforeUpdateOptions();
         $language_ids = Language::getIDs(false);
         foreach ($this->optionsList as $category => $categoryData) {
             $fields = $categoryData['fields'];
             /* Check required fields */
             foreach ($fields as $field => $values) {
                 if (isset($values['required']) && $values['required'] && !empty($_POST['multishopOverrideOption'][$field])) {
                     if (isset($values['type']) && $values['type'] == 'textLang') {
                         foreach ($language_ids as $id_lang) {
                             if (($value = Tools::getValue($field . '_' . $id_lang)) == false && (string) $value != '0') {
                                 $this->_errors[] = sprintf(Tools::displayError('field %s is required.'), $values['title']);
                             }
                         }
                     } elseif (($value = Tools::getValue($field)) == false && (string) $value != '0') {
                         $this->_errors[] = sprintf(Tools::displayError('field %s is required.'), $values['title']);
                     }
                 }
             }
             /* Check fields validity */
             foreach ($fields as $field => $values) {
                 if (isset($values['type']) && $values['type'] == 'textLang') {
                     foreach ($language_ids as $id_lang) {
                         if (Tools::getValue($field . '_' . $id_lang) && isset($values['validation'])) {
                             $values_validation = $values['validation'];
                             if (!Validate::$values_validation(Tools::getValue($field . '_' . $id_lang))) {
                                 $this->_errors[] = sprintf(Tools::displayError('field %s is invalid.'), $values['title']);
                             }
                         }
                     }
                 } elseif (Tools::getValue($field) && isset($values['validation'])) {
                     $values_validation = $values['validation'];
                     if (!Validate::$values_validation(Tools::getValue($field))) {
                         $this->_errors[] = sprintf(Tools::displayError('field %s is invalid.'), $values['title']);
                     }
                 }
             }
             /* Default value if null */
             foreach ($fields as $field => $values) {
                 if (!Tools::getValue($field) && isset($values['default'])) {
                     $_POST[$field] = $values['default'];
                 }
             }
             if (!count($this->_errors)) {
                 foreach ($fields as $key => $options) {
                     if (isset($options['visibility']) && $options['visibility'] > Shop::getContext()) {
                         continue;
                     }
                     if (Shop::isFeatureActive() && empty($_POST['multishopOverrideOption'][$key])) {
                         Configuration::deleteFromContext($key);
                         continue;
                     }
                     // check if a method updateOptionFieldName is available
                     $method_name = 'updateOption' . Tools::toCamelCase($key, true);
                     if (method_exists($this, $method_name)) {
                         $this->{$method_name}(Tools::getValue($key));
                     } elseif (isset($options['type']) && in_array($options['type'], array('textLang', 'textareaLang'))) {
                         $list = array();
                         foreach ($language_ids as $id_lang) {
                             $val = isset($options['cast']) ? $options['cast'](Tools::getValue($key . '_' . $id_lang)) : Tools::getValue($key . '_' . $id_lang);
                             if ($this->validateField($val, $options)) {
                                 if (Validate::isCleanHtml($val)) {
                                     $list[$id_lang] = $val;
                                 } else {
                                     $this->_errors[] = Tools::displayError('Can not add configuration ' . $key . ' for lang ' . Language::getIsoById((int) $id_lang));
                                 }
                             }
                         }
                         Configuration::updateValue($key, $list);
                     } else {
                         $val = isset($options['cast']) ? $options['cast'](Tools::getValue($key)) : Tools::getValue($key);
                         if ($this->validateField($val, $options)) {
                             if (Validate::isCleanHtml($val)) {
                                 Configuration::updateValue($key, $val);
                             } else {
                                 $this->_errors[] = Tools::displayError('Can not add configuration ' . $key);
                             }
                         }
                     }
                 }
             }
         }
         if (count($this->_errors) <= 0) {
             Tools::redirectAdmin(self::$currentIndex . '&conf=6&token=' . $token);
         }
     } else {
         $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
     }
 }
开发者ID:abdoumej,项目名称:libsamy,代码行数:96,代码来源:AdminTab.php

示例5: apiKeyPostProcessConfiguration

 /**
  *This method is called when the user sets the API key and hits the submit button.
  *It adds the necessary configurations for SendinBlue in PrestaShop which allows
  *PrestaShop to use the SendinBlue settings.
  */
 public function apiKeyPostProcessConfiguration()
 {
     // endif User put new key after having old key
     $this->postValidation();
     if (!count($this->post_errors)) {
         //If the API key is valid, we activate the module, otherwise we deactivate it.
         $status = trim(Tools::getValue('status'));
         if (isset($status)) {
             Configuration::updateValue('Sendin_Api_Key_Status', $status, '', $this->id_shop_group, $this->id_shop);
         }
         if ($status == 1) {
             $apikey = trim(Tools::getValue('apikey'));
             $res = $this->getResultListValue($apikey);
             $row_list = Tools::jsonDecode($res);
             if (!empty($row_list->errorMsg) && $row_list->errorMsg == 'Key Not Found In Database') {
                 //We reset all settings  in case the API key is invalid.
                 Configuration::updateValue('Sendin_Api_Key_Status', 0, '', $this->id_shop_group, $this->id_shop);
                 $this->resetDataBaseValue();
                 $this->resetConfigSendinSmtp($this->id_shop_group, $this->id_shop);
                 $this->redirectPage($this->l('API key is invalid.'), 'ERROR');
             } else {
                 //If a user enters a new API key, we remove all records that belongs to the
                 //old API key.
                 $old_api_key = trim(Configuration::get('Sendin_Api_Key', '', $this->id_shop_group, $this->id_shop));
                 // Old key
                 if ($apikey != $old_api_key) {
                     // Reset data for old key
                     $id_shop_group = !empty($this->id_shop_group) ? $this->id_shop_group : 'NULL';
                     $id_shop = !empty($this->id_shop) ? $this->id_shop : 'NULL';
                     if ($id_shop_group === 'NULL' && $id_shop === 'NULL') {
                         Configuration::deleteByName('Sendin_First_Request');
                         Configuration::deleteByName('Sendin_Subscribe_Setting');
                         Configuration::deleteByName('Sendin_Tracking_Status');
                         Configuration::deleteByName('Sendin_Smtp_Result');
                         Configuration::deleteByName('Sendin_Api_Key');
                         Configuration::deleteByName('Sendin_Api_Key_Status');
                         Configuration::deleteByName('Sendin_Api_Smtp_Status');
                         Configuration::deleteByName('Sendin_Selected_List_Data');
                     } else {
                         Configuration::deleteFromContext('Sendin_First_Request');
                         Configuration::deleteFromContext('Sendin_Subscribe_Setting');
                         Configuration::deleteFromContext('Sendin_Tracking_Status');
                         Configuration::deleteFromContext('Sendin_Smtp_Result');
                         Configuration::deleteFromContext('Sendin_Api_Key');
                         Configuration::deleteFromContext('Sendin_Api_Key_Status');
                         Configuration::deleteFromContext('Sendin_Api_Smtp_Status');
                         Configuration::deleteFromContext('Sendin_Selected_List_Data');
                     }
                 }
                 if (isset($apikey)) {
                     Configuration::updateValue('Sendin_Api_Key', $apikey, '', $this->id_shop_group, $this->id_shop);
                 }
                 if (isset($status)) {
                     Configuration::updateValue('Sendin_Api_Key_Status', $status, '', $this->id_shop_group, $this->id_shop);
                 }
                 $sendin_listdata = Configuration::get('Sendin_Selected_List_Data', '', $this->id_shop_group, $this->id_shop);
                 $sendin_firstrequest = Configuration::get('Sendin_First_Request', '', $this->id_shop_group, $this->id_shop);
                 if (empty($sendin_listdata) && empty($sendin_firstrequest)) {
                     $this->getOldNewsletterEmails();
                     Configuration::updateValue('Sendin_First_Request', 1, '', $this->id_shop_group, $this->id_shop);
                     Configuration::updateValue('Sendin_Subscribe_Setting', 1, '', $this->id_shop_group, $this->id_shop);
                     Configuration::updateValue('Sendin_Notify_Cron_Executed', 0, '', $this->id_shop_group, $this->id_shop);
                     //We remove the default newsletter block since we
                     //have to add the Sendin newsletter block.
                     $this->restoreBlocknewsletterBlock();
                     if (empty($old_api_key)) {
                         $this->enableSendinblueBlock();
                     }
                     $this->createFolderName();
                 }
                 //We set the default status of SendinBlue SMTP and tracking code to 0
                 $this->checkSmtpStatus();
                 Configuration::updateValue('SENDINBLUE_CONFIGURATION_OK', true, '', $this->id_shop_group, $this->id_shop);
                 $this->redirectPage($this->l('Successfully updated'), 'SUCCESS');
             }
         }
     } else {
         $err_msg = '';
         foreach ($this->post_errors as $err) {
             $err_msg .= $err;
         }
         $this->redirectPage($this->l($err_msg), 'ERROR');
     }
 }
开发者ID:ac3gam3r,项目名称:Maxokraft,代码行数:89,代码来源:sendinblue.php


注:本文中的Configuration::deleteFromContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。