diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 76556feb4ee..add7d7b643b 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -70,6 +70,8 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $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); $canvas = $object->canvas?$object->canvas:GETPOST("canvas"); @@ -302,10 +304,16 @@ 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) { + 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')); + //$object->facebook = trim(GETPOST("facebook", 'alpha')); + //$object->linkedin = trim(GETPOST("linkedin", 'alpha')); $object->birth = $birthdate; $object->typeid = GETPOST("typeid", 'int'); @@ -448,10 +456,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 +486,19 @@ 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 (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + $object->socialnetworks[$key] = GETPOST("member_".$key, 'alphanohtml'); + } + } + } - $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; @@ -1028,29 +1044,12 @@ else // Mobile phone print ''.img_picto('', 'object_phoning_mobile').' '.$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']) break; + print ''.$langs->trans($value['label']).''; + } + } // Birth Date print "".$langs->trans("DateToBirth")."\n"; @@ -1297,29 +1296,12 @@ else // Mobile phone print ''.img_picto('', 'object_phoning_mobile').' '.$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']) break; + print ''.$langs->trans($value['label']).''; + } + } // Birth Date print "".$langs->trans("DateToBirth")."\n"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index f7278f9007a..ff2e5082736 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; @@ -566,10 +575,7 @@ 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.= ", 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"); @@ -694,10 +700,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; @@ -736,10 +739,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; @@ -1228,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.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,"; @@ -1307,10 +1307,7 @@ 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; + $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); $this->photo = $obj->photo; $this->statut = $obj->statut; @@ -2385,10 +2382,12 @@ 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', + 'facebook' => 'facebookpseudo', + 'linkedin' => 'linkedinpseudo', + ); $this->phone = '0999999999'; $this->phone_perso = '0999999998'; $this->phone_mobile = '0999999997'; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index af61dd1c09f..974fba8fa1d 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 @@ -88,7 +89,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 +131,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 +172,7 @@ $tablib[34]= "DictionaryFunction"; $tablib[35]= "DictionaryExpenseTaxCat"; $tablib[36]= "DictionaryExpenseTaxRange"; $tablib[37]= "DictionaryMeasuringUnits"; +$tablib[38]= "DictionarySocialNetworks"; // Requests to extract data $tabsql=array(); @@ -210,6 +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, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -250,6 +254,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"; // Field names in select result for dictionary display $tabfield=array(); @@ -290,6 +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,entity"; // Edit field names for editing a record $tabfieldvalue=array(); @@ -330,6 +336,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"; // Field names in the table for inserting a record $tabfieldinsert=array(); @@ -371,6 +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]= "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 @@ -413,6 +421,7 @@ $tabrowid[34]= "rowid"; $tabrowid[35]= ""; $tabrowid[36]= ""; $tabrowid[37]= ""; +$tabrowid[38]= ""; // Condition to show dictionary in setup page $tabcond=array(); @@ -453,6 +462,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 +503,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 +544,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/contact/card.php b/htdocs/contact/card.php index fe64122b52c..9642cdfa84c 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -62,6 +62,8 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $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,17 +188,25 @@ 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 (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } $object->email = GETPOST("email", 'alpha'); $object->no_email = GETPOST("no_email", "int"); $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'); @@ -378,19 +388,26 @@ if (empty($reshook)) $object->email = GETPOST("email", 'alpha'); $object->no_email = GETPOST("no_email", "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'); + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml')!='') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } $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'); - $object->roles = GETPOST("roles", 'array'); + $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -727,39 +744,53 @@ 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']) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + 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 ''; @@ -1028,39 +1059,53 @@ 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']) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + 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 033c9471f51..f8a43d70494 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -83,6 +83,11 @@ class Contact extends CommonObject public $civility_id; // In fact we store civility_code public $civility_code; public $civility; + + /** + * Address + * @var string + */ public $address; public $zip; public $town; @@ -97,11 +102,60 @@ class Contact extends CommonObject public $statut; // 0=inactif, 1=actif public $code; + + /** + * Email + * @var string + */ public $email; - public $no_email; // 1 = contact has globaly unsubscribe of all mass emailings + + /** + * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings + * @var int + */ + public $no_email; + + /** + * @var array array of socialnetworks + */ + public $socialnetworks; + + /** + * Skype username + * @var string + * @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; @@ -123,6 +177,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 public $roles=array(); @@ -345,10 +403,7 @@ 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 .= ", 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"); @@ -356,7 +411,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"); @@ -439,29 +493,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++; } } } @@ -713,7 +772,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,"; + $sql.= " c.socialnetworks,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; $sql.= " c.import_key,"; @@ -782,11 +842,7 @@ 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; + $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; @@ -1333,8 +1389,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'; $this->phone_mobile = '0909090903'; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d23963fde0a..43c6c9c7f1d 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -41,6 +41,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.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'); @@ -71,10 +73,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_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'); @@ -168,11 +173,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 +180,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->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { @@ -236,10 +246,13 @@ if (empty($reshook)) $search_fax=""; $search_email=""; $search_no_email=-1; - $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=''; @@ -275,7 +288,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,"; $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"; // Add fields from extrafields @@ -337,10 +351,14 @@ 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_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 (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active'] && strlen($search_{$key})) { + //$sql.= natural_search("p.socialnetworks->'$.".$key."'", $search_{$key}); + $sql.= ' AND p.socialnetworks LIKE \'%"'.$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); @@ -641,35 +659,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'])) { @@ -743,11 +743,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 @@ -784,7 +786,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; @@ -796,6 +798,7 @@ while ($i < min($num, $limit)) $contactstatic->phone_mobile=$obj->phone_mobile; $contactstatic->zip=$obj->zip; $contactstatic->town=$obj->town; + $contactstatic->socialnetworks = $arraysocialnetworks; $contactstatic->country = $obj->country; $contactstatic->country_code = $obj->country_code; @@ -896,36 +899,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($obj->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($obj->jabberid, $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 (! $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 (! $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 (! $i) $totalarray['nbfield']++; - } // Company if (! empty($arrayfields['p.thirdparty']['checked'])) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0f70652242c..0cfe1958f03 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -692,16 +692,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.='
'; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 8cb023237d4..d87f59eefa2 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -876,6 +876,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $search_poste = GETPOST("search_poste", 'alpha'); $search_roles = GETPOST("search_roles", 'array'); + $socialnetworks = getArrayOfSocialNetworks(); + $searchAddressPhoneDBFields = array( //Address 't.address', @@ -892,18 +894,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"; @@ -919,11 +916,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $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'=>'PostOrFunction', '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), - 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), - 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, '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'=>'PostOrFunction', '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), + 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), + 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), ); // Definition of fields for list @@ -1020,7 +1017,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)"; @@ -1028,7 +1025,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); + } if (count($search_roles)>0) { $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } @@ -1132,7 +1131,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); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f0c57cda966..11fbf512ab1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1899,7 +1899,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang /** - * Return an array with locale date info. + * Return an array with locale date info. * PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows * WARNING: This function always use PHP server timezone to return locale informations !!! * Usage must be avoid. @@ -2037,9 +2037,9 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ /** - * Return date for now. In most cases, we use this function without parameters (that means GMT time). + * Return date for now. In most cases, we use this function without parameters (that means GMT time). * - * @param string $mode 'gmt' => we return GMT timestamp, + * @param string $mode 'gmt' => we return GMT timestamp, * 'tzserver' => we add the PHP server timezone * 'tzref' => we add the company timezone * 'tzuser' => we add the user timezone @@ -2198,6 +2198,32 @@ 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"; + $sql.= " WHERE entity=".$conf->entity; + $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 * @@ -2211,42 +2237,43 @@ 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', 0); - $newskype.=$value; + $htmllink = '
'; + $htmllink .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); + $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=''; + $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; } /** @@ -3033,6 +3060,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'stats', 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'wrench', 'globe', 'jabber','skype','twitter','facebook','linkedin', + 'instagram', 'snapchat', 'youtube', 'google-plus-g','whatsapp', 'chevron-left','chevron-right','chevron-down','chevron-top', 'home', 'companies', 'products', 'commercial', 'invoicing', 'accountancy', 'project', 'hrm', 'members', 'ticket', 'generic', 'error','warning', @@ -3146,7 +3174,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithouttext == 'jabber') { $fakey = 'fa-comment-o'; } - 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; $fa = 'fab'; } diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index cb27047996b..2347f68dcbc 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/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 783e8b3737e..4cc39f781df 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2209,7 +2209,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 f18cad2a266..37d38ea69eb 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2194,7 +2194,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)) 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 d5d46aea152..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,7 +149,6 @@ 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; - ALTER TABLE llx_mailing ADD COLUMN tms timestamp; ALTER TABLE llx_mailing_cibles ADD COLUMN tms timestamp; @@ -252,18 +251,69 @@ 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-GANDI', 0, 117, '', 0, 10, 2, 1); +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, + icon varchar(20), + 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 (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); + +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; + ALTER TABLE llx_product ADD COLUMN net_measure float; ALTER TABLE llx_product ADD COLUMN net_measure_units tinyint; create table llx_adherent_type_lang ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_type integer DEFAULT 0 NOT NULL, - lang varchar(5) DEFAULT 0 NOT NULL, - label varchar(255) NOT NULL, - description text, - email text, - import_key varchar(14) DEFAULT NULL + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_type integer DEFAULT 0 NOT NULL, + lang varchar(5) DEFAULT 0 NOT NULL, + label varchar(255) NOT NULL, + description text, + email text, + import_key varchar(14) DEFAULT NULL )ENGINE=innodb; create table llx_fichinter_rec diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index b071e31eb27..cb96ab98164 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_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..b2d0b44c371 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_socialnetworks.sql @@ -0,0 +1,27 @@ +-- ======================================================================== +-- +-- 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, + entity integer DEFAULT 1 NOT NULL, + code varchar(100), + label varchar(150), + url text, + icon varchar(20), + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index f312015a662..fc3100b823d 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 @@ -112,7 +113,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 99338d4a206..fceb2044649 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 a5ff97a0e15..16170267bee 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/install/upgrade2.php b/htdocs/install/upgrade2.php index 0787c84762b..232cee40440 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -451,6 +451,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. @@ -4926,3 +4936,369 @@ 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; + // skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + $error = 0; + $db->begin(); + print ''; + $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; + $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 ''; +} + +/** + * Migrate members fields facebook and co to socialnetworks + * + * @return void + */ +function migrate_members_socialnetworks() +{ + global $db, $langs; + + print ''; + $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); + $db->rollback(); + } + print ''.$langs->trans('MigrationMembersSocialNetworks')."
\n"; + print ''; +} + +/** + * Migrate contacts fields facebook and co to socialnetworks + * + * @return void + */ +function migrate_contacts_socialnetworks() +{ + global $db, $langs; + // jabberid,skype,twitter,facebook,linkedin,instagram,snapchat,googleplus,youtube,whatsapp + $error = 0; + $db->begin(); + 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 .= ' 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); + $db->rollback(); + } + print ''.$langs->trans('MigrationContactsSocialNetworks')."
\n"; + print ''; +} + +/** + * 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 + $error = 0; + $db->begin(); + print ''; + $sql = 'SELECT rowid, socialnetworks'; + $sql .= ', skype, twitter, facebook, linkedin, instagram, snapchat, googleplus, youtube, whatsapp FROM '.MAIN_DB_PREFIX.'societe 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.'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); + $db->rollback(); + } + print ''.$langs->trans('MigrationThirdpartiesSocialNetworks')."
\n"; + print ''; +} diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2b172f2ea18..ebc8431f5e3 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 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 diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index edfb3767f11..5ba0b3b6cc9 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -70,6 +70,8 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $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')); @@ -147,7 +149,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', @@ -407,11 +409,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)); @@ -974,10 +984,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); @@ -1304,42 +1322,57 @@ else print ''.img_picto('', 'globe').' '.$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 ''; + // } + // } + // Prof ids $i=1; $j=0; while ($i <= 6) @@ -1612,10 +1645,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); @@ -1927,33 +1968,47 @@ else print ''.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $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 ''; + // } + // } // Prof ids $i=1; $j=0; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9ba0bdcfd12..21213272a26 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 @@ -200,24 +201,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; /** @@ -873,10 +885,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,11 +1024,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 .= ",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 .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null"); + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); $sql .= ",parent = " . ($this->parent > 0 ? $this->parent : "null"); @@ -1162,10 +1167,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; @@ -1272,7 +1274,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'; + $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'; @@ -1324,7 +1328,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; } @@ -1365,11 +1369,9 @@ class Societe extends CommonObject $this->stcomm_id = $obj->fk_stcomm; // id status prospect $this->status_prospect_label = $label; // label status prospect - $this->email = $obj->email; - $this->skype = $obj->skype; - $this->twitter = $obj->twitter; - $this->facebook = $obj->facebook; - $this->linkedin = $obj->linkedin; + $this->email = $obj->email; + $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); + $this->url = $obj->url; $this->phone = $obj->phone; $this->fax = $obj->fax; @@ -3391,10 +3393,7 @@ 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 $this->code_client = ($customercode?$customercode:-1); @@ -3562,10 +3561,12 @@ 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', + 'facebook' => 'tomhanson', + 'linkedin' => 'tomhanson', + ); $this->url='http://www.specimen.com'; $this->phone='0909090901'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index c924aae08bf..79c5d65b246 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -99,6 +99,8 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); +$socialnetworks = getArrayOfSocialNetworks(); + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('usercard', 'globalcard')); @@ -107,7 +109,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'); @@ -211,10 +212,16 @@ 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) { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml')); $object->job = GETPOST("job", 'nohtml'); @@ -366,12 +373,16 @@ 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", '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) { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml')); $object->job = GETPOST("job", 'nohtml'); $object->signature = GETPOST("signature", 'none'); @@ -630,10 +641,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]; } @@ -1085,73 +1096,95 @@ 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']) { + print ''.$langs->trans($value['label']).''; + print ''; + if (! empty($ldap_social[$key])) { + print ''; + print $ldap_social[$key]; + } else { + print ''; + } + print ''; + } else { + // if social network is not active but value exist we do not want to loose it + if (! empty($ldap_social[$key])) { + print ''; + } else { + 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 ''; + // } // Accountancy code if ($conf->accounting->enabled) @@ -2431,73 +2464,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 ''; + // } // OpenID url if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 76d4d431561..6702953878c 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -74,9 +74,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 @@ -255,7 +281,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,"; $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 as note_private, u.note_public,"; @@ -366,11 +393,8 @@ 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; + $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); $this->job = $obj->job; $this->signature = $obj->signature; $this->admin = $obj->admin; @@ -1292,10 +1316,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; @@ -1511,11 +1532,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_public = trim($this->note_public); @@ -1568,10 +1584,7 @@ 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.= ", job = '".$this->db->escape($this->job)."'"; $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; @@ -1661,10 +1674,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; @@ -1714,10 +1724,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; @@ -2701,10 +2708,12 @@ class User extends CommonObject $this->note_private='This is a note private'; $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', + 'facebook' => 'facebookpseudo', + 'linkedin' => 'linkedinpseudo', + ); $this->office_phone='0999999999'; $this->office_fax='0999999998'; $this->user_mobile='0999999997'; diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index f4b5fc71616..8fdaea0cbe7 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -207,7 +207,7 @@ 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'; $result=$localobject->update($localobject->id, $user); @@ -257,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);