* Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2017 Philippe Grand * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2017 Rui Strecht * Copyright (C) 2020 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 * 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 . */ /** * \file htdocs/admin/company_socialnetworks.php * \ingroup company * \brief Setup page to configure company social networks */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search // Load translation files required by the page $langs->loadLangs(array('admin', 'companies')); if (!$user->admin) { accessforbidden(); } $listofnetworks = getArrayOfSocialNetworks(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('adminsocialnetworkscompany', 'globaladmin')); /* * Actions */ $parameters = array(); $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'); } if (($action == 'update' && !GETPOST("cancel", 'alpha'))) { foreach ($listofnetworks as $key => $value) { if (!empty($value['active'])) { $networkconstname = 'MAIN_INFO_SOCIETE_'.strtoupper($key).'_URL'; $networkconstid = 'MAIN_INFO_SOCIETE_'.strtoupper($key); if (GETPOSTISSET($key.'url') && GETPOST($key.'url', 'alpha') != '') { dolibarr_set_const($db, $networkconstname, GETPOST($key.'url', 'alpha'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $networkconstid, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); } elseif (GETPOSTISSET($key) && GETPOST($key, 'alpha') != '') { if (!empty($listofnetworks[$key]['url'])) { $url = str_replace('{socialid}', GETPOST($key, 'alpha'), $listofnetworks[$key]['url']); dolibarr_set_const($db, $networkconstname, $url, 'chaine', 0, '', $conf->entity); } dolibarr_set_const($db, $networkconstid, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); } else { dolibarr_del_const($db, $networkconstname, $conf->entity); dolibarr_del_const($db, $networkconstid, $conf->entity); } } } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } /* * View */ $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); $head = company_admin_prepare_head(); print dol_get_fiche_head($head, 'socialnetworks', '', -1, ''); print ''.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."
\n"; print ''.$langs->trans("MoreNetworksAvailableWithModule")."
\n"; print "
\n"; /** * Edit parameters */ print '
'; print ''; print ''; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $listofnetworks = dol_sort_array($listofnetworks, 'label'); //var_dump($listofnetworks); foreach ($listofnetworks as $key => $value) { if (!empty($value['active'])) { print ''; print ''; $networkconstname = 'MAIN_INFO_SOCIETE_'.strtoupper($key).'_URL'; $networkconstid = 'MAIN_INFO_SOCIETE_'.strtoupper($key); print ''; print ''; print ''."\n"; } } print "
'.$langs->trans("SocialNetworksInformation").''.$langs->trans("SocialNetworkId").''.$form->textwithpicto($langs->trans("Url"), $langs->trans("KeepEmptyToUseDefault")).'
'; print ''; print ''; print ''; print ''.dol_print_socialnetworks((!empty($conf->global->$networkconstid) ? dol_escape_htmltag($conf->global->$networkconstid) : ''), 0, 0, $key, $listofnetworks).'
"; print '
'; print $form->buttonsSaveCancel("Save", ''); print '
'; // End of page llxFooter(); $db->close();