Qual: Reduce cyclomatic complexity
This commit is contained in:
parent
e20038708c
commit
6cd38ecbb8
@ -62,7 +62,7 @@ class Import
|
|||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter);
|
dol_syslog("Import::load_arrays user=".$user->id." filter=".$filter);
|
||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
$i=0;
|
$i=0;
|
||||||
@ -168,18 +168,19 @@ class Import
|
|||||||
* Build an import example file.
|
* Build an import example file.
|
||||||
* Arrays this->array_export_xxx are already loaded for required datatoexport
|
* Arrays this->array_export_xxx are already loaded for required datatoexport
|
||||||
*
|
*
|
||||||
* @param string $model Name of import engine ('csv', ...)
|
* @param User $user User qui exporte
|
||||||
|
* @param string $model Modele d'export
|
||||||
* @param string $headerlinefields Array of values for first line of example file
|
* @param string $headerlinefields Array of values for first line of example file
|
||||||
* @param string $contentlinevalues Array of values for content line of example file
|
* @param string $contentlinevalues Array of values for content line of example file
|
||||||
* @return string <0 if KO, >0 if OK
|
* @return string <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function build_example_file($model, $headerlinefields, $contentlinevalues)
|
function build_example_file($user, $model, $headerlinefields, $contentlinevalues)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
$indice=0;
|
$indice=0;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::build_example_file ".$model);
|
dol_syslog("Import::build_example_file ".$model);
|
||||||
|
|
||||||
// Creation de la classe d'import du model Import_XXX
|
// Creation de la classe d'import du model Import_XXX
|
||||||
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/import/";
|
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/import/";
|
||||||
@ -230,7 +231,7 @@ class Import
|
|||||||
$sql.= ')';
|
$sql.= ')';
|
||||||
$sql.= " VALUES (".($user->id > 0 ? $user->id : 0).", '".$this->db->escape($this->model_name)."', '".$this->datatoimport."', '".$this->hexa."')";
|
$sql.= " VALUES (".($user->id > 0 ? $user->id : 0).", '".$this->db->escape($this->model_name)."', '".$this->datatoimport."', '".$this->hexa."')";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
|
dol_syslog("Import::create sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -241,7 +242,7 @@ class Import
|
|||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
$this->errno=$this->db->lasterrno();
|
$this->errno=$this->db->lasterrno();
|
||||||
dol_syslog(get_class($this)."::create error ".$this->error, LOG_ERR);
|
dol_syslog("Import::create error ".$this->error, LOG_ERR);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -259,7 +260,7 @@ class Import
|
|||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'import_model as em';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'import_model as em';
|
||||||
$sql.= ' WHERE em.rowid = '.$id;
|
$sql.= ' WHERE em.rowid = '.$id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
dol_syslog("Import::fetch sql=".$sql, LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -86,6 +86,6 @@ foreach($fieldstarget as $code=>$label)
|
|||||||
//var_dump($headerlinefields);
|
//var_dump($headerlinefields);
|
||||||
//var_dump($contentlinevalues);
|
//var_dump($contentlinevalues);
|
||||||
|
|
||||||
print $objimport->build_example_file($format,$headerlinefields,$contentlinevalues);
|
print $objimport->build_example_file($user,$format,$headerlinefields,$contentlinevalues);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -86,7 +86,11 @@ if ($action == 'add')
|
|||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
|
||||||
$sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
|
$sql .= " VALUES ('".$db->idate($now)."',".$socid.",".$contactid.",".$actionid.")";
|
||||||
|
|
||||||
if (! $db->query($sql))
|
if ($db->query($sql))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
@ -111,7 +115,7 @@ if ($action == 'add')
|
|||||||
// Remove a notification
|
// Remove a notification
|
||||||
if ($action == 'delete')
|
if ($action == 'delete')
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"];
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"].";";
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user