Clean old deprecated code on social networks fields

This commit is contained in:
Laurent Destailleur 2023-01-30 14:13:02 +01:00
parent 2dd13f540b
commit 2a0a0fc470
11 changed files with 13 additions and 169 deletions

View File

@ -313,10 +313,6 @@ if (empty($reshook)) {
$object->socialnetworks[$key] = trim(GETPOST($key, 'alphanohtml'));
}
}
//$object->skype = trim(GETPOST("skype", 'alpha'));
//$object->twitter = trim(GETPOST("twitter", 'alpha'));
//$object->facebook = trim(GETPOST("facebook", 'alpha'));
//$object->linkedin = trim(GETPOST("linkedin", 'alpha'));
$object->birth = $birthdate;
$object->default_lang = GETPOST('default_lang', 'alpha');
$object->typeid = GETPOST("typeid", 'int');
@ -488,11 +484,6 @@ if (empty($reshook)) {
}
}
// $object->skype = $skype;
// $object->twitter = $twitter;
// $object->facebook = $facebook;
// $object->linkedin = $linkedin;
$object->email = $email;
$object->url = $url;
$object->login = $login;

View File

@ -1762,11 +1762,6 @@ class Setup extends DolibarrApi
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_COMPANY');
}
unset($mysoc->skype);
unset($mysoc->twitter);
unset($mysoc->facebook);
unset($mysoc->linkedin);
unset($mysoc->pays);
unset($mysoc->note);
unset($mysoc->nom);

View File

