From 3fddef0c9e25b7173dbe43b6c4df51ecacc73664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 11 Sep 2019 22:27:09 +0200 Subject: [PATCH 01/47] add socialnetworks dictionary --- htdocs/adherents/card.php | 107 ++++++++---------- htdocs/adherents/class/adherent.class.php | 47 ++++++-- htdocs/admin/dict.php | 13 ++- htdocs/core/class/commonobject.class.php | 29 +++-- htdocs/core/lib/functions.lib.php | 36 +++--- .../core/modules/modSocialNetworks.class.php | 2 +- .../install/mysql/migration/10.0.0-11.0.0.sql | 30 ++++- htdocs/install/mysql/tables/llx_adherent.sql | 1 + htdocs/install/mysql/tables/llx_societe.sql | 9 +- htdocs/install/mysql/tables/llx_socpeople.sql | 5 +- htdocs/install/mysql/tables/llx_user.sql | 9 +- htdocs/societe/class/societe.class.php | 8 +- 12 files changed, 183 insertions(+), 113 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 5836bf48332..01e85616f3d 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -66,7 +66,19 @@ if (! empty($conf->mailmanspip->enabled)) $object = new Adherent($db); $extrafields = new ExtraFields($db); - +$sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; +$socialnetworks = array(); +$resql = $db->query($sql); +if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $socialnetworks[$obj->code] = array( + 'rowid' => $obj->rowid, + 'label' => $obj->label, + 'url' => $obj->url, + 'active' => $obj->active, + ); + } +} // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); @@ -302,10 +314,14 @@ if (empty($reshook)) $object->phone_perso = trim(GETPOST("phone_perso", 'alpha')); $object->phone_mobile= trim(GETPOST("phone_mobile", 'alpha')); $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); - $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->socialnetworks = array(); + foreach ($socialnetworks as $key => $value) { + $object->socialnetworks[$key] = trim(GETPOST($key, 'alpha')); + } + //$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->typeid = GETPOST("typeid", 'int'); @@ -448,10 +464,10 @@ if (empty($reshook)) $phone=GETPOST("phone", 'alpha'); $phone_perso=GETPOST("phone_perso", 'alpha'); $phone_mobile=GETPOST("phone_mobile", 'alpha'); - $skype=GETPOST("member_skype", 'alpha'); - $twitter=GETPOST("member_twitter", 'alpha'); - $facebook=GETPOST("member_facebook", 'alpha'); - $linkedin=GETPOST("member_linkedin", 'alpha'); + // $skype=GETPOST("member_skype", 'alpha'); + // $twitter=GETPOST("member_twitter", 'alpha'); + // $facebook=GETPOST("member_facebook", 'alpha'); + // $linkedin=GETPOST("member_linkedin", 'alpha'); $email=preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $login=GETPOST("member_login", 'alpha'); $pass=GETPOST("password", 'alpha'); @@ -478,11 +494,18 @@ if (empty($reshook)) $object->phone = $phone; $object->phone_perso = $phone_perso; $object->phone_mobile= $phone_mobile; + $object->socialnetworks = array(); + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) continue; + $object->socialnetworks[$key] = GETPOST("member_".$key, 'alpha'); + } + } - $object->skype = $skype; - $object->twitter = $twitter; - $object->facebook = $facebook; - $object->linkedin = $linkedin; + // $object->skype = $skype; + // $object->twitter = $twitter; + // $object->facebook = $facebook; + // $object->linkedin = $linkedin; $object->email = $email; $object->login = $login; @@ -1015,29 +1038,12 @@ else // Mobile phone print ''.$langs->trans("PhoneMobile").''; - // Skype - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Skype").''; - } - - // Twitter - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Twitter").''; - } - - // Facebook - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Facebook").''; - } - - // LinkedIn - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("LinkedIn").''; - } + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) continue; + print ''.$langs->trans($value['label']).''; + } + } // Birthday print "".$langs->trans("Birthday")."\n"; @@ -1284,29 +1290,12 @@ else // Mobile phone print ''.$langs->trans("PhoneMobile").'phone_mobile).'">'; - // Skype - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Skype").'skype).'">'; - } - - // Twitter - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Twitter").'twitter).'">'; - } - - // Facebook - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Facebook").'facebook).'">'; - } - - // LinkedIn - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("LinkedIn").'linkedin).'">'; - } + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) continue; + print ''.$langs->trans($value['label']).''; + } + } // Birthday print "".$langs->trans("Birthday")."\n"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7085f08be91..ac9701bc862 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -566,10 +566,11 @@ class Adherent extends CommonObject $sql.= ", country = ".($this->country_id>0?$this->db->escape($this->country_id):"null"); $sql.= ", state_id = ".($this->state_id>0?$this->db->escape($this->state_id):"null"); $sql.= ", email = '".$this->db->escape($this->email)."'"; - $sql.= ", skype = '".$this->db->escape($this->skype)."'"; - $sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; - $sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; - $sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; + $sql.= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + // $sql.= ", skype = '".$this->db->escape($this->skype)."'"; + // $sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; + // $sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; + // $sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null"); $sql.= ", phone_perso = ".($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql.= ", phone_mobile = ".($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null"); @@ -1227,7 +1228,7 @@ class Adherent extends CommonObject $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql.= " d.note_public,"; - $sql.= " d.email, d.skype, d.twitter, d.facebook, d.linkedin, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; + $sql.= " d.email, d.socialnetworks, d.skype, d.twitter, d.facebook, d.linkedin, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql.= " d.datec as datec,"; $sql.= " d.tms as datem,"; @@ -1306,10 +1307,38 @@ class Adherent extends CommonObject $this->phone_mobile = $obj->phone_mobile; $this->email = $obj->email; - $this->skype = $obj->skype; - $this->twitter = $obj->twitter; - $this->facebook = $obj->facebook; - $this->linkedin = $obj->linkedin; + $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; + } + $this->socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + if ($updatesocial) { + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'adherent 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->photo = $obj->photo; $this->statut = $obj->statut; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ff4c3cc6a6b..d466c899d01 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -88,7 +88,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,32,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,37,0,25,0); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,38,0,5,11,0,32,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,37,0,25,0); // Name of SQL tables of dictionaries $tabname=array(); @@ -130,6 +130,7 @@ $tabname[34]= MAIN_DB_PREFIX."c_hrm_function"; $tabname[35]= MAIN_DB_PREFIX."c_exp_tax_cat"; $tabname[36]= MAIN_DB_PREFIX."c_exp_tax_range"; $tabname[37]= MAIN_DB_PREFIX."c_units"; +$tabname[38]= MAIN_DB_PREFIX."c_socialnetworks"; // Dictionary labels $tablib=array(); @@ -170,6 +171,7 @@ $tablib[34]= "DictionaryFunction"; $tablib[35]= "DictionaryExpenseTaxCat"; $tablib[36]= "DictionaryExpenseTaxRange"; $tablib[37]= "DictionaryMeasuringUnits"; +$tablib[38]= "DictionarySocialNetworks"; // Requests to extract data $tabsql=array(); @@ -210,6 +212,7 @@ $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PRE $tabsql[35]= "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c"; $tabsql[36]= "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r"; $tabsql[37]= "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r"; +$tabsql[38]= "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -250,6 +253,7 @@ $tabsqlsort[34]="code ASC"; $tabsqlsort[35]="c.label ASC"; $tabsqlsort[36]="r.fk_c_exp_tax_cat ASC, r.range_ik ASC"; $tabsqlsort[37]="r.unit_type ASC, r.scale ASC, r.code ASC"; +$tabsqlsort[38]="rowid, code ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); @@ -290,6 +294,7 @@ $tabfield[34]= "code,label"; $tabfield[35]= "label"; $tabfield[36]= "range_ik,fk_c_exp_tax_cat"; $tabfield[37]= "code,label,short_label,unit_type,scale"; +$tabfield[38]= "code,label,url,icon"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); @@ -330,6 +335,7 @@ $tabfieldvalue[34]= "code,label"; $tabfieldvalue[35]= "label"; $tabfieldvalue[36]= "range_ik,fk_c_exp_tax_cat"; $tabfieldvalue[37]= "code,label,short_label,unit_type,scale"; +$tabfieldvalue[38]= "code,label,url,icon"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); @@ -371,6 +377,7 @@ $tabfieldinsert[34]= "code,label"; $tabfieldinsert[35]= "label"; $tabfieldinsert[36]= "range_ik,fk_c_exp_tax_cat"; $tabfieldinsert[37]= "code,label,short_label,unit_type,scale"; +$tabfieldinsert[38]= "code,label,url,icon"; // Rowid name of field depending if field is autoincrement on or off.. // Use "" if id field is "rowid" and has autoincrement on @@ -413,6 +420,7 @@ $tabrowid[34]= "rowid"; $tabrowid[35]= ""; $tabrowid[36]= ""; $tabrowid[37]= ""; +$tabrowid[38]= ""; // Condition to show dictionary in setup page $tabcond=array(); @@ -453,6 +461,7 @@ $tabcond[34]= ! empty($conf->hrm->enabled); $tabcond[35]= ! empty($conf->expensereport->enabled); $tabcond[36]= ! empty($conf->expensereport->enabled); $tabcond[37]= ! empty($conf->product->enabled); +$tabcond[38]= ! empty($conf->socialnetworks->enabled); // List of help for fields $tabhelp=array(); @@ -493,6 +502,7 @@ $tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[35] = array(); $tabhelp[36] = array('range_ik'=>$langs->trans('PrevRangeToThisRange')); $tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode")); +$tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc')); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); @@ -533,6 +543,7 @@ $tabfieldcheck[34] = array(); $tabfieldcheck[35] = array(); $tabfieldcheck[36] = array(); $tabfieldcheck[37] = array(); +$tabfieldcheck[38] = array(); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ebfe7f1abee..d8a4d40d20f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -680,16 +680,23 @@ abstract class CommonObject $out.='
'; if (! empty($conf->socialnetworks->enabled)) { - if ($this->skype) $out.=dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); - $outdone++; - if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); - $outdone++; - if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); - $outdone++; - if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); - $outdone++; - if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); - $outdone++; + if (is_array($this->socialnetworks) && count($this->socialnetworks)>0) { + foreach ($this->socialnetworks as $key => $value) { + $out.=dol_print_socialnetworks($value, $this->id, $object->id, $key); + $outdone++; + } + } else { + if ($this->skype) $out.=dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); + $outdone++; + if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); + $outdone++; + if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); + $outdone++; + if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); + $outdone++; + if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); + $outdone++; + } } $out.='
'; @@ -4517,7 +4524,7 @@ abstract class CommonObject $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - + if(empty($reshook)) { dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 03c13a9c230..3563152c80b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2199,42 +2199,42 @@ function dol_print_socialnetworks($value, $cid, $socid, $type) { global $conf,$user,$langs; - $newskype=$value; + $htmllink=$value; if (empty($value)) return ' '; if (! empty($type)) { - $newskype ='
'; - $newskype.=img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright'); - $newskype.=$value; + $htmllink ='
'; + $htmllink.=img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright'); + $htmllink.=$value; if ($type == 'skype') { - $newskype.= ' '; - $newskype.=''; - $newskype.=''; - $newskype.=''; - $newskype.=''; - $newskype.=''; + $htmllink.= ' '; + $htmllink.=''; + $htmllink.=''; + $htmllink.=''; + $htmllink.=''; + $htmllink.=''; } if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type=='skype') { $addlink='AC_SKYPE'; $link=''; if (! empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link=''.img_object($langs->trans("AddAction"), "calendar").''; - $newskype.=($link?' '.$link:''); + $htmllink.=($link?' '.$link:''); } - $newskype.='
'; + $htmllink.='
'; } else { $langs->load("errors"); - $newskype.=img_warning($langs->trans("ErrorBadSocialNetworkValue", $value)); + $htmllink.=img_warning($langs->trans("ErrorBadSocialNetworkValue", $value)); } - return $newskype; + return $htmllink; } /** diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index d8d8d8fb76e..a3fdd612f04 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -62,7 +62,7 @@ class modSocialNetworks extends DolibarrModules $this->dirs = array(); // Config pages - $this->config_page_url = array("socialnetworks.php"); + $this->config_page_url = array(/*"socialnetworks.php"*/); // Dependencies $this->hidden = ! empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index cc375e72714..6c07c48770e 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -94,13 +94,13 @@ ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT; ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL; ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL; - + create table llx_c_hrm_public_holiday ( id integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 0 NOT NULL, -- multi company id, 0 = all - fk_country integer, + fk_country integer, code varchar(62), dayrule varchar(64) DEFAULT '', -- 'easter', 'eastermonday', ... day integer, @@ -163,4 +163,30 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, m INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('IN-REPUBLICDAY', 0, 117, '', 0, 1, 26, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('IN-GANDI', 0, 117, '', 0, 10, 2, 1); +create table llx_c_socialnetworks +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(100), + label varchar(150), + url text, + icon varchar(15), + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; + +ALTER TABLE llx_c_socialnetworks ADD UNIQUE INDEX idx_c_socialnetworks_code (code); + +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-googleplus', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); + +ALTER TABLE llx_adherent ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; +ALTER TABLE llx_societe ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; +ALTER TABLE llx_socpeople ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; +ALTER TABLE llx_user ADD COLUMN socialnetworks text DEFAULT NULL AFTER personal_email; diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 588fb323dae..45c87f25c67 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -48,6 +48,7 @@ create table llx_adherent country integer, email varchar(255), + socialnetworks text DEFAULT NULL, -- json with socialnetworks skype varchar(255), twitter varchar(255), -- facebook varchar(255), -- diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index e7a948d67c2..2c4e075a97e 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -34,7 +34,7 @@ create table llx_societe statut tinyint DEFAULT 0, -- statut parent integer, - status tinyint DEFAULT 1, -- cessation d'activité ( 1 -- en activité, 0 -- cessation d'activité) + status tinyint DEFAULT 1, -- cessation d'activité ( 1 -- en activité, 0 -- cessation d'activité) code_client varchar(24), -- code client code_fournisseur varchar(24), -- code founisseur @@ -50,7 +50,8 @@ create table llx_societe fax varchar(20), -- fax number url varchar(255), -- email varchar(128), -- - + + socialnetworks text DEFAULT NULL, -- json with socialnetworks skype varchar(255), -- twitter varchar(255), -- facebook varchar(255), -- @@ -60,7 +61,7 @@ create table llx_societe googleplus varchar(255), -- youtube varchar(255), -- whatsapp varchar(255), -- - + fk_effectif integer DEFAULT 0, -- fk_typent integer DEFAULT 0, -- fk_forme_juridique integer DEFAULT 0, -- juridical status @@ -111,7 +112,7 @@ create table llx_societe fk_entrepot integer DEFAULT 0, -- if we need a link between third party and warehouse webservices_url varchar(255), -- supplier webservice url webservices_key varchar(128), -- supplier webservice key - + tms timestamp, -- last modification date datec datetime, -- creation date fk_user_creat integer NULL, -- utilisateur qui a cree l'info diff --git a/htdocs/install/mysql/tables/llx_socpeople.sql b/htdocs/install/mysql/tables/llx_socpeople.sql index 4ed401e39da..cb373d015c5 100644 --- a/htdocs/install/mysql/tables/llx_socpeople.sql +++ b/htdocs/install/mysql/tables/llx_socpeople.sql @@ -41,7 +41,8 @@ create table llx_socpeople phone_mobile varchar(30), fax varchar(30), email varchar(255), - + + socialnetworks text DEFAULT NULL, -- json with socialnetworks jabberid varchar(255), skype varchar(255), twitter varchar(255), -- @@ -52,7 +53,7 @@ create table llx_socpeople googleplus varchar(255), -- youtube varchar(255), -- whatsapp varchar(255), -- - + photo varchar(255), no_email smallint NOT NULL DEFAULT 0, -- deprecated. Use table llx_mailing_unsubscribe instead priv smallint NOT NULL DEFAULT 0, diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index ac29410873a..ac2f60faad2 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -24,7 +24,7 @@ create table llx_user ref_ext varchar(50), -- reference into an external system (not used by dolibarr) ref_int varchar(50), -- reference into an internal system (deprecated) - + employee tinyint DEFAULT 1, -- 1 if user is an employee fk_establishment integer DEFAULT 0, @@ -48,14 +48,15 @@ create table llx_user fk_state integer DEFAULT 0, fk_country integer DEFAULT 0, birth date, -- birthday - job varchar(128), + job varchar(128), office_phone varchar(20), office_fax varchar(20), user_mobile varchar(20), personal_mobile varchar(20), email varchar(255), personal_email varchar(255), - + + socialnetworks text DEFAULT NULL, -- json with socialnetworks jabberid varchar(255), skype varchar(255), twitter varchar(255), -- @@ -66,7 +67,7 @@ create table llx_user googleplus varchar(255), -- youtube varchar(255), -- whatsapp varchar(255), -- - + signature text DEFAULT NULL, admin smallint DEFAULT 0, module_comm smallint DEFAULT 1, diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 26ad0c6bed9..89d1308d8af 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1257,7 +1257,9 @@ class Societe extends CommonObject $sql .= ', s.status'; $sql .= ', s.price_level'; $sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif'; - $sql .= ', s.phone, s.fax, s.email, s.skype, s.twitter, s.facebook, s.linkedin, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; + $sql .= ', s.phone, s.fax, s.email'; + $sql .= ', s.socialnetworks, s.skype, s.twitter, s.facebook, s.linkedin'; + $sql .= ', s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; $sql .= ', s.capital, s.tva_intra'; $sql .= ', s.fk_typent as typent_id'; @@ -1309,7 +1311,7 @@ class Societe extends CommonObject $num=$this->db->num_rows($resql); if ($num > 1) { - $this->error='Fetch found several records. Rename one of tirdparties to avoid duplicate.'; + $this->error='Fetch found several records. Rename one of thirdparties to avoid duplicate.'; dol_syslog($this->error, LOG_ERR); $result = -2; } @@ -1355,6 +1357,8 @@ class Societe extends CommonObject $this->twitter = $obj->twitter; $this->facebook = $obj->facebook; $this->linkedin = $obj->linkedin; + $this->socialnetworks = json_decode($obj->socialnetworks); + $this->url = $obj->url; $this->phone = $obj->phone; $this->fax = $obj->fax; From e0f17cc71c65e0635d2cbd95597ea67bec671e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 11 Sep 2019 22:47:23 +0200 Subject: [PATCH 02/47] add socialnetworks dictionary --- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3563152c80b..b59f66ed596 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3016,7 +3016,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (empty($srconly) && in_array($pictowithoutext, array( 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'note', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', - 'jabber','skype','twitter','facebook','linkedin', + 'jabber','skype','twitter','facebook','linkedin','instagram','snapchat','youtube','google-plus-g','whatsapp', 'chevron-left','chevron-right','chevron-down','chevron-top' ) )) { @@ -3133,7 +3133,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithoutext == 'jabber') { $fakey = 'fa-comment-o'; } - elseif (in_array($pictowithoutext, array('skype', 'twitter', 'facebook', 'linkedin'))) { + elseif (in_array($pictowithoutext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram','snapchat','youtube','google-plus-g','whatsapp'))) { $fakey = 'fa-'.$pictowithoutext; if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) $fa = 'fab'; } diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 6c07c48770e..3ffbce43eda 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -181,7 +181,7 @@ INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('twitte INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-googleplus', 1); +INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 1); INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); From dc2ea3cef9aeda14b66e533c22d241318263cc53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 11 Sep 2019 23:00:14 +0200 Subject: [PATCH 03/47] add socialnetworks dictionary --- htdocs/adherents/class/adherent.class.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ac9701bc862..6dbd466b220 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -124,23 +124,32 @@ class Adherent extends CommonObject */ public $email; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; + /** * @var string skype account + * @deprecated */ public $skype; /** * @var string twitter account + * @deprecated */ public $twitter; /** * @var string facebook account + * @deprecated */ public $facebook; /** * @var string linkedin account + * @deprecated */ public $linkedin; @@ -2440,6 +2449,12 @@ class Adherent extends CommonObject $this->twitter = 'twitterpseudo'; $this->facebook = 'facebookpseudo'; $this->linkedin = 'linkedinpseudo'; + $this->socialnetworks = array( + 'skype' => 'skypepseudo', + 'twitter' => 'twitterpseudo', + 'facebook' => 'facebookpseudo', + 'linkedin' => 'linkedinpseudo', + ); $this->phone = '0999999999'; $this->phone_perso = '0999999998'; $this->phone_mobile = '0999999997'; From 3e114768108923d6653466923047136602c52acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 11 Sep 2019 23:09:20 +0200 Subject: [PATCH 04/47] add socialnetworks dictionary --- .../mysql/tables/llx_c_socialnetworks.key.sql | 19 ++++++++++++++ .../mysql/tables/llx_c_socialnetworks.sql | 26 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_c_socialnetworks.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_socialnetworks.sql diff --git a/htdocs/install/mysql/tables/llx_c_socialnetworks.key.sql b/htdocs/install/mysql/tables/llx_c_socialnetworks.key.sql new file mode 100644 index 00000000000..2b7dcdc9d4e --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_socialnetworks.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + + +ALTER TABLE llx_c_socialnetworks ADD UNIQUE INDEX idx_c_socialnetworks_code (code); diff --git a/htdocs/install/mysql/tables/llx_c_socialnetworks.sql b/htdocs/install/mysql/tables/llx_c_socialnetworks.sql new file mode 100644 index 00000000000..2460ca653a0 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_socialnetworks.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +create table llx_c_socialnetworks +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(100), + label varchar(150), + url text, + icon varchar(15), + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; From 9f3c54e5a53c4142105e1d4b85ee83d8cc6fac66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 18:04:24 +0200 Subject: [PATCH 05/47] definitions --- htdocs/contact/class/contact.class.php | 15 +++++++++++++++ htdocs/societe/class/societe.class.php | 11 +++++++++++ htdocs/user/class/user.class.php | 26 ++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ebfafa698b7..e51a3358614 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -98,6 +98,17 @@ class Contact extends CommonObject public $code; public $email; + + /** + * @var array array of socialnetworks + */ + public $socialnetworks; + + /** + * Skype username + * @var string + * @deprecated + */ public $skype; public $photo; public $jabberid; @@ -122,6 +133,10 @@ class Contact extends CommonObject // END MODULEBUILDER PROPERTIES + /** + * Old copy + * @var Contact + */ public $oldcopy; // To contains a clone of this when we need to save old properties of object diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 89d1308d8af..cc01b3700b6 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -197,24 +197,35 @@ class Societe extends CommonObject * @var string */ public $email; + + /** + * @var array array of socialnetworks + */ + public $socialnetworks; + /** * Skype username * @var string + * @deprecated */ public $skype; + /** * Twitter username * @var string + * @deprecated */ public $twitter; /** * Facebook username * @var string + * @deprecated */ public $facebook; /** * LinkedIn username * @var string + * @deprecated */ public $linkedin; /** diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 4d78aa1b892..ad7f8e7ec27 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -72,9 +72,35 @@ class User extends CommonObject public $email; public $personal_email; + + /** + * @var array array of socialnetworks + */ + public $socialnetworks; + + /** + * Skype username + * @var string + * @deprecated + */ public $skype; + /** + * Twitter username + * @var string + * @deprecated + */ public $twitter; + /** + * Facebook username + * @var string + * @deprecated + */ public $facebook; + /** + * Linkedin username + * @var string + * @deprecated + */ public $linkedin; public $job; // job position From 62922884fec8b73de6d7243c6b6092541f72c4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 18:12:28 +0200 Subject: [PATCH 06/47] specimens --- htdocs/contact/class/contact.class.php | 5 ++++- htdocs/societe/class/societe.class.php | 6 ++++++ htdocs/user/class/user.class.php | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e51a3358614..77743ba26d6 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1328,7 +1328,10 @@ class Contact extends CommonObject $this->country_code = 'FR'; $this->country = 'France'; $this->email = 'specimen@specimen.com'; - $this->skype = 'tom.hanson'; + $this->skype = 'tom.hanson'; + $this->socialnetworks = array( + 'skype' => 'tom.hanson', + ); $this->phone_pro = '0909090901'; $this->phone_perso = '0909090902'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index cc01b3700b6..f2d507059b9 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3579,6 +3579,12 @@ class Societe extends CommonObject $this->twitter='tomhanson'; $this->facebook='tomhanson'; $this->linkedin='tomhanson'; + $this->socialnetworks = array( + 'skype' => 'tom.hanson', + 'twitter' => 'tomhanson', + 'facebook' => 'tomhanson', + 'linkedin' => 'tomhanson', + ); $this->url='http://www.specimen.com'; $this->phone='0909090901'; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ad7f8e7ec27..39d4066b84c 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2713,6 +2713,12 @@ class User extends CommonObject $this->twitter='twitterpseudo'; $this->facebook='facebookpseudo'; $this->linkedin='linkedinpseudo'; + $this->socialnetworks = array( + 'skype' => 'skypepseudo', + 'twitter' => 'twitterpseudo', + 'facebook' => 'facebookpseudo', + 'linkedin' => 'linkedinpseudo', + ); $this->office_phone='0999999999'; $this->office_fax='0999999998'; $this->user_mobile='0999999997'; From 34f928556d642c9559520e6e0aadb8753c7e81b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 18:32:47 +0200 Subject: [PATCH 07/47] work on user --- htdocs/user/class/user.class.php | 50 +++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 39d4066b84c..20a2fbb6fc2 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -272,7 +272,8 @@ class User extends CommonObject $login=trim($login); // Get user - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.birth, u.email, u.personal_email, u.job, u.skype, u.twitter, u.facebook, u.linkedin,"; + $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.birth, u.email, u.personal_email, u.job,"; + $sql.= " u.socialnetworks, u.skype, u.twitter, u.facebook, u.linkedin,"; $sql.= " u.signature, u.office_phone, u.office_fax, u.user_mobile, u.personal_mobile,"; $sql.= " u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,"; $sql.= " u.admin, u.login, u.note,"; @@ -379,11 +380,39 @@ class User extends CommonObject $this->user_mobile = $obj->user_mobile; $this->personal_mobile = $obj->personal_mobile; $this->email = $obj->email; - $this->personal_email = $obj->personal_email; - $this->skype = $obj->skype; - $this->twitter = $obj->twitter; - $this->facebook = $obj->facebook; - $this->linkedin = $obj->linkedin; + $this->personal_email = $obj->personal_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; + } + $this->socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + if ($updatesocial) { + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'user 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->job = $obj->job; $this->signature = $obj->signature; $this->admin = $obj->admin; @@ -1576,10 +1605,11 @@ class User extends CommonObject $sql.= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; $sql.= ", email = '".$this->db->escape($this->email)."'"; $sql.= ", personal_email = '".$this->db->escape($this->personal_email)."'"; - $sql.= ", skype = '".$this->db->escape($this->skype)."'"; - $sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; - $sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; - $sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; + $sql.= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + //$sql.= ", skype = '".$this->db->escape($this->skype)."'"; + //$sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; + //$sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; + //$sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; $sql.= ", job = '".$this->db->escape($this->job)."'"; $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; From e4a0de245a313e11974336a2d9b3f894b081822a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 18:41:26 +0200 Subject: [PATCH 08/47] work on user --- htdocs/adherents/class/adherent.class.php | 3 ++- htdocs/user/class/user.class.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6dbd466b220..eb3e225c4d6 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1334,7 +1334,8 @@ class Adherent extends CommonObject $arraysocialnetworks['linkedin'] = $obj->linkedin; $updatesocial = true; } - $this->socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $socialarray = ($obj->socialnetworks==''?array():json_decode($obj->socialnetworks, true)); + $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); if ($updatesocial) { $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'adherent SET skype=null'; $sqlupd .= ', twitter=null'; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 20a2fbb6fc2..cfb79cfc06f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -399,7 +399,8 @@ class User extends CommonObject $arraysocialnetworks['linkedin'] = $obj->linkedin; $updatesocial = true; } - $this->socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $socialarray = ($obj->socialnetworks==''?array():json_decode($obj->socialnetworks, true)); + $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); if ($updatesocial) { $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'user SET skype=null'; $sqlupd .= ', twitter=null'; From fa44af1df8ab4c1d2b1e4e29015fb6384787ee39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 20:03:28 +0200 Subject: [PATCH 09/47] work on user --- htdocs/adherents/card.php | 6 +- htdocs/user/card.php | 191 +++++++++++++++++++++++--------------- 2 files changed, 120 insertions(+), 77 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 01e85616f3d..77c54c5736e 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -66,6 +66,10 @@ if (! empty($conf->mailmanspip->enabled)) $object = new Adherent($db); $extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + $sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; $socialnetworks = array(); $resql = $db->query($sql); @@ -79,8 +83,6 @@ if ($resql) { ); } } -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 13035d1fb0e..ab2d47dbe87 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -100,6 +100,20 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; +$socialnetworks = array(); +$resql = $db->query($sql); +if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $socialnetworks[$obj->code] = array( + 'rowid' => $obj->rowid, + 'label' => $obj->label, + 'url' => $obj->url, + 'active' => $obj->active, + ); + } +} + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('usercard','globalcard')); @@ -212,11 +226,17 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alphanohtml'); $object->user_mobile = GETPOST("user_mobile", 'alphanohtml'); - $object->skype = GETPOST("skype", 'alphanohtml'); - $object->twitter = GETPOST("twitter", 'alphanohtml'); - $object->facebook = GETPOST("facebook", 'alphanohtml'); - $object->linkedin = GETPOST("linkedin", 'alphanohtml'); - + //$object->skype = GETPOST("skype", 'alphanohtml'); + //$object->twitter = GETPOST("twitter", 'alphanohtml'); + //$object->facebook = GETPOST("facebook", 'alphanohtml'); + //$object->linkedin = GETPOST("linkedin", 'alphanohtml'); + $object->socialnetworks = array(); + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) continue; + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature", 'none'); @@ -365,10 +385,17 @@ if (empty($reshook)) { $object->office_phone = GETPOST("office_phone", 'alphanohtml'); $object->office_fax = GETPOST("office_fax", 'alphanohtml'); $object->user_mobile = GETPOST("user_mobile", 'alphanohtml'); - $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 (!$value['active']) continue; + $object->socialnetworks[$key] = GETPOST($key, 'alpha'); + } + } $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature", 'none'); @@ -625,10 +652,10 @@ if (empty($reshook)) { $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE]; $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX]; $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE]; - $ldap_skype = $attribute[$conf->global->LDAP_FIELD_SKYPE]; - $ldap_twitter = $attribute[$conf->global->LDAP_FIELD_TWITTER]; - $ldap_facebook = $attribute[$conf->global->LDAP_FIELD_FACEBOOK]; - $ldap_linkedin = $attribute[$conf->global->LDAP_FIELD_LINKEDIN]; + $ldap_social['skype'] = $attribute[$conf->global->LDAP_FIELD_SKYPE]; + $ldap_social['twitter'] = $attribute[$conf->global->LDAP_FIELD_TWITTER]; + $ldap_social['facebook'] = $attribute[$conf->global->LDAP_FIELD_FACEBOOK]; + $ldap_social['linkedin'] = $attribute[$conf->global->LDAP_FIELD_LINKEDIN]; $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL]; $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; } @@ -1040,73 +1067,87 @@ if ($action == 'create' || $action == 'adduserldap') } print ''; - // Skype - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Skype").''; - print ''; - if (! empty($ldap_skype)) - { - print ''; - print $ldap_skype; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) continue; + print ''.$langs->trans($value['label']).''; + print ''; + if (! empty($ldap_social[$key])) { + print ''; + print $ldap_social[$key]; + } else { + print ''; + } + print ''; } - else - { - print ''; - } - print ''; } + // // Skype + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Skype").''; + // print ''; + // if (! empty($ldap_skype)) + // { + // print ''; + // print $ldap_skype; + // } + // else + // { + // print ''; + // } + // print ''; + // } - // Twitter - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Twitter").''; - print ''; - if (! empty($ldap_twitter)) - { - print ''; - print $ldap_twitter; - } - else - { - print ''; - } - print ''; - } + // // Twitter + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Twitter").''; + // print ''; + // if (! empty($ldap_twitter)) + // { + // print ''; + // print $ldap_twitter; + // } + // else + // { + // print ''; + // } + // print ''; + // } - // Facebook - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Facebook").''; - print ''; - if (! empty($ldap_facebook)) - { - print ''; - print $ldap_facebook; - } - else - { - print ''; - } - print ''; - } + // // Facebook + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Facebook").''; + // print ''; + // if (! empty($ldap_facebook)) + // { + // print ''; + // print $ldap_facebook; + // } + // else + // { + // print ''; + // } + // print ''; + // } - // LinkedIn - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("LinkedIn").''; - print ''; - if (! empty($ldap_linkedin)) - { - print ''; - print $ldap_linkedin; - } - else - { - print ''; - } - print ''; - } + // // LinkedIn + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("LinkedIn").''; + // print ''; + // if (! empty($ldap_linkedin)) + // { + // print ''; + // print $ldap_linkedin; + // } + // else + // { + // print ''; + // } + // print ''; + // } // EMail print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; From cd109d04cdc9076bef5979c95813c411e0140515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 20:44:24 +0200 Subject: [PATCH 10/47] add function --- htdocs/adherents/card.php | 14 +------------- htdocs/core/lib/functions.lib.php | 25 +++++++++++++++++++++++++ htdocs/user/card.php | 14 +------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 77c54c5736e..ce8ade06e09 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -70,19 +70,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -$sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; -$socialnetworks = array(); -$resql = $db->query($sql); -if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $socialnetworks[$obj->code] = array( - 'rowid' => $obj->rowid, - 'label' => $obj->label, - 'url' => $obj->url, - 'active' => $obj->active, - ); - } -} +$socialnetworks = getArrayOfSocialNetworks(); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b59f66ed596..a51118b2c32 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2186,6 +2186,31 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, return $rep; } +/** + * Get array of social network dictionary + * + * @return array Array of Social Networks Dictionary + */ +function getArrayOfSocialNetworks() +{ + global $conf, $db; + $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; + $socialnetworks = array(); + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $socialnetworks[$obj->code] = array( + 'rowid' => $obj->rowid, + 'label' => $obj->label, + 'url' => $obj->url, + 'icon' => $obj->icon, + 'active' => $obj->active, + ); + } + } + return $socialnetworks; +} + /** * Show social network link * diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ab2d47dbe87..e348dfbe273 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -100,19 +100,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -$sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; -$socialnetworks = array(); -$resql = $db->query($sql); -if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $socialnetworks[$obj->code] = array( - 'rowid' => $obj->rowid, - 'label' => $obj->label, - 'url' => $obj->url, - 'active' => $obj->active, - ); - } -} +$socialnetworks = getArrayOfSocialNetworks(); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('usercard','globalcard')); From 6f33874d757c0d3bbd2282e492376463c55400a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 21:13:00 +0200 Subject: [PATCH 11/47] add entity --- htdocs/admin/dict.php | 7 ++++--- htdocs/core/lib/functions.lib.php | 1 + .../install/mysql/migration/10.0.0-11.0.0.sql | 19 ++++++++++--------- htdocs/langs/en_US/admin.lang | 5 +++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d466c899d01..e4af504fcc3 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -11,6 +11,7 @@ * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud + * Copyright (C) 2019 Frédéric France * * 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 @@ -212,7 +213,7 @@ $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PRE $tabsql[35]= "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c"; $tabsql[36]= "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r"; $tabsql[37]= "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r"; -$tabsql[38]= "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; +$tabsql[38]= "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -294,7 +295,7 @@ $tabfield[34]= "code,label"; $tabfield[35]= "label"; $tabfield[36]= "range_ik,fk_c_exp_tax_cat"; $tabfield[37]= "code,label,short_label,unit_type,scale"; -$tabfield[38]= "code,label,url,icon"; +$tabfield[38]= "code,label,url,icon,entity"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); @@ -377,7 +378,7 @@ $tabfieldinsert[34]= "code,label"; $tabfieldinsert[35]= "label"; $tabfieldinsert[36]= "range_ik,fk_c_exp_tax_cat"; $tabfieldinsert[37]= "code,label,short_label,unit_type,scale"; -$tabfieldinsert[38]= "code,label,url,icon"; +$tabfieldinsert[38]= "entity,code,label,url,icon"; // Rowid name of field depending if field is autoincrement on or off.. // Use "" if id field is "rowid" and has autoincrement on diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a51118b2c32..9bb4c239663 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2195,6 +2195,7 @@ function getArrayOfSocialNetworks() { global $conf, $db; $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; + $sql.= " WHERE entity=".$conf->entity; $socialnetworks = array(); $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 3ffbce43eda..fb884afba66 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -166,6 +166,7 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, m create table llx_c_socialnetworks ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, code varchar(100), label varchar(150), url text, @@ -175,15 +176,15 @@ create table llx_c_socialnetworks ALTER TABLE llx_c_socialnetworks ADD UNIQUE INDEX idx_c_socialnetworks_code (code); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); -INSERT INTO llx_c_socialnetworks (code, label, url, icon, active) VALUES('whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); +INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); +INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); +INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); +INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); +INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); +INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 1); +INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); +INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); ALTER TABLE llx_adherent ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; ALTER TABLE llx_societe ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a8f7f9643ce..5fac7433680 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -149,7 +149,7 @@ SystemToolsAreaDesc=This area provides administration functions. Use the menu to Purge=Purge PurgeAreaDesc=This page allows you to delete all files generated or stored by Dolibarr (temporary files or all files in %s directory). Using this feature is not normally necessary. It is provided as a workaround for users whose Dolibarr is hosted by a provider that does not offer permissions to delete files generated by the web server. PurgeDeleteLogFile=Delete log files, including %s defined for Syslog module (no risk of losing data) -PurgeDeleteTemporaryFiles=Delete all temporary files (no risk of losing data). Note: Deletion is done only if the temp directory was created 24 hours ago. +PurgeDeleteTemporaryFiles=Delete all temporary files (no risk of losing data). Note: Deletion is done only if the temp directory was created 24 hours ago. PurgeDeleteTemporaryFilesShort=Delete temporary files PurgeDeleteAllFilesInDocumentsDir=Delete all files in directory: %s.
This will delete all generated documents related to elements (third parties, invoices etc...), files uploaded into the ECM module, database backup dumps and temporary files. PurgeRunNow=Purge now @@ -476,7 +476,7 @@ TheKeyIsTheNameOfHtmlField=This is the name of the HTML field. Technical knowled PageUrlForDefaultValues=You must enter the relative path of the page URL. If you include parameters in URL, the default values will be effective if all parameters are set to same value. PageUrlForDefaultValuesCreate=
Example:
For the form to create a new third party, it is %s.
For URL of external modules installed into custom directory, do not include the "custom/", so use path like mymodule/mypage.php and not custom/mymodule/mypage.php.
If you want default value only if url has some parameter, you can use %s PageUrlForDefaultValuesList=
Example:
For the page that lists third parties, it is %s.
For URL of external modules installed into custom directory, do not include the "custom/" so use a path like mymodule/mypagelist.php and not custom/mymodule/mypagelist.php.
If you want default value only if url has some parameter, you can use %s -AlsoDefaultValuesAreEffectiveForActionCreate=Also note that overwritting default values for form creation works only for pages that were correctly designed (so with parameter action=create or presend...) +AlsoDefaultValuesAreEffectiveForActionCreate=Also note that overwritting default values for form creation works only for pages that were correctly designed (so with parameter action=create or presend...) EnableDefaultValues=Enable customization of default values EnableOverwriteTranslation=Enable usage of overwritten translation GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code. To change this value, you must edit it from Home-Setup-translation. @@ -964,6 +964,7 @@ DictionaryAccountancyJournal=Accounting journals DictionaryEMailTemplates=Email Templates DictionaryUnits=Units DictionaryMeasuringUnits=Measuring Units +DictionarySocialNetworks=Social Networks DictionaryProspectStatus=Prospect status DictionaryHolidayTypes=Types of leave DictionaryOpportunityStatus=Lead status for project/lead From bed959bb383f51b09a4fa6c832fa77198bd31b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 21:17:52 +0200 Subject: [PATCH 12/47] add entity --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 16 ++++++++-------- .../mysql/tables/llx_c_socialnetworks.sql | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index fb884afba66..03cb7cf80f7 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -177,14 +177,14 @@ create table llx_c_socialnetworks ALTER TABLE llx_c_socialnetworks ADD UNIQUE INDEX idx_c_socialnetworks_code (code); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); -INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); -INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); -INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); -INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); -INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); -INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 1); -INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); -INSERT INTO llx_c_socialnetworks (entity,code, label, url, icon, active) VALUES(1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); ALTER TABLE llx_adherent ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; ALTER TABLE llx_societe ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; diff --git a/htdocs/install/mysql/tables/llx_c_socialnetworks.sql b/htdocs/install/mysql/tables/llx_c_socialnetworks.sql index 2460ca653a0..44741a2704f 100644 --- a/htdocs/install/mysql/tables/llx_c_socialnetworks.sql +++ b/htdocs/install/mysql/tables/llx_c_socialnetworks.sql @@ -18,6 +18,7 @@ create table llx_c_socialnetworks ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, code varchar(100), label varchar(150), url text, From 230c14e1890a3533604a83a5ac76267ff5a98e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 12 Sep 2019 22:32:41 +0200 Subject: [PATCH 13/47] add social networks --- .../mysql/data/llx_c_socialnetworks.sql | 55 +++++++++++++++++++ .../install/mysql/migration/10.0.0-11.0.0.sql | 23 ++++++++ 2 files changed, 78 insertions(+) create mode 100644 htdocs/install/mysql/data/llx_c_socialnetworks.sql diff --git a/htdocs/install/mysql/data/llx_c_socialnetworks.sql b/htdocs/install/mysql/data/llx_c_socialnetworks.sql new file mode 100644 index 00000000000..07c993525d8 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_socialnetworks.sql @@ -0,0 +1,55 @@ +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- + +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + +-- socialnetworks + +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'facebook', 'Facebook', 'https://www.facebook.com/{socialid}', 'fa-facebook', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'skype', 'Skype', 'https://www.skype.com/{socialid}', 'fa-skype', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/{socialid}', 'fa-linkedin', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'snapchat', 'Snapchat', '{socialid}', 'fa-snapchat', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'tumblr', 'Tumblr', 'https://www.tumblr.com/{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'vero', 'Vero', 'https://vero.co/{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'viadeo', 'Viadeo', 'https://fr.viadeo.com/fr/{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'slack', 'Slack', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'xing', 'Xing', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'meetup', 'Meetup', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'pinterest', 'Pinterest', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'flickr', 'Flickr', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, '500px', '500px', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'giphy', 'Giphy', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'gifycat', 'Gificat', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'dailymotion', 'Dailymotion', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'vimeo', 'Vimeo', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'periscope', 'Periscope', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'twitch', 'Twitch', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'discord', 'Discord', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'wikipedia', 'Wikipedia', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'reddit', 'Reddit', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'quora', 'Quora', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'tripadvisor', 'Tripadvisor', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'mastodon', 'Mastodon', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'diaspora', 'Diaspora', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'viber', 'Viber', '{socialid}', '', 0); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 03cb7cf80f7..15a06c62927 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -185,6 +185,29 @@ INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus-g', 1); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'tumblr', 'Tumblr', 'https://www.tumblr.com/{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'vero', 'Vero', 'https://vero.co/{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'viadeo', 'Viadeo', 'https://fr.viadeo.com/fr/{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'slack', 'Slack', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'xing', 'Xing', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'meetup', 'Meetup', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'pinterest', 'Pinterest', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'flickr', 'Flickr', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, '500px', '500px', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'giphy', 'Giphy', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'gifycat', 'Gificat', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'dailymotion', 'Dailymotion', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'vimeo', 'Vimeo', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'periscope', 'Periscope', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'twitch', 'Twitch', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'discord', 'Discord', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'wikipedia', 'Wikipedia', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'reddit', 'Reddit', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'quora', 'Quora', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'tripadvisor', 'Tripadvisor', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'mastodon', 'Mastodon', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'diaspora', 'Diaspora', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'viber', 'Viber', '{socialid}', '', 0); ALTER TABLE llx_adherent ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; ALTER TABLE llx_societe ADD COLUMN socialnetworks text DEFAULT NULL AFTER email; From 1cd59cc16aa2b41b8a93379f3bd40c8f36016c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 14 Sep 2019 11:26:31 +0200 Subject: [PATCH 14/47] work on user --- htdocs/adherents/card.php | 6 +- htdocs/contact/card.php | 181 +++++++++++++++---------- htdocs/contact/class/contact.class.php | 130 +++++++++++++----- htdocs/user/card.php | 6 +- 4 files changed, 214 insertions(+), 109 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index ce8ade06e09..1b099a55c10 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -487,7 +487,7 @@ if (empty($reshook)) $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST("member_".$key, 'alpha'); } } @@ -1030,7 +1030,7 @@ else if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; print ''.$langs->trans($value['label']).''; } } @@ -1282,7 +1282,7 @@ else if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; print ''.$langs->trans($value['label']).''; } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 76d0e3911b5..31758db3e15 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -62,6 +62,8 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$socialnetworks = getArrayOfSocialNetworks(); + // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); $objcanvas=null; @@ -186,16 +188,23 @@ 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->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 (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) break; + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } $object->email = GETPOST("email", 'alpha'); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); $object->fax = GETPOST("fax", 'alpha'); - $object->jabberid = GETPOST("jabberid", 'alpha'); $object->priv = GETPOST("priv", 'int'); $object->note_public = GETPOST("note_public", 'none'); $object->note_private = GETPOST("note_private", 'none'); @@ -359,15 +368,21 @@ if (empty($reshook)) $object->country_id = GETPOST("country_id", 'int'); $object->email = GETPOST("email", 'alpha'); - $object->skype = GETPOST("skype", 'alpha'); - $object->twitter = GETPOST("twitter", 'alpha'); - $object->facebook = GETPOST("facebook", 'alpha'); - $object->linkedin = GETPOST("linkedin", 'alpha'); + //$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'); + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) break; + $object->socialnetworks[$key] = GETPOST($key, 'alpha'); + } + } $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); $object->fax = GETPOST("fax", 'alpha'); - $object->jabberid = GETPOST("jabberid", 'alpha'); $object->priv = GETPOST("priv", 'int'); $object->note_public = GETPOST("note_public", 'none'); $object->note_private = GETPOST("note_private", 'none'); @@ -676,39 +691,50 @@ else } print ''; - if (! empty($conf->socialnetworks->enabled)) - { - // Jabber - if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - { - print ''; - print 'jabberid).'">'; - } - // Skype - if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - { - print ''; - print 'skype).'">'; - } - // Twitter - if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - { - print ''; - print 'twitter).'">'; - } - // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''; - print 'facebook).'">'; - } - // LinkedIn - if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - { - print ''; - print 'linkedin).'">'; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) break; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Jabber + // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) + // { + // print ''; + // print 'jabberid).'">'; + // } + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''; + // print 'skype).'">'; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''; + // print 'twitter).'">'; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''; + // print 'facebook).'">'; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''; + // print 'linkedin).'">'; + // } + // } // Visibility print ''; @@ -968,39 +994,50 @@ else } print ''; - if (! empty($conf->socialnetworks->enabled)) - { - // Jabber ID - if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - { - print ''; - print 'jabberid).'">'; - } - // Skype - if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - { - print ''; - print 'skype).'">'; - } - // Twitter - if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - { - print ''; - print 'twitter).'">'; - } - // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''; - print 'facebook).'">'; - } - // LinkedIn - if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - { - print ''; - print 'linkedin).'">'; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) break; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Jabber ID + // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) + // { + // print ''; + // print 'jabberid).'">'; + // } + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''; + // print 'skype).'">'; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''; + // print 'twitter).'">'; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''; + // print 'facebook).'">'; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''; + // print 'linkedin).'">'; + // } + // } // Visibility print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 77743ba26d6..082c178ef12 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -110,8 +110,36 @@ class Contact extends CommonObject * @deprecated */ public $skype; - public $photo; + + /** + * Twitter username + * @var string + * @deprecated + */ + public $twitter; + + /** + * Facebook username + * @var string + * @deprecated + */ + public $facebook; + + /** + * Linkedin username + * @var string + * @deprecated + */ + public $linkedin; + + /** + * Jabber username + * @var string + * @deprecated + */ public $jabberid; + + public $photo; public $phone_pro; public $phone_perso; public $phone_mobile; @@ -357,10 +385,12 @@ class Contact extends CommonObject $sql .= ", poste='".$this->db->escape($this->poste)."'"; $sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", email='".$this->db->escape($this->email)."'"; - $sql .= ", skype='".$this->db->escape($this->skype)."'"; - $sql .= ", twitter='".$this->db->escape($this->twitter)."'"; - $sql .= ", facebook='".$this->db->escape($this->facebook)."'"; - $sql .= ", linkedin='".$this->db->escape($this->linkedin)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + //$sql .= ", jabberid = ".(isset($this->jabberid)?"'".$this->db->escape($this->jabberid)."'":"null"); + //$sql .= ", skype='".$this->db->escape($this->skype)."'"; + //$sql .= ", twitter='".$this->db->escape($this->twitter)."'"; + //$sql .= ", facebook='".$this->db->escape($this->facebook)."'"; + //$sql .= ", linkedin='".$this->db->escape($this->linkedin)."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); @@ -368,7 +398,6 @@ class Contact extends CommonObject $sql .= ", phone = ".(isset($this->phone_pro)?"'".$this->db->escape($this->phone_pro)."'":"null"); $sql .= ", phone_perso = ".(isset($this->phone_perso)?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql .= ", phone_mobile = ".(isset($this->phone_mobile)?"'".$this->db->escape($this->phone_mobile)."'":"null"); - $sql .= ", jabberid = ".(isset($this->jabberid)?"'".$this->db->escape($this->jabberid)."'":"null"); $sql .= ", priv = '".$this->db->escape($this->priv)."'"; $sql .= ", statut = ".$this->db->escape($this->statut); $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL"); @@ -442,29 +471,34 @@ class Contact extends CommonObject $tmpobj->email = $this->email; $usermustbemodified++; } - if ($tmpobj->skype != $this->skype) + if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks))) { - $tmpobj->skype = $this->skype; + $tmpobj->socialnetworks = $this->socialnetworks; $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 ($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); + $result = $tmpobj->update($user, 0, 1, 1, 1); if ($result < 0) { $error++; } } } @@ -716,7 +750,8 @@ class Contact extends CommonObject $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement as state_id,"; $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook, c.linkedin,"; + $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,"; + $sql.= " c.socialnetworks, c.skype, c.twitter, c.facebook, c.linkedin,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; $sql.= " c.import_key,"; @@ -785,11 +820,45 @@ class Contact extends CommonObject $this->phone_mobile = trim($obj->phone_mobile); $this->email = $obj->email; - $this->jabberid = $obj->jabberid; - $this->skype = $obj->skype; - $this->twitter = $obj->twitter; - $this->facebook = $obj->facebook; - $this->linkedin = $obj->linkedin; + $arraysocialnetworks = array(); + $updatesocial = false; + if (!empty($obj->jabberid)) { + $arraysocialnetworks['jabber'] = $obj->jabberid; + $updatesocial = true; + } + 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.'socpeople SET skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', jabberid=null'; + $sqlupd .= ', socialnetworks="'.$this->db->escape(json_encode($this->socialnetworks)).'"'; + $sqlupd .= ' WHERE rowid='.$this->id; + $this->db->query($sqlupd); + } + $this->jabberid = $this->socialnetworks['jabber']; + $this->skype = $this->socialnetworks['skype']; + $this->twitter = $this->socialnetworks['twitter']; + $this->facebook = $this->socialnetworks['facebook']; + $this->linkedin = $this->socialnetworks['linkedin']; $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; @@ -1332,7 +1401,6 @@ class Contact extends CommonObject $this->socialnetworks = array( 'skype' => 'tom.hanson', ); - $this->phone_pro = '0909090901'; $this->phone_perso = '0909090902'; $this->phone_mobile = '0909090903'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e348dfbe273..fa297df75eb 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -221,7 +221,7 @@ if (empty($reshook)) { $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } @@ -380,7 +380,7 @@ if (empty($reshook)) { $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST($key, 'alpha'); } } @@ -1057,7 +1057,7 @@ if ($action == 'create' || $action == 'adduserldap') if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; print ''.$langs->trans($value['label']).''; print ''; if (! empty($ldap_social[$key])) { From 5731f7402532340c4053d4ca09bdc2b81b8d5bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 14 Sep 2019 12:00:39 +0200 Subject: [PATCH 15/47] work on user --- htdocs/user/card.php | 170 ++++++++++++++++++++++++------------------- 1 file changed, 97 insertions(+), 73 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fa297df75eb..6de4271ec83 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -110,7 +110,6 @@ $hookmanager->initHooks(array('usercard','globalcard')); /** * Actions */ - $parameters=array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup); $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -221,7 +220,6 @@ if (empty($reshook)) { $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } @@ -380,7 +378,6 @@ if (empty($reshook)) { $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST($key, 'alpha'); } } @@ -1057,16 +1054,24 @@ if ($action == 'create' || $action == 'adduserldap') if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; - print ''.$langs->trans($value['label']).''; - print ''; - if (! empty($ldap_social[$key])) { - print ''; - print $ldap_social[$key]; + if ($value['active']) { + print ''.$langs->trans($value['label']).''; + print ''; + if (! empty($ldap_social[$key])) { + print ''; + print $ldap_social[$key]; + } else { + print ''; + } + print ''; } else { - print ''; + // if social network is not active but value exist we do not want to loose it + if (! empty($ldap_social[$key])) { + print ''; + } else { + print ''; + } } - print ''; } } // // Skype @@ -2347,73 +2352,92 @@ else } print ''; - // Skype - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Skype").''; - print ''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''.$langs->trans($value['label']).''; + print ''; + if ($caneditfield && empty($object->ldap_sid)) { + print ''; + } else { + print ''; + print $object->socialnetworks[$key]; + } + print ''; + } else { + // if social network is not active but value exist we do not want to loose it + print ''; + } } - else - { - print ''; - print $object->skype; - } - print ''; } - // Twitter - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Twitter").''; - print ''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->twitter; - } - print ''; - } + // // Skype + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Skype").''; + // print ''; + // if ($caneditfield && empty($object->ldap_sid)) + // { + // print ''; + // } + // else + // { + // print ''; + // print $object->skype; + // } + // print ''; + // } - // Facebook - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Facebook").''; - print ''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->facebook; - } - print ''; - } + // // Twitter + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Twitter").''; + // print ''; + // if ($caneditfield && empty($object->ldap_sid)) + // { + // print ''; + // } + // else + // { + // print ''; + // print $object->twitter; + // } + // print ''; + // } - // LinkedIn - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("LinkedIn").''; - print ''; - if ($caneditfield && empty($object->ldap_sid)) - { - print ''; - } - else - { - print ''; - print $object->linkedin; - } - print ''; - } + // // Facebook + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Facebook").''; + // print ''; + // if ($caneditfield && empty($object->ldap_sid)) + // { + // print ''; + // } + // else + // { + // print ''; + // print $object->facebook; + // } + // print ''; + // } + + // // LinkedIn + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("LinkedIn").''; + // print ''; + // if ($caneditfield && empty($object->ldap_sid)) + // { + // print ''; + // } + // else + // { + // print ''; + // print $object->linkedin; + // } + // print ''; + // } // EMail print "".'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; From 79bd426363c858be2722ac31cd9044bd6254a3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 14 Sep 2019 12:52:55 +0200 Subject: [PATCH 16/47] work on user --- htdocs/contact/card.php | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 31758db3e15..83143901148 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -196,7 +196,6 @@ if (empty($reshook)) $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } @@ -375,7 +374,6 @@ if (empty($reshook)) //$object->linkedin = GETPOST("linkedin", 'alpha'); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST($key, 'alpha'); } } @@ -693,13 +691,16 @@ else if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } } } // if (! empty($conf->socialnetworks->enabled)) @@ -996,13 +997,16 @@ else if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } } } // if (! empty($conf->socialnetworks->enabled)) From af63ac40514e6422c1251b823adbe437152767d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 14 Sep 2019 13:31:26 +0200 Subject: [PATCH 17/47] work on contact --- htdocs/adherents/card.php | 1 - htdocs/contact/card.php | 10 +++++++--- htdocs/contact/class/contact.class.php | 4 ++-- test/phpunit/ContactTest.php | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 1b099a55c10..cbc7e5774e9 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -487,7 +487,6 @@ if (empty($reshook)) $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST("member_".$key, 'alpha'); } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 83143901148..d122ae509a7 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -196,7 +196,9 @@ if (empty($reshook)) $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } } } $object->email = GETPOST("email", 'alpha'); @@ -374,7 +376,9 @@ if (empty($reshook)) //$object->linkedin = GETPOST("linkedin", 'alpha'); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - $object->socialnetworks[$key] = GETPOST($key, 'alpha'); + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } } } $object->phone_pro = GETPOST("phone_pro", 'alpha'); @@ -383,7 +387,7 @@ if (empty($reshook)) $object->fax = GETPOST("fax", 'alpha'); $object->priv = GETPOST("priv", 'int'); $object->note_public = GETPOST("note_public", 'none'); - $object->note_private = GETPOST("note_private", 'none'); + $object->note_private = GETPOST("note_private", 'none'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 082c178ef12..2170927d2d7 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -750,8 +750,8 @@ class Contact extends CommonObject $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement as state_id,"; $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,"; - $sql.= " c.socialnetworks, c.skype, c.twitter, c.facebook, c.linkedin,"; + $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; + $sql.= " c.socialnetworks, c.jabberid, c.skype, c.twitter, c.facebook, c.linkedin,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; $sql.= " c.import_key,"; diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index c0ed8d7843f..726b674220a 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -208,6 +208,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobject->fax='New fax'; $localobject->email='newemail@newemail.com'; $localobject->jabberid='New im id'; + $localobject->socialnetworks['jabber']='New im id'; $localobject->default_lang='es_ES'; $result=$localobject->update($localobject->id, $user); From ccaa4cc1f31e73f17157c2c68841b23545b3a161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 14 Sep 2019 16:35:18 +0200 Subject: [PATCH 18/47] work on contact --- htdocs/adherents/card.php | 8 ++++++-- test/phpunit/ContactTest.php | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index cbc7e5774e9..885c3ae2a20 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -306,7 +306,9 @@ if (empty($reshook)) $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); $object->socialnetworks = array(); foreach ($socialnetworks as $key => $value) { - $object->socialnetworks[$key] = trim(GETPOST($key, 'alpha')); + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + $object->socialnetworks[$key] = trim(GETPOST($key, 'alphanohtml')); + } } //$object->skype = trim(GETPOST("skype", 'alpha')); //$object->twitter = trim(GETPOST("twitter", 'alpha')); @@ -487,7 +489,9 @@ if (empty($reshook)) $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - $object->socialnetworks[$key] = GETPOST("member_".$key, 'alpha'); + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + $object->socialnetworks[$key] = GETPOST("member_".$key, 'alphanohtml'); + } } } diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index 726b674220a..cf9ddb07fd0 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -207,7 +207,6 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobject->phone_mobile='New tel mobile'; $localobject->fax='New fax'; $localobject->email='newemail@newemail.com'; - $localobject->jabberid='New im id'; $localobject->socialnetworks['jabber']='New im id'; $localobject->default_lang='es_ES'; @@ -258,8 +257,8 @@ class ContactTest extends PHPUnit\Framework\TestCase $this->assertEquals($localobject->fax, $newobject->fax); print __METHOD__." old=".$localobject->email." new=".$newobject->email."\n"; $this->assertEquals($localobject->email, $newobject->email); - print __METHOD__." old=".$localobject->jabberid." new=".$newobject->jabberid."\n"; - $this->assertEquals($localobject->jabberid, $newobject->jabberid); + print __METHOD__." old=".$localobject->socialnetworks['jabber']." new=".$newobject->socialnetworks['jabber']."\n"; + $this->assertEquals($localobject->socialnetworks['jabber'], $newobject->socialnetworks['jabber']); print __METHOD__." old=".$localobject->default_lang." new=".$newobject->default_lang."\n"; $this->assertEquals($localobject->default_lang, $newobject->default_lang); From 6c8dc75c960d7e459d52faa8a7d031e441e81d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2019 11:20:23 +0200 Subject: [PATCH 19/47] socialnetworks for thirdparties --- htdocs/contact/card.php | 2 +- htdocs/societe/card.php | 201 ++++++++++++++++--------- htdocs/societe/class/societe.class.php | 48 +++++- 3 files changed, 169 insertions(+), 82 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index d122ae509a7..9689a2be18e 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -697,7 +697,7 @@ else foreach ($socialnetworks as $key => $value) { if ($value['active']) { print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ab224245de8..cdc1af37d4e 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -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 ''.$form->editfieldkey('Web', 'url', '', $object, 0).''; print ''; - if (! empty($conf->socialnetworks->enabled)) - { - // Skype - if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - { - print ''.$form->editfieldkey('Skype', 'skype', '', $object, 0).''; - print ''; - print 'skype).'">'; - print ''; - } - // Twitter - if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - { - print ''.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).''; - print ''; - print 'twitter).'">'; - print ''; - } - // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).''; - print ''; - print 'facebook).'">'; - print ''; - } - // LinkedIn - if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - { - print ''.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).''; - print ''; - print 'linkedin).'">'; - print ''; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } } } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''.$form->editfieldkey('Skype', 'skype', '', $object, 0).''; + // print ''; + // print 'skype).'">'; + // print ''; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).''; + // print ''; + // print 'twitter).'">'; + // print ''; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).''; + // print ''; + // print 'facebook).'">'; + // print ''; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).''; + // print ''; + // print 'linkedin).'">'; + // print ''; + // } + // } + // Phone / Fax print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; print ''; @@ -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 ''.$form->editfieldkey('Web', 'url', '', $object, 0).''; print ''; - if (! empty($conf->socialnetworks->enabled)) - { - // Skype - if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - { - print ''.$form->editfieldkey('Skype', 'skype', '', $object, 0).''; - print ''; - } - // Twitter - if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - { - print ''.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).''; - print ''; - } - // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).''; - print ''; - } - // LinkedIn - if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - { - print ''.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).''; - print ''; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } } - } + } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''.$form->editfieldkey('Skype', 'skype', '', $object, 0).''; + // print ''; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''.$form->editfieldkey('Twitter', 'twitter', '', $object, 0).''; + // print ''; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''.$form->editfieldkey('Facebook', 'facebook', '', $object, 0).''; + // print ''; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''.$form->editfieldkey('LinkedIn', 'linkedin', '', $object, 0).''; + // print ''; + // } + // } // Phone / Fax print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ef2f5f66868..3c79e6ff61a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018 Philippe Grand * Copyright (C) 2019 Josep Lluís Amador + * Copyright (C) 2019 Frédéric France * * 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); From 05f3d86921a3b87c882f3cbd2a30cc4caf4cc797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2019 11:48:53 +0200 Subject: [PATCH 20/47] fix? --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3c79e6ff61a..0d44ced2ff0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1384,7 +1384,7 @@ class Societe extends CommonObject $arraysocialnetworks['linkedin'] = $obj->linkedin; $updatesocial = true; } - $socialarray = ($obj->socialnetworks==''?array():json_decode($obj->socialnetworks, true)); + $socialarray = (empty($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'; From cedad3dc269e10b26880374a17faf7fadeff2d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2019 11:56:53 +0200 Subject: [PATCH 21/47] fix? fix? fix --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0d44ced2ff0..6a15de6e97a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1384,7 +1384,7 @@ class Societe extends CommonObject $arraysocialnetworks['linkedin'] = $obj->linkedin; $updatesocial = true; } - $socialarray = (empty($obj->socialnetworks)?array():json_decode($obj->socialnetworks, true)); + $socialarray = ((is_null($obj->socialnetworks) || $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'; From 4bac865205c0c9b33e745e68ad3291850fd3f699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2019 18:40:36 +0200 Subject: [PATCH 22/47] test --- htdocs/societe/class/societe.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6a15de6e97a..0c02ea4dcbd 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1385,7 +1385,11 @@ class Societe extends CommonObject $updatesocial = true; } $socialarray = ((is_null($obj->socialnetworks) || $obj->socialnetworks=='')?array():json_decode($obj->socialnetworks, true)); - $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); + if (is_array($socialarray)) { + $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); + } else { + $this->socialnetworks = $arraysocialnetworks; + } if ($updatesocial) { $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'societe SET skype=null'; $sqlupd .= ', twitter=null'; From 1ef3a676441be253e372c7400971bc598700fa44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2019 19:26:25 +0200 Subject: [PATCH 23/47] test --- htdocs/societe/class/societe.class.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0c02ea4dcbd..20b27c9be41 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1385,11 +1385,7 @@ class Societe extends CommonObject $updatesocial = true; } $socialarray = ((is_null($obj->socialnetworks) || $obj->socialnetworks=='')?array():json_decode($obj->socialnetworks, true)); - if (is_array($socialarray)) { - $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); - } else { - $this->socialnetworks = $arraysocialnetworks; - } + $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); if ($updatesocial) { $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'societe SET skype=null'; $sqlupd .= ', twitter=null'; @@ -3611,10 +3607,10 @@ class Societe extends CommonObject $this->country_id=1; $this->country_code='FR'; $this->email='specimen@specimen.com'; - $this->skype='tom.hanson'; - $this->twitter='tomhanson'; - $this->facebook='tomhanson'; - $this->linkedin='tomhanson'; + // $this->skype='tom.hanson'; + // $this->twitter='tomhanson'; + // $this->facebook='tomhanson'; + // $this->linkedin='tomhanson'; $this->socialnetworks = array( 'skype' => 'tom.hanson', 'twitter' => 'tomhanson', From 1a12c93dc7d9e61d973695edf85c73a80f61f428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2019 20:06:30 +0200 Subject: [PATCH 24/47] test --- htdocs/societe/class/societe.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 20b27c9be41..a8fe31362bc 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1016,10 +1016,10 @@ class Societe extends CommonObject $sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"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"); - $sql .= ",linkedin = ".(! empty($this->linkedin)?"'".$this->db->escape($this->linkedin)."'":"null"); + //$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"); + //$sql .= ",linkedin = ".(! empty($this->linkedin)?"'".$this->db->escape($this->linkedin)."'":"null"); $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); $sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null"); @@ -3607,10 +3607,10 @@ class Societe extends CommonObject $this->country_id=1; $this->country_code='FR'; $this->email='specimen@specimen.com'; - // $this->skype='tom.hanson'; - // $this->twitter='tomhanson'; - // $this->facebook='tomhanson'; - // $this->linkedin='tomhanson'; + $this->skype='tom.hanson'; + $this->twitter='tomhanson'; + $this->facebook='tomhanson'; + $this->linkedin='tomhanson'; $this->socialnetworks = array( 'skype' => 'tom.hanson', 'twitter' => 'tomhanson', From 0735bb58601f0f0889aaaccc5bd520501c81f948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2019 20:21:05 +0200 Subject: [PATCH 25/47] test --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a8fe31362bc..976ff422104 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1384,7 +1384,7 @@ class Societe extends CommonObject $arraysocialnetworks['linkedin'] = $obj->linkedin; $updatesocial = true; } - $socialarray = ((is_null($obj->socialnetworks) || $obj->socialnetworks=='')?array():json_decode($obj->socialnetworks, true)); + $socialarray = ((is_null($obj->socialnetworks) || $obj->socialnetworks=='')?array():(array)json_decode($obj->socialnetworks, true)); $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); if ($updatesocial) { $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'societe SET skype=null'; From 21db14b22a14bc4a8011778a166a42cc95670233 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 29 Sep 2019 18:21:26 +0000 Subject: [PATCH 26/47] Fixing style errors. --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 976ff422104..58114a37cfa 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1384,7 +1384,7 @@ class Societe extends CommonObject $arraysocialnetworks['linkedin'] = $obj->linkedin; $updatesocial = true; } - $socialarray = ((is_null($obj->socialnetworks) || $obj->socialnetworks=='')?array():(array)json_decode($obj->socialnetworks, true)); + $socialarray = ((is_null($obj->socialnetworks) || $obj->socialnetworks=='')?array():(array) json_decode($obj->socialnetworks, true)); $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); if ($updatesocial) { $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'societe SET skype=null'; From c7120e9e31fd29b6fa8dec949c3dfaa652f0aa49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2019 20:36:18 +0200 Subject: [PATCH 27/47] test --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 58114a37cfa..1e764edbdb6 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1384,7 +1384,7 @@ class Societe extends CommonObject $arraysocialnetworks['linkedin'] = $obj->linkedin; $updatesocial = true; } - $socialarray = ((is_null($obj->socialnetworks) || $obj->socialnetworks=='')?array():(array) json_decode($obj->socialnetworks, true)); + $socialarray = (array) json_decode($obj->socialnetworks, true); $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); if ($updatesocial) { $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'societe SET skype=null'; From f32f528bc211a21526228437bf1aef9f4f759644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 30 Sep 2019 19:36:57 +0200 Subject: [PATCH 28/47] fix merge --- htdocs/core/lib/functions.lib.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 811ac2e22f1..e042d93ad36 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3160,13 +3160,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithouttext == 'jabber') { $fakey = 'fa-comment-o'; } -<<<<<<< HEAD - elseif (in_array($pictowithoutext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram','snapchat','youtube','google-plus-g','whatsapp'))) { - $fakey = 'fa-'.$pictowithoutext; -======= - elseif (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin'))) { + elseif (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram','snapchat','youtube','google-plus-g','whatsapp'))) { $fakey = 'fa-'.$pictowithouttext; ->>>>>>> upstream/develop if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) $fa = 'fab'; } // Img for type of views From be051e0f9d39a2aadd2a5262db9d75e8b7ddf963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 00:10:33 +0200 Subject: [PATCH 29/47] work on socpeople list --- htdocs/contact/list.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b0db8b0affb..8dc0fdc91b8 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -70,6 +70,7 @@ $search_phone_mobile=GETPOST("search_phone_mobile", 'alpha'); $search_fax=GETPOST("search_fax", 'alpha'); $search_email=GETPOST("search_email", 'alpha'); $search_no_email=GETPOST("search_no_email", 'int'); +$search_jabberid=GETPOST("search_jabberid", 'alpha'); $search_skype=GETPOST("search_skype", 'alpha'); $search_twitter=GETPOST("search_twitter", 'alpha'); $search_facebook=GETPOST("search_facebook", 'alpha'); @@ -135,6 +136,8 @@ $object = new Contact($db); $hookmanager->initHooks(array('contactlist')); $extrafields = new ExtraFields($db); +$socialnetworks = getArrayOfSocialNetworks(); + // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('contact'); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -230,6 +233,7 @@ if (empty($reshook)) $search_fax=""; $search_email=""; $search_no_email=-1; + $search_jabberid=""; $search_skype=""; $search_twitter=""; $search_facebook=""; @@ -267,7 +271,8 @@ $contactstatic=new Contact($db); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); $sql = "SELECT s.rowid as socid, s.nom as name,"; -$sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email, p.skype,"; +$sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; +$sql.= " p.socialnetworks, p.skype, p.facebook,"; $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql.= " co.code as country_code"; // Add fields from extrafields @@ -327,6 +332,7 @@ if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $sear if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone_pro); if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $search_phone_mobile); if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); +if (strlen($search_jabberid)) $sql.= natural_search('p.jabberid', $search_jabberid); if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype); if (strlen($search_twitter)) $sql.= natural_search('p.twitter', $search_twitter); if (strlen($search_facebook)) $sql.= natural_search('p.facebook', $search_facebook); @@ -766,7 +772,7 @@ while ($i < min($num, $limit)) $obj = $db->fetch_object($result); print ''; - + $arraysocialnetworks = (array) json_decode($obj->socialnetworks, true); $contactstatic->lastname=$obj->lastname; $contactstatic->firstname=''; $contactstatic->id=$obj->rowid; @@ -778,6 +784,7 @@ while ($i < min($num, $limit)) $contactstatic->phone_mobile=$obj->phone_mobile; $contactstatic->zip=$obj->zip; $contactstatic->town=$obj->town; + $contactstatic->socialnetworks = $arraysocialnetworks; // ID if (! empty($arrayfields['p.rowid']['checked'])) @@ -879,31 +886,31 @@ while ($i < min($num, $limit)) // Skype if (! empty($arrayfields['p.skype']['checked'])) { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($obj->skype, $obj->rowid, $obj->socid, 'skype').''; } + if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['skype'], $obj->rowid, $obj->socid, 'skype').''; } if (! $i) $totalarray['nbfield']++; } // Jabber if (! empty($arrayfields['p.jabberid']['checked'])) { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($obj->jabberid, $obj->rowid, $obj->socid, 'jabberid').''; } + if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['jabber'], $obj->rowid, $obj->socid, 'jabberid').''; } if (! $i) $totalarray['nbfield']++; } // Twitter if (! empty($arrayfields['p.twitter']['checked'])) { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($obj->twitter, $obj->rowid, $obj->socid, 'twitter').''; } + if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['twitter'], $obj->rowid, $obj->socid, 'twitter').''; } if (! $i) $totalarray['nbfield']++; } // Facebook if (! empty($arrayfields['p.facebook']['checked'])) { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($obj->facebook, $obj->rowid, $obj->socid, 'facebook').''; } + if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['facebook'], $obj->rowid, $obj->socid, 'facebook').''; } if (! $i) $totalarray['nbfield']++; } // LinkedIn if (! empty($arrayfields['p.linkedin']['checked'])) { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($obj->linkedin, $obj->rowid, $obj->socid, 'linkedin').''; } + if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['linkedin'], $obj->rowid, $obj->socid, 'linkedin').''; } if (! $i) $totalarray['nbfield']++; } // Company From 420d9722805e96e46766931a6299534305594a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 00:35:08 +0200 Subject: [PATCH 30/47] work on socpeople list --- htdocs/contact/list.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 8dc0fdc91b8..ed588e26adc 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -272,7 +272,8 @@ $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(" $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; -$sql.= " p.socialnetworks, p.skype, p.facebook,"; +// socialnetworks->>'$.facebook' as facebook +$sql.= " p.socialnetworks,"; $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql.= " co.code as country_code"; // Add fields from extrafields @@ -332,11 +333,11 @@ if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $sear if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone_pro); if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $search_phone_mobile); if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); -if (strlen($search_jabberid)) $sql.= natural_search('p.jabberid', $search_jabberid); -if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype); -if (strlen($search_twitter)) $sql.= natural_search('p.twitter', $search_twitter); -if (strlen($search_facebook)) $sql.= natural_search('p.facebook', $search_facebook); -if (strlen($search_linkedin)) $sql.= natural_search('p.linkedin', $search_linkedin); +if (strlen($search_jabberid)) $sql.= natural_search("p.socialnetworks->>'$.jabber'", $search_jabberid); +if (strlen($search_skype)) $sql.= natural_search("p.socialnetworks->>'$.skype'", $search_skype); +if (strlen($search_twitter)) $sql.= natural_search("p.socialnetworks->>'$.twitter'", $search_twitter); +if (strlen($search_facebook)) $sql.= natural_search("p.socialnetworks->>'$.facebook'", $search_facebook); +if (strlen($search_linkedin)) $sql.= natural_search("p.socialnetworks->>'$.linkedin'", $search_linkedin); if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip); if (strlen($search_town)) $sql.= natural_search("p.town", $search_town); @@ -653,7 +654,7 @@ if (! empty($arrayfields['p.facebook']['checked'])) print ''; print ''; } -if (! empty($arrayfields['p.linkedin']['checked'])) +if (! empty($arrayfields['p.lp.facebookinkedin']['checked'])) { print ''; print ''; From 0c9956ab96216e67ba8382b6c2e5369e0fe74a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 00:37:10 +0200 Subject: [PATCH 31/47] work on socpeople list --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index ed588e26adc..c60a7ced7e4 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -654,7 +654,7 @@ if (! empty($arrayfields['p.facebook']['checked'])) print ''; print ''; } -if (! empty($arrayfields['p.lp.facebookinkedin']['checked'])) +if (! empty($arrayfields['p.linkedin']['checked'])) { print ''; print ''; From 9755d15f5235071a4f4d101e9d77a87a5b427ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 17:51:44 +0200 Subject: [PATCH 32/47] work on migration script --- .../install/mysql/migration/10.0.0-11.0.0.sql | 2 +- .../mysql/tables/llx_c_socialnetworks.sql | 2 +- htdocs/install/upgrade2.php | 70 +++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index a7aeaf4b6ea..4f0cd4d39a9 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -203,7 +203,7 @@ create table llx_c_socialnetworks code varchar(100), label varchar(150), url text, - icon varchar(15), + icon varchar(20), active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_c_socialnetworks.sql b/htdocs/install/mysql/tables/llx_c_socialnetworks.sql index 44741a2704f..b2d0b44c371 100644 --- a/htdocs/install/mysql/tables/llx_c_socialnetworks.sql +++ b/htdocs/install/mysql/tables/llx_c_socialnetworks.sql @@ -22,6 +22,6 @@ create table llx_c_socialnetworks code varchar(100), label varchar(150), url text, - icon varchar(15), + icon varchar(20), active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 24d73da5485..c2b12b23d43 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -448,6 +448,16 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a { migrate_user_photospath(); } + + // Scripts for 11.0 + $afterversionarray=explode('.', '10.0.9'); + $beforeversionarray=explode('.', '11.0.9'); + if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { + migrate_users_socialnetworks(); + migrate_members_socialnetworks(); + migrate_contacts_socialnetworks(); + migrate_thirdparties_socialnetworks(); + } } // Code executed only if migration is LAST ONE. Must always be done. @@ -4925,3 +4935,63 @@ On les corrige: update llx_facture set paye=1, fk_statut=2 where close_code is null and rowid in (...) */ + +/** + * Migrate users fields facebook and co to socialnetworks + * + * @return void + */ +function migrate_users_socialnetworks() +{ + global $db, $langs; + + print ''; + + print ''.$langs->trans('MigrationUsersSocialNetworks')."
\n"; + print ''; +} + +/** + * Migrate members fields facebook and co to socialnetworks + * + * @return void + */ +function migrate_members_socialnetworks() +{ + global $db, $langs; + + print ''; + + print ''.$langs->trans('MigrationMembersSocialNetworks')."
\n"; + print ''; +} + +/** + * Migrate contacts fields facebook and co to socialnetworks + * + * @return void + */ +function migrate_contacts_socialnetworks() +{ + global $db, $langs; + + print ''; + + print ''.$langs->trans('MigrationContactsSocialNetworks')."
\n"; + print ''; +} + +/** + * Migrate thirdpartie fields facebook and co to socialnetworks + * + * @return void + */ +function migrate_thirdparties_socialnetworks() +{ + global $db, $langs; + + print ''; + + print ''.$langs->trans('MigrationThirdpartiesSocialNetworks')."
\n"; + print ''; +} From 5821caa7fcfa34fa256b0933e242e0466bfed0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 18:02:39 +0200 Subject: [PATCH 33/47] work on migration script --- htdocs/langs/en_US/install.lang | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 3ef3532a08e..cfd95d879b7 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -205,6 +205,10 @@ MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_exce MigrationUserRightsEntity=Update entity field value of llx_user_rights MigrationUserGroupRightsEntity=Update entity field value of llx_usergroup_rights MigrationUserPhotoPath=Migration of photo paths for users +MigrationUsersSocialNetworks=Migration of users fields social networks +MigrationMembersSocialNetworks=Migration of members fields social networks +MigrationContactsSocialNetworks=Migration of contacts fields social networks +MigrationThirdpartiesSocialNetworks=Migration of thirdparties fields social networks MigrationReloadModule=Reload module %s MigrationResetBlockedLog=Reset module BlockedLog for v7 algorithm ShowNotAvailableOptions=Show unavailable options From 2ac908ffcf6632d77f2d002b3dd8e9b7a49e9e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 19:59:49 +0200 Subject: [PATCH 34/47] work on migration script --- htdocs/install/upgrade2.php | 17 ++++++++- htdocs/user/class/user.class.php | 64 +++----------------------------- 2 files changed, 20 insertions(+), 61 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index c2b12b23d43..26646937656 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4944,9 +4944,21 @@ and rowid in (...) function migrate_users_socialnetworks() { global $db, $langs; + // jabberid,skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp print ''; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks=JSON_OBJECT('; + $sql.= '"skype", skype,'; + $sql.= '"twitter", twitter,'; + $sql.= '"facebook", facebook,'; + $sql.= '"linkedin", linkedin,'; + $sql.= '"instagram", instagram,'; + $sql.= '"snapchat", snapchat,'; + $sql.= '"googleplus", googleplus,'; + $sql.= '"youtube", youtube,'; + $sql.= '"whatsapp", whatsapp)'; + //print $sql; + $db->query($sql); print ''.$langs->trans('MigrationUsersSocialNetworks')."
\n"; print ''; } @@ -4982,13 +4994,14 @@ function migrate_contacts_socialnetworks() } /** - * Migrate thirdpartie fields facebook and co to socialnetworks + * Migrate thirdparties fields facebook and co to socialnetworks * * @return void */ function migrate_thirdparties_socialnetworks() { global $db, $langs; + // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp print ''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 34a820564b5..fed147e0e98 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -275,7 +275,7 @@ class User extends CommonObject // Get user $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.birth, u.email, u.personal_email, u.job,"; - $sql.= " u.socialnetworks, u.skype, u.twitter, u.facebook, u.linkedin,"; + $sql.= " u.socialnetworks,"; $sql.= " u.signature, u.office_phone, u.office_fax, u.user_mobile, u.personal_mobile,"; $sql.= " u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,"; $sql.= " u.admin, u.login, u.note,"; @@ -383,39 +383,7 @@ class User extends CommonObject $this->personal_mobile = $obj->personal_mobile; $this->email = $obj->email; $this->personal_email = $obj->personal_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.'user 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->socialnetworks = (array) json_decode($obj->socialnetworks, true); $this->job = $obj->job; $this->signature = $obj->signature; $this->admin = $obj->admin; @@ -1334,10 +1302,7 @@ class User extends CommonObject $this->firstname = $contact->firstname; $this->gender = $contact->gender; $this->email = $contact->email; - $this->skype = $contact->skype; - $this->twitter = $contact->twitter; - $this->facebook = $contact->facebook; - $this->linkedin = $contact->linkedin; + $this->socialnetworks = $contact->socialnetworks; $this->office_phone = $contact->phone_pro; $this->office_fax = $contact->fax; $this->user_mobile = $contact->phone_mobile; @@ -1554,11 +1519,6 @@ class User extends CommonObject $this->email = trim($this->email); $this->personal_email = trim($this->personal_email); - $this->skype = trim($this->skype); - $this->twitter = trim($this->twitter); - $this->facebook = trim($this->facebook); - $this->linkedin = trim($this->linkedin); - $this->job = trim($this->job); $this->signature = trim($this->signature); $this->note = trim($this->note); @@ -1611,10 +1571,6 @@ class User extends CommonObject $sql.= ", email = '".$this->db->escape($this->email)."'"; $sql.= ", personal_email = '".$this->db->escape($this->personal_email)."'"; $sql.= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; - //$sql.= ", skype = '".$this->db->escape($this->skype)."'"; - //$sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; - //$sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; - //$sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; $sql.= ", job = '".$this->db->escape($this->job)."'"; $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; @@ -1703,10 +1659,7 @@ class User extends CommonObject $adh->email=$this->email; - $adh->skype=$this->skype; - $adh->twitter=$this->twitter; - $adh->facebook=$this->facebook; - $adh->linkedin=$this->linkedin; + $adh->socialnetworks=$this->socialnetworks; $adh->phone=$this->office_phone; $adh->phone_mobile=$this->user_mobile; @@ -1756,10 +1709,7 @@ class User extends CommonObject $tmpobj->email=$this->email; - $tmpobj->skype=$this->skype; - $tmpobj->twitter=$this->twitter; - $tmpobj->facebook=$this->facebook; - $tmpobj->linkedin=$this->linkedin; + $tmpobj->socialnetworks=$this->socialnetworks; $tmpobj->phone_pro=$this->office_phone; $tmpobj->phone_mobile=$this->user_mobile; @@ -2758,10 +2708,6 @@ class User extends CommonObject $this->note='This is a note'; $this->email='email@specimen.com'; $this->personal_email='personalemail@specimen.com'; - $this->skype='skypepseudo'; - $this->twitter='twitterpseudo'; - $this->facebook='facebookpseudo'; - $this->linkedin='linkedinpseudo'; $this->socialnetworks = array( 'skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', From 010b2723b68cc245d98c5332922758214ce6cd03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 20:14:06 +0200 Subject: [PATCH 35/47] work on migration script --- htdocs/adherents/class/adherent.class.php | 54 ++---------------- htdocs/contact/class/contact.class.php | 47 +--------------- htdocs/install/upgrade2.php | 68 +++++++++++++++++------ htdocs/societe/class/societe.class.php | 58 +------------------ 4 files changed, 60 insertions(+), 167 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index eb07cddd4d7..5063af6c960 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -576,10 +576,6 @@ class Adherent extends CommonObject $sql.= ", state_id = ".($this->state_id>0?$this->db->escape($this->state_id):"null"); $sql.= ", email = '".$this->db->escape($this->email)."'"; $sql.= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; - // $sql.= ", skype = '".$this->db->escape($this->skype)."'"; - // $sql.= ", twitter = '".$this->db->escape($this->twitter)."'"; - // $sql.= ", facebook = '".$this->db->escape($this->facebook)."'"; - // $sql.= ", linkedin = '".$this->db->escape($this->linkedin)."'"; $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null"); $sql.= ", phone_perso = ".($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql.= ", phone_mobile = ".($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null"); @@ -703,10 +699,7 @@ class Adherent extends CommonObject $luser->state_id=$this->state_id; $luser->email=$this->email; - $luser->skype=$this->skype; - $luser->twitter=$this->twitter; - $luser->facebook=$this->facebook; - $luser->linkedin=$this->linkedin; + $luser->socialnetworks=$this->socialnetworks; $luser->office_phone=$this->phone; $luser->user_mobile=$this->phone_mobile; @@ -745,10 +738,7 @@ class Adherent extends CommonObject $lthirdparty->zip=$this->zip; $lthirdparty->town=$this->town; $lthirdparty->email=$this->email; - $lthirdparty->skype=$this->skype; - $lthirdparty->twitter=$this->twitter; - $lthirdparty->facebook=$this->facebook; - $lthirdparty->linkedin=$this->linkedin; + $lthirdparty->socialnetworks=$this->socialnetworks; $lthirdparty->phone=$this->phone; $lthirdparty->state_id=$this->state_id; $lthirdparty->country_id=$this->country_id; @@ -1237,7 +1227,7 @@ class Adherent extends CommonObject $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql.= " d.note_public,"; - $sql.= " d.email, d.socialnetworks, d.skype, d.twitter, d.facebook, d.linkedin, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; + $sql.= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql.= " d.datec as datec,"; $sql.= " d.tms as datem,"; @@ -1316,39 +1306,7 @@ class Adherent extends CommonObject $this->phone_mobile = $obj->phone_mobile; $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.'adherent 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->socialnetworks = (array) json_decode($obj->socialnetworks, true); $this->photo = $obj->photo; $this->statut = $obj->statut; @@ -2444,10 +2402,6 @@ class Adherent extends CommonObject $this->country = 'France'; $this->morphy = 'mor'; $this->email = 'specimen@specimen.com'; - $this->skype = 'skypepseudo'; - $this->twitter = 'twitterpseudo'; - $this->facebook = 'facebookpseudo'; - $this->linkedin = 'linkedinpseudo'; $this->socialnetworks = array( 'skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index a3e026c37f5..1f6fc8f34ae 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -386,11 +386,6 @@ class Contact extends CommonObject $sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", email='".$this->db->escape($this->email)."'"; $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; - //$sql .= ", jabberid = ".(isset($this->jabberid)?"'".$this->db->escape($this->jabberid)."'":"null"); - //$sql .= ", skype='".$this->db->escape($this->skype)."'"; - //$sql .= ", twitter='".$this->db->escape($this->twitter)."'"; - //$sql .= ", facebook='".$this->db->escape($this->facebook)."'"; - //$sql .= ", linkedin='".$this->db->escape($this->linkedin)."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); @@ -751,7 +746,7 @@ class Contact extends CommonObject $sql.= " c.fk_departement as state_id,"; $sql.= " c.birthday,"; $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; - $sql.= " c.socialnetworks, c.jabberid, c.skype, c.twitter, c.facebook, c.linkedin,"; + $sql.= " c.socialnetworks,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; $sql.= " c.import_key,"; @@ -820,45 +815,7 @@ class Contact extends CommonObject $this->phone_mobile = trim($obj->phone_mobile); $this->email = $obj->email; - $arraysocialnetworks = array(); - $updatesocial = false; - if (!empty($obj->jabberid)) { - $arraysocialnetworks['jabber'] = $obj->jabberid; - $updatesocial = true; - } - 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.'socpeople SET skype=null'; - $sqlupd .= ', twitter=null'; - $sqlupd .= ', facebook=null'; - $sqlupd .= ', linkedin=null'; - $sqlupd .= ', jabberid=null'; - $sqlupd .= ', socialnetworks="'.$this->db->escape(json_encode($this->socialnetworks)).'"'; - $sqlupd .= ' WHERE rowid='.$this->id; - $this->db->query($sqlupd); - } - $this->jabberid = $this->socialnetworks['jabber']; - $this->skype = $this->socialnetworks['skype']; - $this->twitter = $this->socialnetworks['twitter']; - $this->facebook = $this->socialnetworks['facebook']; - $this->linkedin = $this->socialnetworks['linkedin']; + $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 26646937656..3a6d76e30ef 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4944,21 +4944,21 @@ and rowid in (...) function migrate_users_socialnetworks() { global $db, $langs; - // jabberid,skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp print ''; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks=JSON_OBJECT('; - $sql.= '"skype", skype,'; - $sql.= '"twitter", twitter,'; - $sql.= '"facebook", facebook,'; - $sql.= '"linkedin", linkedin,'; - $sql.= '"instagram", instagram,'; - $sql.= '"snapchat", snapchat,'; - $sql.= '"googleplus", googleplus,'; - $sql.= '"youtube", youtube,'; - $sql.= '"whatsapp", whatsapp)'; - //print $sql; - $db->query($sql); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks=JSON_OBJECT('; + $sql.= '"skype", skype,'; + $sql.= '"twitter", twitter,'; + $sql.= '"facebook", facebook,'; + $sql.= '"linkedin", linkedin,'; + $sql.= '"instagram", instagram,'; + $sql.= '"snapchat", snapchat,'; + $sql.= '"googleplus", googleplus,'; + $sql.= '"youtube", youtube,'; + $sql.= '"whatsapp", whatsapp)'; + //print $sql; + $db->query($sql); print ''.$langs->trans('MigrationUsersSocialNetworks')."
\n"; print ''; } @@ -4973,7 +4973,18 @@ function migrate_members_socialnetworks() global $db, $langs; print ''; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.'adherent SET socialnetworks=JSON_OBJECT('; + $sql.= '"skype", skype,'; + $sql.= '"twitter", twitter,'; + $sql.= '"facebook", facebook,'; + $sql.= '"linkedin", linkedin,'; + $sql.= '"instagram", instagram,'; + $sql.= '"snapchat", snapchat,'; + $sql.= '"googleplus", googleplus,'; + $sql.= '"youtube", youtube,'; + $sql.= '"whatsapp", whatsapp)'; + //print $sql; + $db->query($sql); print ''.$langs->trans('MigrationMembersSocialNetworks')."
\n"; print ''; } @@ -4986,9 +4997,21 @@ function migrate_members_socialnetworks() function migrate_contacts_socialnetworks() { global $db, $langs; - + // jabberid,skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp print ''; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.'socpeople SET socialnetworks=JSON_OBJECT('; + $sql.= '"jabber", jabberid,'; + $sql.= '"skype", skype,'; + $sql.= '"twitter", twitter,'; + $sql.= '"facebook", facebook,'; + $sql.= '"linkedin", linkedin,'; + $sql.= '"instagram", instagram,'; + $sql.= '"snapchat", snapchat,'; + $sql.= '"googleplus", googleplus,'; + $sql.= '"youtube", youtube,'; + $sql.= '"whatsapp", whatsapp)'; + //print $sql; + $db->query($sql); print ''.$langs->trans('MigrationContactsSocialNetworks')."
\n"; print ''; } @@ -5004,7 +5027,18 @@ function migrate_thirdparties_socialnetworks() // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp print ''; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe SET socialnetworks=JSON_OBJECT('; + $sql.= '"skype", skype,'; + $sql.= '"twitter", twitter,'; + $sql.= '"facebook", facebook,'; + $sql.= '"linkedin", linkedin,'; + $sql.= '"instagram", instagram,'; + $sql.= '"snapchat", snapchat,'; + $sql.= '"googleplus", googleplus,'; + $sql.= '"youtube", youtube,'; + $sql.= '"whatsapp", whatsapp)'; + //print $sql; + $db->query($sql); print ''.$langs->trans('MigrationThirdpartiesSocialNetworks')."
\n"; print ''; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5b173707b74..32e7fc468f8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -871,10 +871,6 @@ class Societe extends CommonObject $this->fax = preg_replace("/\s/", "", $this->fax); $this->fax = preg_replace("/\./", "", $this->fax); $this->email = trim($this->email); - $this->skype = trim($this->skype); - $this->twitter = trim($this->twitter); - $this->facebook = trim($this->facebook); - $this->linkedin = trim($this->linkedin); $this->url = $this->url?clean_url($this->url, 0):''; $this->note_private = trim($this->note_private); $this->note_public = trim($this->note_public); @@ -1016,10 +1012,6 @@ class Societe extends CommonObject $sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"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"); - //$sql .= ",linkedin = ".(! empty($this->linkedin)?"'".$this->db->escape($this->linkedin)."'":"null"); $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); $sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null"); @@ -1160,10 +1152,7 @@ class Societe extends CommonObject $lmember->zip=$this->zip; $lmember->town=$this->town; $lmember->email=$this->email; - $lmember->skype=$this->skype; - $lmember->twitter=$this->twitter; - $lmember->facebook=$this->facebook; - $lmember->linkedin=$this->linkedin; + $lmember->socialnetworks=$this->socialnetworks; $lmember->phone=$this->phone; $lmember->state_id=$this->state_id; $lmember->country_id=$this->country_id; @@ -1271,7 +1260,7 @@ class Societe extends CommonObject $sql .= ', s.price_level'; $sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif'; $sql .= ', s.phone, s.fax, s.email'; - $sql .= ', s.socialnetworks, s.skype, s.twitter, s.facebook, s.linkedin'; + $sql .= ', s.socialnetworks'; $sql .= ', s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; $sql .= ', s.capital, s.tva_intra'; @@ -1366,40 +1355,7 @@ class Societe extends CommonObject $this->statut_commercial = $libelle; // libelle statut commercial $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 = (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->socialnetworks = (array) json_decode($obj->socialnetworks, true); $this->url = $obj->url; $this->phone = $obj->phone; @@ -3438,10 +3394,6 @@ class Societe extends CommonObject $this->country_id=$member->country_id; $this->phone=$member->phone; // Prof phone $this->email=$member->email; - $this->skype=$member->skype; - $this->twitter=$member->twitter; - $this->facebook=$member->facebook; - $this->linkedin=$member->linkedin; $this->socialnetworks = $member->socialnetworks; $this->client = 1; // A member is a customer by default @@ -3607,10 +3559,6 @@ class Societe extends CommonObject $this->country_id=1; $this->country_code='FR'; $this->email='specimen@specimen.com'; - $this->skype='tom.hanson'; - $this->twitter='tomhanson'; - $this->facebook='tomhanson'; - $this->linkedin='tomhanson'; $this->socialnetworks = array( 'skype' => 'tom.hanson', 'twitter' => 'tomhanson', From 872a1f42eb31ea12801489ce0dc3ef561464da52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 20:51:49 +0200 Subject: [PATCH 36/47] list contacts with all fields --- htdocs/contact/list.php | 143 ++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 85 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index c60a7ced7e4..8056b5c076c 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -40,6 +40,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "suppliers", "categories")); +$socialnetworks = getArrayOfSocialNetworks(); + $action=GETPOST('action', 'alpha'); $massaction=GETPOST('massaction', 'alpha'); $show_files=GETPOST('show_files', 'int'); @@ -70,11 +72,13 @@ $search_phone_mobile=GETPOST("search_phone_mobile", 'alpha'); $search_fax=GETPOST("search_fax", 'alpha'); $search_email=GETPOST("search_email", 'alpha'); $search_no_email=GETPOST("search_no_email", 'int'); -$search_jabberid=GETPOST("search_jabberid", 'alpha'); -$search_skype=GETPOST("search_skype", 'alpha'); -$search_twitter=GETPOST("search_twitter", 'alpha'); -$search_facebook=GETPOST("search_facebook", 'alpha'); -$search_linkedin=GETPOST("search_linkedin", 'alpha'); +if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + $search_{$key} = GETPOST("search_".$key, 'alpha'); + } + } +} $search_priv=GETPOST("search_priv", 'alpha'); $search_categ=GETPOST("search_categ", 'int'); $search_categ_thirdparty=GETPOST("search_categ_thirdparty", 'int'); @@ -136,8 +140,6 @@ $object = new Contact($db); $hookmanager->initHooks(array('contactlist')); $extrafields = new ExtraFields($db); -$socialnetworks = getArrayOfSocialNetworks(); - // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('contact'); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -168,11 +170,6 @@ $arrayfields=array( 'p.fax'=>array('label'=>"Fax", 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'checked'=>1), 'p.no_email'=>array('label'=>"No_Email", 'checked'=>0, 'enabled'=>(! empty($conf->mailing->enabled))), - 'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), - 'p.jabberid'=>array('label'=>"Jabber", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), - 'p.twitter'=>array('label'=>"Twitter", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), - 'p.facebook'=>array('label'=>"Facebook", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), - 'p.linkedin'=>array('label'=>"LinkedIn", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.thirdparty'=>array('label'=>"ThirdParty", 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200), 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), @@ -180,6 +177,16 @@ $arrayfields=array( 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); +if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + $arrayfields['p.'.$key] = array( + 'label' => $value['label'], + 'checked' => 0, + ); + } + } +} // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -233,11 +240,13 @@ if (empty($reshook)) $search_fax=""; $search_email=""; $search_no_email=-1; - $search_jabberid=""; - $search_skype=""; - $search_twitter=""; - $search_facebook=""; - $search_linkedin=""; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + $search_{$key} = ""; + } + } + } $search_priv=""; $search_status=-1; $search_categ=''; @@ -333,11 +342,13 @@ if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $sear if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone_pro); if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $search_phone_mobile); if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); -if (strlen($search_jabberid)) $sql.= natural_search("p.socialnetworks->>'$.jabber'", $search_jabberid); -if (strlen($search_skype)) $sql.= natural_search("p.socialnetworks->>'$.skype'", $search_skype); -if (strlen($search_twitter)) $sql.= natural_search("p.socialnetworks->>'$.twitter'", $search_twitter); -if (strlen($search_facebook)) $sql.= natural_search("p.socialnetworks->>'$.facebook'", $search_facebook); -if (strlen($search_linkedin)) $sql.= natural_search("p.socialnetworks->>'$.linkedin'", $search_linkedin); +if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active'] && strlen($search_{$key})) { + $sql.= natural_search("p.socialnetworks->>'$.".$key."'", $search_{$key}); + } + } +} if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip); if (strlen($search_town)) $sql.= natural_search("p.town", $search_town); @@ -630,35 +641,17 @@ if (! empty($arrayfields['p.no_email']['checked'])) print $form->selectarray('search_no_email', array('-1'=>'', '0'=>$langs->trans('No'), '1'=>$langs->trans('Yes')), $search_no_email); print ''; } -if (! empty($arrayfields['p.skype']['checked'])) -{ - print ''; - print ''; - print ''; -} -if (! empty($arrayfields['p.jabberid']['checked'])) -{ - print ''; - print ''; - print ''; -} -if (! empty($arrayfields['p.twitter']['checked'])) -{ - print ''; - print ''; - print ''; -} -if (! empty($arrayfields['p.facebook']['checked'])) -{ - print ''; - print ''; - print ''; -} -if (! empty($arrayfields['p.linkedin']['checked'])) -{ - print ''; - print ''; - print ''; +if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + if (! empty($arrayfields['p.'.$key]['checked'])) + { + print ''; + print ''; + print ''; + } + } + } } if (! empty($arrayfields['p.thirdparty']['checked'])) { @@ -732,11 +725,13 @@ if (! empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field if (! empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'], $_SERVER["PHP_SELF"], "p.fax", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($arrayfields['p.skype']['label'], $_SERVER["PHP_SELF"], "p.skype", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.jabberid']['checked'])) print_liste_field_titre($arrayfields['p.jabberid']['label'], $_SERVER["PHP_SELF"], "p.jabberid", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.twitter']['checked'])) print_liste_field_titre($arrayfields['p.twitter']['label'], $_SERVER["PHP_SELF"], "p.twitter", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.facebook']['checked'])) print_liste_field_titre($arrayfields['p.facebook']['label'], $_SERVER["PHP_SELF"], "p.facebook", $begin, $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['p.linkedin']['checked'])) print_liste_field_titre($arrayfields['p.linkedin']['label'], $_SERVER["PHP_SELF"], "p.linkedin", $begin, $param, '', $sortfield, $sortorder); +if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active'] && ! empty($arrayfields['p.'.$key]['checked'])) { + print_liste_field_titre($arrayfields['p.'.$key]['label'], $_SERVER["PHP_SELF"], "p.".$key, $begin, $param, '', $sortfield, $sortorder); + } + } +} if (! empty($arrayfields['p.thirdparty']['checked'])) print_liste_field_titre($arrayfields['p.thirdparty']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.priv']['checked'])) print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); // Extra fields @@ -884,36 +879,14 @@ while ($i < min($num, $limit)) print ''.yn($obj->no_email).''; if (! $i) $totalarray['nbfield']++; } - // Skype - if (! empty($arrayfields['p.skype']['checked'])) - { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['skype'], $obj->rowid, $obj->socid, 'skype').''; } - if (! $i) $totalarray['nbfield']++; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active'] && ! empty($arrayfields['p.'.$key]['checked'])) { + print ''.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key).''; + if (! $i) $totalarray['nbfield']++; + } + } } - // Jabber - if (! empty($arrayfields['p.jabberid']['checked'])) - { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['jabber'], $obj->rowid, $obj->socid, 'jabberid').''; } - if (! $i) $totalarray['nbfield']++; - } - // Twitter - if (! empty($arrayfields['p.twitter']['checked'])) - { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['twitter'], $obj->rowid, $obj->socid, 'twitter').''; } - if (! $i) $totalarray['nbfield']++; - } - // Facebook - if (! empty($arrayfields['p.facebook']['checked'])) - { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['facebook'], $obj->rowid, $obj->socid, 'facebook').''; } - if (! $i) $totalarray['nbfield']++; - } - // LinkedIn - if (! empty($arrayfields['p.linkedin']['checked'])) - { - if (! empty($conf->socialnetworks->enabled)) { print ''.dol_print_socialnetworks($arraysocialnetworks['linkedin'], $obj->rowid, $obj->socid, 'linkedin').''; } - if (! $i) $totalarray['nbfield']++; - } // Company if (! empty($arrayfields['p.thirdparty']['checked'])) { From 26c34198bf88dc880f1bd9157c48f1aaf282d517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Oct 2019 21:38:16 +0200 Subject: [PATCH 37/47] show contact --- htdocs/core/lib/company.lib.php | 47 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 698a8dfa67a..97a241ba7c7 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -873,6 +873,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $search_address = GETPOST("search_address", 'alpha'); $search_poste = GETPOST("search_poste", 'alpha'); + $socialnetworks = getArrayOfSocialNetworks(); + $searchAddressPhoneDBFields = array( //Address 't.address', @@ -889,18 +891,13 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') //E-mail 't.email', - - //Social media - "t.skype", - "t.jabberid", - "t.twitter", - "t.facebook", - "t.linkedin", - "t.whatsapp", - "t.youtube", - "t.snapchat", - "t.instagram" ); + //Social media + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->>'$.".$key."'"; + } + } if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="t.lastname"; @@ -916,19 +913,19 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $extralabels=$extrafields->fetch_name_optionals_label($contactstatic->table_element); $contactstatic->fields=array( - 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), - 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOfFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), - 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), - 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>40, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), + 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOfFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), + 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), + 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>40, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), ); // Definition of fields for list $arrayfields=array( - 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'position'=>1), - 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), - 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), - 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'class'=>'center'), + 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'position'=>1), + 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), + 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), + 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), + 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'class'=>'center'), ); // Extra fields if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) @@ -1012,7 +1009,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.skype, t.statut, t.photo,"; + $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,"; $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -1020,7 +1017,9 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); if ($search_poste) $sql .= natural_search('t.poste', $search_poste); - if ($search_address) $sql .= natural_search($searchAddressPhoneDBFields, $search_address); + if ($search_address) { + $sql .= natural_search($searchAddressPhoneDBFields, $search_address); + } // Add where from extra fields $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -1047,7 +1046,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; if (in_array($key, array('t.statut'))){ print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); - }else{ + } else { $fieldName = substr($key, 2); print sprintf('', $fieldName, dol_escape_htmltag($search[$key])); } @@ -1116,7 +1115,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->phone_perso = $obj->phone_perso; $contactstatic->email = $obj->email; $contactstatic->web = $obj->web; - $contactstatic->skype = $obj->skype; + $contactstatic->socialnetworks = $obj->socialnetworks; $contactstatic->photo = $obj->photo; $country_code = getCountry($obj->country_id, 2); From cc03a0a63f6675d803c94773a94bd2dfe893b8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 2 Oct 2019 20:53:47 +0200 Subject: [PATCH 38/47] new migration script for user --- htdocs/install/upgrade2.php | 113 +++++++++++++++++++++++++++++++----- 1 file changed, 97 insertions(+), 16 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 9bf8becd75e..cfefcc62ec5 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4944,21 +4944,84 @@ and rowid in (...) function migrate_users_socialnetworks() { global $db, $langs; - // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp - + // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + $error = 0; + $db->begin(); print ''; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks=JSON_OBJECT('; - $sql.= '"skype", skype,'; - $sql.= '"twitter", twitter,'; - $sql.= '"facebook", facebook,'; - $sql.= '"linkedin", linkedin,'; - $sql.= '"instagram", instagram,'; - $sql.= '"snapchat", snapchat,'; - $sql.= '"googleplus", googleplus,'; - $sql.= '"youtube", youtube,'; - $sql.= '"whatsapp", whatsapp)'; + $sql = 'SELECT rowid, socialnetworks'; + $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'user WHERE '; + $sql .= ' skype IS NOT NULL OR skype !=""'; + $sql .= ' OR twitter IS NOT NULL OR twitter !=""'; + $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; + $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; + $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; + $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""'; + $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""'; + $sql .= ' OR youtube IS NOT NULL OR youtube!=""'; + $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""'; //print $sql; - $db->query($sql); + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $arraysocialnetworks = array(); + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks=='' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"'; + $sqlupd.= ', skype=null'; + $sqlupd.= ', twitter=null'; + $sqlupd.= ', facebook=null'; + $sqlupd.= ', linkedin=null'; + $sqlupd.= ', instagram=null'; + $sqlupd.= ', snapchat=null'; + $sqlupd.= ', googleplus=null'; + $sqlupd.= ', youtube=null'; + $sqlupd.= ', whatsapp=null'; + $sqlupd.= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (! $resqlupd) { + dol_print_error($db); + $error++; + } + } + } else { + $error++; + } + if (! $error) { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } print ''.$langs->trans('MigrationUsersSocialNetworks')."
\n"; print ''; } @@ -4984,7 +5047,13 @@ function migrate_members_socialnetworks() $sql.= '"youtube", youtube,'; $sql.= '"whatsapp", whatsapp)'; //print $sql; - $db->query($sql); + $resql = $db->query($sql); + if ($resql) { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } print ''.$langs->trans('MigrationMembersSocialNetworks')."
\n"; print ''; } @@ -5011,7 +5080,13 @@ function migrate_contacts_socialnetworks() $sql.= '"youtube", youtube,'; $sql.= '"whatsapp", whatsapp)'; //print $sql; - $db->query($sql); + $resql = $db->query($sql); + if ($resql) { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } print ''.$langs->trans('MigrationContactsSocialNetworks')."
\n"; print ''; } @@ -5038,7 +5113,13 @@ function migrate_thirdparties_socialnetworks() $sql.= '"youtube", youtube,'; $sql.= '"whatsapp", whatsapp)'; //print $sql; - $db->query($sql); + $resql = $db->query($sql); + if ($resql) { + $db->commit(); + } else { + dol_print_error($db); + $db->rollback(); + } print ''.$langs->trans('MigrationThirdpartiesSocialNetworks')."
\n"; print ''; } From b96911e9b758e45dcfd8c7fa50f4a21c32eb5436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 2 Oct 2019 21:05:19 +0200 Subject: [PATCH 39/47] new migration script for members --- htdocs/install/upgrade2.php | 187 ++++++++++++++++++++++++------------ 1 file changed, 123 insertions(+), 64 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index cfefcc62ec5..57df60658a7 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4944,8 +4944,8 @@ and rowid in (...) function migrate_users_socialnetworks() { global $db, $langs; - // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp - $error = 0; + // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + $error = 0; $db->begin(); print ''; $sql = 'SELECT rowid, socialnetworks'; @@ -4963,59 +4963,59 @@ function migrate_users_socialnetworks() $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { - $arraysocialnetworks = array(); - if (!empty($obj->skype)) { - $arraysocialnetworks['skype'] = $obj->skype; - } - if (!empty($obj->twitter)) { - $arraysocialnetworks['twitter'] = $obj->twitter; - } - if (!empty($obj->facebook)) { - $arraysocialnetworks['facebook'] = $obj->facebook; - } - if (!empty($obj->linkedin)) { - $arraysocialnetworks['linkedin'] = $obj->linkedin; - } - if (!empty($obj->instagram)) { - $arraysocialnetworks['instagram'] = $obj->instagram; - } - if (!empty($obj->snapchat)) { - $arraysocialnetworks['snapchat'] = $obj->snapchat; - } - if (!empty($obj->googleplus)) { - $arraysocialnetworks['googleplus'] = $obj->googleplus; - } - if (!empty($obj->youtube)) { - $arraysocialnetworks['youtube'] = $obj->youtube; - } - if (!empty($obj->whatsapp)) { - $arraysocialnetworks['whatsapp'] = $obj->whatsapp; - } - if ($obj->socialnetworks=='' || is_null($obj->socialnetworks)) { - $obj->socialnetworks = '[]'; - } - $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); - $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"'; - $sqlupd.= ', skype=null'; - $sqlupd.= ', twitter=null'; - $sqlupd.= ', facebook=null'; - $sqlupd.= ', linkedin=null'; - $sqlupd.= ', instagram=null'; - $sqlupd.= ', snapchat=null'; - $sqlupd.= ', googleplus=null'; - $sqlupd.= ', youtube=null'; - $sqlupd.= ', whatsapp=null'; - $sqlupd.= ' WHERE rowid='.$obj->rowid; - //print $sqlupd."
"; - $resqlupd = $db->query($sqlupd); - if (! $resqlupd) { - dol_print_error($db); - $error++; - } - } + $arraysocialnetworks = array(); + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'user SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"'; + $sqlupd.= ', skype=null'; + $sqlupd.= ', twitter=null'; + $sqlupd.= ', facebook=null'; + $sqlupd.= ', linkedin=null'; + $sqlupd.= ', instagram=null'; + $sqlupd.= ', snapchat=null'; + $sqlupd.= ', googleplus=null'; + $sqlupd.= ', youtube=null'; + $sqlupd.= ', whatsapp=null'; + $sqlupd.= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (! $resqlupd) { + dol_print_error($db); + $error++; + } + } } else { - $error++; - } + $error++; + } if (! $error) { $db->commit(); } else { @@ -5036,19 +5036,78 @@ function migrate_members_socialnetworks() global $db, $langs; print ''; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'adherent SET socialnetworks=JSON_OBJECT('; - $sql.= '"skype", skype,'; - $sql.= '"twitter", twitter,'; - $sql.= '"facebook", facebook,'; - $sql.= '"linkedin", linkedin,'; - $sql.= '"instagram", instagram,'; - $sql.= '"snapchat", snapchat,'; - $sql.= '"googleplus", googleplus,'; - $sql.= '"youtube", youtube,'; - $sql.= '"whatsapp", whatsapp)'; + $error = 0; + $db->begin(); + print ''; + $sql = 'SELECT rowid, socialnetworks'; + $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'adherent WHERE '; + $sql .= ' skype IS NOT NULL OR skype !=""'; + $sql .= ' OR twitter IS NOT NULL OR twitter !=""'; + $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; + $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; + $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; + $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""'; + $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""'; + $sql .= ' OR youtube IS NOT NULL OR youtube!=""'; + $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""'; //print $sql; $resql = $db->query($sql); if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $arraysocialnetworks = array(); + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'adherent SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"'; + $sqlupd.= ', skype=null'; + $sqlupd.= ', twitter=null'; + $sqlupd.= ', facebook=null'; + $sqlupd.= ', linkedin=null'; + $sqlupd.= ', instagram=null'; + $sqlupd.= ', snapchat=null'; + $sqlupd.= ', googleplus=null'; + $sqlupd.= ', youtube=null'; + $sqlupd.= ', whatsapp=null'; + $sqlupd.= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (! $resqlupd) { + dol_print_error($db); + $error++; + } + } + } else { + $error++; + } + if (! $error) { $db->commit(); } else { dol_print_error($db); From 634fc5727ca7f61c5f7f9fa0a0bfa0086b1f3697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 2 Oct 2019 21:08:41 +0200 Subject: [PATCH 40/47] new migration script for contacts --- htdocs/install/upgrade2.php | 84 ++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 11 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 57df60658a7..b1f491c6d88 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -5126,21 +5126,83 @@ function migrate_contacts_socialnetworks() { global $db, $langs; // jabberid,skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + $error = 0; + $db->begin(); print ''; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'socpeople SET socialnetworks=JSON_OBJECT('; - $sql.= '"jabber", jabberid,'; - $sql.= '"skype", skype,'; - $sql.= '"twitter", twitter,'; - $sql.= '"facebook", facebook,'; - $sql.= '"linkedin", linkedin,'; - $sql.= '"instagram", instagram,'; - $sql.= '"snapchat", snapchat,'; - $sql.= '"googleplus", googleplus,'; - $sql.= '"youtube", youtube,'; - $sql.= '"whatsapp", whatsapp)'; + $sql = 'SELECT rowid, socialnetworks'; + $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 .= ' OR skype IS NOT NULL OR skype !=""'; + $sql .= ' OR twitter IS NOT NULL OR twitter !=""'; + $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; + $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; + $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; + $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""'; + $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""'; + $sql .= ' OR youtube IS NOT NULL OR youtube!=""'; + $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""'; //print $sql; $resql = $db->query($sql); if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $arraysocialnetworks = array(); + if (!empty($obj->jabberid)) { + $arraysocialnetworks['jabber'] = $obj->jabberid; + } + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'socpeople SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"'; + $sqlupd.= ', jabberid=null'; + $sqlupd.= ', skype=null'; + $sqlupd.= ', twitter=null'; + $sqlupd.= ', facebook=null'; + $sqlupd.= ', linkedin=null'; + $sqlupd.= ', instagram=null'; + $sqlupd.= ', snapchat=null'; + $sqlupd.= ', googleplus=null'; + $sqlupd.= ', youtube=null'; + $sqlupd.= ', whatsapp=null'; + $sqlupd.= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (! $resqlupd) { + dol_print_error($db); + $error++; + } + } + } else { + $error++; + } + if (! $error) { $db->commit(); } else { dol_print_error($db); From fe4629cd87779ff0b83063912b82123701320e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 2 Oct 2019 21:11:21 +0200 Subject: [PATCH 41/47] new migration script for thirdparties --- htdocs/install/upgrade2.php | 79 +++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 11 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index b1f491c6d88..85a0e19ea4d 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -5221,21 +5221,78 @@ function migrate_thirdparties_socialnetworks() { global $db, $langs; // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp - + $error = 0; + $db->begin(); print ''; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe SET socialnetworks=JSON_OBJECT('; - $sql.= '"skype", skype,'; - $sql.= '"twitter", twitter,'; - $sql.= '"facebook", facebook,'; - $sql.= '"linkedin", linkedin,'; - $sql.= '"instagram", instagram,'; - $sql.= '"snapchat", snapchat,'; - $sql.= '"googleplus", googleplus,'; - $sql.= '"youtube", youtube,'; - $sql.= '"whatsapp", whatsapp)'; + $sql = 'SELECT rowid, socialnetworks'; + $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'societe WHERE '; + $sql .= ' OR skype IS NOT NULL OR skype !=""'; + $sql .= ' OR twitter IS NOT NULL OR twitter !=""'; + $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; + $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; + $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; + $sql .= ' OR snapchat IS NOT NULL OR snapchat!=""'; + $sql .= ' OR googleplus IS NOT NULL OR googleplus!=""'; + $sql .= ' OR youtube IS NOT NULL OR youtube!=""'; + $sql .= ' OR whatsapp IS NOT NULL OR whatsapp!=""'; //print $sql; $resql = $db->query($sql); if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $arraysocialnetworks = array(); + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + } + if (!empty($obj->instagram)) { + $arraysocialnetworks['instagram'] = $obj->instagram; + } + if (!empty($obj->snapchat)) { + $arraysocialnetworks['snapchat'] = $obj->snapchat; + } + if (!empty($obj->googleplus)) { + $arraysocialnetworks['googleplus'] = $obj->googleplus; + } + if (!empty($obj->youtube)) { + $arraysocialnetworks['youtube'] = $obj->youtube; + } + if (!empty($obj->whatsapp)) { + $arraysocialnetworks['whatsapp'] = $obj->whatsapp; + } + if ($obj->socialnetworks == '' || is_null($obj->socialnetworks)) { + $obj->socialnetworks = '[]'; + } + $socialnetworks = array_merge($arraysocialnetworks, json_decode($obj->socialnetworks, true)); + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'societe SET socialnetworks="'.$db->escape(json_encode($socialnetworks, true)).'"'; + $sqlupd.= ', skype=null'; + $sqlupd.= ', twitter=null'; + $sqlupd.= ', facebook=null'; + $sqlupd.= ', linkedin=null'; + $sqlupd.= ', instagram=null'; + $sqlupd.= ', snapchat=null'; + $sqlupd.= ', googleplus=null'; + $sqlupd.= ', youtube=null'; + $sqlupd.= ', whatsapp=null'; + $sqlupd.= ' WHERE rowid='.$obj->rowid; + //print $sqlupd."
"; + $resqlupd = $db->query($sqlupd); + if (! $resqlupd) { + dol_print_error($db); + $error++; + } + } + } else { + $error++; + } + if (! $error) { $db->commit(); } else { dol_print_error($db); From 91761e8185fcbafcb92d9ab5c4cb70796ef40009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 2 Oct 2019 21:16:33 +0200 Subject: [PATCH 42/47] fix migration script for thirdparties --- htdocs/install/upgrade2.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 85a0e19ea4d..8d8a2433de8 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -5041,8 +5041,8 @@ function migrate_members_socialnetworks() print ''; $sql = 'SELECT rowid, socialnetworks'; $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'adherent WHERE '; - $sql .= ' skype IS NOT NULL OR skype !=""'; - $sql .= ' OR twitter IS NOT NULL OR twitter !=""'; + $sql .= ' skype IS NOT NULL OR skype!=""'; + $sql .= ' OR twitter IS NOT NULL OR twitter!=""'; $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; @@ -5131,9 +5131,9 @@ function migrate_contacts_socialnetworks() print ''; $sql = 'SELECT rowid, socialnetworks'; $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 .= ' OR skype IS NOT NULL OR skype !=""'; - $sql .= ' OR twitter IS NOT NULL OR twitter !=""'; + $sql .= ' jabberid IS NOT NULL OR jabberid!=""'; + $sql .= ' OR skype IS NOT NULL OR skype!=""'; + $sql .= ' OR twitter IS NOT NULL OR twitter!=""'; $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; @@ -5226,8 +5226,8 @@ function migrate_thirdparties_socialnetworks() print ''; $sql = 'SELECT rowid, socialnetworks'; $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'societe WHERE '; - $sql .= ' OR skype IS NOT NULL OR skype !=""'; - $sql .= ' OR twitter IS NOT NULL OR twitter !=""'; + $sql .= ' skype IS NOT NULL OR skype!=""'; + $sql .= ' OR twitter IS NOT NULL OR twitter!=""'; $sql .= ' OR facebook IS NOT NULL OR facebook!=""'; $sql .= ' OR linkedin IS NOT NULL OR linkedin!=""'; $sql .= ' OR instagram IS NOT NULL OR instagram!=""'; From feaa5e2bd021cddd3ff513ecbd70cf6a1184e895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 2 Oct 2019 22:15:24 +0200 Subject: [PATCH 43/47] json query path --- htdocs/contact/list.php | 2 +- htdocs/core/lib/company.lib.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 42c2e7cf0ad..be4cf227df0 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -345,7 +345,7 @@ if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && strlen($search_{$key})) { - $sql.= natural_search("p.socialnetworks->>'$.".$key."'", $search_{$key}); + $sql.= natural_search("p.socialnetworks->'$.".$key."'", $search_{$key}); } } } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 490f2f99adf..01775909a5d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -895,7 +895,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') //Social media foreach ($socialnetworks as $key => $value) { if ($value['active']) { - $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->>'$.".$key."'"; + $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; } } @@ -948,7 +948,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { $queryName = 'search_'.substr($key, 2); if (GETPOST($queryName, 'alpha')){ - $search[$key]=GETPOST($queryName, 'alpha'); + $search[substr($key, 2)]=GETPOST($queryName, 'alpha'); } } $search_array_options=$extrafields->getOptionalsFromPost($contactstatic->table_element, '', 'search_'); @@ -1047,8 +1047,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($key, array('statut'))){ print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); } else { - $fieldName = substr($key, 2); - print sprintf('', $fieldName, dol_escape_htmltag($search[$key])); + print ''; } print ''; } From e443538f717982fe7e8b5e9c174dbc5339a35113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 3 Oct 2019 17:23:50 +0200 Subject: [PATCH 44/47] wip --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/holiday/class/holiday.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 19a65abdfd9..a3f967092f5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2205,7 +2205,7 @@ class FactureFournisseur extends CommonInvoice $response->label=$langs->trans("SupplierBillsToPay"); $response->labelShort=$langs->trans("StatusToPay"); - $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=billing&leftmenu=suppliers_bills'; + $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=billing&leftmenu=suppliers_bills'; $response->img=img_object($langs->trans("Bills"), "bill"); $facturestatic = new FactureFournisseur($this->db); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 756cc7cd5d2..37de6440e60 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2232,7 +2232,7 @@ class Holiday extends CommonObject $response->warning_delay=$conf->holiday->approve->warning_delay/60/60/24; $response->label=$langs->trans("HolidaysToApprove"); $response->labelShort=$langs->trans("ToApprove"); - $response->url=DOL_URL_ROOT.'/holiday/list.php?search_statut=2&mainmenu=hrm&leftmenu=holiday'; + $response->url=DOL_URL_ROOT.'/holiday/list.php?search_statut=2&mainmenu=hrm&leftmenu=holiday'; $response->img=img_object('', "holiday"); while ($obj=$this->db->fetch_object($resql)) From d46f51943823e7da4b89d3eacf7448377b0a7d6a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 30 Oct 2019 19:07:50 +0000 Subject: [PATCH 45/47] Fixing style errors. --- htdocs/contact/class/contact.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 8b16e66ed92..c6c674bd4cd 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -132,14 +132,14 @@ class Contact extends CommonObject * @var string * @deprecated */ - public $twitter; + public $twitter; /** * Facebook username * @var string * @deprecated */ - public $facebook; + public $facebook; /** * Linkedin username From 569c543ca007872f73b8aad70ad1eb085d655c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 3 Nov 2019 22:34:57 +0100 Subject: [PATCH 46/47] search --- htdocs/contact/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 6694c363977..1f90e109c5b 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -289,7 +289,6 @@ $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(" $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,"; -// socialnetworks->>'$.facebook' as facebook $sql.= " p.socialnetworks,"; $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql.= " co.label as country, co.code as country_code"; @@ -355,7 +354,8 @@ if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && strlen($search_{$key})) { - $sql.= natural_search("p.socialnetworks->'$.".$key."'", $search_{$key}); + //$sql.= natural_search("p.socialnetworks->'$.".$key."'", $search_{$key}); + $sql.= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\''; } } } From 7ecdfa7c96c43f014f267ba748d9b3508f59bfad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 3 Nov 2019 22:51:42 +0100 Subject: [PATCH 47/47] oups --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index a343215c611..6ac83f249ed 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -149,10 +149,9 @@ ALTER TABLE llx_oauth_token ADD COLUMN fk_soc integer DEFAULT NULL after token; ALTER TABLE llx_adherent_type ADD COLUMN duration varchar(6) DEFAULT NULL after morphy; -https://www.royalmail.com/track-your-item#/ -https://www.royalmail.com/track-your-item#/ -https://www.royalmail.com/track-your-item#/ -https://www.royalmail.com/track-your-item#/ +ALTER TABLE llx_mailing ADD COLUMN tms timestamp; +ALTER TABLE llx_mailing_cibles ADD COLUMN tms timestamp; + ALTER TABLE llx_projet ADD COLUMN usage_opportunity integer DEFAULT 0; ALTER TABLE llx_projet ADD COLUMN usage_task integer DEFAULT 1; ALTER TABLE llx_projet CHANGE COLUMN bill_time usage_bill_time integer DEFAULT 0; -- rename existing field