dolibarr 19.0.4
agenda_extsites.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2016 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32
33require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
36
37// Load translation files required by page
38$langs->loadLangs(array('agenda', 'admin', 'other'));
39
40$def = array();
41$actiontest = GETPOST('test', 'alpha');
42$actionsave = GETPOST('save', 'alpha');
43$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'useragenda'; // To manage different context of search
44
45if (!getDolGlobalString('AGENDA_EXT_NB')) {
46 $conf->global->AGENDA_EXT_NB = 5;
47}
48$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
49
50// List of available colors
51$colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', 'A4A4A5');
52
53// Security check
54$id = GETPOST('id', 'int');
55
56if (!isset($id) || empty($id)) {
58}
59
60$object = new User($db);
61$object->fetch($id, '', '', 1);
62$object->getrights();
63
64// Security check
65$socid = 0;
66if ($user->socid > 0) {
67 $socid = $user->socid;
68}
69$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
70
71$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
72
73// If user is not user that read and no permission to read other users, we stop
74if (($object->id != $user->id) && (!$user->hasRight('user', 'user', 'lire'))) {
76}
77
78// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
79$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard'));
80
81/*
82 * Actions
83 */
84
85$parameters = array('id'=>$socid);
86$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
87if ($reshook < 0) {
88 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
89}
90
91if (empty($reshook)) {
92 if ($actionsave) {
93 $db->begin();
94
95 $errorsaved = 0;
96 $error = 0;
97 $tabparam = array();
98
99 // Save agendas
100 $i = 1;
101 while ($i <= $MAXAGENDA) {
102 $name = trim(GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$i, 'alpha'));
103 $src = trim(GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$i, 'alpha'));
104 $offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ_'.$id.'_'.$i, 'alpha'));
105 $color = trim(GETPOST('AGENDA_EXT_COLOR_'.$id.'_'.$i, 'alpha'));
106 if ($color == '-1') {
107 $color = '';
108 }
109 $enabled = trim(GETPOST('AGENDA_EXT_ENABLED_'.$id.'_'.$i, 'alpha'));
110
111 if (!empty($src) && !dol_is_url($src)) {
112 setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
113 $error++;
114 $errorsaved++;
115 break;
116 }
117
118 $tabparam['AGENDA_EXT_NAME_'.$id.'_'.$i] = $name;
119 $tabparam['AGENDA_EXT_SRC_'.$id.'_'.$i] = $src;
120 $tabparam['AGENDA_EXT_OFFSETTZ_'.$id.'_'.$i] = $offsettz;
121 $tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i] = $color;
122 $tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i] = $enabled;
123
124 $i++;
125 }
126
127 if (!$error) {
128 $result = dol_set_user_param($db, $conf, $object, $tabparam);
129 if (!($result > 0)) {
130 $error++;
131 }
132 }
133
134 if (!$error) {
135 $db->commit();
136 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
137 } else {
138 $db->rollback();
139 if (empty($errorsaved)) {
140 setEventMessages($langs->trans("Error"), null, 'errors');
141 }
142 }
143 }
144}
145
146/*
147 * View
148 */
149
150$form = new Form($db);
151$formadmin = new FormAdmin($db);
152$formother = new FormOther($db);
153
154$arrayofjs = array();
155$arrayofcss = array();
156
157$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
158$title = $person_name." - ".$langs->trans('ExtSites');
159$help_url = '';
160
161llxHeader('', $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
162
163
164print '<form name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
165print '<input type="hidden" name="id" value="'.$id.'">';
166print '<input type="hidden" name="token" value="'.newToken().'">';
167
168$head = user_prepare_head($object);
169
170print dol_get_fiche_head($head, 'extsites', $langs->trans("User"), -1, 'user');
171
172$linkback = '';
173
174if ($user->hasRight('user', 'user', 'lire') || $user->admin) {
175 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
176}
177
178$morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid" rel="noopener">';
179$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
180$morehtmlref .= '</a>';
181
182$urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
183$morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
184
185dol_banner_tab($object, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin, 'rowid', 'ref', $morehtmlref);
186
187print '<div class="fichecenter">';
188
189print '<div class="underbanner clearboth"></div>';
190print '<table class="border tableforfield centpercent">';
191
192// Login
193print '<tr><td id="anchorforperms" class="titlefield">'.$langs->trans("Login").'</td>';
194if (!empty($object->ldap_sid) && $object->statut == 0) {
195 print '<td class="error">';
196 print $langs->trans("LoginAccountDisableInDolibarr");
197 print '</td>';
198} else {
199 print '<td>';
200 $addadmin = '';
201 if (property_exists($object, 'admin')) {
202 if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
203 $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
204 } elseif (!empty($object->admin)) {
205 $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
206 }
207 }
208 print showValueWithClipboardCPButton($object->login).$addadmin;
209 print '</td>';
210}
211print '</tr>'."\n";
212
213print '</table>';
214
215print '</div>';
216
217print dol_get_fiche_end();
218
219
220print '<br>';
221print '<span class="opacitymedium">'.$langs->trans("AgendaExtSitesDesc")."</span><br>\n";
222print "<br>\n";
223
224$selectedvalue = !getDolGlobalString('AGENDA_DISABLE_EXT') ? 0 : $conf->global->AGENDA_DISABLE_EXT;
225if ($selectedvalue == 1) {
226 $selectedvalue = 0;
227} else {
228 $selectedvalue = 1;
229}
230
231
232print '<div class="div-table-responsive">';
233print '<table class="noborder centpercent">';
234
235print "<tr class=\"liste_titre\">";
236print "<td>".$langs->trans("Parameter")."</td>";
237print "<td>".$langs->trans("Name")."</td>";
238print "<td>".$langs->trans("ExtSiteUrlAgenda").'<div class="hideonsmartphone opacitymedium">'." (".$langs->trans("Example").': https://externalcalendar/agenda/agenda.ics)</div></td>';
239print "<td>".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFixTZOnlyIfRequired"), 1).'</td>';
240print '<td class="right">'.$langs->trans("Color").'</td>';
241print "</tr>";
242
243$i = 1;
244while ($i <= $MAXAGENDA) {
245 $key = $i;
246 $name = 'AGENDA_EXT_NAME_'.$id.'_'.$key;
247 $src = 'AGENDA_EXT_SRC_'.$id.'_'.$key;
248 $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key;
249 $color = 'AGENDA_EXT_COLOR_'.$id.'_'.$key;
250
251 print '<tr class="oddeven">';
252 // Nb
253 print '<td class="maxwidth50onsmartphone">'.$langs->trans("AgendaExtNb", $key)."</td>";
254 // Name
255 $name_value = (GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$key) ? GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$key) : (empty($object->conf->$name) ? '' : $object->conf->$name));
256 print '<td><input type="text" class="flat hideifnotset minwidth100 maxwidth100onsmartphone" name="AGENDA_EXT_NAME_'.$id.'_'.$key.'" value="'.$name_value.'"></td>';
257 // URL
258 $src_value = (GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$key) ? GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$key) : (empty($object->conf->$src) ? '' : $object->conf->$src));
259 print '<td><input type="url" class="flat hideifnotset width300" name="AGENDA_EXT_SRC_'.$id.'_'.$key.'" value="'.$src_value.'"></td>';
260 // Offset TZ
261 $offsettz_value = (GETPOST('AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key) ? GETPOST('AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key) : (empty($object->conf->$offsettz) ? '' : $object->conf->$offsettz));
262 print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key.'" value="'.$offsettz_value.'" size="1"></td>';
263 // Color (Possible colors are limited by Google)
264 print '<td class="nowraponall right">';
265 $color_value = (GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key) ? GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key) : (empty($object->conf->$color) ? 'ffffff' : $object->conf->$color));
266 print $formother->selectColor($color_value, "AGENDA_EXT_COLOR_".$id.'_'.$key, '', 1, '', 'hideifnotset');
267 print '</td>';
268 print "</tr>";
269 $i++;
270}
271
272print '</table>';
273print '</div>';
274
275$addition_button = array(
276 'name' => 'save',
277 'label_key' => 'Save',
278 'addclass' => 'hideifnotset',
279);
280print $form->buttonsSaveCancel("", "", $addition_button);
281
282print dol_get_fiche_end();
283
284print "</form>\n";
285
286// End of page
287llxFooter();
288$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to generate html code for admin pages.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage Dolibarr users.
dol_is_url($url)
Return if path is an URL.
dol_set_user_param($db, $conf, &$user, $tab)
Save personnal parameter.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
Definition inc.php:403
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.