dolibarr 20.0.2
website.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24// Load Dolibarr environment
25require '../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
27require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
33require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
34
35// Load translation files required by the page
36$langs->loadlangs(array('errors', 'admin', 'companies', 'website'));
37
38$action = GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view';
39$confirm = GETPOST('confirm', 'alpha');
40$backtopage = GETPOST('backtopage', 'alpha');
41
42$rowid = GETPOST('rowid', 'alpha');
43
44$id = 1;
45
46$acts[0] = "activate";
47$acts[1] = "disable";
48$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"');
49$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"');
50
51// Load variable for pagination
52$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
53$sortfield = GETPOST('sortfield', 'aZ09comma');
54$sortorder = GETPOST('sortorder', 'aZ09comma');
55$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
56if (empty($page) || $page == -1) {
57 $page = 0;
58} // If $page is not defined, or '' or -1
59$offset = $limit * $page;
60$pageprev = $page - 1;
61$pagenext = $page + 1;
62
63if (empty($sortfield)) {
64 $sortfield = 'position, ref';
65}
66if (empty($sortorder)) {
67 $sortorder = 'ASC';
68}
69
70// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
71$hookmanager->initHooks(array('website'));
72
73// Name of SQL tables of dictionaries
74$tabname = array();
75$tabname[1] = MAIN_DB_PREFIX."website";
76
77// Dictionary labels
78$tablib = array();
79$tablib[1] = "Websites";
80
81// Requests to extract data
82$tabsql = array();
83$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.position, f.status, f.date_creation, f.lastaccess, f.pageviews_previous_month, f.pageviews_total FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')';
84
85// Criteria to sort dictionaries
86$tabsqlsort = array();
87$tabsqlsort[1] = "ref ASC";
88
89// Nom des champs en resultat de select pour affichage du dictionnaire
90$tabfield = array();
91$tabfield[1] = "ref,description,virtualhost,position,date_creation,lastaccess,pageviews_previous_month,pageviews_total";
92
93// Nom des champs d'edition pour modification d'un enregistrement
94$tabfieldvalue = array();
95$tabfieldvalue[1] = "ref,description,virtualhost,position,entity";
96
97// Nom des champs dans la table pour insertion d'un enregistrement
98$tabfieldinsert = array();
99$tabfieldinsert[1] = "ref,description,virtualhost,position,entity";
100
101// Nom du rowid si le champ n'est pas de type autoincrement
102// Example: "" if id field is "rowid" and has autoincrement on
103// "nameoffield" if id field is not "rowid" or has not autoincrement on
104$tabrowid = array();
105$tabrowid[1] = "";
106
107// Condition to show dictionary in setup page
108$tabcond = array();
109$tabcond[1] = (isModEnabled('website'));
110
111// List of help for fields
112$tabhelp = array();
113$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/<i>websiteref</i>'));
114
115// List of check for fields (NOT USED YET)
116$tabfieldcheck = array();
117$tabfieldcheck[1] = array();
118
119
120// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
121$elementList = array();
122$sourceList = array();
123
124if (!$user->admin) {
126}
127
128
129/*
130 * Actions
131 */
132
133// Actions add or modify a website
134if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
135 $listfield = explode(',', $tabfield[$id]);
136 $listfieldinsert = explode(',', $tabfieldinsert[$id]);
137 $listfieldmodify = explode(',', $tabfieldinsert[$id]);
138 $listfieldvalue = explode(',', $tabfieldvalue[$id]);
139
140 // Check that all fields are filled
141 $ok = 1;
142 foreach ($listfield as $f => $value) {
143 if ($value == 'ref' && (!GETPOSTISSET($value) || GETPOST($value) == '')) {
144 $ok = 0;
145 $fieldnamekey = $listfield[$f];
146 setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
147 break;
148 } elseif ($value == 'ref' && !preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST($value))) {
149 $ok = 0;
150 $fieldnamekey = $listfield[$f];
151 setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities($fieldnamekey)), null, 'errors');
152 break;
153 }
154 }
155
156 // Clean parameters
157 if (GETPOST('ref')) {
158 $websitekey = strtolower(GETPOST('ref'));
159 }
160
161 // Si verif ok et action add, on ajoute la ligne
162 if ($ok && GETPOST('actionadd', 'alpha')) {
163 if ($tabrowid[$id]) {
164 // Get free id for insert
165 $newid = 0;
166 $sql = "SELECT MAX(".$tabrowid[$id].") newid from ".$tabname[$id];
167 $result = $db->query($sql);
168 if ($result) {
169 $obj = $db->fetch_object($result);
170 $newid = ($obj->newid + 1);
171 } else {
172 dol_print_error($db);
173 }
174 }
175
176 /* $website=new Website($db);
177 $website->ref=
178 $website->description=
179 $website->virtualhost=
180 $website->create($user); */
181
182 // Add new entry
183 $sql = "INSERT INTO ".$tabname[$id]." (";
184 // List of fields
185 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
186 $sql .= $tabrowid[$id].",";
187 }
188 $sql .= $tabfieldinsert[$id];
189 $sql .= ", status, date_creation)";
190 $sql .= " VALUES(";
191
192 // List of values
193 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
194 $sql .= $newid.",";
195 }
196 $i = 0;
197 foreach ($listfieldinsert as $f => $value) {
198 if ($value == 'entity') {
199 $_POST[$listfieldvalue[$i]] = $conf->entity;
200 }
201 if ($value == 'ref') {
202 $_POST[$listfieldvalue[$i]] = strtolower(GETPOST($listfieldvalue[$i]));
203 }
204 if ($i) {
205 $sql .= ",";
206 }
207 if (GETPOST($listfieldvalue[$i]) == '') {
208 $sql .= "null";
209 } else {
210 $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'";
211 }
212 $i++;
213 }
214 $sql .= ", 1, '".$db->idate(dol_now())."')";
215
216 dol_syslog("actionadd", LOG_DEBUG);
217 $result = $db->query($sql);
218 if ($result) { // Add is ok
219 setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
220 unset($_POST); // Clean $_POST array, we keep only
221 } else {
222 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
223 setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
224 } else {
225 dol_print_error($db);
226 }
227 }
228 }
229
230 // Si verif ok et action modify, on modifie la ligne
231 if ($ok && GETPOST('actionmodify', 'alpha')) {
232 if ($tabrowid[$id]) {
233 $rowidcol = $tabrowid[$id];
234 } else {
235 $rowidcol = "rowid";
236 }
237
238 $db->begin();
239
240 $website = new Website($db);
241 $rowid = GETPOSTINT('rowid');
242 $website->fetch($rowid);
243
244 // Modify entry
245 $sql = "UPDATE ".$tabname[$id]." SET ";
246 // Modifie valeur des champs
247 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
248 $sql .= $tabrowid[$id]."=";
249 $sql .= "'".$db->escape($rowid)."', ";
250 }
251 $i = 0;
252 foreach ($listfieldmodify as $field) {
253 if ($field == 'entity') {
254 $_POST[$listfieldvalue[$i]] = $conf->entity;
255 }
256 if ($i) {
257 $sql .= ",";
258 }
259 $sql .= $field."=";
260 if (GETPOST($listfieldvalue[$i]) == '') {
261 $sql .= "null";
262 } else {
263 $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'";
264 }
265 $i++;
266 }
267 $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
268
269 dol_syslog("actionmodify", LOG_DEBUG);
270 //print $sql;
271 $resql = $db->query($sql);
272 if ($resql) {
273 $newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09'));
274 if ($newname != $website->ref) {
275 $srcfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website->ref;
276 $destfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$newname;
277
278 if (dol_is_dir($destfile)) {
279 $error++;
280 setEventMessages($langs->trans('ErrorDirAlreadyExists', $destfile), null, 'errors');
281 } else {
282 @rename($srcfile, $destfile);
283
284 // We must now rename $website->ref into $newname inside files
285 $arrayreplacement = array($website->ref.'/htmlheader.html' => $newname.'/htmlheader.html');
286 $listofilestochange = dol_dir_list($destfile, 'files', 0, '\.php$');
287 foreach ($listofilestochange as $key => $value) {
288 dolReplaceInFile($value['fullname'], $arrayreplacement);
289 }
290 }
291 }
292 } else {
293 $error++;
294 setEventMessages($db->lasterror(), null, 'errors');
295 }
296
297 if (!$error) {
298 $db->commit();
299 } else {
300 $db->rollback();
301 }
302 }
303}
304
305if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
306 if ($tabrowid[$id]) {
307 $rowidcol = $tabrowid[$id];
308 } else {
309 $rowidcol = "rowid";
310 }
311
312 $website = new Website($db);
313 $website->fetch($rowid);
314
315 if ($website->id > 0) {
316 $sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website = ".((int) $rowid);
317 $result = $db->query($sql);
318
319 $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website = ".((int) $rowid);
320 $result = $db->query($sql);
321
322 $sql = "DELETE from ".MAIN_DB_PREFIX."website_extrafields WHERE fk_object = ".((int) $rowid);
323 $result = $db->query($sql);
324
325 $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid = ".((int) $rowid);
326 $result = $db->query($sql);
327 if (!$result) {
328 if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
329 setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
330 } else {
331 dol_print_error($db);
332 }
333 }
334
335 if ($website->ref) {
336 dol_delete_dir_recursive($conf->website->dir_output.'/'.$website->ref);
337 }
338 } else {
339 dol_print_error($db, 'Failed to load website with id '.$rowid);
340 }
341}
342
343// activate
344if ($action == $acts[0]) {
345 if ($tabrowid[$id]) {
346 $rowidcol = $tabrowid[$id];
347 } else {
348 $rowidcol = "rowid";
349 }
350
351 if ($rowid) {
352 $sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid = ".((int) $rowid);
353 }
354
355 $result = $db->query($sql);
356 if (!$result) {
357 dol_print_error($db);
358 }
359}
360
361// disable
362if ($action == $acts[1]) {
363 if ($tabrowid[$id]) {
364 $rowidcol = $tabrowid[$id];
365 } else {
366 $rowidcol = "rowid";
367 }
368
369 if ($rowid) {
370 $sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid = ".((int) $rowid);
371 }
372
373 $result = $db->query($sql);
374 if (!$result) {
375 dol_print_error($db);
376 }
377}
378
379
380
381/*
382 * View
383 */
384
385$form = new Form($db);
386$formadmin = new FormAdmin($db);
387
388llxHeader('', $langs->trans("WebsiteSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-website');
389
390$titre = $langs->trans("WebsiteSetup");
391$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
392print load_fiche_titre($titre, $linkback, 'title_setup');
393
394// Onglets
395$head = array();
396$h = 0;
397
398$head[$h][0] = DOL_URL_ROOT."/admin/website.php";
399$head[$h][1] = $langs->trans("WebSites");
400$head[$h][2] = 'website';
401$h++;
402
403$head[$h][0] = DOL_URL_ROOT."/admin/website_options.php";
404$head[$h][1] = $langs->trans("Options");
405$head[$h][2] = 'options';
406$h++;
407
408print dol_get_fiche_head($head, 'website', '', -1);
409
410
411print '<span class="opacitymedium">'.$langs->trans("WebsiteSetupDesc").'</span><br>';
412print "<br>\n";
413
414
415// Confirmation de la suppression de la ligne
416if ($action == 'delete') {
417 print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete', '', 0, 1, 220);
418}
419//var_dump($elementList);
420
421/*
422 * Show website list
423 */
424if ($id) {
425 // Complete requete recherche valeurs avec critere de tri
426 $sql = $tabsql[$id];
427 $sql .= $db->order($sortfield, $sortorder);
428 $sql .= $db->plimit($limit + 1, $offset);
429 //print $sql;
430
431 $fieldlist = explode(',', $tabfield[$id]);
432
433 print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
434 print '<input type="hidden" name="token" value="'.newToken().'">';
435 print '<table class="noborder centpercent">';
436
437 // Form to add a new line
438 if ($tabname[$id]) {
439 // Line for title
440 print '<tr class="liste_titre">';
441 foreach ($fieldlist as $field => $value) {
442 if (in_array($fieldlist[$field], array('date_creation', 'lastaccess', 'pageviews_previous_month', 'pageviews_month', 'pageviews_total'))) {
443 continue;
444 }
445
446 // Determine le nom du champ par rapport aux noms possibles
447 // dans les dictionnaires de donnees
448 $valuetoshow = ucfirst($fieldlist[$field]); // By default
449 $valuetoshow = $langs->trans($valuetoshow); // try to translate
450 $align = '';
451 if ($fieldlist[$field] == 'lang') {
452 $valuetoshow = $langs->trans("Language");
453 }
454 if ($valuetoshow != '') {
455 print '<td class="'.$align.'">';
456 if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
457 print '<a href="'.$tabhelp[$id][$value].'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
458 } elseif (!empty($tabhelp[$id][$value])) {
459 if ($value == 'virtualhost') {
460 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual');
461 } else {
462 print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
463 }
464 } else {
465 print $valuetoshow;
466 }
467 print '</td>';
468 }
469 }
470
471 print '<td colspan="4">';
472 print '</td>';
473 print '</tr>';
474
475 // Line to enter new values
476 print '<tr class="oddeven">';
477
478 $obj = new stdClass();
479 // If data was already input, we define them in obj to populate input fields.
480 if (GETPOST('actionadd', 'alpha')) {
481 foreach ($fieldlist as $key => $val) {
482 if (GETPOST($val, 'alpha')) {
483 $obj->$val = GETPOST($val);
484 }
485 }
486 }
487 if (!isset($obj->position)) {
488 $obj->position = 1;
489 }
490
491 fieldListWebsites($fieldlist, $obj, $tabname[$id], 'add');
492
493 print '<td colspan="3" class="right">';
494 if ($action != 'edit') {
495 print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'">';
496 }
497 print '</td>';
498 print "</tr>";
499 }
500
501 print '</table>';
502 print '</form>';
503
504
505 // List of websites in database
506 $resql = $db->query($sql);
507 if ($resql) {
508 $num = $db->num_rows($resql);
509 $i = 0;
510 if ($num) {
511 print '<br>';
512
513 print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
514 print '<input type="hidden" name="token" value="'.newToken().'">';
515 print '<input type="hidden" name="page" value="'.$page.'">';
516 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
517
518 print '<div class="div-table-responsive">';
519 print '<table class="noborder centpercent">';
520
521 // Title of lines
522 print '<tr class="liste_titre">';
523 foreach ($fieldlist as $field => $value) {
524 // Determine le nom du champ par rapport aux noms possibles
525 // dans les dictionnaires de donnees
526 $showfield = 1; // By default
527 $align = "left";
528 $sortable = 1;
529 $valuetoshow = '';
530 if (in_array($fieldlist[$field], array('pageviews_total', 'pageviews_previous_month'))) {
531 $align = 'right';
532 }
533
534 /*
535 $tmparray=getLabelOfField($fieldlist[$field]);
536 $showfield=$tmp['showfield'];
537 $valuetoshow=$tmp['valuetoshow'];
538 $align=$tmp['align'];
539 $sortable=$tmp['sortable'];
540 */
541 $valuetoshow = ucfirst($fieldlist[$field]); // By default
542 $valuetoshow = $langs->trans($valuetoshow); // try to translate
543 if ($fieldlist[$field] == 'lang') {
544 $valuetoshow = $langs->trans("Language");
545 }
546 if ($fieldlist[$field] == 'type') {
547 $valuetoshow = $langs->trans("Type");
548 }
549 if ($fieldlist[$field] == 'code') {
550 $valuetoshow = $langs->trans("Code");
551 }
552 if ($fieldlist[$field] == 'date_creation') {
553 $valuetoshow = $langs->trans("DateCreation");
554 }
555 if ($fieldlist[$field] == 'lastaccess') {
556 $valuetoshow = $langs->trans("LastAccess");
557 }
558 if ($fieldlist[$field] == 'pageviews_previous_month') {
559 $valuetoshow = $langs->trans("PagesViewedPreviousMonth");
560 }
561 if ($fieldlist[$field] == 'pageviews_total') {
562 $valuetoshow = $langs->trans("PagesViewedTotal");
563 }
564
565 // Affiche nom du champ
566 if ($showfield) {
567 print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", '', $sortfield, $sortorder, $align.' ');
568 }
569 }
570
571 // Status
572 print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", '', $sortfield, $sortorder, 'center ');
573 print getTitleFieldOfList('');
574 print getTitleFieldOfList('');
575 print '</tr>';
576
577 // Lines with values
578 while ($i < $num) {
579 $obj = $db->fetch_object($resql);
580 //print_r($obj);
581 print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
582 if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
583 $tmpaction = 'edit';
584 $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
585 $reshook = $hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
586 $error = $hookmanager->error;
587 $errors = $hookmanager->errors;
588
589 if (empty($reshook)) {
590 fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit');
591 }
592
593 print '<td colspan="7" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a>';
594 print '<input type="submit" class="button button-edit small" name="actionmodify" value="'.$langs->trans("Modify").'">';
595 print '&nbsp;';
596 print '<input type="submit" class="button button-cancel small" name="actioncancel" value="'.$langs->trans("Cancel").'">';
597 print '</td>';
598 } else {
599 $tmpaction = 'view';
600 $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
601 $reshook = $hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
602
603 $error = $hookmanager->error;
604 $errors = $hookmanager->errors;
605
606 if (empty($reshook)) {
607 foreach ($fieldlist as $field => $value) {
608 $showfield = 1;
609 $fieldname = $fieldlist[$field];
610 $align = "left";
611 if (in_array($fieldname, array('pageviews_total', 'pageviews_previous_month'))) {
612 $align = 'right';
613 }
614 $valuetoshow = $obj->$fieldname;
615
616 // Show value for field
617 if ($showfield) {
618 print '<td class="'.$align.'">'.$valuetoshow.'</td>';
619 }
620 }
621 }
622
623 // Can an entry be erased or disabled ?
624 $iserasable = 1;
625 $isdisable = 1; // true by default
626 if ($obj->status) {
627 $iserasable = 0; // We can't delete a website on. Disable it first.
628 }
629
630 $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&amp;code='.(!empty($obj->code) ? urlencode($obj->code) : '').'&amp;';
631
632
633 // Active
634 print '<td align="center" class="nowrap">';
635 print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'&token='.newToken().'">'.$actl[($obj->status ? 1 : 0)].'</a>';
636 print "</td>";
637
638 // Modify link
639 print '<td align="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
640
641 // Delete link
642 if ($iserasable) {
643 print '<td align="center"><a class="reposition" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>';
644 } else {
645 print '<td class="center">'.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'</td>';
646 }
647
648 print "</tr>\n";
649 }
650 $i++;
651 }
652
653 print '</table>';
654 print '</div>';
655
656 print '</form>';
657 }
658 } else {
659 dol_print_error($db);
660 }
661}
662
663print dol_get_fiche_end();
664
665// End of page
666llxFooter();
667$db->close();
668
669
679function fieldListWebsites($fieldlist, $obj = null, $tabname = '', $context = '')
680{
681 global $conf, $langs, $db;
682 global $form;
683 global $region_id;
684 global $elementList, $sourceList, $localtax_typeList;
685 global $bc;
686
687 $formadmin = new FormAdmin($db);
688
689 foreach ($fieldlist as $field => $value) {
690 if (in_array($fieldlist[$field], array('lastaccess', 'pageviews_previous_month', 'pageviews_month', 'pageviews_total'))) {
691 continue;
692 }
693
694 $fieldname = $fieldlist[$field];
695
696 if ($fieldlist[$field] == 'lang') {
697 print '<td>';
698 print $formadmin->select_language(getDolGlobalString('MAIN_LANG_DEFAULT'), 'lang');
699 print '</td>';
700 } elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) {
701 print '<td><input type="text" class="flat" value="'.(!empty($obj->$fieldname) ? $obj->$fieldname : '').'" size="10" name="'.$fieldlist[$field].'"></td>';
702 } else {
703 if ($fieldlist[$field] == 'date_creation') {
704 continue;
705 }
706
707 print '<td>';
708 $size = '';
709 if ($fieldlist[$field] == 'code') {
710 $size = 'size="8" ';
711 }
712 if ($fieldlist[$field] == 'position') {
713 $size = 'size="4" ';
714 }
715 if ($fieldlist[$field] == 'libelle') {
716 $size = 'size="32" ';
717 }
718 if ($fieldlist[$field] == 'tracking') {
719 $size = 'size="92" ';
720 }
721 if ($fieldlist[$field] == 'sortorder') {
722 $size = 'size="2" ';
723 }
724 print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldname) ? $obj->$fieldname : '').'" name="'.$fieldlist[$field].'">';
725 print '</td>';
726 }
727 }
728}
fieldListWebsites($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
Definition website.php:679
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.
Class Website.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
dol_is_dir($folder)
Test if filename is a directory.
dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask='0', $indexdatabase=0, $arrayreplacementisregex=0)
Make replacement of strings into a file.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_now($mode='auto')
Return date for now.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
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.
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 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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.