dolibarr  16.0.5
company_socialnetworks.php
Go to the documentation of this file.
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 
31 require '../main.inc.php';
32 require_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 
40 if (!$user->admin) {
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
54 if ($reshook < 0) {
55  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
56 }
57 if (($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  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
79 }
80 
81 
82 /*
83  * View
84  */
85 
86 $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
87 llxHeader('', $langs->trans("Setup"), $wikihelp);
88 
89 print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
90 
92 
93 print dol_get_fiche_head($head, 'socialnetworks', '', -1, '');
94 
95 print '<span class="opacitymedium">'.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."</span><br>\n";
96 print "<br>\n";
97 
98 
103 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
104 print '<input type="hidden" name="token" value="'.newToken().'">';
105 print '<input type="hidden" name="action" value="update">';
106 
107 
108 print '<div class="div-table-responsive-no-min">';
109 print '<table class="noborder centpercent editmode">';
110 print '<tr class="liste_titre">';
111 print '<td class="titlefieldcreate">'.$langs->trans("SocialNetworksInformation").'</td>';
112 print '<td>'.$langs->trans("SocialNetworkId").'</td>';
113 print '<td>'.$form->textwithpicto($langs->trans("Url"), $langs->trans("KeepEmptyToUseDefault")).'</td>';
114 print '<td></td>';
115 print "</tr>\n";
116 
117 $listofnetworks = dol_sort_array($listofnetworks, 'label');
118 //var_dump($listofnetworks);
119 
120 foreach ($listofnetworks as $key => $value) {
121  if (!empty($value['active'])) {
122  print '<tr class="oddeven">';
123  print '<td><label for="'.$key.'url">'.$langs->trans(ucfirst($key)).'</label></td>';
124  $networkconstname = 'MAIN_INFO_SOCIETE_'.strtoupper($key).'_URL';
125  $networkconstid = 'MAIN_INFO_SOCIETE_'.strtoupper($key);
126  print '<td class="nowraponall"><span class="fa paddingright '.($value['icon'] ? $value['icon'] : 'fa-link').'"></span>';
127  print '<input name="'.$key.'" id="'.$key.'" class="minwidth300" value="'.(!empty($conf->global->$networkconstid) ? dol_escape_htmltag($conf->global->$networkconstid) : '').'">';
128  print '</td><td>';
129  print '<input name="'.$key.'url" id="'.$key.'url" class="minwidth300" value="'.(!empty($conf->global->$networkconstname) ? dol_escape_htmltag($conf->global->$networkconstname) : '').'">';
130  print '</td>';
131  print '<td class="nowraponall">'.dol_print_socialnetworks((!empty($conf->global->$networkconstid) ? dol_escape_htmltag($conf->global->$networkconstid) : ''), 0, 0, $key, $listofnetworks).'</td>';
132  print '</tr>'."\n";
133  }
134 }
135 
136 print "</table>";
137 print '</div>';
138 
139 
140 print $form->buttonsSaveCancel("Save", '');
141 
142 print '</form>';
143 
144 
145 // End of page
146 llxFooter();
147 $db->close();
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_sort_array
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
Definition: functions.lib.php:8385
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
getArrayOfSocialNetworks
getArrayOfSocialNetworks()
Get array of social network dictionary.
Definition: functions.lib.php:3026
$wikihelp
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:72
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
company_admin_prepare_head
company_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: admin.lib.php:1952