dolibarr 20.0.0
partnershipcard.controller.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formcardwebportal.class.php';
27
32{
36 protected $formCard;
37
38
44 public function checkAccess()
45 {
46 $context = Context::getInstance();
47 $cardAccess = getDolGlobalString('WEBPORTAL_PARTNERSHIP_CARD_ACCESS');
48 $this->accessRight = isModEnabled('partnership') && in_array($cardAccess, array('visible', 'edit')) && $context->logged_partnership && $context->logged_partnership->id > 0;
49 return parent::checkAccess();
50 }
51
58 public function action()
59 {
60 global $langs;
61
62 $context = Context::getInstance();
63 if (!$context->controllerInstance->checkAccess()) {
64 return -1;
65 }
66
67 // Load translation files required by the page
68 $langs->loadLangs(array('partnership'));
69
70 $context->title = $langs->trans('WebPortalPartnershipCardTitle');
71 $context->desc = $langs->trans('WebPortalPartnershipCardDesc');
72 $context->menu_active[] = 'partnership_card';
73
74 // set form card
75 $cardAccess = getDolGlobalString('WEBPORTAL_PARTNERSHIP_CARD_ACCESS');
76 $permissiontoread = (int) isModEnabled('partnership') && in_array($cardAccess, array('visible', 'edit'));
77 $permissiontoadd = (int) isModEnabled('partnership') && in_array($cardAccess, array('edit'));
78 $permissiontodelete = 0;
79 $permissionnote = 0;
80 $permissiondellink = 0;
81 $formCardWebPortal = new FormCardWebPortal($this->db);
82 $formCardWebPortal->init('partnership', $context->logged_partnership->id, $permissiontoread, $permissiontoadd, $permissiontodelete, $permissionnote, $permissiondellink);
83
84 // hook for action
85 $hookRes = $this->hookDoAction();
86 if (empty($hookRes)) {
87 $formCardWebPortal->doActions();
88 }
89
90 $this->formCard = $formCardWebPortal;
91
92 return 1;
93 }
94
100 public function display()
101 {
102 $context = Context::getInstance();
103 if (!$context->controllerInstance->checkAccess()) {
104 $this->display404();
105 return;
106 }
107
108 $this->loadTemplate('header');
109 $this->loadTemplate('menu');
110 $this->loadTemplate('hero-header-banner');
111
112 $hookRes = $this->hookPrintPageView();
113 if (empty($hookRes)) {
114 print '<main class="container">';
115 print $this->formCard->elementCard($context);
116 print '</main>';
117 }
118
119 $this->loadTemplate('footer');
120 }
121}
static getInstance()
Singleton method to create one instance of this object.
Class to manage pages.
hookPrintPageView($parameters=array())
Execute hook PrintPageView.
display404()
Display error template.
hookDoAction($parameters=array())
Execute hook doActions.
loadTemplate($templateName, $vars=false)
Load a template .tpl file.
Class to manage generation of HTML components Only common components for WebPortal must be here.
Class for PartnershipCardController.
action()
Action method is called before html output can be used to manage security and change context.
checkAccess()
Check current access to controller.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.