diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 77c54c5736e..ce8ade06e09 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -70,19 +70,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -$sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; -$socialnetworks = array(); -$resql = $db->query($sql); -if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $socialnetworks[$obj->code] = array( - 'rowid' => $obj->rowid, - 'label' => $obj->label, - 'url' => $obj->url, - 'active' => $obj->active, - ); - } -} +$socialnetworks = getArrayOfSocialNetworks(); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b59f66ed596..a51118b2c32 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2186,6 +2186,31 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, return $rep; } +/** + * Get array of social network dictionary + * + * @return array Array of Social Networks Dictionary + */ +function getArrayOfSocialNetworks() +{ + global $conf, $db; + $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; + $socialnetworks = array(); + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $socialnetworks[$obj->code] = array( + 'rowid' => $obj->rowid, + 'label' => $obj->label, + 'url' => $obj->url, + 'icon' => $obj->icon, + 'active' => $obj->active, + ); + } + } + return $socialnetworks; +} + /** * Show social network link * diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ab2d47dbe87..e348dfbe273 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -100,19 +100,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -$sql = "SELECT rowid, code, label, url, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; -$socialnetworks = array(); -$resql = $db->query($sql); -if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $socialnetworks[$obj->code] = array( - 'rowid' => $obj->rowid, - 'label' => $obj->label, - 'url' => $obj->url, - 'active' => $obj->active, - ); - } -} +$socialnetworks = getArrayOfSocialNetworks(); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('usercard','globalcard'));