diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index ce8ade06e09..1b099a55c10 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -487,7 +487,7 @@ if (empty($reshook)) $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST("member_".$key, 'alpha'); } } @@ -1030,7 +1030,7 @@ else if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; print ''.$langs->trans($value['label']).''; } } @@ -1282,7 +1282,7 @@ else if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; print ''.$langs->trans($value['label']).''; } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 76d0e3911b5..31758db3e15 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -62,6 +62,8 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$socialnetworks = getArrayOfSocialNetworks(); + // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); $objcanvas=null; @@ -186,16 +188,23 @@ if (empty($reshook)) $object->town = GETPOST("town", 'alpha'); $object->country_id = GETPOST("country_id", 'int'); $object->state_id = GETPOST("state_id", 'int'); - $object->skype = GETPOST("skype", 'alpha'); - $object->twitter = GETPOST("twitter", 'alpha'); - $object->facebook = GETPOST("facebook", 'alpha'); - $object->linkedin = GETPOST("linkedin", 'alpha'); + //$object->jabberid = GETPOST("jabberid", 'alpha'); + //$object->skype = GETPOST("skype", 'alpha'); + //$object->twitter = GETPOST("twitter", 'alpha'); + //$object->facebook = GETPOST("facebook", 'alpha'); + //$object->linkedin = GETPOST("linkedin", 'alpha'); + $object->socialnetworks = array(); + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) break; + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } $object->email = GETPOST("email", 'alpha'); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); $object->fax = GETPOST("fax", 'alpha'); - $object->jabberid = GETPOST("jabberid", 'alpha'); $object->priv = GETPOST("priv", 'int'); $object->note_public = GETPOST("note_public", 'none'); $object->note_private = GETPOST("note_private", 'none'); @@ -359,15 +368,21 @@ if (empty($reshook)) $object->country_id = GETPOST("country_id", 'int'); $object->email = GETPOST("email", 'alpha'); - $object->skype = GETPOST("skype", 'alpha'); - $object->twitter = GETPOST("twitter", 'alpha'); - $object->facebook = GETPOST("facebook", 'alpha'); - $object->linkedin = GETPOST("linkedin", 'alpha'); + //$object->jabberid = GETPOST("jabberid", 'alpha'); + //$object->skype = GETPOST("skype", 'alpha'); + //$object->twitter = GETPOST("twitter", 'alpha'); + //$object->facebook = GETPOST("facebook", 'alpha'); + //$object->linkedin = GETPOST("linkedin", 'alpha'); + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) break; + $object->socialnetworks[$key] = GETPOST($key, 'alpha'); + } + } $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); $object->fax = GETPOST("fax", 'alpha'); - $object->jabberid = GETPOST("jabberid", 'alpha'); $object->priv = GETPOST("priv", 'int'); $object->note_public = GETPOST("note_public", 'none'); $object->note_private = GETPOST("note_private", 'none'); @@ -676,39 +691,50 @@ else } print ''; - if (! empty($conf->socialnetworks->enabled)) - { - // Jabber - if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - { - print ''; - print 'jabberid).'">'; - } - // Skype - if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - { - print ''; - print 'skype).'">'; - } - // Twitter - if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - { - print ''; - print 'twitter).'">'; - } - // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''; - print 'facebook).'">'; - } - // LinkedIn - if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - { - print ''; - print 'linkedin).'">'; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) break; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Jabber + // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) + // { + // print ''; + // print 'jabberid).'">'; + // } + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''; + // print 'skype).'">'; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''; + // print 'twitter).'">'; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''; + // print 'facebook).'">'; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''; + // print 'linkedin).'">'; + // } + // } // Visibility print ''; @@ -968,39 +994,50 @@ else } print ''; - if (! empty($conf->socialnetworks->enabled)) - { - // Jabber ID - if (! empty($conf->global->SOCIALNETWORKS_JABBER)) - { - print ''; - print 'jabberid).'">'; - } - // Skype - if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) - { - print ''; - print 'skype).'">'; - } - // Twitter - if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) - { - print ''; - print 'twitter).'">'; - } - // Facebook - if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) - { - print ''; - print 'facebook).'">'; - } - // LinkedIn - if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) - { - print ''; - print 'linkedin).'">'; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) break; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } } + // if (! empty($conf->socialnetworks->enabled)) + // { + // // Jabber ID + // if (! empty($conf->global->SOCIALNETWORKS_JABBER)) + // { + // print ''; + // print 'jabberid).'">'; + // } + // // Skype + // if (! empty($conf->global->SOCIALNETWORKS_SKYPE)) + // { + // print ''; + // print 'skype).'">'; + // } + // // Twitter + // if (! empty($conf->global->SOCIALNETWORKS_TWITTER)) + // { + // print ''; + // print 'twitter).'">'; + // } + // // Facebook + // if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK)) + // { + // print ''; + // print 'facebook).'">'; + // } + // // LinkedIn + // if (! empty($conf->global->SOCIALNETWORKS_LINKEDIN)) + // { + // print ''; + // print 'linkedin).'">'; + // } + // } // Visibility print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 77743ba26d6..082c178ef12 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -110,8 +110,36 @@ class Contact extends CommonObject * @deprecated */ public $skype; - public $photo; + + /** + * Twitter username + * @var string + * @deprecated + */ + public $twitter; + + /** + * Facebook username + * @var string + * @deprecated + */ + public $facebook; + + /** + * Linkedin username + * @var string + * @deprecated + */ + public $linkedin; + + /** + * Jabber username + * @var string + * @deprecated + */ public $jabberid; + + public $photo; public $phone_pro; public $phone_perso; public $phone_mobile; @@ -357,10 +385,12 @@ class Contact extends CommonObject $sql .= ", poste='".$this->db->escape($this->poste)."'"; $sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", email='".$this->db->escape($this->email)."'"; - $sql .= ", skype='".$this->db->escape($this->skype)."'"; - $sql .= ", twitter='".$this->db->escape($this->twitter)."'"; - $sql .= ", facebook='".$this->db->escape($this->facebook)."'"; - $sql .= ", linkedin='".$this->db->escape($this->linkedin)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + //$sql .= ", jabberid = ".(isset($this->jabberid)?"'".$this->db->escape($this->jabberid)."'":"null"); + //$sql .= ", skype='".$this->db->escape($this->skype)."'"; + //$sql .= ", twitter='".$this->db->escape($this->twitter)."'"; + //$sql .= ", facebook='".$this->db->escape($this->facebook)."'"; + //$sql .= ", linkedin='".$this->db->escape($this->linkedin)."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); @@ -368,7 +398,6 @@ class Contact extends CommonObject $sql .= ", phone = ".(isset($this->phone_pro)?"'".$this->db->escape($this->phone_pro)."'":"null"); $sql .= ", phone_perso = ".(isset($this->phone_perso)?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql .= ", phone_mobile = ".(isset($this->phone_mobile)?"'".$this->db->escape($this->phone_mobile)."'":"null"); - $sql .= ", jabberid = ".(isset($this->jabberid)?"'".$this->db->escape($this->jabberid)."'":"null"); $sql .= ", priv = '".$this->db->escape($this->priv)."'"; $sql .= ", statut = ".$this->db->escape($this->statut); $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL"); @@ -442,29 +471,34 @@ class Contact extends CommonObject $tmpobj->email = $this->email; $usermustbemodified++; } - if ($tmpobj->skype != $this->skype) + if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks))) { - $tmpobj->skype = $this->skype; + $tmpobj->socialnetworks = $this->socialnetworks; $usermustbemodified++; } - if ($tmpobj->twitter != $this->twitter) - { - $tmpobj->twitter = $this->twitter; - $usermustbemodified++; - } - if ($tmpobj->facebook != $this->facebook) - { - $tmpobj->facebook = $this->facebook; - $usermustbemodified++; - } - if ($tmpobj->linkedin != $this->linkedin) - { - $tmpobj->linkedin = $this->linkedin; - $usermustbemodified++; - } + // if ($tmpobj->skype != $this->skype) + // { + // $tmpobj->skype = $this->skype; + // $usermustbemodified++; + // } + // if ($tmpobj->twitter != $this->twitter) + // { + // $tmpobj->twitter = $this->twitter; + // $usermustbemodified++; + // } + // if ($tmpobj->facebook != $this->facebook) + // { + // $tmpobj->facebook = $this->facebook; + // $usermustbemodified++; + // } + // if ($tmpobj->linkedin != $this->linkedin) + // { + // $tmpobj->linkedin = $this->linkedin; + // $usermustbemodified++; + // } if ($usermustbemodified) { - $result=$tmpobj->update($user, 0, 1, 1, 1); + $result = $tmpobj->update($user, 0, 1, 1, 1); if ($result < 0) { $error++; } } } @@ -716,7 +750,8 @@ class Contact extends CommonObject $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement as state_id,"; $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid, c.skype, c.twitter, c.facebook, c.linkedin,"; + $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,"; + $sql.= " c.socialnetworks, c.skype, c.twitter, c.facebook, c.linkedin,"; $sql.= " c.photo,"; $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; $sql.= " c.import_key,"; @@ -785,11 +820,45 @@ class Contact extends CommonObject $this->phone_mobile = trim($obj->phone_mobile); $this->email = $obj->email; - $this->jabberid = $obj->jabberid; - $this->skype = $obj->skype; - $this->twitter = $obj->twitter; - $this->facebook = $obj->facebook; - $this->linkedin = $obj->linkedin; + $arraysocialnetworks = array(); + $updatesocial = false; + if (!empty($obj->jabberid)) { + $arraysocialnetworks['jabber'] = $obj->jabberid; + $updatesocial = true; + } + if (!empty($obj->skype)) { + $arraysocialnetworks['skype'] = $obj->skype; + $updatesocial = true; + } + if (!empty($obj->twitter)) { + $arraysocialnetworks['twitter'] = $obj->twitter; + $updatesocial = true; + } + if (!empty($obj->facebook)) { + $arraysocialnetworks['facebook'] = $obj->facebook; + $updatesocial = true; + } + if (!empty($obj->linkedin)) { + $arraysocialnetworks['linkedin'] = $obj->linkedin; + $updatesocial = true; + } + $socialarray = ($obj->socialnetworks==''?array():json_decode($obj->socialnetworks, true)); + $this->socialnetworks = array_merge($arraysocialnetworks, $socialarray); + if ($updatesocial) { + $sqlupd = 'UPDATE '.MAIN_DB_PREFIX.'socpeople SET skype=null'; + $sqlupd .= ', twitter=null'; + $sqlupd .= ', facebook=null'; + $sqlupd .= ', linkedin=null'; + $sqlupd .= ', jabberid=null'; + $sqlupd .= ', socialnetworks="'.$this->db->escape(json_encode($this->socialnetworks)).'"'; + $sqlupd .= ' WHERE rowid='.$this->id; + $this->db->query($sqlupd); + } + $this->jabberid = $this->socialnetworks['jabber']; + $this->skype = $this->socialnetworks['skype']; + $this->twitter = $this->socialnetworks['twitter']; + $this->facebook = $this->socialnetworks['facebook']; + $this->linkedin = $this->socialnetworks['linkedin']; $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; @@ -1332,7 +1401,6 @@ class Contact extends CommonObject $this->socialnetworks = array( 'skype' => 'tom.hanson', ); - $this->phone_pro = '0909090901'; $this->phone_perso = '0909090902'; $this->phone_mobile = '0909090903'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e348dfbe273..fa297df75eb 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -221,7 +221,7 @@ if (empty($reshook)) { $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); } } @@ -380,7 +380,7 @@ if (empty($reshook)) { $object->socialnetworks = array(); if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; $object->socialnetworks[$key] = GETPOST($key, 'alpha'); } } @@ -1057,7 +1057,7 @@ if ($action == 'create' || $action == 'adduserldap') if (! empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) continue; + if (!$value['active']) break; print ''.$langs->trans($value['label']).''; print ''; if (! empty($ldap_social[$key])) {