Clean code

This commit is contained in:
Laurent Destailleur 2021-06-10 00:09:38 +02:00
parent 7b31ef0ff3
commit 067f37e22e
9 changed files with 10 additions and 26 deletions

View File

@ -283,10 +283,7 @@ abstract class ActionsContactCardCommon
// phpcs:enable // phpcs:enable
global $langs, $mysoc; global $langs, $mysoc;
$this->object->old_name = GETPOST("old_name"); $this->object->socid = GETPOST("socid", 'int');
$this->object->old_firstname = GETPOST("old_firstname");
$this->object->socid = GETPOST("socid");
$this->object->lastname = GETPOST("name"); $this->object->lastname = GETPOST("name");
$this->object->firstname = GETPOST("firstname"); $this->object->firstname = GETPOST("firstname");
$this->object->civility_id = GETPOST("civility_id"); $this->object->civility_id = GETPOST("civility_id");
@ -301,7 +298,6 @@ abstract class ActionsContactCardCommon
$this->object->phone_mobile = GETPOST("phone_mobile"); $this->object->phone_mobile = GETPOST("phone_mobile");
$this->object->fax = GETPOST("fax"); $this->object->fax = GETPOST("fax");
$this->object->email = GETPOST("email"); $this->object->email = GETPOST("email");
$this->object->jabberid = GETPOST("jabberid");
$this->object->priv = GETPOST("priv"); $this->object->priv = GETPOST("priv");
$this->object->note = GETPOST("note", "restricthtml"); $this->object->note = GETPOST("note", "restricthtml");
$this->object->canvas = GETPOST("canvas"); $this->object->canvas = GETPOST("canvas");

View File

