socialnetworks for thirdparties

This commit is contained in:
Frédéric FRANCE 2019-09-29 11:20:23 +02:00
parent cea3669ffa
commit 6c8dc75c96
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
3 changed files with 169 additions and 82 deletions

View File

@ -697,7 +697,7 @@ else
foreach ($socialnetworks as $key => $value) {
if ($value['active']) {
print '<tr>';
print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label]'], $key, '', $object, 0).'</label></td>';
print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label'], $key, '', $object, 0).'</label></td>';
print '<td colspan="3">';
print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET($key)?GETPOST($key, 'alphanohtml'):$object->socialnetworks[$key]).'">';
print '</td>';

View File

@ -69,6 +69,8 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$socialnetworks = getArrayOfSocialNetworks();
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('thirdpartycard','globalcard'));
@ -146,7 +148,7 @@ if (empty($reshook))
$object->client = $object->client | $soc_origin->client;
$object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
$listofproperties=array(
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'linkedin', 'url', 'barcode',
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'linkedin', 'socialnetworks', 'url', 'barcode',
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
@ -405,11 +407,19 @@ if (empty($reshook))
$object->town = GETPOST('town', 'alpha');
$object->country_id = GETPOST('country_id', 'int');
$object->state_id = GETPOST('state_id', 'int');
$object->skype = GETPOST('skype', 'alpha');
$object->twitter = GETPOST('twitter', 'alpha');
$object->facebook = GETPOST('facebook', 'alpha');
$object->linkedin = GETPOST('linkedin', 'alpha');
$object->phone = GETPOST('phone', '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 (! empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') {
$object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
}
}
}
$object->phone = GETPOST('phone', 'alpha');
$object->fax = GETPOST('fax', 'alpha');
$object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
$object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
@ -971,10 +981,18 @@ else
$object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha');
$object->state_id = GETPOST('state_id', 'int');
$object->skype = GETPOST('skype', 'alpha');
$object->twitter = GETPOST('twitter', 'alpha');
$object->facebook = GETPOST('facebook', 'alpha');
$object->linkedin = GETPOST('linkedin', '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 (! empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') {
$object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
}
}
}
$object->phone = GETPOST('phone', 'alpha');
$object->fax = GETPOST('fax', 'alpha');
$object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
@ -1295,42 +1313,57 @@ else
print '<tr><td>'.$form->editfieldkey('Web', 'url', '', $object, 0).'</td>';
print '<td colspan="3"><input type="text" name="url" id="url" value="'.$object->url.'"></td></tr>';
if (! empty($conf->socialnetworks->enabled))
{
// Skype
if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
{
print '<tr><td>'.$form->editfieldkey('Skype', 'skype', '', $object, 0).'</td>';
print '<td colspan="3">';
print '<input type="text" name="skype" class="minwidth100" maxlength="80" id="skype" value="'.dol_escape_htmltag(GETPOSTISSET("skype")?GETPOST("skype", 'alpha'):$object->skype).'">';
print '</td></tr>';
}
// Twitter
if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
{
print '<tr><td>'.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).'</td>';
print '<td colspan="3">';
print '<input type="text" name="twitter" class="minwidth100" maxlength="80" id="twitter" value="'.dol_escape_htmltag(GETPOSTISSET("twitter")?GETPOST("twitter", 'alpha'):$object->twitter).'">';
print '</td></tr>';
}
// Facebook
if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
{
print '<tr><td>'.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).'</td>';
print '<td colspan="3">';
print '<input type="text" name="facebook" class="minwidth100" maxlength="80" id="facebook" value="'.dol_escape_htmltag(GETPOSTISSET("facebook")?GETPOST("facebook", 'alpha'):$object->facebook).'">';
print '</td></tr>';
}
// LinkedIn
if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN))
{
print '<tr><td>'.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).'</td>';
print '<td colspan="3">';
print '<input type="text" name="linkedin" class="minwidth100" maxlength="80" id="linkedin" value="'.dol_escape_htmltag(GETPOSTISSET("linkedin")?GETPOST("linkedin", 'alpha'):$object->linkedin).'">';
print '</td></tr>';
if (! empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
if ($value['active']) {
print '<tr>';
print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label'], $key, '', $object, 0).'</label></td>';
print '<td colspan="3">';
print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET($key)?GETPOST($key, 'alphanohtml'):$object->socialnetworks[$key]).'">';
print '</td>';
print '</tr>';
} elseif (!empty($object->socialnetworks[$key])) {
print '<input type="hidden" name="'.$key.'" value="'.$object->socialnetworks[$key].'">';
}
}
}
// if (! empty($conf->socialnetworks->enabled))
// {
// // Skype
// if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
// {
// print '<tr><td>'.$form->editfieldkey('Skype', 'skype', '', $object, 0).'</td>';
// print '<td colspan="3">';
// print '<input type="text" name="skype" class="minwidth100" maxlength="80" id="skype" value="'.dol_escape_htmltag(GETPOSTISSET("skype")?GETPOST("skype", 'alpha'):$object->skype).'">';
// print '</td></tr>';
// }
// // Twitter
// if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
// {
// print '<tr><td>'.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).'</td>';
// print '<td colspan="3">';
// print '<input type="text" name="twitter" class="minwidth100" maxlength="80" id="twitter" value="'.dol_escape_htmltag(GETPOSTISSET("twitter")?GETPOST("twitter", 'alpha'):$object->twitter).'">';
// print '</td></tr>';
// }
// // Facebook
// if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
// {
// print '<tr><td>'.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).'</td>';
// print '<td colspan="3">';
// print '<input type="text" name="facebook" class="minwidth100" maxlength="80" id="facebook" value="'.dol_escape_htmltag(GETPOSTISSET("facebook")?GETPOST("facebook", 'alpha'):$object->facebook).'">';
// print '</td></tr>';
// }
// // LinkedIn
// if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN))
// {
// print '<tr><td>'.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).'</td>';
// print '<td colspan="3">';
// print '<input type="text" name="linkedin" class="minwidth100" maxlength="80" id="linkedin" value="'.dol_escape_htmltag(GETPOSTISSET("linkedin")?GETPOST("linkedin", 'alpha'):$object->linkedin).'">';
// print '</td></tr>';
// }
// }
// Phone / Fax
print '<tr><td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';
print '<td><input type="text" name="phone" id="phone" class="maxwidth100onsmartphone quatrevingtpercent" value="'.$object->phone.'"></td>';
@ -1609,10 +1642,18 @@ else
$object->town = GETPOST('town', 'alpha');
$object->country_id = GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id;
$object->state_id = GETPOST('state_id', 'int');
$object->skype = GETPOST('skype', 'alpha');
$object->twitter = GETPOST('twitter', 'alpha');
$object->facebook = GETPOST('facebook', 'alpha');
$object->linkedin = GETPOST('linkedin', '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 (! empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') {
$object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
}
}
}
$object->phone = GETPOST('phone', 'alpha');
$object->fax = GETPOST('fax', 'alpha');
$object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
@ -1918,33 +1959,47 @@ else
print '<tr><td>'.$form->editfieldkey('Web', 'url', '', $object, 0).'</td>';
print '<td colspan="3"><input type="text" name="url" id="url" size="32" value="'.$object->url.'"></td></tr>';
if (! empty($conf->socialnetworks->enabled))
{
// Skype
if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
{
print '<tr><td>'.$form->editfieldkey('Skype', 'skype', '', $object, 0).'</td>';
print '<td colspan="3"><input type="text" name="skype" id="skype" value="'.$object->skype.'"></td></tr>';
}
// Twitter
if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
{
print '<tr><td>'.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).'</td>';
print '<td colspan="3"><input type="text" name="twitter" id="twitter" value="'.$object->twitter.'"></td></tr>';
}
// Facebook
if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
{
print '<tr><td>'.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).'</td>';
print '<td colspan="3"><input type="text" name="facebook" id="facebook" value="'.$object->facebook.'"></td></tr>';
}
// LinkedIn
if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN))
{
print '<tr><td>'.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).'</td>';
print '<td colspan="3"><input type="text" name="linkedin" id="linkedin" value="'.$object->linkedin.'"></td></tr>';
if (! empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) {
if ($value['active']) {
print '<tr>';
print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label'], $key, '', $object, 0).'</label></td>';
print '<td colspan="3">';
print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.$object->socialnetworks[$key].'">';
print '</td>';
print '</tr>';
} elseif (!empty($object->socialnetworks[$key])) {
print '<input type="hidden" name="'.$key.'" value="'.$object->socialnetworks[$key].'">';
}
}
}
}
// if (! empty($conf->socialnetworks->enabled))
// {
// // Skype
// if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
// {
// print '<tr><td>'.$form->editfieldkey('Skype', 'skype', '', $object, 0).'</td>';
// print '<td colspan="3"><input type="text" name="skype" id="skype" value="'.$object->skype.'"></td></tr>';
// }
// // Twitter
// if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
// {
// print '<tr><td>'.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).'</td>';
// print '<td colspan="3"><input type="text" name="twitter" id="twitter" value="'.$object->twitter.'"></td></tr>';
// }
// // Facebook
// if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
// {
// print '<tr><td>'.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).'</td>';
// print '<td colspan="3"><input type="text" name="facebook" id="facebook" value="'.$object->facebook.'"></td></tr>';
// }
// // LinkedIn
// if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN))
// {
// print '<tr><td>'.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).'</td>';
// print '<td colspan="3"><input type="text" name="linkedin" id="linkedin" value="'.$object->linkedin.'"></td></tr>';
// }
// }
// Phone / Fax
print '<tr><td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';

