dolibarr 21.0.0-alpha
fediverse.php
1<?php
2/* Copyright (C) 2003 Eric Seigne <erics@rycks.com>
3 * Copyright (C) 2003,2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
10 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
11 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33//load Dolibarr environment
34require '../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/socialnetwork.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/modules/modSocialNetworks.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/fediverseparser.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/boxes/box_fediverse.php';
41
42
43
44//load translation files requires by the page
45$langs->loadLangs(array('admin', 'users', 'dict'));
46
47$action = GETPOST('action', 'aZ09');
48
49// Security check
50if (!$user->admin) {
52}
53if (!isModEnabled('socialnetworks')) {
54 accessforbidden('Module Social Networks is not enabled');
55}
56
57// List of oauth services
58$oauthservices = array();
59
60foreach ($conf->global as $key => $val) {
61 if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
62 $key = preg_replace('/^OAUTH_/', '', $key);
63 $key = preg_replace('/_ID$/', '', $key);
64 if (preg_match('/^.*-/', $key)) {
65 $name = preg_replace('/^.*-/', '', $key);
66 } else {
67 $name = $langs->trans("NoName");
68 }
69 $provider = preg_replace('/-.*$/', '', $key);
70 $provider = ucfirst(strtolower($provider));
71
72 $oauthservices[$key] = $name." (".$provider.")";
73 }
74}
75
76/*
77 * Actions
78 */
79
80if ($action == 'add') {
81 $error = 0;
82
83 if (empty(GETPOST('socialnetwork_name')) || empty(GETPOST('socialnetwork_url'))) {
84 $error++;
85 }
86
87 $socialNetworkName = GETPOST('socialnetwork_name', 'alpha');
88 $socialNetworkUrl = GETPOST('socialnetwork_url', 'alpha');
89 if (GETPOSTISSET("OAUTH_SERVICE_SOCIAL_NETWORK")) {
90 dolibarr_set_const($db, "OAUTH_SERVICE_SOCIAL_NETWORK", GETPOST("OAUTH_SERVICE_SOCIAL_NETWORK", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
91 }
92
93 // other params if exist
94 $paramNames = GETPOST('param_name', 'array');
95 $paramValues = GETPOST('param_value', 'array');
96
97 $additionalParams = [];
98 if (!empty($paramNames) && is_array($paramNames)) {
99 foreach ($paramNames as $index => $paramName) {
100 if (!empty($paramName) && isset($paramValues[$index])) {
101 $additionalParams[$paramName] = $paramValues[$index];
102 }
103 }
104 }
105 if (!$error) {
106 $db->begin();
107
108 $socialNetworkData = array(
109 'title' => $socialNetworkName,
110 'url' => $socialNetworkUrl
111 );
112
113 $socialNetworkData = array_merge($socialNetworkData, $additionalParams);
114
115 $boxlabel = '(SocialNetwoksInformations)';
116
117 $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)";
118 $sql .= " VALUES ('box_fediverse.php', '".$db->escape($socialNetworkName)."')";
119
120 if (!$db->query($sql)) {
121 dol_print_error($db);
122 $error++;
123 } else {
124 $jsonData = json_encode($socialNetworkData);
125 $result = dolibarr_set_const($db, "SOCIAL_NETWORKS_DATA_".$socialNetworkName, $jsonData, 'chaine', 0, '', $conf->entity);
126 }
127 }
128 if ($result) {
129 $db->commit();
130 header("Location: ".$_SERVER["PHP_SELF"]);
131 exit;
132 } else {
133 $db->rollback();
134 dol_print_error($db);
135 }
136}
137
138if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') {
139 $error = 0;
140 $key = GETPOST('key', 'alpha');
141 $name = '';
142 $sqlgetName = "SELECT note FROM ".MAIN_DB_PREFIX."boxes_def WHERE rowid=".((int) $key);
143
144 $resqName = $db->query($sqlgetName);
145 if ($resqName) {
146 $objName = $db->fetch_object($resqName);
147 $name = $objName->note;
148 }
149
150 $db->begin();
151
152 $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
153 $sql .= " WHERE entity = ".$conf->entity;
154 $sql .= " AND box_id = ".((int) $key);
155 $resql1 = $db->query($sql);
156
157 $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def";
158 $sql .= " WHERE rowid = ".((int) $key);
159 $resql2 = $db->query($sql);
160
161 if (!$resql1 || !$resql2) {
162 $db->rollback();
163 dol_print_error($db, "sql=".$sql);
164 exit;
165 } else {
166 $result = dolibarr_del_const($db, "SOCIAL_NETWORKS_DATA_".$name, $conf->entity);
167 if ($result) {
168 $db->commit();
169 header("Location: ".$_SERVER["PHP_SELF"]);
170 exit;
171 } else {
172 $db->rollback();
173 dol_print_error($db);
174 }
175 }
176}
177
178if ($action == 'updatesocialnetwork') {
179 $error = 0;
180 $id = GETPOST('key', 'alpha');
181 $name = GETPOST('socialnetwork_name');
182 $url = GETPOST('socialnetwork_url');
183 $paramsKey = GETPOST('paramsKey', 'array');
184 $paramsVal = GETPOST('paramsVal', 'array');
185
186 $result = dolibarr_get_const($db, "SOCIAL_NETWORKS_DATA_".$name, $conf);
187 $socialNetworkData = json_decode($result, true);
188
189 foreach ($paramsKey as $index => $key) {
190 if (empty($key) || empty($paramsVal[$index])) {
191 $error++;
192 }
193 }
194 // delete others params
195 foreach ($socialNetworkData as $key => $value) {
196 if ($key != 'title' && $key != 'url') {
197 unset($socialNetworkData[$key]);
198 }
199 }
200
201 // new keys and new values in array
202 $mergedParams = array();
203 foreach ($paramsKey as $index => $key) {
204 if (isset($paramsVal[$index])) {
205 $mergedParams[$key] = $paramsVal[$index];
206 }
207 }
208
209 // Add new key, value if changed
210 foreach ($mergedParams as $newKey => $newValue) {
211 if (!isset($socialNetworkData[$newKey]) || $socialNetworkData[$newKey] !== $newValue) {
212 $socialNetworkData[$newKey] = $newValue;
213 }
214 }
215 if (!$error) {
216 $newData = json_encode($socialNetworkData);
217 $result = dolibarr_set_const($db, "SOCIAL_NETWORKS_DATA_".$name, $newData, 'chaine', 0, '', $conf->entity);
218 if ($result) {
219 $db->commit();
220 header("Location: ".$_SERVER["PHP_SELF"]);
221 exit;
222 } else {
223 $db->rollback();
224 dol_print_error($db);
225 }
226 } else {
227 setEventMessages($langs->trans("ErrorInputRequired"), null, 'errors');
228 header("Location: ".$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&key='.$id);
229 exit;
230 }
231}
232
233if ($action == 'editsocialnetwork' && GETPOST('confirm') == 'yes') {
234 $paramKey = GETPOST('paramkey', 'alpha');
235 $key = GETPOST('key', 'alpha');
236 $name = GETPOST('name');
237 $result = dolibarr_get_const($db, "SOCIAL_NETWORKS_DATA_".$name, $conf);
238 $socialNetworkData = json_decode($result, true);
239
240 unset($socialNetworkData[$paramKey]);
241 $newData = json_encode($socialNetworkData);
242
243 $result = dolibarr_set_const($db, "SOCIAL_NETWORKS_DATA_".$name, $newData, 'chaine', 0, '', $conf->entity);
244 if ($result) {
245 $db->commit();
246 header("Location: ".$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&key='.urlencode($key));
247 exit;
248 } else {
249 $db->rollback();
250 dol_print_error($db);
251 }
252}
253
254
255
256/*
257 * View
258 */
259
260$form = new Form($db);
261
262llxHeader('', $langs->trans("FediverseSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-dict');
263
264$head = socialnetwork_prepare_head();
265
266$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
267print dol_get_fiche_head($head, 'divers', $langs->trans('MenuDict'), -1, 'user', 0, $linkback, '', 0, '', 0);
268
269$title = $langs->trans("ConfigImportSocialNetwork");
270
271print_barre_liste($title, '', $_SERVER["PHP_SELF"], '', '', '', '', -1, '', 'tools', 0, '', '', -1, 0, 0, 0, '');
272
273
274print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
275print '<input type="hidden" name="token" value="'.newToken().'">';
276
277print '<div class="div-table-responsive-no-min">';
278print '<table class="noborder centpercent">';
279
280print '<tr class="liste_titre">';
281print '<td colspan="2">'.$langs->trans("NewSocialNetwork").'</td>';
282print '<td>'.$langs->trans("Example").'</td>';
283print '</tr>';
284
285print '<tr class="oddeven">';
286print '<td>'.$langs->trans("Title").'</td>';
287print '<td><input type="text" class="flat minwidth300" name="socialnetwork_name"></td>';
288print '<td>Mastodon</td>';
289print '</tr>';
290
291print '<tr class="oddeven">';
292print '<td>'.$langs->trans('SocialNetworkUrl').'</td>';
293print '<td><input type="text" class="flat minwidth300" name="socialnetwork_url"></td>';
294print '<td>https://mastodon.social/api/v1/accounts/id_user</td>';
295print '</tr>';
296$vartosmtpstype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING';
297
298print '<script>
299$(document).ready(function() {
300 function toggleOAuthServiceDisplay() {
301 if ($("#radio_oauth").is(":checked")) {
302 $("#oauth_service_div").show();
303 } else {
304 $("#oauth_service_div").hide();
305 }
306 }
307
308 toggleOAuthServiceDisplay();
309
310 $("input[name=\"'.$vartosmtpstype.'\"]").change(function() {
311 toggleOAuthServiceDisplay();
312 });
313});
314</script>';
315
316// Methods oauth
317print '<tr><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td>';
318print '<td>';
319print '<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.'" value="XOAUTH2"'.(getDolGlobalString($vartosmtpstype) == 'XOAUTH2' ? ' checked' : '').(isModEnabled('oauth') ? '' : ' disabled').'>';
320print '<label for="radio_oauth">'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
321if (!isModEnabled('oauth')) {
322 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword=oauth">'.$langs->trans("EnableModuleX", "OAuth").'</a>';
323} else {
324 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/oauth.php">'.$langs->trans("SetupModuleX", " OAuth").'</a>';
325}
326print '</td>';
327print '</tr>';
328
329print '<tr class="oddeven" id="oauth_service_div" style="display: none;">';
330print '<td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td>';
331print '<td>';
332
333$oauthservicesStringKeys = [];
334foreach ($oauthservices as $key => $value) {
335 $key = (string) $key;
336 $oauthservicesStringKeys[$key] = $value;
337}
338
340if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
341 print $form->selectarray('OAUTH_SERVICE_SOCIAL_NETWORK', $oauthservicesStringKeys, (string) $conf->global->OAUTH_SERVICE_SOCIAL_NETWORK);
342} else {
343 $selectedKey = (string) getDolGlobalString('OAUTH_SERVICE_SOCIAL_NETWORK');
344 $text = isset($oauthservicesStringKeys[$selectedKey]) ? $oauthservicesStringKeys[$selectedKey]['label'] : '';
345 if (empty($text)) {
346 $text = $langs->trans("Undefined");
347 }
348 $htmltext = $langs->trans("ContactSuperAdminForChange");
349 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
350 print '<input type="hidden" name="OAUTH_SERVICE_SOCIAL_NETWORK" value="'.$selectedKey.'">';
351}
352print '</td>';
353print '</tr>';
354
355print '<tr class="oddeven" id="add_param_row"><td>';
356print $form->textwithpicto($langs->trans("Others"), $langs->trans("AddMoreParams"));
357print '</td><td><button type="button" id="addParamButton">'.img_picto($langs->trans("AddMoreParams"), 'add', 'pictofixedwidth').'</button></td>';
358print '<td>Token : ****<br>Cookie : ****</td>';
359print '</tr>';
360
361print '<tr class="oddeven">';
362print '<td colspan="2">';
363print '<div id="additionalParams"></div>';
364print '</td>';
365print '<td></td>';
366print '</tr>';
367
368
369print '</table>';
370
371print '</div>';
372
373print $form->buttonsSaveCancel("Add", '');
374print '<input type="hidden" name="action" value="add">';
375print '<script type="text/javascript">
376 $(document).ready(function() {
377 function toggleOAuthServiceDisplay() {
378 if ($("#radio_oauth").is(":checked")) {
379 $("#oauth_service_div").show(); // Afficher le sélecteur OAuth
380 } else {
381 $("#oauth_service_div").hide(); // Cacher le sélecteur OAuth
382 }
383 }
384
385 function toggleAddParamRow() {
386 if ($("#radio_oauth").is(":checked")) {
387 $("#add_param_row").hide(); // Cacher toute la ligne
388 } else {
389 $("#add_param_row").show(); // Afficher toute la ligne
390 }
391 }
392
393 toggleOAuthServiceDisplay();
394 toggleAddParamRow();
395
396 $("input[name=\"'.$vartosmtpstype.'\"]").change(function() {
397 toggleOAuthServiceDisplay();
398 toggleAddParamRow();
399 });
400
401 $("#addParamButton").click(function() {
402 var container = $("#additionalParams");
403 var index = container.children().length;
404 var newParam = $("<div class=\'pair-group\'><input type=\'text\' class=\'flat minwidth300\' name=\'param_name[]\' placeholder=\''.$langs->trans("ParamName").'\' class=\'flat\' /> <input type=\'text\' class=\'flat minwidth300\' name=\'param_value[]\' placeholder=\''.$langs->trans("ParamValue").'\' class=\'flat\' /></div>");
405 container.append(newParam);
406 });
407 });
408</script>';
409print '</form>';
410
411print '<br><br>';
412print '<span class="opacitymedium">'.$langs->trans('SocialNetworksNote').'</span>';
413print ' - ';
414print '<a href="'.DOL_URL_ROOT.'/admin/boxes.php?backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.$langs->trans('JumpToBoxes').'</a>';
415print '<br><br>';
416
417
418if ($action == 'deletesocialnetwork') {
419 $formconfirm = $form->formconfirm(
420 $_SERVER["PHP_SELF"].'?key='.urlencode(GETPOST('key', 'alpha')),
421 $langs->trans('Delete'),
422 $langs->trans('ConfirmDeleteSocialNetwork', GETPOST('key', 'alpha')),
423 'confirm_delete',
424 '',
425 0,
426 1
427 );
428 print $formconfirm;
429}
430// delete params of social network
431if ($action == 'editsocialnetwork' && GETPOST('paramkey', 'alpha')) {
432 $paramKey = GETPOST('paramkey', 'alpha');
433 $name = GETPOST('name', 'alpha');
434
435 $formconfirm = $form->formconfirm(
436 $_SERVER["PHP_SELF"].'?key='.urlencode(GETPOST('key', 'alpha')).'&paramkey='.urlencode($paramKey).'&name='.urlencode($name),
437 $langs->trans('Delete'),
438 $langs->trans('ConfirmDeleteParamOfSocialNetwork', $paramKey),
439 'editsocialnetwork',
440 '',
441 0,
442 1
443 );
444 print $formconfirm;
445}
446$sql = "SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def";
447$sql .= " WHERE file = 'box_fediverse.php'";
448$sql .= " ORDER BY note";
449
450dol_syslog("select socialnetworks boxes", LOG_DEBUG);
451$resql = $db->query($sql);
452if ($resql) {
453 $boxlist = InfoBox::listBoxes($db, 'activated', -1, null);
454 $num = $db->num_rows($resql);
455 $i = 0;
456 while ($i < $num) {
457 $obj = $db->fetch_object($resql);
458
459 $jsonData = getDolGlobalString("SOCIAL_NETWORKS_DATA_".$obj->note);
460
461 $socialNetworkData = json_decode($jsonData, true);
462
463 $socialNetworkTitle = $socialNetworkData['title'];
464 $socialNetworkUrl = $socialNetworkData['url'];
465 $socialNetworkId = $obj->rowid;
466
467 $fediverseparser = new SocialNetworkManager($socialNetworkTitle);
468 $path_fediverse = DOL_DATA_ROOT.'/fediverse/temp/'.$socialNetworkTitle;
469
470 //check if other params exist
471 $authParams = [];
472 foreach ($socialNetworkData as $key => $value) {
473 if ($key !== 'title' && $key !== 'url') {
474 $authParams[$key] = $value;
475 }
476 }
477
478 $result = $fediverseparser->fetchPosts($socialNetworkUrl, 5, 300, $path_fediverse, $authParams);
479
480 print "<br>";
481 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
482 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
483
484 print '<table class="noborder centpercent">'."\n";
485
486 print '<tr class="liste_titre">';
487 print "<td>".$langs->trans("SocialNetworks")." ".($i + 1)."</td>";
488 print '<td class="right">';
489 print '<a class="viewfielda reposition marginleftonly marginrighttonly showInputBtn" href="'.$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&key='.urlencode($socialNetworkId).'">'.img_edit().'</a>';
490 print '<a class="deletefielda reposition marginleftonly right" href="'.$_SERVER["PHP_SELF"].'?action=deletesocialnetwork&token='.newToken().'&key='.urlencode($socialNetworkId).'">'.img_delete().'</a>';
491 print '<input type="hidden" name="id" value="'.$socialNetworkId.'">';
492 print '</td>';
493 print '</tr>'."\n";
494
495 print '<tr class="oddeven">';
496 print '<td>'.$langs->trans("Title")."</td>";
497 print '<td><input type="text" class="flat minwidth300" name="socialnetwork_name" value="'.dol_escape_htmltag($socialNetworkTitle).'" '.($action != "editsocialnetwork" ? 'disabled' : '').'></td>';
498 print '</tr>'."\n";
499
500 print '<tr class="oddeven">';
501 print "<td>".$langs->trans("URL")."</td>";
502 print '<td><input type="text" class="flat minwidth300" name="socialnetwork_url" value="'.dol_escape_htmltag($socialNetworkUrl).'" '.($action != "editsocialnetwork" ? 'disabled' : '').'></td>';
503 print '</tr>'."\n";
504
505 print '<tr class="oddeven">';
506 print "<td>".$langs->trans("Status")."</td>";
507 print "<td>";
508 if ($result > 0 && empty($fediverseparser->error)) {
509 print '<span class="ok">'.img_picto($langs->trans("Online"), 'tick', 'class="pictofixedwidth"').$langs->trans("Online").'</div>';
510 } else {
511 print '<span class="error">'.$langs->trans("Offline");
512 $langs->load("errors");
513 if ($fediverseparser->error) {
514 print ' - '.$langs->trans($fediverseparser->error);
515 }
516 print '</div>';
517 }
518 print "</td>";
519 print '</tr>'."\n";
520
521 // Active
522 $active = _isInBoxListFediverse((int) $socialNetworkId, $boxlist) ? 'yes' : 'no';
523
524 print '<tr class="oddeven">';
525 print '<td>'.$langs->trans('WidgetAvailable').'</td>';
526 print '<td>'.yn($active);
527 print ' &nbsp; - &nbsp; <a href="'.DOL_URL_ROOT.'/admin/boxes.php?backtopage='.urlencode($_SERVER["PHP_SELF"]).'">';
528 print $langs->trans("JumpToBoxes");
529 print '</a>';
530 print '</td>';
531 print '</tr>'."\n";
532
533 if ($action == 'editsocialnetwork' && $socialNetworkId == GETPOST('key')) {
534 foreach ($socialNetworkData as $k => $val) {
535 if ($k != 'title' && $k != 'url') {
536 print '<tr class="oddeven">';
537 print '<td><input type="text" class="flat minwidth200" name="paramsKey[]" value="'.dol_escape_htmltag($k).'"</td>';
538 if ($k == 'password') {
539 print '<td><input type="password" class="flat minwidth300" name="paramsVal[]" value="'.dol_escape_htmltag($val).'" />';
540 } else {
541 print '<td><input type="text" class="flat minwidth300" name="paramsVal[]" value="'.dol_escape_htmltag($val).'" />';
542 }
543 print '<button type="button" class="delete-param-btn" data-paramkey="'.htmlspecialchars($k).'">'.img_delete().'</button>';
544
545 print '</td>';
546 print '</tr>'."\n";
547 }
548 }
549
550 print '<tr class="oddeven">';
551 print '<td><input type="hidden" name="action" value="updatesocialnetwork" /></td>';
552 print '<td><input class="button " type="submit" name="update" value="'.$langs->trans('Modify').'" /></td>';
553 print '</tr>'."\n";
554
555 print '<script>
556 $(document).ready(function() {
557 $(\'.delete-param-btn\').on(\'click\', function() {
558 var paramKey = $(this).data(\'paramkey\');
559 var socialNetworkId = \''.htmlspecialchars($socialNetworkId).'\';
560 var socialNetworkName = \''.htmlspecialchars($socialNetworkTitle).'\';
561 window.location.href = \''.$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&paramkey=\' + encodeURIComponent(paramKey) + \'&key=\' + encodeURIComponent(socialNetworkId) + \'&name=\' + encodeURIComponent(socialNetworkName);
562 });
563 });
564 </script>';
565 }
566
567 print '</table>'."\n";
568
569 print "</form>\n";
570
571 $i++;
572 }
573} else {
574 dol_print_error($db);
575}
576
577print dol_get_fiche_end();
578
579llxFooter();
580$db->close();
581
589function _isInBoxListFediverse(int $id, array $boxlist)
590{
591 foreach ($boxlist as $box) {
592 if ($box->boxcode === "lastfediverseinfos") {
593 return true;
594 }
595 }
596 return false;
597}
$id
Definition account.php:39
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.
dolibarr_get_const($db, $name, $entity=1)
Get the value of a setup constant from database.
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:70
Class to manage generation of HTML components Only common components must be here.
static listBoxes($dbs, $mode, $zone, $user=null, $excludelist=array(), $includehidden=1)
Return array of boxes qualified for area and user.
Class to manage Social network posts.
llxFooter()
Footer empty.
Definition document.php:107
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.