@ -109,11 +109,6 @@ echo $this->control->tpl['ajax_selectcountry']; ?>
<td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['email']; ?>"></td> <td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['email']; ?>"></td>
</tr> </tr>
<tr>
<td><?php echo $langs->trans("IM"); ?></td>
<td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['jabberid']; ?>"></td>
</tr>
<tr> <tr>
<td><?php echo $langs->trans("ContactVisibility"); ?></td> <td><?php echo $langs->trans("ContactVisibility"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_visibility']; ?></td> <td colspan="3"><?php echo $this->control->tpl['select_visibility']; ?></td>

View File

@ -297,7 +297,7 @@ if (empty($reshook)) {
$object->old_lastname = (string) GETPOST("old_lastname", 'alpha'); $object->old_lastname = (string) GETPOST("old_lastname", 'alpha');
$object->old_firstname = (string) GETPOST("old_firstname", 'alpha'); $object->old_firstname = (string) GETPOST("old_firstname", 'alpha');
$result = $object->delete(); $result = $object->delete(); // TODO Add $user as first param
if ($result > 0) { if ($result > 0) {
if ($backtopage) { if ($backtopage) {
header("Location: ".$backtopage); header("Location: ".$backtopage);
@ -443,8 +443,6 @@ if (empty($reshook)) {
} }
} }
$object->old_lastname = '';
$object->old_firstname = '';
$action = 'view'; $action = 'view';
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');

View File

@ -545,8 +545,6 @@ class Contact extends CommonObject
$this->phone_pro = trim($this->phone_pro); $this->phone_pro = trim($this->phone_pro);
$this->phone_perso = trim($this->phone_perso); $this->phone_perso = trim($this->phone_perso);
$this->phone_mobile = trim($this->phone_mobile); $this->phone_mobile = trim($this->phone_mobile);
$this->jabberid = trim($this->jabberid);
$this->skype = trim($this->skype);
$this->photo = trim($this->photo); $this->photo = trim($this->photo);
$this->fax = trim($this->fax); $this->fax = trim($this->fax);
$this->zip = (empty($this->zip) ? '' : trim($this->zip)); $this->zip = (empty($this->zip) ? '' : trim($this->zip));
@ -1190,10 +1188,11 @@ class Contact extends CommonObject
} }
/** /**
* Efface le contact de la base * Delete a contact from database
* // TODO Add $user as first param
* *
* @param int $notrigger Disable all trigger * @param int $notrigger Disable all trigger
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete($notrigger = 0) public function delete($notrigger = 0)
{ {

View File

@ -60,8 +60,8 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->societe->contact
$result = $object->update_perso($id, $user); $result = $object->update_perso($id, $user);
if ($result > 0) { if ($result > 0) {
$object->old_name = ''; $object->oldcopy = clone $object;
$object->old_firstname = '';
// Logo/Photo save // Logo/Photo save
$dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos'; $dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos';

View File

@ -321,7 +321,6 @@ abstract class CommonDocGenerator
$array_key.'_statut' => $object->statut, $array_key.'_statut' => $object->statut,
$array_key.'_code' => $object->code, $array_key.'_code' => $object->code,
$array_key.'_email' => $object->email, $array_key.'_email' => $object->email,
$array_key.'_jabberid' => $object->jabberid, // deprecated
$array_key.'_phone_pro' => $object->phone_pro, $array_key.'_phone_pro' => $object->phone_pro,
$array_key.'_phone_perso' => $object->phone_perso, $array_key.'_phone_perso' => $object->phone_perso,
$array_key.'_phone_mobile' => $object->phone_mobile, $array_key.'_phone_mobile' => $object->phone_mobile,

View File

@ -196,7 +196,6 @@ class ActionsDatapolicy
echo $object->phone_pro.';'; echo $object->phone_pro.';';
echo $object->phone_perso.';'; echo $object->phone_perso.';';
echo $object->phone_mobile.';'; echo $object->phone_mobile.';';
echo $object->jabberid.';';
echo dol_print_date($object->birth).';'; echo dol_print_date($object->birth).';';
exit; exit;
} elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'send_datapolicy') { } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'send_datapolicy') {

View File

@ -4710,7 +4710,7 @@ function migrate_contacts_socialnetworks()
$db->begin(); $db->begin();
print '<tr><td colspan="4">'; print '<tr><td colspan="4">';
$sql = 'SELECT rowid, socialnetworks'; $sql = 'SELECT rowid, socialnetworks';
$sql .= ', jabberid, skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'socpeople WHERE '; $sql .= ', jabberid, skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'socpeople WHERE';
$sql .= " jabberid IS NOT NULL OR jabberid <> ''"; $sql .= " jabberid IS NOT NULL OR jabberid <> ''";
$sql .= " OR skype IS NOT NULL OR skype <> ''"; $sql .= " OR skype IS NOT NULL OR skype <> ''";
$sql .= " OR twitter IS NOT NULL OR twitter <> ''"; $sql .= " OR twitter IS NOT NULL OR twitter <> ''";

View File

@ -492,8 +492,7 @@ function getContactsForThirdParty($authentication, $idthirdparty)
$sql .= " c.fk_pays as country_id,"; $sql .= " c.fk_pays as country_id,";
$sql .= " c.fk_departement as state_id,"; $sql .= " c.fk_departement as state_id,";
$sql .= " c.birthday,"; $sql .= " c.birthday,";
$sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,"; $sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,";
//$sql.= " c.priv, c.note, c.default_lang, c.canvas,";
$sql .= " co.label as country, co.code as country_code,"; $sql .= " co.label as country, co.code as country_code,";
$sql .= " d.nom as state, d.code_departement as state_code,"; $sql .= " d.nom as state, d.code_departement as state_code,";
$sql .= " u.rowid as user_id, u.login as user_login,"; $sql .= " u.rowid as user_id, u.login as user_login,";
@ -545,7 +544,6 @@ function getContactsForThirdParty($authentication, $idthirdparty)
'phone_mobile' => $contact->phone_mobile ? $contact->phone_mobile : '', 'phone_mobile' => $contact->phone_mobile ? $contact->phone_mobile : '',
'email' => $contact->email ? $contact->email : '', 'email' => $contact->email ? $contact->email : '',
'jabberid' => $contact->jabberid ? $contact->jabberid : '',
'priv' => $contact->priv ? $contact->priv : '', 'priv' => $contact->priv ? $contact->priv : '',
'mail' => $contact->mail ? $contact->mail : '', 'mail' => $contact->mail ? $contact->mail : '',