Jump to content

Fixing $_POST


Open Presta

Recommended Posts

	public function copyFromPost()
	{
		$languages = Language::getLanguages(false);
		$arrayTypelayer = array();
		foreach ($_POST AS $key => $value)
		{
			if (key_exists($key, $this) AND $key != 'id_'.$this->table)
			{
				if($key == 'content')
				{
					.... 



$_POST should be replaced with Tools::getValue() 

 

but getvalue need to have a parameter 

 

 

Link to comment
Share on other sites

You should respond to them stating you are doing exactly what Prestashop does in their AdminController.  In this case, Tools::getValue is not applicable and could not be used

    protected function copyFromPost(&$object, $table)
    {
        /* Classical fields */
        foreach ($_POST as $key => $value)
            if (key_exists($key, $object) && $key != 'id_'.$table)
            {
                /* Do not take care of password field if empty */
                if ($key == 'passwd' && Tools::getValue('id_'.$table) && empty($value))
                    continue;
                /* Automatically encrypt password in MD5 */
                if ($key == 'passwd' && !empty($value))
                    $value = Tools::encrypt($value);
                $object->{$key} = $value;
            }

        /* Multilingual fields */
        $rules = call_user_func(array(get_class($object), 'getValidationRules'), get_class($object));
        if (count($rules['validateLang']))
        {
            $languages = Language::getLanguages(false);
            foreach ($languages as $language)
                foreach (array_keys($rules['validateLang']) as $field)
                    if (isset($_POST[$field.'_'.(int)$language['id_lang']]))
                        $object->{$field}[(int)$language['id_lang']] = $_POST[$field.'_'.(int)$language['id_lang']];
        }
    }

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...