Qual: Clean a lot of deprecated code

This commit is contained in:
Laurent Destailleur 2014-09-24 01:35:29 +02:00
parent d6385fe1cc
commit a4d8739477
6 changed files with 51 additions and 53 deletions

View File

@ -240,12 +240,15 @@ if ($action == 'add')
} }
$object->note = trim($_POST["note"]); $object->note = trim($_POST["note"]);
if (isset($_POST["contactid"])) $object->contact = $contact; if (isset($_POST["contactid"])) $object->contact = $contact;
if (GETPOST('socid','int') > 0) if (GETPOST('socid','int') > 0)
{ {
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch(GETPOST('socid','int')); $societe->fetch(GETPOST('socid','int'));
$object->societe = $societe; $object->societe = $societe; // deprecated
$object->thirdparty = $societe;
} }
// Special for module webcal and phenix // Special for module webcal and phenix
@ -359,8 +362,10 @@ if ($action == 'update')
$object->priority = $_POST["priority"]; $object->priority = $_POST["priority"];
$object->fulldayevent= $_POST["fullday"]?1:0; $object->fulldayevent= $_POST["fullday"]?1:0;
$object->location = GETPOST('location'); $object->location = GETPOST('location');
$object->societe->id = $_POST["socid"]; $object->socid = $_POST["socid"];
$object->contact->id = $_POST["contactid"]; $object->contactid = $_POST["contactid"];
$object->societe->id = $_POST["socid"]; // deprecated
$object->contact->id = $_POST["contactid"]; // deprecated
$object->fk_project = $_POST["projectid"]; $object->fk_project = $_POST["projectid"];
$object->note = $_POST["note"]; $object->note = $_POST["note"];
$object->pnote = $_POST["note"]; $object->pnote = $_POST["note"];
@ -795,22 +800,16 @@ if ($action == 'create')
if ($id > 0) if ($id > 0)
{ {
$result1=$object->fetch($id); $result1=$object->fetch($id);
$result2=$object->fetch_userassigned(); $result2=$object->fetch_thirdparty();
$result3=$object->fetch_optionals($id,$extralabels); $result3=$object->fetch_userassigned();
$result4=$object->fetch_optionals($id,$extralabels);
if ($result1 < 0 || $result2 < 0 || $result3 < 0) if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0)
{ {
dol_print_error($db,$object->error); dol_print_error($db,$object->error);
exit; exit;
} }
$societe = new Societe($db);
if ($object->societe->id)
{
$result=$societe->fetch($object->societe->id);
}
$object->societe = $societe;
if ($object->author->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->author->id); $object->author=$tmpuser; } if ($object->author->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->author->id); $object->author=$tmpuser; }
if ($object->usermod->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermod->id); $object->usermod=$tmpuser; } if ($object->usermod->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermod->id); $object->usermod=$tmpuser; }
if ($object->usertodo->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usertodo->id); $object->usertodo=$tmpuser; } if ($object->usertodo->id > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usertodo->id); $object->usertodo=$tmpuser; }
@ -959,12 +958,12 @@ if ($id > 0)
print '<td>'; print '<td>';
$events=array(); $events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
print $form->select_company($object->societe->id,'socid','',1,1,0,$events); print $form->select_company($object->thirdparty->id,'socid','',1,1,0,$events);
print '</td>'; print '</td>';
// Contact // Contact
print '<td>'.$langs->trans("Contact").'</td><td width="30%">'; print '<td>'.$langs->trans("Contact").'</td><td width="30%">';
$form->select_contacts($object->societe->id, $object->contact->id,'contactid',1); $form->select_contacts($object->thirdparty->id, $object->contact->id,'contactid',1);
print '</td></tr>'; print '</td></tr>';
} }
@ -978,7 +977,7 @@ if ($id > 0)
$langs->load("project"); $langs->load("project");
print '<tr><td width="30%" valign="top">'.$langs->trans("Project").'</td><td colspan="3">'; print '<tr><td width="30%" valign="top">'.$langs->trans("Project").'</td><td colspan="3">';
$numprojet=$formproject->select_projects($object->societe->id,$object->fk_project,'projectid'); $numprojet=$formproject->select_projects($object->thirdparty->id,$object->fk_project,'projectid');
if ($numprojet==0) if ($numprojet==0)
{ {
print ' &nbsp; <a href="../../projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>'; print ' &nbsp; <a href="../../projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>';
@ -1152,12 +1151,12 @@ if ($id > 0)
// Third party - Contact // Third party - Contact
if ($conf->societe->enabled) if ($conf->societe->enabled)
{ {
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None")); print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
if ($object->societe->id && $object->type_code == 'AC_TEL') if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
{ {
if ($object->societe->fetch($object->societe->id)) if ($object->thirdparty->fetch($object->thirdparty->id))
{ {
print "<br>".dol_print_phone($object->societe->phone); print "<br>".dol_print_phone($object->thirdparty->phone);
} }
} }
print '</td>'; print '</td>';

View File

@ -192,10 +192,10 @@ class ActionComm extends CommonObject
$sql.= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; // deprecated $sql.= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; // deprecated
$sql.= (isset($this->type_id)?$this->type_id:"null").","; $sql.= (isset($this->type_id)?$this->type_id:"null").",";
$sql.= (isset($this->code)?" '".$this->code."'":"null").","; $sql.= (isset($this->code)?" '".$this->code."'":"null").",";
$sql.= (isset($this->societe->id) && $this->societe->id > 0?" '".$this->societe->id."'":"null").","; $sql.= (isset($this->socid) && $this->socid > 0?" '".$this->socid."'":"null").",";
$sql.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").","; $sql.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").",";
$sql.= " '".$this->db->escape($this->note)."',"; $sql.= " '".$this->db->escape($this->note)."',";
$sql.= (isset($this->contact->id) && $this->contact->id > 0?"'".$this->contact->id."'":"null").","; $sql.= (isset($this->contactid) && $this->contactid > 0?"'".$this->contactid."'":"null").",";
$sql.= (isset($user->id) && $user->id > 0 ? "'".$user->id."'":"null").","; $sql.= (isset($user->id) && $user->id > 0 ? "'".$user->id."'":"null").",";
$sql.= (isset($this->usertodo->id) && $this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").","; $sql.= (isset($this->usertodo->id) && $this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").",";
$sql.= (isset($this->userdone->id) && $this->userdone->id > 0?"'".$this->userdone->id."'":"null").","; $sql.= (isset($this->userdone->id) && $this->userdone->id > 0?"'".$this->userdone->id."'":"null").",";
@ -358,10 +358,12 @@ class ActionComm extends CommonObject
$this->location = $obj->location; $this->location = $obj->location;
$this->transparency = $obj->transparency; $this->transparency = $obj->transparency;
$this->socid = $obj->fk_soc; // To have fetch_thirdparty method working $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working
$this->societe->id = $obj->fk_soc; $this->contactid = $obj->fk_contact;
$this->contact->id = $obj->fk_contact; $this->fk_project = $obj->fk_project; // To have fetch_project method working
$this->fk_project = $obj->fk_project;
$this->societe->id = $obj->fk_soc; // For backward compatibility
$this->contact->id = $obj->fk_contact; // For backward compatibility
$this->fk_element = $obj->fk_element; $this->fk_element = $obj->fk_element;
$this->elementtype = $obj->elementtype; $this->elementtype = $obj->elementtype;

View File

@ -60,12 +60,7 @@ $object = new ActionComm($db);
if ($objectid > 0) if ($objectid > 0)
{ {
$ret = $object->fetch($objectid); $ret = $object->fetch($objectid);
if ($ret > 0) { $object->fetch_thirdparty();
$company=new Societe($db);
$company->fetch($object->societe->id);
$object->societe=$company; // For backward compatibility
$object->thirdparty=$company;
}
} }
// Get parameters // Get parameters
@ -207,12 +202,12 @@ if ($object->id > 0)
// Third party - Contact // Third party - Contact
print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None")); print '<tr><td width="30%">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
if ($object->societe->id && $object->type_code == 'AC_TEL') if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
{ {
if ($object->societe->fetch($object->societe->id)) if ($object->thirdparty->fetch($object->thirdparty->id))
{ {
print "<br>".dol_print_phone($object->societe->phone); print "<br>".dol_print_phone($object->thirdparty->phone);
} }
} }
print '</td>'; print '</td>';

View File

@ -323,8 +323,6 @@ class Project extends CommonObject
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->societe=(object)array();// To avoid warning on next line
$this->societe->id = $obj->fk_soc; // TODO For backward compatibility
$this->user_author_id = $obj->fk_user_creat; $this->user_author_id = $obj->fk_user_creat;
$this->public = $obj->public; $this->public = $obj->public;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;

View File

@ -72,8 +72,10 @@ class User extends CommonObject
var $datem; var $datem;
//! If this is defined, it is an external user //! If this is defined, it is an external user
var $societe_id; var $societe_id; // deprecated
var $contact_id; var $contact_id; // deprecated
var $socid;
var $contactid;
var $fk_member; var $fk_member;
var $fk_user; var $fk_user;
@ -237,8 +239,10 @@ class User extends CommonObject
$this->datelastlogin = $this->db->jdate($obj->datel); $this->datelastlogin = $this->db->jdate($obj->datel);
$this->datepreviouslogin = $this->db->jdate($obj->datep); $this->datepreviouslogin = $this->db->jdate($obj->datep);
$this->societe_id = $obj->fk_societe; $this->societe_id = $obj->fk_societe; // deprecated
$this->contact_id = $obj->fk_socpeople; $this->contact_id = $obj->fk_socpeople; // deprecated
$this->socid = $obj->fk_societe;
$this->contactid = $obj->fk_socpeople;
$this->fk_member = $obj->fk_member; $this->fk_member = $obj->fk_member;
$this->fk_user = $obj->fk_user; $this->fk_user = $obj->fk_user;

View File

@ -433,10 +433,10 @@ function createActionComm($authentication,$actioncomm)
$newobject->datep=$actioncomm['datep']; $newobject->datep=$actioncomm['datep'];
$newobject->datef=$actioncomm['datef']; $newobject->datef=$actioncomm['datef'];
$newobject->type_code=$actioncomm['type_code']; $newobject->type_code=$actioncomm['type_code'];
$newobject->societe->id=$actioncomm['socid']; $newobject->socid=$actioncomm['socid'];
$newobject->fk_project=$actioncomm['projectid']; $newobject->fk_project=$actioncomm['projectid'];
$newobject->note=$actioncomm['note']; $newobject->note=$actioncomm['note'];
$newobject->contact->id=$actioncomm['contactid']; $newobject->contactid=$actioncomm['contactid'];
$newobject->usertodo->id=$actioncomm['usertodo']; $newobject->usertodo->id=$actioncomm['usertodo'];
$newobject->userdone->id=$actioncomm['userdone']; $newobject->userdone->id=$actioncomm['userdone'];
$newobject->label=$actioncomm['label']; $newobject->label=$actioncomm['label'];
@ -528,10 +528,10 @@ function updateActionComm($authentication,$actioncomm)
$object->datep=$actioncomm['datep']; $object->datep=$actioncomm['datep'];
$object->datef=$actioncomm['datef']; $object->datef=$actioncomm['datef'];
$object->type_code=$actioncomm['type_code']; $object->type_code=$actioncomm['type_code'];
$object->societe->id=$actioncomm['socid']; $object->socid=$actioncomm['socid'];
$object->contactid=$actioncomm['contactid'];
$object->fk_project=$actioncomm['projectid']; $object->fk_project=$actioncomm['projectid'];
$object->note=$actioncomm['note']; $object->note=$actioncomm['note'];
$object->contact->id=$actioncomm['contactid'];
$object->usertodo->id=$actioncomm['usertodo']; $object->usertodo->id=$actioncomm['usertodo'];
$object->userdone->id=$actioncomm['userdone']; $object->userdone->id=$actioncomm['userdone'];
$object->label=$actioncomm['label']; $object->label=$actioncomm['label'];