Fix: Error in code generator
This commit is contained in:
parent
5129918adb
commit
26af0cb262
@ -163,7 +163,9 @@ foreach($property as $key => $prop)
|
|||||||
{
|
{
|
||||||
if ($prop['field'] != 'rowid')
|
if ($prop['field'] != 'rowid')
|
||||||
{
|
{
|
||||||
$varprop.="\tvar \$".$prop['field'].";";
|
$varprop.="\tvar \$".$prop['field'];
|
||||||
|
if ($prop['istime']) $varprop.="=''";
|
||||||
|
$varprop.=";";
|
||||||
if ($prop['comment']) $varprop.="\t// ".$prop['extra'];
|
if ($prop['comment']) $varprop.="\t// ".$prop['extra'];
|
||||||
$varprop.="\n";
|
$varprop.="\n";
|
||||||
}
|
}
|
||||||
@ -192,7 +194,11 @@ $i=0;
|
|||||||
foreach($property as $key => $prop)
|
foreach($property as $key => $prop)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
if ($prop['field'] != 'rowid' || $prop['extra'] != 'auto_increment')
|
$addfield=1;
|
||||||
|
if ($prop['field'] == 'tms') $addfield=0; // This is a field of type timestamp edited automatically
|
||||||
|
if ($prop['extra'] == 'auto_increment') $addfield=0;
|
||||||
|
|
||||||
|
if ($addfield)
|
||||||
{
|
{
|
||||||
$varprop.="\t\t\$sql.= \"".$prop['field'];
|
$varprop.="\t\t\$sql.= \"".$prop['field'];
|
||||||
if ($i < sizeof($property)) $varprop.=",";
|
if ($i < sizeof($property)) $varprop.=",";
|
||||||
@ -210,16 +216,29 @@ $i=0;
|
|||||||
foreach($property as $key => $prop)
|
foreach($property as $key => $prop)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
if ($prop['field'] != 'rowid' || $prop['extra'] != 'auto_increment')
|
$addfield=1;
|
||||||
|
if ($prop['field'] == 'tms') $addfield=0; // This is a field of type timestamp edited automatically
|
||||||
|
if ($prop['extra'] == 'auto_increment') $addfield=0;
|
||||||
|
|
||||||
|
if ($addfield)
|
||||||
{
|
{
|
||||||
$varprop.="\t\t\$sql.= \" ";
|
$varprop.="\t\t\$sql.= \" ";
|
||||||
if ($prop['istime']) $varprop.='".$this->db->idate(';
|
if ($prop['istime'])
|
||||||
else $varprop.="'\".";
|
{
|
||||||
$varprop.="\$this->".$prop['field']."";
|
$varprop.='".(! isset($this->'.$prop['field'].') || $this->'.$prop['field'].'==\'\'?\'NULL\':$this->db->idate(';
|
||||||
if ($prop['istime']) $varprop.=')."';
|
$varprop.="\$this->".$prop['field']."";
|
||||||
else $varprop.=".\"'";
|
$varprop.='))."';
|
||||||
if ($i < sizeof($property)) $varprop.=",";
|
if ($i < sizeof($property)) $varprop.=",";
|
||||||
$varprop.="\";";
|
$varprop.="\";";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$varprop.='".(! isset($this->'.$prop['field'].')?\'NULL\':"\'".';
|
||||||
|
$varprop.="\$this->".$prop['field']."";
|
||||||
|
$varprop.='."\'")."';
|
||||||
|
if ($i < sizeof($property)) $varprop.=",";
|
||||||
|
$varprop.='";';
|
||||||
|
}
|
||||||
$varprop.="\n";
|
$varprop.="\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -976,7 +976,8 @@ if ($rowid && $action != 'edit')
|
|||||||
*/
|
*/
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if ($user->rights->adherent->creer || ($user->rights->adherent->self->creer && $adh->user_id == $user->id))
|
// Modify
|
||||||
|
if ($user->rights->adherent->creer || ($user->rights->adherent->self->creer && $adh->user_id == $user->id))
|
||||||
{
|
{
|
||||||
print "<a class=\"butAction\" href=\"fiche.php?rowid=$rowid&action=edit\">".$langs->trans("Modify")."</a>";
|
print "<a class=\"butAction\" href=\"fiche.php?rowid=$rowid&action=edit\">".$langs->trans("Modify")."</a>";
|
||||||
}
|
}
|
||||||
@ -1037,7 +1038,7 @@ if ($rowid && $action != 'edit')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Barre d'actions
|
// Create user
|
||||||
if (! $user->societe_id && ! $adh->user_id)
|
if (! $user->societe_id && ! $adh->user_id)
|
||||||
{
|
{
|
||||||
if ($user->rights->user->user->creer)
|
if ($user->rights->user->user->creer)
|
||||||
|
|||||||
@ -76,16 +76,13 @@ class Events // extends CommonObject
|
|||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
|
|
||||||
$this->id=trim($this->id);
|
$this->id=trim($this->id);
|
||||||
$this->fk_action=trim($this->fk_action);
|
$this->fk_action=trim($this->fk_action);
|
||||||
$this->label=trim($this->label);
|
$this->label=trim($this->label);
|
||||||
$this->description=trim($this->description);
|
$this->description=trim($this->description);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
// Put here code to add control on parameters values
|
if (! $user->id) { $this->error='ErrorBadValueForParameter'; return -1; }
|
||||||
|
|
||||||
// Insert request
|
// Insert request
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."events(";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."events(";
|
||||||
@ -96,7 +93,6 @@ class Events // extends CommonObject
|
|||||||
$sql.= "label,";
|
$sql.= "label,";
|
||||||
$sql.= "description";
|
$sql.= "description";
|
||||||
|
|
||||||
|
|
||||||
$sql.= ") VALUES (";
|
$sql.= ") VALUES (";
|
||||||
|
|
||||||
$sql.= " '".$this->type."',";
|
$sql.= " '".$this->type."',";
|
||||||
|
|||||||
@ -689,9 +689,9 @@ class User extends CommonObject
|
|||||||
* \param notrigger 1 ne declenche pas les triggers, 0 sinon
|
* \param notrigger 1 ne declenche pas les triggers, 0 sinon
|
||||||
* \return int <0 si KO, id compte cree si OK
|
* \return int <0 si KO, id compte cree si OK
|
||||||
*/
|
*/
|
||||||
function create($user='',$notrigger=0)
|
function create($user,$notrigger=0)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf,$langs;
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
$this->login = trim($this->login);
|
$this->login = trim($this->login);
|
||||||
@ -798,7 +798,7 @@ class User extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function create_from_contact($contact)
|
function create_from_contact($contact)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $user,$langs;
|
||||||
|
|
||||||
// Positionne parametres
|
// Positionne parametres
|
||||||
$this->nom = $contact->nom;
|
$this->nom = $contact->nom;
|
||||||
@ -812,7 +812,7 @@ class User extends CommonObject
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Cree et positionne $this->id
|
// Cree et positionne $this->id
|
||||||
$result=$this->create();
|
$result=$this->create($user);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
@ -853,7 +853,7 @@ class User extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function create_from_member($member)
|
function create_from_member($member)
|
||||||
{
|
{
|
||||||
global $conf, $user,$langs;
|
global $conf,$user,$langs;
|
||||||
|
|
||||||
// Positionne parametres
|
// Positionne parametres
|
||||||
$this->nom = $member->nom;
|
$this->nom = $member->nom;
|
||||||
@ -868,7 +868,7 @@ class User extends CommonObject
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Cree et positionne $this->id
|
// Cree et positionne $this->id
|
||||||
$result=$this->create();
|
$result=$this->create($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$result=$this->setPassword($user,$this->pass);
|
$result=$this->setPassword($user,$this->pass);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user