[-] BO: Modified treatment. now the limit of upload can be modified in the "preferences" tab
This commit is contained in:
@@ -33,6 +33,10 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
$this->context = Context::getContext();
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$max_upload = (int)ini_get('upload_max_filesize');
|
||||
$max_post = (int)ini_get('post_max_size');
|
||||
$upload_mb = min($max_upload, $max_post);
|
||||
|
||||
// Prevent classes which extend AdminPreferences to load useless data
|
||||
if (get_class($this) == 'AdminPreferencesController')
|
||||
@@ -156,13 +160,6 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
'default' => '480',
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
),
|
||||
'PS_B2B_ENABLE' => array(
|
||||
'title' => $this->l('Enable B2B mode'),
|
||||
'desc' => $this->l('Activate or deactivate B2B mode. When this option is enable some features about B2B appear.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_ORDER_PROCESS_TYPE' => array(
|
||||
'title' => $this->l('Order process type'),
|
||||
'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'),
|
||||
@@ -319,9 +316,27 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
)
|
||||
),
|
||||
'PS_LIMIT_UPLOAD_FILE_VALUE' => array(
|
||||
'title' => $this->l('Limit upload file value'),
|
||||
'desc' => $this->l('Define the limit upload for a downloadable product, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).',$upload_mb),
|
||||
'validation' => 'isInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
'suffix' => $this->l('Megabits'),
|
||||
'default' => '1'
|
||||
),
|
||||
'PS_LIMIT_UPLOAD_IMAGE_VALUE' => array(
|
||||
'title' => $this->l('Limit upload image value'),
|
||||
'desc' => $this->l('Define the limit upload for an image, this value have to be inferior or egal to your server\'s maximum upload file ').sprintf('(%s MB).',$upload_mb),
|
||||
'validation' => 'isInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
'suffix' => $this->l('Megabits'),
|
||||
'default' => '1'
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
if (function_exists('date_default_timezone_set'))
|
||||
$fields['PS_TIMEZONE'] = array(
|
||||
'title' => $this->l('Time Zone:'),
|
||||
@@ -345,7 +360,8 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
'title' => $this->l('General'),
|
||||
'icon' => 'tab-preferences',
|
||||
'fields' => $fields,
|
||||
'submit' => array('title' => $this->l(' Save '), 'class' => 'button')
|
||||
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -355,6 +371,22 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
$upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize'));
|
||||
$post_max_size = (int)str_replace('M', '', ini_get('post_max_size'));
|
||||
$max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size;
|
||||
|
||||
if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $max_size or Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $max_size)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('The limit choosen is superior to the server\'s maximum upload file You need to improve the limit of your server.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Tools::getIsset('PS_LIMIT_UPLOAD_FILE_VALUE') && !Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE'))
|
||||
$_POST['PS_LIMIT_UPLOAD_FILE_VALUE'] = 1;
|
||||
|
||||
if (Tools::getIsset('PS_LIMIT_UPLOAD_IMAGE_VALUE') && !Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE'))
|
||||
$_POST['PS_LIMIT_UPLOAD_IMAGE_VALUE'] = 1;
|
||||
|
||||
Tools::clearCache($this->context->smarty);
|
||||
parent::postProcess();
|
||||
}
|
||||
@@ -385,37 +417,15 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
/**
|
||||
* Update PS_ATTACHMENT_MAXIMUM_SIZE
|
||||
*/
|
||||
public function updateOptionPsAttachmentMaximumSize($value)
|
||||
public function updateOptionPsAttachementMaximumSize($value)
|
||||
{
|
||||
if (!$value)
|
||||
return;
|
||||
|
||||
$upload_max_size = Tools::convertBytes(ini_get('upload_max_filesize'));
|
||||
$post_max_size = Tools::convertBytes(ini_get('post_max_size'));
|
||||
$max_size = ($upload_max_size < $post_max_size ? $upload_max_size : $post_max_size) / 1048576;
|
||||
// at this point, all values are in megaBytes
|
||||
$upload_max_size = (int)str_replace('M', '', ini_get('upload_max_filesize'));
|
||||
$post_max_size = (int)str_replace('M', '', ini_get('post_max_size'));
|
||||
$max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size;
|
||||
$value = ($max_size < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE')) ? $max_size : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE');
|
||||
Configuration::update('PS_ATTACHMENT_MAXIMUM_SIZE', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update PS_B2B_ENABLE and enables / disables the associated tabs
|
||||
* @param $value integer Value of option
|
||||
*/
|
||||
public function updateOptionPsB2bEnable($value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
|
||||
$tabs_class_name = array('AdminOutstanding');
|
||||
if (!empty($tabs_class_name)) {
|
||||
foreach ($tabs_class_name as $tab_class_name) {
|
||||
$tab = Tab::getInstanceFromClassName($tab_class_name);
|
||||
if (Validate::isLoadedObject($tab)) {
|
||||
$tab->active = $value;
|
||||
$tab->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Configuration::updateValue('PS_B2B_ENABLE', $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
|
||||
class AdminProductsControllerCore extends AdminController
|
||||
{
|
||||
protected $max_file_size = 20000000;
|
||||
protected $max_file_size = NULL;
|
||||
|
||||
/** @var integer Max image size for upload
|
||||
* As of 1.5 it is recommended to not set a limit to max image size
|
||||
**/
|
||||
protected $max_image_size;
|
||||
protected $max_image_size = NULL;
|
||||
|
||||
private $_category;
|
||||
/**
|
||||
@@ -90,7 +90,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->imageType = 'jpg';
|
||||
$this->context = Context::getContext();
|
||||
$this->_defaultOrderBy = 'position';
|
||||
|
||||
$this->max_file_size = (Configuration::get('PS_LIMIT_UPLOAD_IMAGE_VALUE') * 1000000);
|
||||
$this->max_image_size = (Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000);
|
||||
|
||||
$categoriesArray = array();
|
||||
$categories = Category::getSimpleCategories($this->context->language->id);
|
||||
|
||||
|
||||
+1648
-1646
File diff suppressed because it is too large
Load Diff
@@ -2370,6 +2370,11 @@ $_LANGADM['AdminPreferences8004e61ca76ff500d1e6ee92f7cb7f93'] = 'Affiche les not
|
||||
$_LANGADM['AdminPreferencesae1d865ef6ce7ebb9492ea7a7f1bc8a5'] = 'Afficher les notifications lorsque de nouveaux clients s\'inscriront sur votre boutique';
|
||||
$_LANGADM['AdminPreferences4e7ff7ca556a7ac8329ab27834e9631b'] = 'Affiche les notifications pour les nouveaux messages';
|
||||
$_LANGADM['AdminPreferences051fd283c29527d33402475333dfb1da'] = 'Afficher les notifications lorsque de nouveaux clients vous enverront de nouveaux messages sur votre boutique';
|
||||
$_LANGADM['AdminPreferences1301a51cbee38f0c34369720070e5e1b'] = 'Limite de téléchargement de fichier';
|
||||
$_LANGADM['AdminPreferences656ff9c98ad48192724f8a74f5e18733'] = 'Définit la limite de téléchargement pour un produit. Cette valeur doit être inférieure ou égale à celle de votre serveur';
|
||||
$_LANGADM['AdminPreferences77dcf778f486e4dcbe5b400bd08ac3a6'] = 'mégaoctets';
|
||||
$_LANGADM['AdminPreferences5870c50004d9568f8de39d09363533a7'] = 'Limite de téléchargement d\'images';
|
||||
$_LANGADM['AdminPreferences8cde7b1fa570f328143c41677032b507'] = 'Définit la limite de téléchargement pour une image. Cette valeur doit être inférieure ou égale à celle de votre serveur';
|
||||
$_LANGADM['AdminPreferencesd5bc5fd307b108537039b6b6f98889d5'] = 'Fuseau horaire :';
|
||||
$_LANGADM['AdminPreferencesbbd6622dbbdf4bcb166f5e3f018a2351'] = 'Cliquez ici pour utiliser le protocole HTTPS avant d\'activer le mode SSL.';
|
||||
$_LANGADM['AdminPreferences0db377921f4ce762c62526131097968f'] = 'Général';
|
||||
|
||||
@@ -140,8 +140,6 @@ $_ERRORS['b9c1228a8e8c3412befae5d854508114'] = 'Une commande a déjà été pass
|
||||
$_ERRORS['1d744a9ad1dac20645cfc4a36b77323b'] = 'image(s)';
|
||||
$_ERRORS['b08d3867be98e6fff3233cd40ab8134a'] = 'La création de la commande a échoué';
|
||||
$_ERRORS['a0db299e2909bf7fc86ed75bf66f9079'] = 'Le panier ne peut pas être chargé ou une commande a déjà été placé en utilisant ce panier';
|
||||
$_ERRORS['aba7bdb49b66dd8485c2586a2c88c84e'] = 'Le fichier';
|
||||
$_ERRORS['2dd3ed3563a4e175ad6f9c20ca5173af'] = 'est déprécié(e) et sera supprimé(e) lors de notre prochaine version majeure';
|
||||
$_ERRORS['f996dce5bdfb1b1094e41cf996c5fdae'] = 'merci de spécifier l\'URL du module';
|
||||
$_ERRORS['a478ec266116342449ae1705c79d5cc2'] = 'type d\'archive inconnu';
|
||||
$_ERRORS['f9c7939a8397ee022fefee2bdb3407af'] = 'URL invalide';
|
||||
@@ -463,6 +461,7 @@ $_ERRORS['aadb27e7677e4c4c85e4aa747ef7626e'] = 'Pour utiliser Xcache, vous devez
|
||||
$_ERRORS['3d064d5efb6cf2ed52cf72bfef7c7db2'] = 'Pour utiliser CacheFS, le dossier';
|
||||
$_ERRORS['a9b036d3e91d53892d6a67c31327e456'] = 'doit avoir les droits d\'écriture';
|
||||
$_ERRORS['8e4b5b9003a1e89146ecd623f76f4179'] = 'Merci de définir une profondeur répertoire ';
|
||||
$_ERRORS['77cdfaefb21a2a1187a097ade3ab89c8'] = 'La limite choisie est superieure à celle du serveur. Vous devez augmenter la limite d\\\'envoi de votre serveur';
|
||||
$_ERRORS['db7a282fcab155c89c9324ff799d8140'] = 'Assignez une page cms de conditions générales de vente si vous voulez qu\'elle soit lue';
|
||||
$_ERRORS['bfd99559857dfcfc40cb0d0e6c8aee1b'] = 'Nom invalide';
|
||||
$_ERRORS['931b7343428529d2673554b2cfb06211'] = 'Nom trop long';
|
||||
@@ -579,6 +578,7 @@ $_ERRORS['8227e4867a9388488b04ea32665bcc18'] = 'Le répertoire du module doit av
|
||||
$_ERRORS['3b3a2ea2a2b4d1120caf9e7ad8c04fb4'] = 'Vous n\'avez pas les permissions requises pour ajouter des entrepôts/';
|
||||
$_ERRORS['59e3d45dc17f2e9fc4caac2f887bd075'] = 'La fonction';
|
||||
$_ERRORS['4803e6b9e63dabf04de980788d6a13c4'] = 'ligne';
|
||||
$_ERRORS['2dd3ed3563a4e175ad6f9c20ca5173af'] = 'est déprécié(e) et sera supprimé(e) lors de notre prochaine version majeure';
|
||||
$_ERRORS['2031a6bfe5f5bed90694c02868ebf2ed'] = 'Le paramètre';
|
||||
$_ERRORS['4a86eb1f2e0779658266fd6a8582dc9a'] = 'dans la fonction';
|
||||
$_ERRORS['350bf1d858bae55fa9c344b39ea9afcd'] = 'Le produit ne peut pas être chargé';
|
||||
|
||||
Reference in New Issue
Block a user