From a4d8739477d4de409f1fdb69bb3b25628f88ec38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Sep 2014 01:35:29 +0200 Subject: [PATCH] Qual: Clean a lot of deprecated code --- htdocs/comm/action/card.php | 39 +++++++++---------- htdocs/comm/action/class/actioncomm.class.php | 14 ++++--- htdocs/comm/action/document.php | 19 ++++----- htdocs/projet/class/project.class.php | 2 - htdocs/user/class/user.class.php | 12 ++++-- htdocs/webservices/server_actioncomm.php | 18 ++++----- 6 files changed, 51 insertions(+), 53 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 7ca82a2751e..aef2d5fad3d 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -240,12 +240,15 @@ if ($action == 'add') } $object->note = trim($_POST["note"]); + if (isset($_POST["contactid"])) $object->contact = $contact; + if (GETPOST('socid','int') > 0) { $societe = new Societe($db); $societe->fetch(GETPOST('socid','int')); - $object->societe = $societe; + $object->societe = $societe; // deprecated + $object->thirdparty = $societe; } // Special for module webcal and phenix @@ -359,8 +362,10 @@ if ($action == 'update') $object->priority = $_POST["priority"]; $object->fulldayevent= $_POST["fullday"]?1:0; $object->location = GETPOST('location'); - $object->societe->id = $_POST["socid"]; - $object->contact->id = $_POST["contactid"]; + $object->socid = $_POST["socid"]; + $object->contactid = $_POST["contactid"]; + $object->societe->id = $_POST["socid"]; // deprecated + $object->contact->id = $_POST["contactid"]; // deprecated $object->fk_project = $_POST["projectid"]; $object->note = $_POST["note"]; $object->pnote = $_POST["note"]; @@ -795,22 +800,16 @@ if ($action == 'create') if ($id > 0) { $result1=$object->fetch($id); - $result2=$object->fetch_userassigned(); - $result3=$object->fetch_optionals($id,$extralabels); + $result2=$object->fetch_thirdparty(); + $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); 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->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; } @@ -959,12 +958,12 @@ if ($id > 0) print ''; $events=array(); $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 ''; // Contact print ''.$langs->trans("Contact").''; - $form->select_contacts($object->societe->id, $object->contact->id,'contactid',1); + $form->select_contacts($object->thirdparty->id, $object->contact->id,'contactid',1); print ''; } @@ -978,7 +977,7 @@ if ($id > 0) $langs->load("project"); print ''.$langs->trans("Project").''; - $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) { print '   '.$langs->trans("AddProject").''; @@ -1152,12 +1151,12 @@ if ($id > 0) // Third party - Contact if ($conf->societe->enabled) { - print ''.$langs->trans("ActionOnCompany").''.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None")); - if ($object->societe->id && $object->type_code == 'AC_TEL') + print ''.$langs->trans("ActionOnCompany").''.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None")); + 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 "
".dol_print_phone($object->societe->phone); + print "
".dol_print_phone($object->thirdparty->phone); } } print ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ffe07614b7d..1d7cf0efd68 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -192,10 +192,10 @@ class ActionComm extends CommonObject $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->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.= " '".$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($this->usertodo->id) && $this->usertodo->id > 0?"'".$this->usertodo->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->transparency = $obj->transparency; - $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->societe->id = $obj->fk_soc; - $this->contact->id = $obj->fk_contact; - $this->fk_project = $obj->fk_project; + $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working + $this->contactid = $obj->fk_contact; + $this->fk_project = $obj->fk_project; // To have fetch_project method working + + $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->elementtype = $obj->elementtype; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index b000d2017d7..0556e532f35 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -60,12 +60,7 @@ $object = new ActionComm($db); if ($objectid > 0) { $ret = $object->fetch($objectid); - if ($ret > 0) { - $company=new Societe($db); - $company->fetch($object->societe->id); - $object->societe=$company; // For backward compatibility - $object->thirdparty=$company; - } + $object->fetch_thirdparty(); } // Get parameters @@ -112,7 +107,7 @@ if ($object->id > 0) $now=dol_now(); $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; - + dol_fiche_head($head, 'documents', $langs->trans("Action"),0,'action'); // Affichage fiche action en mode visu @@ -202,17 +197,17 @@ if ($object->id > 0) print ''.$langs->trans("ActionAffectedTo").''; if ($object->usertodo->id > 0) print $object->usertodo->getNomUrl(1); print ''; - + print '

'; // Third party - Contact - print ''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7fb6c6e373a..fb7da8636b2 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -323,8 +323,6 @@ class Project extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $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->public = $obj->public; $this->statut = $obj->fk_statut; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 5177bb3dbed..72db0966699 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -72,8 +72,10 @@ class User extends CommonObject var $datem; //! If this is defined, it is an external user - var $societe_id; - var $contact_id; + var $societe_id; // deprecated + var $contact_id; // deprecated + var $socid; + var $contactid; var $fk_member; var $fk_user; @@ -237,8 +239,10 @@ class User extends CommonObject $this->datelastlogin = $this->db->jdate($obj->datel); $this->datepreviouslogin = $this->db->jdate($obj->datep); - $this->societe_id = $obj->fk_societe; - $this->contact_id = $obj->fk_socpeople; + $this->societe_id = $obj->fk_societe; // deprecated + $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_user = $obj->fk_user; diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index d5d9c45fa36..2a41a769314 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -433,10 +433,10 @@ function createActionComm($authentication,$actioncomm) $newobject->datep=$actioncomm['datep']; $newobject->datef=$actioncomm['datef']; $newobject->type_code=$actioncomm['type_code']; - $newobject->societe->id=$actioncomm['socid']; + $newobject->socid=$actioncomm['socid']; $newobject->fk_project=$actioncomm['projectid']; $newobject->note=$actioncomm['note']; - $newobject->contact->id=$actioncomm['contactid']; + $newobject->contactid=$actioncomm['contactid']; $newobject->usertodo->id=$actioncomm['usertodo']; $newobject->userdone->id=$actioncomm['userdone']; $newobject->label=$actioncomm['label']; @@ -517,21 +517,21 @@ function updateActionComm($authentication,$actioncomm) if (! $error) { $objectfound=false; - + $object=new ActionComm($db); $result=$object->fetch($actioncomm['id']); - + if (!empty($object->id)) { - + $objectfound=true; $object->datep=$actioncomm['datep']; $object->datef=$actioncomm['datef']; $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->note=$actioncomm['note']; - $object->contact->id=$actioncomm['contactid']; $object->usertodo->id=$actioncomm['usertodo']; $object->userdone->id=$actioncomm['userdone']; $object->label=$actioncomm['label']; @@ -541,7 +541,7 @@ function updateActionComm($authentication,$actioncomm) $object->location=$actioncomm['location']; $object->fk_element=$actioncomm['fk_element']; $object->elementtype=$actioncomm['elementtype']; - + //Retreive all extrafield for actioncomm // fetch optionals attributes and labels $extrafields=new ExtraFields($db); @@ -551,7 +551,7 @@ function updateActionComm($authentication,$actioncomm) $key='options_'.$key; $object->array_options[$key]=$actioncomm[$key]; } - + $db->begin(); $result=$object->update($fuser);
'.$langs->trans("ActionOnCompany").''.($object->societe->id?$object->societe->getNomUrl(1):$langs->trans("None")); - if ($object->societe->id && $object->type_code == 'AC_TEL') + print '
'.$langs->trans("ActionOnCompany").''.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None")); + 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 "
".dol_print_phone($object->societe->phone); + print "
".dol_print_phone($object->thirdparty->phone); } } print '