diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 01e85616f3d..77c54c5736e 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -66,6 +66,10 @@ if (! empty($conf->mailmanspip->enabled)) $object = new Adherent($db); $extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + $sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; $socialnetworks = array(); $resql = $db->query($sql); @@ -79,8 +83,6 @@ if ($resql) { ); } } -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 13035d1fb0e..ab2d47dbe87 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -100,6 +100,20 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; +$socialnetworks = array(); +$resql = $db->query($sql); +if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $socialnetworks[$obj->code] = array( + 'rowid' => $obj->rowid, + 'label' => $obj->label, + 'url' => $obj->url, + 'active' => $obj->active, + ); + } +} + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('usercard','globalcard')); @@ -212,11 +226,17 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alphanohtml'); $object->user_mobile = GETPOST("user_mobile", 'alphanohtml'); - $object->skype = GETPOST("skype", 'alphanohtml'); - $object->twitter = GETPOST("twitter", 'alphanohtml'); - $object->facebook = GETPOST("facebook", 'alphanohtml'); - $object->linkedin = GETPOST("linkedin", 'alphanohtml'); - + //$object->skype = GETPOST("skype", 'alphanohtml'); + //$object->twitter = GETPOST("twitter", 'alphanohtml'); + //$object->facebook = GETPOST("facebook", 'alphanohtml'); + //$object->linkedin = GETPOST("linkedin", 'alphanohtml'); + $object->socialnetworks = array(); + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) continue; + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature", 'none'); @@ -365,10 +385,17 @@ if (empty($reshook)) { $object->office_phone = GETPOST("office_phone", 'alphanohtml'); $object->office_fax = GETPOST("office_fax", 'alphanohtml'); $object->user_mobile = GETPOST("user_mobile", 'alphanohtml'); - $object->skype = GETPOST("skype", 'alpha'); - $object->twitter = GETPOST("twitter", 'alpha'); - $object->facebook = GETPOST("facebook", 'alpha'); - $object->linkedin = GETPOST("linkedin", 'alpha'); + //$object->skype = GETPOST("skype", 'alpha'); + //$object->twitter = GETPOST("twitter", 'alpha'); + //$object->facebook = GETPOST("facebook", 'alpha'); + //$object->linkedin = GETPOST("linkedin", 'alpha'); + $object->socialnetworks = array(); + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) continue; + $object->socialnetworks[$key] = GETPOST($key, 'alpha'); + } + } $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature", 'none'); @@ -625,10 +652,10 @@ if (empty($reshook)) { $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE]; $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX]; $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE]; - $ldap_skype = $attribute[$conf->global->LDAP_FIELD_SKYPE]; - $ldap_twitter = $attribute[$conf->global->LDAP_FIELD_TWITTER]; - $ldap_facebook = $attribute[$conf->global->LDAP_FIELD_FACEBOOK]; - $ldap_linkedin = $attribute[$conf->global->LDAP_FIELD_LINKEDIN]; + $ldap_social['skype'] = $attribute[$conf->global->LDAP_FIELD_SKYPE]; + $ldap_social['twitter'] = $attribute[$conf->global->LDAP_FIELD_TWITTER]; + $ldap_social['facebook'] = $attribute[$conf->global->LDAP_FIELD_FACEBOOK]; + $ldap_social['linkedin'] = $attribute[$conf->global->LDAP_FIELD_LINKEDIN]; $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL]; $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; } @@ -1040,73 +1067,87 @@ if ($action == 'create' || $action == 'adduserldap') } print ''; - // Skype - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Skype").''; - print ''; - if (! empty($ldap_skype)) - { - print ''; - print $ldap_skype; + if (! empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (!$value['active']) continue; + print ''.$langs->trans($value['label']).''; + print ''; + if (! empty($ldap_social[$key])) { + print ''; + print $ldap_social[$key]; + } else { + print ''; + } + print ''; } - else - { - print ''; - } - print ''; } + // // Skype + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Skype").''; + // print ''; + // if (! empty($ldap_skype)) + // { + // print ''; + // print $ldap_skype; + // } + // else + // { + // print ''; + // } + // print ''; + // } - // Twitter - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Twitter").''; - print ''; - if (! empty($ldap_twitter)) - { - print ''; - print $ldap_twitter; - } - else - { - print ''; - } - print ''; - } + // // Twitter + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Twitter").''; + // print ''; + // if (! empty($ldap_twitter)) + // { + // print ''; + // print $ldap_twitter; + // } + // else + // { + // print ''; + // } + // print ''; + // } - // Facebook - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("Facebook").''; - print ''; - if (! empty($ldap_facebook)) - { - print ''; - print $ldap_facebook; - } - else - { - print ''; - } - print ''; - } + // // Facebook + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("Facebook").''; + // print ''; + // if (! empty($ldap_facebook)) + // { + // print ''; + // print $ldap_facebook; + // } + // else + // { + // print ''; + // } + // print ''; + // } - // LinkedIn - if (! empty($conf->socialnetworks->enabled)) - { - print ''.$langs->trans("LinkedIn").''; - print ''; - if (! empty($ldap_linkedin)) - { - print ''; - print $ldap_linkedin; - } - else - { - print ''; - } - print ''; - } + // // LinkedIn + // if (! empty($conf->socialnetworks->enabled)) + // { + // print ''.$langs->trans("LinkedIn").''; + // print ''; + // if (! empty($ldap_linkedin)) + // { + // print ''; + // print $ldap_linkedin; + // } + // else + // { + // print ''; + // } + // print ''; + // } // EMail print 'global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").'';