dolibarr 22.0.5
membercard.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 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formcardwebportal.class.php';
28
33{
37 protected $formCard;
38
44 public function checkAccess()
45 {
47 $cardAccess = getDolGlobalString('WEBPORTAL_MEMBER_CARD_ACCESS');
48 $this->accessRight = isModEnabled('member') && in_array($cardAccess, array('visible', 'edit')) && $context->logged_member && $context->logged_member->id > 0;
49
50 return parent::checkAccess();
51 }
52
59 public function action()
60 {
61 global $langs;
62
64 if (!$context->controllerInstance->checkAccess()) {
65 return -1;
66 }
67
68 // Load translation files required by the page
69 $langs->loadLangs(array('companies', 'bills', 'members', 'users', 'other', 'paypal'));
70
71 $context->title = $langs->trans('WebPortalMemberCardTitle');
72 $context->desc = $langs->trans('WebPortalMemberCardDesc');
73 $context->menu_active[] = 'member_card';
74
75 // set form card
76 $cardAccess = getDolGlobalString('WEBPORTAL_MEMBER_CARD_ACCESS');
77 $permissiontoread = (int) isModEnabled('member') && in_array($cardAccess, array('visible', 'edit'));
78 $permissiontoadd = (int) isModEnabled('member') && in_array($cardAccess, array('edit'));
79 $permissiontodelete = 0;
80 $permissionnote = 0;
81 $permissiondellink = 0;
82 $formCardWebPortal = new FormCardWebPortal($this->db);
83 $formCardWebPortal->init('member', $context->logged_member->id, (int) $permissiontoread, (int) $permissiontoadd, $permissiontodelete, $permissionnote, $permissiondellink);
84
85 // hook for action
86 $hookRes = $this->hookDoAction();
87 if (empty($hookRes)) {
88 $formCardWebPortal->doActions();
89 }
90
91 $this->formCard = $formCardWebPortal;
92
93 return 1;
94 }
95
101 public function display()
102 {
104 if (!$context->controllerInstance->checkAccess()) {
105 $this->display404();
106 return;
107 }
108
109 $this->loadTemplate('header');
110 $this->loadTemplate('menu');
111 $this->loadTemplate('hero-header-banner');
112
113 $hookRes = $this->hookPrintPageView();
114 if (empty($hookRes)) {
115 print '<main class="container">';
116 print $this->formCard->elementCard($context);
117 print '</main>';
118 }
119
120 $this->loadTemplate('footer');
121 }
122}
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 MemberCardController.
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 a Dolibarr global constant string value.
$context
@method int call_trigger(string $triggerName, User $user)
Definition logout.php:42