View File

@ -15,6 +15,7 @@
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
* Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
*
* 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
@ -1013,7 +1014,8 @@ class Societe extends CommonObject
$sql .= ",phone = ".(! empty($this->phone)?"'".$this->db->escape($this->phone)."'":"null");
$sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null");
$sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null");
$sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null");
$sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'";
$sql .= ",skype = ".(! empty($this->skype)?"'".$this->db->escape($this->skype)."'":"null");
$sql .= ",twitter = ".(! empty($this->twitter)?"'".$this->db->escape($this->twitter)."'":"null");
$sql .= ",facebook = ".(! empty($this->facebook)?"'".$this->db->escape($this->facebook)."'":"null");
@ -1363,12 +1365,41 @@ class Societe extends CommonObject
$this->stcomm_id = $obj->fk_stcomm; // id statut commercial
$this->statut_commercial = $libelle; // libelle statut commercial
$this->email = $obj->email;
$this->skype = $obj->skype;
$this->twitter = $obj->twitter;
$this->facebook = $obj->facebook;
$this->linkedin = $obj->linkedin;
$this->socialnetworks = json_decode($obj->socialnetworks);
$this->email = $obj->email;
$arraysocialnetworks = array();
$updatesocial = false;
if (!empty($obj->skype)) {
$arraysocialnetworks['skype'] = $obj->skype;
$updatesocial = true;
}
if (!empty($obj->twitter)) {
$arraysocialnetworks['twitter'] = $obj->twitter;
$updatesocial = true;
}
if (!empty($obj->facebook)) {
$arraysocialnetworks['facebook'] = $obj->facebook;
$updatesocial = true;
}
if (!empty($obj->linkedin)) {
$arraysocialnetworks['linkedin'] = $obj->linkedin;
$updatesocial = true;
}
$socialarray = ($obj->socialnetworks==''?array():json_decode($obj->socialnetworks, true));
$this->socialnetworks = array_merge($arraysocialnetworks, $socialarray);
if ($updatesocial) {
$sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'societe SET skype=null';
$sqlupd .= ', twitter=null';
$sqlupd .= ', facebook=null';
$sqlupd .= ', linkedin=null';
$sqlupd .= ', socialnetworks="'.$this->db->escape(json_encode($this->socialnetworks)).'"';
$sqlupd .= ' WHERE rowid='.$this->id;
$this->db->query($sqlupd);
}
$this->skype = $this->socialnetworks['skype'];
$this->twitter = $this->socialnetworks['twitter'];
$this->facebook = $this->socialnetworks['facebook'];
$this->linkedin = $this->socialnetworks['linkedin'];
$this->url = $obj->url;
$this->phone = $obj->phone;
@ -3410,7 +3441,8 @@ class Societe extends CommonObject
$this->skype=$member->skype;
$this->twitter=$member->twitter;
$this->facebook=$member->facebook;
$this->linkedin=$member->linkedin;
$this->linkedin=$member->linkedin;
$this->socialnetworks = $member->socialnetworks;
$this->client = 1; // A member is a customer by default
$this->code_client = ($customercode?$customercode:-1);