Fix: bad error management
This commit is contained in:
parent
0df44a7787
commit
dc3fd00557
@ -39,6 +39,10 @@ class ActionsContactCardCommon
|
|||||||
var $object;
|
var $object;
|
||||||
//! Canvas
|
//! Canvas
|
||||||
var $canvas;
|
var $canvas;
|
||||||
|
//! Error string
|
||||||
|
var $error;
|
||||||
|
//! Error array
|
||||||
|
var $errors=array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur de la classe
|
* Constructeur de la classe
|
||||||
@ -269,8 +273,6 @@ class ActionsContactCardCommon
|
|||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
$errors='';
|
|
||||||
|
|
||||||
// Creation utilisateur depuis contact
|
// Creation utilisateur depuis contact
|
||||||
if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes' && $user->rights->user->user->creer)
|
if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes' && $user->rights->user->user->creer)
|
||||||
{
|
{
|
||||||
@ -285,15 +287,13 @@ class ActionsContactCardCommon
|
|||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$errors=$nuser->error;
|
$this->errors=$nuser->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$errors=$this->object->error;
|
$this->errors=$this->object->errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creation contact
|
// Creation contact
|
||||||
@ -303,7 +303,7 @@ class ActionsContactCardCommon
|
|||||||
|
|
||||||
if (! $_POST["name"])
|
if (! $_POST["name"])
|
||||||
{
|
{
|
||||||
array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
array_push($this->errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
|
||||||
$_GET["action"] = $_POST["action"] = 'create';
|
$_GET["action"] = $_POST["action"] = 'create';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,12 +317,10 @@ class ActionsContactCardCommon
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$errors=array($this->object->error);
|
$this->errors=$this->object->errors;
|
||||||
$_GET["action"] = $_POST["action"] = 'create';
|
$_GET["action"] = $_POST["action"] = 'create';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->contact->supprimer)
|
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->contact->supprimer)
|
||||||
@ -340,22 +338,19 @@ class ActionsContactCardCommon
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$errors=$this->object->error;
|
$this->errors=$this->object->errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
|
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
|
||||||
{
|
{
|
||||||
if (empty($_POST["name"]))
|
if (empty($_POST["name"]))
|
||||||
{
|
{
|
||||||
$errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
|
$this->error=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
|
||||||
$error++;
|
|
||||||
$_GET["action"] = $_POST["action"] = 'edit';
|
$_GET["action"] = $_POST["action"] = 'edit';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($errors))
|
if (empty($this->error))
|
||||||
{
|
{
|
||||||
$this->object->fetch($_POST["contactid"]);
|
$this->object->fetch($_POST["contactid"]);
|
||||||
|
|
||||||
@ -372,11 +367,9 @@ class ActionsContactCardCommon
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$errors=$this->object->error;
|
$this->errors=$this->object->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,7 @@ if (! empty($canvas))
|
|||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
|
|
||||||
// Load data control
|
// Load data control
|
||||||
$msg = $objcanvas->doActions($id);
|
$objcanvas->doActions($id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -261,63 +261,60 @@ if (! empty($canvas))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->rights->societe->contact->creer)
|
if (GETPOST("action") == 'create')
|
||||||
{
|
{
|
||||||
if (GETPOST("action") == 'create')
|
// Set action type
|
||||||
|
$objcanvas->setAction(GETPOST("action"));
|
||||||
|
|
||||||
|
// Card header
|
||||||
|
$title = $objcanvas->getTitle();
|
||||||
|
print_fiche_titre($title);
|
||||||
|
|
||||||
|
// Assign _POST data
|
||||||
|
$objcanvas->assign_post();
|
||||||
|
|
||||||
|
// Assign template values
|
||||||
|
$objcanvas->assign_values();
|
||||||
|
|
||||||
|
// Show errors
|
||||||
|
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
||||||
|
|
||||||
|
// Display canvas
|
||||||
|
$objcanvas->display_canvas();
|
||||||
|
}
|
||||||
|
else if (GETPOST("id") && GETPOST("action") == 'edit')
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Mode edition
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Set action type
|
||||||
|
$objcanvas->setAction(GETPOST("action"));
|
||||||
|
|
||||||
|
// Fetch object
|
||||||
|
$result=$objcanvas->fetch($id);
|
||||||
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// Set action type
|
|
||||||
$objcanvas->setAction(GETPOST("action"));
|
|
||||||
|
|
||||||
// Card header
|
// Card header
|
||||||
|
$head = contact_prepare_head($objcanvas->control->object);
|
||||||
$title = $objcanvas->getTitle();
|
$title = $objcanvas->getTitle();
|
||||||
print_fiche_titre($title);
|
dol_fiche_head($head, 'general', $title, 0, 'contact');
|
||||||
|
|
||||||
// Assign _POST data
|
if ($_POST["name"])
|
||||||
$objcanvas->assign_post();
|
{
|
||||||
|
// Assign _POST data
|
||||||
|
$objcanvas->assign_post();
|
||||||
|
}
|
||||||
|
|
||||||
// Assign template values
|
// Assign values
|
||||||
$objcanvas->assign_values();
|
$objcanvas->assign_values();
|
||||||
|
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
|
||||||
|
|
||||||
// Display canvas
|
// Display canvas
|
||||||
$objcanvas->display_canvas();
|
$objcanvas->display_canvas();
|
||||||
}
|
}
|
||||||
else if (GETPOST("id") && GETPOST("action") == 'edit')
|
else
|
||||||
{
|
{
|
||||||
/*
|
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
||||||
* Mode edition
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Set action type
|
|
||||||
$objcanvas->setAction(GETPOST("action"));
|
|
||||||
|
|
||||||
// Fetch object
|
|
||||||
$result=$objcanvas->fetch($id);
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
// Card header
|
|
||||||
$head = contact_prepare_head($objcanvas->control->object);
|
|
||||||
$title = $objcanvas->getTitle();
|
|
||||||
dol_fiche_head($head, 'general', $title, 0, 'contact');
|
|
||||||
|
|
||||||
if ($_POST["name"])
|
|
||||||
{
|
|
||||||
// Assign _POST data
|
|
||||||
$objcanvas->assign_post();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign values
|
|
||||||
$objcanvas->assign_values();
|
|
||||||
|
|
||||||
// Display canvas
|
|
||||||
$objcanvas->display_canvas();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,8 @@
|
|||||||
class Canvas
|
class Canvas
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
var $error;
|
||||||
|
var $errors;
|
||||||
|
|
||||||
var $card;
|
var $card;
|
||||||
var $canvas;
|
var $canvas;
|
||||||
@ -45,7 +47,6 @@ class Canvas
|
|||||||
var $action;
|
var $action;
|
||||||
var $smarty;
|
var $smarty;
|
||||||
|
|
||||||
var $error;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -86,7 +87,12 @@ class Canvas
|
|||||||
*/
|
*/
|
||||||
function doActions($id)
|
function doActions($id)
|
||||||
{
|
{
|
||||||
return $this->control->doActions($id);
|
$out = $this->control->doActions($id);
|
||||||
|
|
||||||
|
$this->errors = ($this->control->errors?$this->control->errors:$this->control->object->errors);
|
||||||
|
$this->error = ($this->control->error?$this->control->error:$this->control->object->error);
|
||||||
|
|
||||||
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -39,6 +39,10 @@ class ActionsCardCommon
|
|||||||
var $object;
|
var $object;
|
||||||
//! Canvas
|
//! Canvas
|
||||||
var $canvas;
|
var $canvas;
|
||||||
|
//! Error string
|
||||||
|
var $error;
|
||||||
|
//! Error array
|
||||||
|
var $errors=array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur de la classe
|
* Constructeur de la classe
|
||||||
@ -477,21 +481,21 @@ class ActionsCardCommon
|
|||||||
{
|
{
|
||||||
$error = 1;
|
$error = 1;
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->object->error = $langs->trans("ErrorBadEMail",$this->object->email);
|
$this->error = $langs->trans("ErrorBadEMail",$this->object->email);
|
||||||
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
|
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
|
||||||
}
|
}
|
||||||
if (! empty($this->object->url) && ! isValidUrl($this->object->url))
|
if (! empty($this->object->url) && ! isValidUrl($this->object->url))
|
||||||
{
|
{
|
||||||
$error = 1;
|
$error = 1;
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->object->error = $langs->trans("ErrorBadUrl",$this->object->url);
|
$this->error = $langs->trans("ErrorBadUrl",$this->object->url);
|
||||||
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
|
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
|
||||||
}
|
}
|
||||||
if ($this->object->fournisseur && ! $conf->fournisseur->enabled)
|
if ($this->object->fournisseur && ! $conf->fournisseur->enabled)
|
||||||
{
|
{
|
||||||
$error = 1;
|
$error = 1;
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->object->error = $langs->trans("ErrorSupplierModuleNotEnabled");
|
$this->error = $langs->trans("ErrorSupplierModuleNotEnabled");
|
||||||
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
|
$_GET["action"] = $_POST["action"]=='add'?'create':'edit';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -530,7 +534,7 @@ class ActionsCardCommon
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg=$this->object->error;
|
$this->errors=$this->object->errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
@ -561,8 +565,7 @@ class ActionsCardCommon
|
|||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
|
|
||||||
$langs->load("errors");
|
$this->errors=$this->object->errors;
|
||||||
$mesg=$langs->trans($this->object->error);
|
|
||||||
$_GET["action"]='create';
|
$_GET["action"]='create';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,8 +597,7 @@ class ActionsCardCommon
|
|||||||
{
|
{
|
||||||
$this->object->id = $socid;
|
$this->object->id = $socid;
|
||||||
$reload = 0;
|
$reload = 0;
|
||||||
|
$this->errors = $this->object->errors;
|
||||||
$mesg = $this->object->error;
|
|
||||||
$_GET["action"]= "edit";
|
$_GET["action"]= "edit";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -616,8 +618,7 @@ class ActionsCardCommon
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$reload = 0;
|
$reload = 0;
|
||||||
$langs->load("errors");
|
$this->errors=$this->object->errors;
|
||||||
$mesg=$langs->trans($this->object->error);
|
|
||||||
$_GET["action"]='';
|
$_GET["action"]='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -629,7 +630,7 @@ class ActionsCardCommon
|
|||||||
{
|
{
|
||||||
if (is_numeric($_REQUEST['model']))
|
if (is_numeric($_REQUEST['model']))
|
||||||
{
|
{
|
||||||
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -409,6 +409,7 @@ if (! empty($canvas))
|
|||||||
// Assign template values
|
// Assign template values
|
||||||
$soccanvas->assign_values();
|
$soccanvas->assign_values();
|
||||||
|
|
||||||
|
// Show errors
|
||||||
dol_htmloutput_errors($soccanvas->error,$soccanvas->errors);
|
dol_htmloutput_errors($soccanvas->error,$soccanvas->errors);
|
||||||
|
|
||||||
// Display canvas
|
// Display canvas
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user