dolibarr 23.0.3
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';
28require_once DOL_DOCUMENT_ROOT . '/webportal/controllers/abstractcard.controller.class.php';
29
34{
40 public function checkAccess()
41 {
43 $cardAccess = getDolGlobalString('WEBPORTAL_MEMBER_CARD_ACCESS');
44 $this->accessRight = isModEnabled('member') && in_array($cardAccess, array('visible', 'edit')) && $context->logged_member && $context->logged_member->id > 0;
45
46 return parent::checkAccess();
47 }
48
55 public function action()
56 {
57 global $langs;
58
60 if (!$context->controllerInstance->checkAccess()) {
61 return -1;
62 }
63
64 // Load translation files required by the page
65 $langs->loadLangs(array('companies', 'bills', 'members', 'users', 'other', 'paypal'));
66
67 $context->title = $langs->trans('WebPortalMemberCardTitle');
68 $context->desc = $langs->trans('WebPortalMemberCardDesc');
69 $context->menu_active[] = 'member_card';
70
71 // set form card
72 $cardAccess = getDolGlobalString('WEBPORTAL_MEMBER_CARD_ACCESS');
73 $permissiontoread = (int) isModEnabled('member') && in_array($cardAccess, array('visible', 'edit'));
74 $permissiontoadd = (int) isModEnabled('member') && in_array($cardAccess, array('edit'));
75 $permissiontodelete = 0;
76 $permissionnote = 0;
77 $permissiondellink = 0;
78 $formCardWebPortal = new FormCardWebPortal($this->db);
79 $formCardWebPortal->init('member', $context->logged_member->id, (int) $permissiontoread, (int) $permissiontoadd, $permissiontodelete, $permissionnote, $permissiondellink);
80
81 // hook for action
82 $hookRes = $this->hookDoAction();
83 if (empty($hookRes)) {
84 $formCardWebPortal->doActions();
85 }
86
87 $this->formCard = $formCardWebPortal;
88
89 return 1;
90 }
91}
Class for AbstractCardController.
static getInstance()
Singleton method to create one instance of this object.
hookDoAction($parameters=array())
Execute hook doActions.
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.
isModEnabled($module)
Is Dolibarr module enabled.
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition logout.php:42