1<?php 2/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com> 5 * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> 6 * Copyright (C) 2011-2017 Philippe Grand <philippe.grand@atoo-net.com> 7 * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr> 8 * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com> 9 * Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr> 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <https://www.gnu.org/licenses/>. 23 */ 24 25/** 26 * \file htdocs/admin/company_socialnetworks.php 27 * \ingroup company 28 * \brief Setup page to configure company social networks 29 */ 30 31require '../main.inc.php'; 32require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 33 34$action = GETPOST('action', 'aZ09'); 35$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search 36 37// Load translation files required by the page 38$langs->loadLangs(array('admin', 'companies')); 39 40if (!$user->admin) { 41 accessforbidden(); 42} 43$listofnetworks = getArrayOfSocialNetworks(); 44 45// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context 46$hookmanager->initHooks(array('adminsocialnetworkscompany', 'globaladmin')); 47 48/* 49 * Actions 50 */ 51 52$parameters = array(); 53$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 54if ($reshook < 0) { 55 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 56} 57if (($action == 'update' && !GETPOST("cancel", 'alpha'))) { 58 foreach ($listofnetworks as $key => $value) { 59 if (!empty($value['active'])) { 60 $networkconstname = 'MAIN_INFO_SOCIETE_'.strtoupper($key).'_URL'; 61 $networkconstid = 'MAIN_INFO_SOCIETE_'.strtoupper($key); 62 if (GETPOSTISSET($key.'url') && GETPOST($key.'url', 'alpha') != '') { 63 dolibarr_set_const($db, $networkconstname, GETPOST($key.'url', 'alpha'), 'chaine', 0, '', $conf->entity); 64 dolibarr_set_const($db, $networkconstid, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); 65 } elseif (GETPOSTISSET($key) && GETPOST($key, 'alpha') != '') { 66 if (!empty($listofnetworks[$key]['url'])) { 67 $url = str_replace('{socialid}', GETPOST($key, 'alpha'), $listofnetworks[$key]['url']); 68 dolibarr_set_const($db, $networkconstname, $url, 'chaine', 0, '', $conf->entity); 69 } 70 dolibarr_set_const($db, $networkconstid, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); 71 } else { 72 dolibarr_del_const($db, $networkconstname, $conf->entity); 73 dolibarr_del_const($db, $networkconstid, $conf->entity); 74 } 75 } 76 } 77} 78 79 80/* 81 * View 82 */ 83 84$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; 85llxHeader('', $langs->trans("Setup"), $wikihelp); 86 87print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); 88 89$head = company_admin_prepare_head(); 90 91print dol_get_fiche_head($head, 'socialnetworks', $langs->trans("SocialNetworksInformation"), -1, 'company'); 92 93print '<span class="opacitymedium">'.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."</span><br>\n"; 94print "<br>\n"; 95 96 97/** 98 * Edit parameters 99 */ 100 101print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; 102print '<input type="hidden" name="token" value="'.newToken().'">'; 103print '<input type="hidden" name="action" value="update">'; 104 105// Social networks 106print '<br>'; 107print '<table class="noborder centpercent editmode">'; 108print '<tr class="liste_titre">'; 109print '<td class="titlefield">'.$langs->trans("SocialNetworksInformation").'</td><td>'.$langs->trans("Url").'</td><td>'.$langs->trans("SocialNetworkId").'</td><td></td>'; 110print "</tr>\n"; 111 112 113foreach ($listofnetworks as $key => $value) { 114 if (!empty($value['active'])) { 115 print '<tr class="oddeven">'; 116 print '<td><label for="'.$key.'url">'.$langs->trans(ucfirst($key)).'</label></td>'; 117 $networkconstname = 'MAIN_INFO_SOCIETE_'.strtoupper($key).'_URL'; 118 $networkconstid = 'MAIN_INFO_SOCIETE_'.strtoupper($key); 119 print '<td><span class="fa paddingright '.($value['icon'] ? $value['icon'] : 'fa-link').'"></span>'; 120 print '<input name="'.$key.'url" id="'.$key.'url" class="minwidth300" value="'.dol_escape_htmltag($conf->global->$networkconstname).'">'; 121 print '</td><td>'; 122 print '<input name="'.$key.'" id="'.$key.'" class="minwidth300" value="'.dol_escape_htmltag($conf->global->$networkconstid).'">'; 123 print '</td>'; 124 print '<td>'.dol_print_socialnetworks($conf->global->$networkconstid, 0, 0, $key, $listofnetworks).'</td>'; 125 print '</tr>'."\n"; 126 } 127} 128 129print "</table>"; 130 131print '<br>'; 132 133print '<br><div class="center">'; 134print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">'; 135print '</div>'; 136 137print '</form>'; 138 139 140// End of page 141llxFooter(); 142$db->close(); 143