[-] MO : #PSFV-640 - Fix bug with image upload
This commit is contained in:
1 parent
4c9438f405
commit
3c6ca0b5a1
1 file changed
+15
-15
@@ -193,7 +193,7 @@ class HomeSlider extends Module
|
|||||||
$this->_postProcess();
|
$this->_postProcess();
|
||||||
$this->_displayForm();
|
$this->_displayForm();
|
||||||
}
|
}
|
||||||
else if (Tools::isSubmit('addSlide') || (Tools::isSubmit('id_slide') && $this->slideExists((int)Tools::getValue('id_slide'))))
|
elseif (Tools::isSubmit('addSlide') || (Tools::isSubmit('id_slide') && $this->slideExists((int)Tools::getValue('id_slide'))))
|
||||||
$this->_displayAddForm();
|
$this->_displayAddForm();
|
||||||
else
|
else
|
||||||
$this->_displayForm();
|
$this->_displayForm();
|
||||||
@@ -331,7 +331,7 @@ class HomeSlider extends Module
|
|||||||
$this->_html .= '<fieldset class="width3">';
|
$this->_html .= '<fieldset class="width3">';
|
||||||
if (Tools::isSubmit('addSlide')) /* Configure legend */
|
if (Tools::isSubmit('addSlide')) /* Configure legend */
|
||||||
$this->_html .= '<legend><img src="'._PS_ADMIN_IMG_.'add.gif" alt="" /> 2 - '.$this->l('Configure your slide').'</legend>';
|
$this->_html .= '<legend><img src="'._PS_ADMIN_IMG_.'add.gif" alt="" /> 2 - '.$this->l('Configure your slide').'</legend>';
|
||||||
else if (Tools::isSubmit('id_slide')) /* Edit legend */
|
elseif (Tools::isSubmit('id_slide')) /* Edit legend */
|
||||||
$this->_html .= '<legend><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/logo.gif" alt="" /> 2 - '.$this->l('Edit your slide').'</legend>';
|
$this->_html .= '<legend><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/logo.gif" alt="" /> 2 - '.$this->l('Edit your slide').'</legend>';
|
||||||
/* Sets id slide as hidden */
|
/* Sets id slide as hidden */
|
||||||
if ($slide && Tools::getValue('id_slide'))
|
if ($slide && Tools::getValue('id_slide'))
|
||||||
@@ -427,13 +427,13 @@ class HomeSlider extends Module
|
|||||||
!Validate::isInt(Tools::getValue('HOMESLIDER_WIDTH')) || !Validate::isInt(Tools::getValue('HOMESLIDER_HEIGHT')))
|
!Validate::isInt(Tools::getValue('HOMESLIDER_WIDTH')) || !Validate::isInt(Tools::getValue('HOMESLIDER_HEIGHT')))
|
||||||
$errors[] = $this->l('Invalid values');
|
$errors[] = $this->l('Invalid values');
|
||||||
} /* Validation for status */
|
} /* Validation for status */
|
||||||
else if (Tools::isSubmit('changeStatus'))
|
elseif (Tools::isSubmit('changeStatus'))
|
||||||
{
|
{
|
||||||
if (!Validate::isInt(Tools::getValue('id_slide')))
|
if (!Validate::isInt(Tools::getValue('id_slide')))
|
||||||
$errors[] = $this->l('Invalid slide');
|
$errors[] = $this->l('Invalid slide');
|
||||||
}
|
}
|
||||||
/* Validation for Slide */
|
/* Validation for Slide */
|
||||||
else if (Tools::isSubmit('submitSlide'))
|
elseif (Tools::isSubmit('submitSlide'))
|
||||||
{
|
{
|
||||||
/* Checks state (active) */
|
/* Checks state (active) */
|
||||||
if (!Validate::isInt(Tools::getValue('active_slide')) || (Tools::getValue('active_slide') != 0 && Tools::getValue('active_slide') != 1))
|
if (!Validate::isInt(Tools::getValue('active_slide')) || (Tools::getValue('active_slide') != 0 && Tools::getValue('active_slide') != 1))
|
||||||
@@ -480,7 +480,7 @@ class HomeSlider extends Module
|
|||||||
if (Tools::getValue('image_old_'.$defaultLanguage) && !Validate::isFileName(Tools::getValue('image_old_'.$defaultLanguage)))
|
if (Tools::getValue('image_old_'.$defaultLanguage) && !Validate::isFileName(Tools::getValue('image_old_'.$defaultLanguage)))
|
||||||
$errors[] = $this->l('Image is not set');
|
$errors[] = $this->l('Image is not set');
|
||||||
} /* Validation for deletion */
|
} /* Validation for deletion */
|
||||||
else if (Tools::isSubmit('delete_id_slide') && (!Validate::isInt(Tools::getValue('delete_id_slide')) || !$this->slideExists((int)Tools::getValue('delete_id_slide'))))
|
elseif (Tools::isSubmit('delete_id_slide') && (!Validate::isInt(Tools::getValue('delete_id_slide')) || !$this->slideExists((int)Tools::getValue('delete_id_slide'))))
|
||||||
$errors[] = $this->l('Invalid id_slide');
|
$errors[] = $this->l('Invalid id_slide');
|
||||||
|
|
||||||
/* Display errors if needed */
|
/* Display errors if needed */
|
||||||
@@ -509,7 +509,7 @@ class HomeSlider extends Module
|
|||||||
$errors .= $this->displayError($this->l('Configuration could not be updated'));
|
$errors .= $this->displayError($this->l('Configuration could not be updated'));
|
||||||
$this->_html .= $this->displayConfirmation($this->l('Configuration updated'));
|
$this->_html .= $this->displayConfirmation($this->l('Configuration updated'));
|
||||||
} /* Process Slide status */
|
} /* Process Slide status */
|
||||||
else if (Tools::isSubmit('changeStatus') && Tools::isSubmit('id_slide'))
|
elseif (Tools::isSubmit('changeStatus') && Tools::isSubmit('id_slide'))
|
||||||
{
|
{
|
||||||
$slide = new HomeSlide((int)Tools::getValue('id_slide'));
|
$slide = new HomeSlide((int)Tools::getValue('id_slide'));
|
||||||
if ($slide->active == 0)
|
if ($slide->active == 0)
|
||||||
@@ -520,7 +520,7 @@ class HomeSlider extends Module
|
|||||||
$this->_html .= ($res ? $this->displayConfirmation($this->l('Configuration updated')) : $this->displayError($this->l('Configuration could not be updated')));
|
$this->_html .= ($res ? $this->displayConfirmation($this->l('Configuration updated')) : $this->displayError($this->l('Configuration could not be updated')));
|
||||||
}
|
}
|
||||||
/* Processes Slide */
|
/* Processes Slide */
|
||||||
else if (Tools::isSubmit('submitSlide'))
|
elseif (Tools::isSubmit('submitSlide'))
|
||||||
{
|
{
|
||||||
/* Sets ID if needed */
|
/* Sets ID if needed */
|
||||||
if (Tools::getValue('id_slide'))
|
if (Tools::getValue('id_slide'))
|
||||||
@@ -566,15 +566,15 @@ class HomeSlider extends Module
|
|||||||
$salt = sha1(microtime());
|
$salt = sha1(microtime());
|
||||||
if ($error = ImageManager::validateUpload($_FILES['image_'.$language['id_lang']]))
|
if ($error = ImageManager::validateUpload($_FILES['image_'.$language['id_lang']]))
|
||||||
$errors .= $error;
|
$errors .= $error;
|
||||||
else if (!$temp_name || !move_uploaded_file($_FILES['image_'.$language['id_lang']]['tmp_name'], $temp_name))
|
elseif (!$temp_name || !move_uploaded_file($_FILES['image_'.$language['id_lang']]['tmp_name'], $temp_name))
|
||||||
return false;
|
return false;
|
||||||
else if (!ImageManager::resize($temp_name, dirname(__FILE__).'/images/'.Tools::encrypt($_FILES['image_'.$language['id_lang']]['name'].$salt).$type))
|
elseif (!ImageManager::resize($temp_name, dirname(__FILE__).'/images/'.Tools::encrypt($_FILES['image_'.$language['id_lang']]['name'].$salt).'.'.$type))
|
||||||
$errors .= $this->displayError($this->l('An error occurred during the image upload.'));
|
$errors .= $this->displayError($this->l('An error occurred during the image upload.'));
|
||||||
if (isset($temp_name))
|
if (isset($temp_name))
|
||||||
@unlink($temp_name);
|
@unlink($temp_name);
|
||||||
$slide->image[$language['id_lang']] = pSQL(Tools::encrypt($_FILES['image_'.($language['id_lang'])]['name'].$salt).$type);
|
$slide->image[$language['id_lang']] = pSQL(Tools::encrypt($_FILES['image_'.($language['id_lang'])]['name'].$salt).'.'.$type);
|
||||||
}
|
}
|
||||||
if (Tools::getValue('image_old_'.$language['id_lang']) != '')
|
elseif (Tools::getValue('image_old_'.$language['id_lang']) != '')
|
||||||
$slide->image[$language['id_lang']] = pSQL(Tools::getValue('image_old_'.$language['id_lang']));
|
$slide->image[$language['id_lang']] = pSQL(Tools::getValue('image_old_'.$language['id_lang']));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,11 +587,11 @@ class HomeSlider extends Module
|
|||||||
if (!$slide->add())
|
if (!$slide->add())
|
||||||
$errors .= $this->displayError($this->l('Slide could not be added'));
|
$errors .= $this->displayError($this->l('Slide could not be added'));
|
||||||
} /* Update */
|
} /* Update */
|
||||||
else if (!$slide->update())
|
elseif (!$slide->update())
|
||||||
$errors .= $this->displayError($this->l('Slide could not be updated'));
|
$errors .= $this->displayError($this->l('Slide could not be updated'));
|
||||||
}
|
}
|
||||||
} /* Deletes */
|
} /* Deletes */
|
||||||
else if (Tools::isSubmit('delete_id_slide'))
|
elseif (Tools::isSubmit('delete_id_slide'))
|
||||||
{
|
{
|
||||||
$slide = new HomeSlide((int)Tools::getValue('delete_id_slide'));
|
$slide = new HomeSlide((int)Tools::getValue('delete_id_slide'));
|
||||||
$res = $slide->delete();
|
$res = $slide->delete();
|
||||||
@@ -604,9 +604,9 @@ class HomeSlider extends Module
|
|||||||
/* Display errors if needed */
|
/* Display errors if needed */
|
||||||
if (count($errors))
|
if (count($errors))
|
||||||
$this->_html .= $this->displayError(implode('<br />', $errors));
|
$this->_html .= $this->displayError(implode('<br />', $errors));
|
||||||
else if (Tools::isSubmit('submitSlide') && Tools::getValue('id_slide'))
|
elseif (Tools::isSubmit('submitSlide') && Tools::getValue('id_slide'))
|
||||||
$this->_html .= $this->displayConfirmation($this->l('Slide updated'));
|
$this->_html .= $this->displayConfirmation($this->l('Slide updated'));
|
||||||
else if (Tools::isSubmit('submitSlide'))
|
elseif (Tools::isSubmit('submitSlide'))
|
||||||
$this->_html .= $this->displayConfirmation($this->l('Slide added'));
|
$this->_html .= $this->displayConfirmation($this->l('Slide added'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user