cache socialnetworks array
This commit is contained in:
parent
41b89ae677
commit
5096c5bf2d
@ -2450,21 +2450,32 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64,
|
|||||||
function getArrayOfSocialNetworks()
|
function getArrayOfSocialNetworks()
|
||||||
{
|
{
|
||||||
global $conf, $db;
|
global $conf, $db;
|
||||||
$sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks";
|
|
||||||
$sql .= " WHERE entity=".$conf->entity;
|
|
||||||
$socialnetworks = array();
|
$socialnetworks = array();
|
||||||
$resql = $db->query($sql);
|
// Enable caching of array
|
||||||
if ($resql) {
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
$cachekey = 'socialnetworks_' . $conf->entity;
|
||||||
$socialnetworks[$obj->code] = array(
|
$dataretrieved = dol_getcache($cachekey);
|
||||||
'rowid' => $obj->rowid,
|
if (!is_null($dataretrieved)) {
|
||||||
'label' => $obj->label,
|
$socialnetworks = $dataretrieved;
|
||||||
'url' => $obj->url,
|
} else {
|
||||||
'icon' => $obj->icon,
|
$sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks";
|
||||||
'active' => $obj->active,
|
$sql .= " WHERE entity=".$conf->entity;
|
||||||
);
|
$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,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
dol_setcache($cachekey, $socialnetworks); // If setting cache fails, this is not a problem, so we do not test result.
|
||||||
}
|
}
|
||||||
|
|
||||||
return $socialnetworks;
|
return $socialnetworks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user