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')
|
||||
{
|
||||
$varprop.="\tvar \$".$prop['field'].";";
|
||||
$varprop.="\tvar \$".$prop['field'];
|
||||
if ($prop['istime']) $varprop.="=''";
|
||||
$varprop.=";";
|
||||
if ($prop['comment']) $varprop.="\t// ".$prop['extra'];
|
||||
$varprop.="\n";
|
||||
}
|
||||
@ -192,7 +194,11 @@ $i=0;
|
||||
foreach($property as $key => $prop)
|
||||
{
|
||||
$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'];
|
||||
if ($i < sizeof($property)) $varprop.=",";
|
||||
@ -210,16 +216,29 @@ $i=0;
|
||||
foreach($property as $key => $prop)
|
||||
{
|
||||
$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.= \" ";
|
||||
if ($prop['istime']) $varprop.='".$this->db->idate(';
|
||||
else $varprop.="'\".";
|
||||
$varprop.="\$this->".$prop['field']."";
|
||||
if ($prop['istime']) $varprop.=')."';
|
||||
else $varprop.=".\"'";
|
||||
if ($i < sizeof($property)) $varprop.=",";
|
||||
$varprop.="\";";
|
||||
if ($prop['istime'])
|
||||
{
|
||||
$varprop.='".(! isset($this->'.$prop['field'].') || $this->'.$prop['field'].'==\'\'?\'NULL\':$this->db->idate(';
|
||||
$varprop.="\$this->".$prop['field']."";
|
||||
$varprop.='))."';
|
||||
if ($i < sizeof($property)) $varprop.=",";
|
||||
$varprop.="\";";
|
||||
}
|
||||
else
|
||||
{
|
||||
$varprop.='".(! isset($this->'.$prop['field'].')?\'NULL\':"\'".';
|
||||
$varprop.="\$this->".$prop['field']."";
|
||||
$varprop.='."\'")."';
|
||||
if ($i < sizeof($property)) $varprop.=",";
|
||||
$varprop.='";';
|
||||
}
|
||||
$varprop.="\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.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
|
||||
* 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">';
|
||||
|
||||
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>";
|
||||
}
|
||||
@ -1037,7 +1038,7 @@ if ($rowid && $action != 'edit')
|
||||
}
|
||||
}
|
||||
|
||||
// Barre d'actions
|
||||
// Create user
|
||||
if (! $user->societe_id && ! $adh->user_id)
|
||||
{
|
||||
if ($user->rights->user->user->creer)
|
||||
|
||||
@ -76,16 +76,13 @@ class Events // extends CommonObject
|
||||
global $conf, $langs;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
$this->id=trim($this->id);
|
||||
$this->fk_action=trim($this->fk_action);
|
||||
$this->label=trim($this->label);
|
||||
$this->description=trim($this->description);
|
||||
|
||||
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
if (! $user->id) { $this->error='ErrorBadValueForParameter'; return -1; }
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."events(";
|
||||
@ -96,9 +93,8 @@ class Events // extends CommonObject
|
||||
$sql.= "label,";
|
||||
$sql.= "description";
|
||||
|
||||
|
||||
$sql.= ") VALUES (";
|
||||
|
||||
|
||||
$sql.= " '".$this->type."',";
|
||||
$sql.= " ".$this->db->idate($this->dateevent).",";
|
||||
$sql.= " '".$user->id."',";
|
||||
|
||||
@ -689,9 +689,9 @@ class User extends CommonObject
|
||||
* \param notrigger 1 ne declenche pas les triggers, 0 sinon
|
||||
* \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
|
||||
$this->login = trim($this->login);
|
||||
@ -798,7 +798,7 @@ class User extends CommonObject
|
||||
*/
|
||||
function create_from_contact($contact)
|
||||
{
|
||||
global $langs;
|
||||
global $user,$langs;
|
||||
|
||||
// Positionne parametres
|
||||
$this->nom = $contact->nom;
|
||||
@ -812,7 +812,7 @@ class User extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
// Cree et positionne $this->id
|
||||
$result=$this->create();
|
||||
$result=$this->create($user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -853,7 +853,7 @@ class User extends CommonObject
|
||||
*/
|
||||
function create_from_member($member)
|
||||
{
|
||||
global $conf, $user,$langs;
|
||||
global $conf,$user,$langs;
|
||||
|
||||
// Positionne parametres
|
||||
$this->nom = $member->nom;
|
||||
@ -868,7 +868,7 @@ class User extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
// Cree et positionne $this->id
|
||||
$result=$this->create();
|
||||
$result=$this->create($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$result=$this->setPassword($user,$this->pass);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user