@ -213,11 +213,6 @@ if (empty($reshook)) {
$object->town = (string) GETPOST("town", 'alpha');
$object->country_id = (int) GETPOST("country_id", 'int');
$object->state_id = (int) GETPOST("state_id", 'int');
//$object->jabberid = GETPOST("jabberid", 'alpha');
//$object->skype = GETPOST("skype", 'alpha');
//$object->twitter = GETPOST("twitter", 'alpha');
//$object->facebook = GETPOST("facebook", 'alpha');
//$object->linkedin = GETPOST("linkedin", 'alpha');
$object->socialnetworks = array();
if (isModEnabled('socialnetworks')) {
foreach ($socialnetworks as $key => $value) {
@ -419,11 +414,6 @@ if (empty($reshook)) {
$object->email = (string) GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
$object->no_email = GETPOST("no_email", "int");
//$object->jabberid = GETPOST("jabberid", 'alpha');
//$object->skype = GETPOST("skype", 'alpha');
//$object->twitter = GETPOST("twitter", 'alpha');
//$object->facebook = GETPOST("facebook", 'alpha');
//$object->linkedin = GETPOST("linkedin", 'alpha');
$object->socialnetworks = array();
if (isModEnabled('socialnetworks')) {
foreach ($socialnetworks as $key => $value) {

View File

@ -702,22 +702,6 @@ class Contact extends CommonObject
$tmpobj->socialnetworks = $this->socialnetworks;
$usermustbemodified++;
}
// if ($tmpobj->skype != $this->skype) {
// $tmpobj->skype = $this->skype;
// $usermustbemodified++;
// }
// if ($tmpobj->twitter != $this->twitter) {
// $tmpobj->twitter = $this->twitter;
// $usermustbemodified++;
// }
// if ($tmpobj->facebook != $this->facebook) {
// $tmpobj->facebook = $this->facebook;
// $usermustbemodified++;
// }
// if ($tmpobj->linkedin != $this->linkedin) {
// $tmpobj->linkedin = $this->linkedin;
// $usermustbemodified++;
// }
if ($usermustbemodified) {
$result = $tmpobj->update($user, 0, 1, 1, 1);
if ($result < 0) {
@ -850,9 +834,6 @@ class Contact extends CommonObject
if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) {
$info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax;
}
if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) {
$info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype;
}
if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) {
$info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2);
}

View File

@ -961,27 +961,6 @@ abstract class CommonObject
}
$outdone++;
}
} else { // Old code to remove
if (!empty($this->skype)) {
$outsocialnetwork .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype');
}
$outdone++;
if (!empty($this->jabberid)) {
$outsocialnetwork .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber');
}
$outdone++;
if (!empty($this->twitter)) {
$outsocialnetwork .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter');
}
$outdone++;
if (!empty($this->facebook)) {
$outsocialnetwork .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook');
}
$outdone++;
if (!empty($this->linkedin)) {
$outsocialnetwork .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin');
}
$outdone++;
}
if ($outsocialnetwork) {

View File

@ -27,6 +27,12 @@
*/
trait CommonSocialNetworks
{
/**
* @var array array of socialnetworks
*/
public $socialnetworks;
/**
* Show social network part if the module is enabled with hiding functionality
*

View File

@ -1291,7 +1291,6 @@ class Ldap
$this->firstname = $this->convToOutputCharset($result[0][$this->attr_firstname][0], $this->ldapcharset);
$this->login = $this->convToOutputCharset($result[0][$this->attr_login][0], $this->ldapcharset);
$this->phone = $this->convToOutputCharset($result[0][$this->attr_phone][0], $this->ldapcharset);
$this->skype = $this->convToOutputCharset($result[0][$this->attr_skype][0], $this->ldapcharset);
$this->fax = $this->convToOutputCharset($result[0][$this->attr_fax][0], $this->ldapcharset);
$this->mail = $this->convToOutputCharset($result[0][$this->attr_mail][0], $this->ldapcharset);
$this->mobile = $this->convToOutputCharset($result[0][$this->attr_mobile][0], $this->ldapcharset);

View File

@ -82,11 +82,11 @@ class ActionsDatapolicy
/**
* Overloading the doActions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
* @param string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code
* @param array $parameters Hook metadatas (context, etc...)
* @param Societe|CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
* @param string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code
*/
public function doActions($parameters, &$object, &$action, $hookmanager)
{
@ -103,7 +103,6 @@ class ActionsDatapolicy
// on verifie si l'objet est utilisé
if ($object->isObjectUsed(GETPOST('socid'))) {
$object->name = $langs->trans('ANONYME');
$object->name_bis = '';
$object->name_alias = '';
$object->address = '';
$object->town = '';
@ -115,7 +114,7 @@ class ActionsDatapolicy
$object->state = '';
$object->country = '';
$object->state_id = '';
$object->skype = '';
$object->socialnetworks = '';
$object->country_id = '';
$object->note_private = $object->note_private.'<br>'.$langs->trans('ANONYMISER_AT', dol_print_date(time()));
@ -128,76 +127,6 @@ class ActionsDatapolicy
header('Location:'.$_SERVER["PHP_SELF"]."?socid=".$object->id);
}
}
} elseif ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'datapolicy_portabilite') {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv');
header('Pragma: no-cache');
$object->fetch(GETPOST('socid'));
echo 'Name;Firstname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL;
echo $object->name.';';
echo ';';
echo ';';
echo ';';
echo ';';
echo $object->address.';';
echo $object->zip.';';
echo $object->town.';';
echo $object->state.';';
echo $object->country.';';
echo $object->email.';';
echo $object->phone.';';
echo ';';
echo ';';
echo $object->skype.';';
echo ';';
exit;
} elseif ($parameters['currentcontext'] == 'membercard' && $action == 'datapolicy_portabilite') {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv');
header('Pragma: no-cache');
$soc = $object->fetch_thirdparty();
echo 'Name;Firstname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL;
echo $object->lastname.';';
echo $object->firstname.';';
echo $object->getCivilityLabel().';';
echo ($soc != -1 ? $object->thirdparty->name : '').';';
echo ';';
echo $object->address.';';
echo $object->zip.';';
echo $object->town.';';
echo $object->state.';';
echo $object->country.';';
echo $object->email.';';
echo $object->phone.';';
echo $object->phone_perso.';';
echo $object->phone_mobile.';';
echo $object->skype.';';
echo dol_print_date($object->birth).';';
exit;
} elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'datapolicy_portabilite') {
$object->fetch(GETPOST('id'));
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv');
header('Pragma: no-cache');
$soc = $object->fetch_thirdparty();
echo 'Name;Firstname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL;
echo $object->lastname.';';
echo $object->firstname.';';
echo $object->getCivilityLabel().';';
echo ($soc != -1 ? $object->thirdparty->name : '').';';
echo $object->poste.';';
echo $object->address.';';
echo $object->zip.';';
echo $object->town.';';
echo $object->state.';';
echo $object->country.';';
echo $object->email.';';
echo $object->phone_pro.';';
echo $object->phone_perso.';';
echo $object->phone_mobile.';';
echo dol_print_date($object->birth).';';
exit;
} elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'send_datapolicy') {
$object->fetch(GETPOST('id'));
@ -358,13 +287,7 @@ class ActionsDatapolicy
} );
</script>';
echo $dialog;
if ($parameters['currentcontext'] == 'thirdpartycard' && in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $object->typent_id == 8) {
echo '<div class="inline-block divButAction"><a target="_blank" rel="noopener noreferrer" id="rpgpdbtn" class="butAction" href="'.$_SERVER["PHP_SELF"]."?socid=".$object->id.'&action=datapolicy_portabilite" title="'.$langs->trans('DATAPOLICY_PORTABILITE_TITLE').'">'.$langs->trans("DATAPOLICY_PORTABILITE").'</a></div>';
} elseif ($parameters['currentcontext'] == 'membercard') {
echo '<div class="inline-block divButAction"><a target="_blank" rel="noopener noreferrer" id="rpgpdbtn" class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id.'&action=datapolicy_portabilite" title="'.$langs->trans('DATAPOLICY_PORTABILITE_TITLE').'">'.$langs->trans("DATAPOLICY_PORTABILITE").'</a></div>';
} elseif ($parameters['currentcontext'] == 'contactcard') {
echo '<div class="inline-block divButAction"><a target="_blank" rel="noopener noreferrer" id="rpgpdbtn" class="butAction" href="'.$_SERVER["PHP_SELF"]."?id=".$object->id.'&action=datapolicy_portabilite" title="'.$langs->trans('DATAPOLICY_PORTABILITE_TITLE').'">'.$langs->trans("DATAPOLICY_PORTABILITE").'</a></div>';
}
// TODO Replace test of hardcoded values
if (!empty($object->mail) && empty($object->array_options['options_datapolicy_send']) && $parameters['currentcontext'] == 'thirdpartycard' && in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $object->typent_id == 8) {
echo '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?socid=".$object->id.'&action=send_datapolicy" title="'.$langs->trans('DATAPOLICY_SEND').'">'.$langs->trans("DATAPOLICY_SEND").'</a></div>';
} elseif (!empty($object->mail) && empty($object->array_options['options_datapolicy_send']) && $parameters['currentcontext'] == 'membercard') {

View File

@ -1826,16 +1826,6 @@ class Thirdparties extends DolibarrApi
unset($object->fk_delivery_address); // deprecated feature
unset($object->skype);
unset($object->twitter);
unset($object->facebook);
unset($object->linkedin);
unset($object->instagram);
unset($object->snapchat);
unset($object->googleplus);
unset($object->youtube);
unset($object->whatsapp);
return $object;
}

View File

@ -382,11 +382,6 @@ class Societe extends CommonObject
*/
public $no_email;
/**
* @var array array of socialnetworks
*/
public $socialnetworks;
/**
* Skype username
* @var string

View File

@ -701,11 +701,6 @@ class Users extends DolibarrApi
unset($object->lines);
unset($object->model_pdf);
unset($object->skype);
unset($object->twitter);
unset($object->facebook);
unset($object->linkedin);
$canreadsalary = ((!empty($conf->salaries->enabled) && !empty(DolibarrApiAccess::$user->rights->salaries->read)) || (empty($conf->salaries->enabled)));
if (!$canreadsalary) {