dolibarr 21.0.0-beta
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
50//load translation files requires by the page
51$langs->loadLangs(array('admin', 'users', 'dict'));
52
53$action = GETPOST('action', 'aZ09');
54
55// Security check
56if (!$user->admin) {
58}
59if (!isModEnabled('socialnetworks')) {
60 accessforbidden('Module Social Networks is not enabled');
61}
62
63// List of oauth services
64$oauthservices = array();
65
66foreach ($conf->global as $key => $val) {
67 if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
68 $key = preg_replace('/^OAUTH_/', '', $key);
69 $key = preg_replace('/_ID$/', '', $key);
70 if (preg_match('/^.*-/', $key)) {
71 $name = preg_replace('/^.*-/', '', $key);
72 } else {
73 $name = $langs->trans("NoName");
74 }
75 $provider = preg_replace('/-.*$/', '', $key);
76 $provider = ucfirst(strtolower($provider));
77
78 $oauthservices[$key] = $name." (".$provider.")";
79 }
80}
81
82/*
83 * Actions
84 */
85
86if ($action == 'add') {
87 $error = 0;
88
89 if (empty(GETPOST('socialnetwork_name')) || empty(GETPOST('socialnetwork_url'))) {
90 $error++;
91 }
92
93 $socialNetworkName = GETPOST('socialnetwork_name', 'alpha');
94 $socialNetworkUrl = GETPOST('socialnetwork_url', 'alpha');
95 if (GETPOSTISSET("OAUTH_SERVICE_SOCIAL_NETWORK")) {
96 dolibarr_set_const($db, "OAUTH_SERVICE_SOCIAL_NETWORK", GETPOST("OAUTH_SERVICE_SOCIAL_NETWORK", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
97 }
98
99 // other params if exist
100 $paramNames = GETPOST('param_name', 'array');
101 $paramValues = GETPOST('param_value', 'array');
102
103 $additionalParams = [];
104 if (!empty($paramNames) && is_array($paramNames)) {
105 foreach ($paramNames as $index => $paramName) {
106 if (!empty($paramName) && isset($paramValues[$index])) {
107 $additionalParams[$paramName] = $paramValues[$index];
108 }
109 }
110 }
111 if (!$error) {
112 $db->begin();
113
114 $socialNetworkData = array(
115 'title' => $socialNetworkName,
116 'url' => $socialNetworkUrl
117 );
118
119 $socialNetworkData = array_merge($socialNetworkData, $additionalParams);
120
121 $boxlabel = '(SocialNetwoksInformations)';
122
123 $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)";
124 $sql .= " VALUES ('box_fediverse.php', '".$db->escape($socialNetworkName)."')";
125
126 if (!$db->query($sql)) {
127 dol_print_error($db);
128 $error++;
129 } else {
130 $jsonData = json_encode($socialNetworkData);
131 $result = dolibarr_set_const($db, "SOCIAL_NETWORKS_DATA_".$socialNetworkName, $jsonData, 'chaine', 0, '', $conf->entity);
132 }
133 }
134 if ($result) {
135 $db->commit();
136 header("Location: ".$_SERVER["PHP_SELF"]);
137 exit;
138 } else {
139 $db->rollback();
140 dol_print_error($db);
141 }
142}
143
144if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') {
145 $error = 0;
146 $key = GETPOST('key', 'alpha');
147 $name = '';
148 $sqlgetName = "SELECT note FROM ".MAIN_DB_PREFIX."boxes_def WHERE rowid=".((int) $key);
149
150 $resqName = $db->query($sqlgetName);
151 if ($resqName) {
152 $objName = $db->fetch_object($resqName);
153 $name = $objName->note;
154 }
155
156 $db->begin();
157
158 $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
159 $sql .= " WHERE entity = ".$conf->entity;
160 $sql .= " AND box_id = ".((int) $key);
161 $resql1 = $db->query($sql);
162
163 $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def";
164 $sql .= " WHERE rowid = ".((int) $key);
165 $resql2 = $db->query($sql);
166
167 if (!$resql1 || !$resql2) {
168 $db->rollback();
169 dol_print_error($db, "sql=".$sql);
170 exit;
171 } else {
172 $result = dolibarr_del_const($db, "SOCIAL_NETWORKS_DATA_".$name, $conf->entity);
173 if ($result) {
174 $db->commit();
175 header("Location: ".$_SERVER["PHP_SELF"]);
176 exit;
177 } else {
178 $db->rollback();
179 dol_print_error($db);
180 }
181 }
182}
183
184if ($action == 'updatesocialnetwork') {
185 $error = 0;
186 $id = GETPOST('key', 'alpha');
187 $name = GETPOST('socialnetwork_name');
188 $url = GETPOST('socialnetwork_url');
189 $paramsKey = GETPOST('paramsKey', 'array');
190 $paramsVal = GETPOST('paramsVal', 'array');
191
192 $result = dolibarr_get_const($db, "SOCIAL_NETWORKS_DATA_".$name, $conf->entity);
193 $socialNetworkData = json_decode($result, true);
194
195 foreach ($paramsKey as $index => $key) {
196 if (empty($key) || empty($paramsVal[$index])) {
197 $error++;
198 }
199 }
200 // delete others params
201 foreach ($socialNetworkData as $key => $value) {
202 if ($key != 'title' && $key != 'url') {
203 unset($socialNetworkData[$key]);
204 }
205 }
206
207 // new keys and new values in array
208 $mergedParams = array();
209 foreach ($paramsKey as $index => $key) {
210 if (isset($paramsVal[$index])) {
211 $mergedParams[$key] = $paramsVal[$index];
212 }
213 }
214
215 // Add new key, value if changed
216 foreach ($mergedParams as $newKey => $newValue) {
217 if (!isset($socialNetworkData[$newKey]) || $socialNetworkData[$newKey] !== $newValue) {
218 $socialNetworkData[$newKey] = $newValue;
219 }
220 }
221 if (!$error) {
222 $newData = json_encode($socialNetworkData);
223 $result = dolibarr_set_const($db, "SOCIAL_NETWORKS_DATA_".$name, $newData, 'chaine', 0, '', $conf->entity);
224 if ($result) {
225 $db->commit();
226 header("Location: ".$_SERVER["PHP_SELF"]);
227 exit;
228 } else {
229 $db->rollback();
230 dol_print_error($db);
231 }
232 } else {
233 setEventMessages($langs->trans("ErrorInputRequired"), null, 'errors');
234 header("Location: ".$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&key='.$id);
235 exit;
236 }
237}
238
239if ($action == 'editsocialnetwork' && GETPOST('confirm') == 'yes') {
240 $paramKey = GETPOST('paramkey', 'alpha');
241 $key = GETPOST('key', 'alpha');
242 $name = GETPOST('name');
243 $result = dolibarr_get_const($db, "SOCIAL_NETWORKS_DATA_".$name, $conf->entity);
244 $socialNetworkData = json_decode($result, true);
245
246 unset($socialNetworkData[$paramKey]);
247 $newData = json_encode($socialNetworkData);
248
249 $result = dolibarr_set_const($db, "SOCIAL_NETWORKS_DATA_".$name, $newData, 'chaine', 0, '', $conf->entity);
250 if ($result) {
251 $db->commit();
252 header("Location: ".$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&key='.urlencode($key));
253 exit;
254 } else {
255 $db->rollback();
256 dol_print_error($db);
257 }
258}
259
260
261
262/*
263 * View
264 */
265
266$form = new Form($db);
267
268llxHeader('', $langs->trans("FediverseSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-dict');
269
270$head = socialnetwork_prepare_head();
271
272$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
273print dol_get_fiche_head($head, 'divers', $langs->trans('MenuDict'), -1, 'user', 0, $linkback, '', 0, '', 0);
274
275$title = $langs->trans("ConfigImportSocialNetwork");
276
277print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', '', '', '', -1, '', 'tools', 0, '', '', -1, 0, 0, 0, '');
278
279
280print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
281print '<input type="hidden" name="token" value="'.newToken().'">';
282
283print '<div class="div-table-responsive-no-min">';
284print '<table class="noborder centpercent">';
285
286print '<tr class="liste_titre">';
287print '<td colspan="2">'.$langs->trans("NewSocialNetwork").'</td>';
288print '<td>'.$langs->trans("Example").'</td>';
289print '</tr>';
290
291print '<tr class="oddeven">';
292print '<td>'.$langs->trans("Title").'</td>';
293print '<td><input type="text" class="flat minwidth300" name="socialnetwork_name"></td>';
294print '<td>Mastodon</td>';
295print '</tr>';
296
297print '<tr class="oddeven">';
298print '<td>'.$langs->trans('SocialNetworkUrl').'</td>';
299print '<td><input type="text" class="flat minwidth300" name="socialnetwork_url"></td>';
300print '<td>https://mastodon.social/api/v1/accounts/id_user</td>';
301print '</tr>';
302$vartosmtpstype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING';
303
304print '<script>
305$(document).ready(function() {
306 function toggleOAuthServiceDisplay() {
307 if ($("#radio_oauth").is(":checked")) {
308 $("#oauth_service_div").show();
309 } else {
310 $("#oauth_service_div").hide();
311 }
312 }
313
314 toggleOAuthServiceDisplay();
315
316 $("input[name=\"'.$vartosmtpstype.'\"]").change(function() {
317 toggleOAuthServiceDisplay();
318 });
319});
320</script>';
321
322// Methods oauth
323print '<tr><td>'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").'</td>';
324print '<td>';
325print '<input type="radio" id="radio_oauth" name="'.$vartosmtpstype.'" value="XOAUTH2"'.(getDolGlobalString($vartosmtpstype) == 'XOAUTH2' ? ' checked' : '').(isModEnabled('oauth') ? '' : ' disabled').'>';
326print '<label for="radio_oauth">'.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).'</label>';
327if (!isModEnabled('oauth')) {
328 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword=oauth">'.$langs->trans("EnableModuleX", "OAuth").'</a>';
329} else {
330 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/admin/oauth.php">'.$langs->trans("SetupModuleX", " OAuth").'</a>';
331}
332print '</td>';
333print '</tr>';
334
335print '<tr class="oddeven" id="oauth_service_div" style="display: none;">';
336print '<td>'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").'</td>';
337print '<td>';
338
339$oauthservicesStringKeys = [];
340foreach ($oauthservices as $key => $value) {
341 $key = (string) $key;
342 $oauthservicesStringKeys[$key] = $value;
343}
344
346if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
347 print $form->selectarray('OAUTH_SERVICE_SOCIAL_NETWORK', $oauthservicesStringKeys, (string) $conf->global->OAUTH_SERVICE_SOCIAL_NETWORK);
348} else {
349 $selectedKey = (string) getDolGlobalString('OAUTH_SERVICE_SOCIAL_NETWORK');
350 $text = isset($oauthservicesStringKeys[$selectedKey]) ? $oauthservicesStringKeys[$selectedKey]['label'] : '';
351 if (empty($text)) {
352 $text = $langs->trans("Undefined");
353 }
354 $htmltext = $langs->trans("ContactSuperAdminForChange");
355 print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
356 print '<input type="hidden" name="OAUTH_SERVICE_SOCIAL_NETWORK" value="'.$selectedKey.'">';
357}
358print '</td>';
359print '</tr>';
360
361print '<tr class="oddeven" id="add_param_row"><td>';
362print $form->textwithpicto($langs->trans("Others"), $langs->trans("AddMoreParams"));
363print '</td><td><button type="button" id="addParamButton">'.img_picto($langs->trans("AddMoreParams"), 'add', 'pictofixedwidth').'</button></td>';
364print '<td>Token : ****<br>Cookie : ****</td>';
365print '</tr>';
366
367print '<tr class="oddeven">';
368print '<td colspan="2">';
369print '<div id="additionalParams"></div>';
370print '</td>';
371print '<td></td>';
372print '</tr>';
373
374
375print '</table>';
376
377print '</div>';
378
379print $form->buttonsSaveCancel("Add", '');
380print '<input type="hidden" name="action" value="add">';
381print '<script type="text/javascript">
382 $(document).ready(function() {
383 function toggleOAuthServiceDisplay() {
384 if ($("#radio_oauth").is(":checked")) {
385 $("#oauth_service_div").show(); // Afficher le sélecteur OAuth
386 } else {
387 $("#oauth_service_div").hide(); // Cacher le sélecteur OAuth
388 }
389 }
390
391 function toggleAddParamRow() {
392 if ($("#radio_oauth").is(":checked")) {
393 $("#add_param_row").hide(); // Cacher toute la ligne
394 } else {
395 $("#add_param_row").show(); // Afficher toute la ligne
396 }
397 }
398
399 toggleOAuthServiceDisplay();
400 toggleAddParamRow();
401
402 $("input[name=\"'.$vartosmtpstype.'\"]").change(function() {
403 toggleOAuthServiceDisplay();
404 toggleAddParamRow();
405 });
406
407 $("#addParamButton").click(function() {
408 var container = $("#additionalParams");
409 var index = container.children().length;
410 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>");
411 container.append(newParam);
412 });
413 });
414</script>';
415print '</form>';
416
417print '<br><br>';
418print '<span class="opacitymedium">'.$langs->trans('SocialNetworksNote').'</span>';
419print ' - ';
420print '<a href="'.DOL_URL_ROOT.'/admin/boxes.php?backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.$langs->trans('JumpToBoxes').'</a>';
421print '<br><br>';
422
423
424if ($action == 'deletesocialnetwork') {
425 $formconfirm = $form->formconfirm(
426 $_SERVER["PHP_SELF"].'?key='.urlencode(GETPOST('key', 'alpha')),
427 $langs->trans('Delete'),
428 $langs->trans('ConfirmDeleteSocialNetwork', GETPOST('key', 'alpha')),
429 'confirm_delete',
430 '',
431 0,
432 1
433 );
434 print $formconfirm;
435}
436// delete params of social network
437if ($action == 'editsocialnetwork' && GETPOST('paramkey', 'alpha')) {
438 $paramKey = GETPOST('paramkey', 'alpha');
439 $name = GETPOST('name', 'alpha');
440
441 $formconfirm = $form->formconfirm(
442 $_SERVER["PHP_SELF"].'?key='.urlencode(GETPOST('key', 'alpha')).'&paramkey='.urlencode($paramKey).'&name='.urlencode($name),
443 $langs->trans('Delete'),
444 $langs->trans('ConfirmDeleteParamOfSocialNetwork', $paramKey),
445 'editsocialnetwork',
446 '',
447 0,
448 1
449 );
450 print $formconfirm;
451}
452$sql = "SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def";
453$sql .= " WHERE file = 'box_fediverse.php'";
454$sql .= " ORDER BY note";
455
456dol_syslog("select socialnetworks boxes", LOG_DEBUG);
457$resql = $db->query($sql);
458if ($resql) {
459 $boxlist = InfoBox::listBoxes($db, 'activated', -1, null);
460 $num = $db->num_rows($resql);
461 $i = 0;
462 while ($i < $num) {
463 $obj = $db->fetch_object($resql);
464
465 $jsonData = getDolGlobalString("SOCIAL_NETWORKS_DATA_".$obj->note);
466
467 $socialNetworkData = json_decode($jsonData, true);
468
469 $socialNetworkTitle = $socialNetworkData['title'];
470 $socialNetworkUrl = $socialNetworkData['url'];
471 $socialNetworkId = $obj->rowid;
472
473 $fediverseparser = new SocialNetworkManager($socialNetworkTitle);
474 $path_fediverse = DOL_DATA_ROOT.'/fediverse/temp/'.$socialNetworkTitle;
475
476 //check if other params exist
477 $authParams = [];
478 foreach ($socialNetworkData as $key => $value) {
479 if ($key !== 'title' && $key !== 'url') {
480 $authParams[$key] = $value;
481 }
482 }
483
484 $result = $fediverseparser->fetchPosts($socialNetworkUrl, 5, 300, $path_fediverse, $authParams);
485
486 print "<br>";
487 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
488 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
489
490 print '<table class="noborder centpercent">'."\n";
491
492 print '<tr class="liste_titre">';
493 print "<td>".$langs->trans("SocialNetworks")." ".($i + 1)."</td>";
494 print '<td class="right">';
495 print '<a class="viewfielda reposition marginleftonly marginrighttonly showInputBtn" href="'.$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&key='.urlencode($socialNetworkId).'">'.img_edit().'</a>';
496 print '<a class="deletefielda reposition marginleftonly right" href="'.$_SERVER["PHP_SELF"].'?action=deletesocialnetwork&token='.newToken().'&key='.urlencode($socialNetworkId).'">'.img_delete().'</a>';
497 print '<input type="hidden" name="id" value="'.$socialNetworkId.'">';
498 print '</td>';
499 print '</tr>'."\n";
500
501 print '<tr class="oddeven">';
502 print '<td>'.$langs->trans("Title")."</td>";
503 print '<td><input type="text" class="flat minwidth300" name="socialnetwork_name" value="'.dol_escape_htmltag($socialNetworkTitle).'" '.($action != "editsocialnetwork" ? 'disabled' : '').'></td>';
504 print '</tr>'."\n";
505
506 print '<tr class="oddeven">';
507 print "<td>".$langs->trans("URL")."</td>";
508 print '<td><input type="text" class="flat minwidth300" name="socialnetwork_url" value="'.dol_escape_htmltag($socialNetworkUrl).'" '.($action != "editsocialnetwork" ? 'disabled' : '').'></td>';
509 print '</tr>'."\n";
510
511 print '<tr class="oddeven">';
512 print "<td>".$langs->trans("Status")."</td>";
513 print "<td>";
514 if ($result > 0 && empty($fediverseparser->error)) {
515 print '<span class="ok">'.img_picto($langs->trans("Online"), 'tick', 'class="pictofixedwidth"').$langs->trans("Online").'</div>';
516 } else {
517 print '<span class="error">'.$langs->trans("Offline");
518 $langs->load("errors");
519 if ($fediverseparser->error) {
520 print ' - '.$langs->trans($fediverseparser->error);
521 }
522 print '</div>';
523 }
524 print "</td>";
525 print '</tr>'."\n";
526
527 // Active
528 $active = _isInBoxListFediverse((int) $socialNetworkId, $boxlist) ? 'yes' : 'no';
529
530 print '<tr class="oddeven">';
531 print '<td>'.$langs->trans('WidgetAvailable').'</td>';
532 print '<td>'.yn($active);
533 print ' &nbsp; - &nbsp; <a href="'.DOL_URL_ROOT.'/admin/boxes.php?backtopage='.urlencode($_SERVER["PHP_SELF"]).'">';
534 print $langs->trans("JumpToBoxes");
535 print '</a>';
536 print '</td>';
537 print '</tr>'."\n";
538
539 if ($action == 'editsocialnetwork' && $socialNetworkId == GETPOST('key')) {
540 foreach ($socialNetworkData as $k => $val) {
541 if ($k != 'title' && $k != 'url') {
542 print '<tr class="oddeven">';
543 print '<td><input type="text" class="flat minwidth200" name="paramsKey[]" value="'.dol_escape_htmltag($k).'"</td>';
544 if ($k == 'password') {
545 print '<td><input type="password" class="flat minwidth300" name="paramsVal[]" value="'.dol_escape_htmltag($val).'" />';
546 } else {
547 print '<td><input type="text" class="flat minwidth300" name="paramsVal[]" value="'.dol_escape_htmltag($val).'" />';
548 }
549 print '<button type="button" class="delete-param-btn" data-paramkey="'.htmlspecialchars($k).'">'.img_delete().'</button>';
550
551 print '</td>';
552 print '</tr>'."\n";
553 }
554 }
555
556 print '<tr class="oddeven">';
557 print '<td><input type="hidden" name="action" value="updatesocialnetwork" /></td>';
558 print '<td><input class="button " type="submit" name="update" value="'.$langs->trans('Modify').'" /></td>';
559 print '</tr>'."\n";
560
561 print '<script>
562 $(document).ready(function() {
563 $(\'.delete-param-btn\').on(\'click\', function() {
564 var paramKey = $(this).data(\'paramkey\');
565 var socialNetworkId = \''.htmlspecialchars($socialNetworkId).'\';
566 var socialNetworkName = \''.htmlspecialchars($socialNetworkTitle).'\';
567 window.location.href = \''.$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&paramkey=\' + encodeURIComponent(paramKey) + \'&key=\' + encodeURIComponent(socialNetworkId) + \'&name=\' + encodeURIComponent(socialNetworkName);
568 });
569 });
570 </script>';
571 }
572
573 print '</table>'."\n";
574
575 print "</form>\n";
576
577 $i++;
578 }
579} else {
580 dol_print_error($db);
581}
582
583print dol_get_fiche_end();
584
585llxFooter();
586$db->close();
587
595function _isInBoxListFediverse(int $id, array $boxlist)
596{
597 foreach ($boxlist as $box) {
598 if ($box->boxcode === "lastfediverseinfos") {
599 return true;
600 }
601 }
602 return false;
603}
$id
Definition account.php:48
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:71
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.
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.