dolibarr 21.0.0-beta
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-2024 Frédéric France <frederic.france@free.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// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34
35$action = GETPOST('action', 'aZ09');
36$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search
37
46// Load translation files required by the page
47$langs->loadLangs(array('admin', 'companies'));
48
49if (!$user->admin) {
51}
52$listofnetworks = getArrayOfSocialNetworks();
53
54// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
55$hookmanager->initHooks(array('adminsocialnetworkscompany', 'globaladmin'));
56
57/*
58 * Actions
59 */
60
61$parameters = array();
62$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
63if ($reshook < 0) {
64 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
65}
66if (($action == 'update' && !GETPOST("cancel", 'alpha'))) {
67 foreach ($listofnetworks as $key => $value) {
68 if (!empty($value['active'])) {
69 $networkconstname = 'MAIN_INFO_SOCIETE_'.strtoupper($key).'_URL';
70 $networkconstid = 'MAIN_INFO_SOCIETE_'.strtoupper($key);
71 if (GETPOSTISSET($key.'url') && GETPOST($key.'url', 'alpha') != '') {
72 dolibarr_set_const($db, $networkconstname, GETPOST($key.'url', 'alpha'), 'chaine', 0, '', $conf->entity);
73 dolibarr_set_const($db, $networkconstid, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity);
74 } elseif (GETPOSTISSET($key) && GETPOST($key, 'alpha') != '') {
75 if (!empty($listofnetworks[$key]['url'])) {
76 $url = str_replace('{socialid}', GETPOST($key, 'alpha'), $listofnetworks[$key]['url']);
77 dolibarr_set_const($db, $networkconstname, $url, 'chaine', 0, '', $conf->entity);
78 }
79 dolibarr_set_const($db, $networkconstid, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity);
80 } else {
81 dolibarr_del_const($db, $networkconstname, $conf->entity);
82 dolibarr_del_const($db, $networkconstid, $conf->entity);
83 }
84 }
85 }
86
87 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
88}
89
90
91/*
92 * View
93 */
94
95$form = new Form($db);
96
97$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
98llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-company_socialnetworks');
99
100print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
101
103
104print dol_get_fiche_head($head, 'socialnetworks', '', -1, '');
105
106print '<span class="opacitymedium">'.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."</span><br>\n";
107print '<span class="opacitymedium">'.$langs->trans("MoreNetworksAvailableWithModule")."</span><br>\n";
108print "<br>\n";
109
110
115print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
116print '<input type="hidden" name="token" value="'.newToken().'">';
117print '<input type="hidden" name="action" value="update">';
118
119
120print '<div class="div-table-responsive-no-min">';
121print '<table class="noborder centpercent editmode">';
122print '<tr class="liste_titre">';
123print '<td class="titlefieldcreate">'.$langs->trans("SocialNetworksInformation").'</td>';
124print '<td>'.$langs->trans("SocialNetworkId").'</td>';
125print '<td>'.$form->textwithpicto($langs->trans("Url"), $langs->trans("KeepEmptyToUseDefault")).'</td>';
126print '<td></td>';
127print "</tr>\n";
128
129$listofnetworks = dol_sort_array($listofnetworks, 'label');
130
131foreach ($listofnetworks as $key => $value) {
132 if (!empty($value['active'])) {
133 print '<tr class="oddeven">';
134 print '<td><label for="'.$key.'url">'.$langs->trans(ucfirst($key)).'</label></td>';
135 $networkconstname = 'MAIN_INFO_SOCIETE_'.strtoupper($key).'_URL';
136 $networkconstid = 'MAIN_INFO_SOCIETE_'.strtoupper($key);
137 print '<td class="nowraponall"><span class="paddingright fab '.($value['icon'] ? $value['icon'] : 'fa-link').'"></span>';
138 print '<input name="'.$key.'" id="'.$key.'" class="minwidth300" value="'.dol_escape_htmltag(getDolGlobalString($networkconstid)).'">';
139 print '</td><td>';
140 print '<input name="'.$key.'url" id="'.$key.'url" class="minwidth300" value="'.dol_escape_htmltag(getDolGlobalString($networkconstname)).'">';
141 print '</td>';
142 print '<td class="nowraponall">'.dol_print_socialnetworks(dol_escape_htmltag(getDolGlobalString($networkconstid)), 0, 0, $key, $listofnetworks).'</td>';
143 print '</tr>'."\n";
144 }
145}
146
147print "</table>";
148print '</div>';
149
150
151print $form->buttonsSaveCancel("Save", '');
152
153print '</form>';
154
155
156// End of page
157llxFooter();
158$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
company_admin_prepare_head()
Return array head with list of tabs to view object information.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.