dolibarr 24.0.0-beta
public_interface.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2006-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2006-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
43
44// Load translation files required by the page
45$langs->loadLangs(array("admin", "accountancy", "companies", "other"));
46
47$action = GETPOST('action', 'aZ09');
48
49if (!$user->admin) {
51}
52
53$error = 0;
54
55
56/*
57 * Actions
58 */
59
60if ($action == 'setSOCIETE_ENABLE_PUBLIC') {
61 if (GETPOST('value')) {
62 dolibarr_set_const($db, 'SOCIETE_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
63 } else {
64 dolibarr_set_const($db, 'SOCIETE_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
65 }
66}
67
68if ($action == 'update') {
69 $public = GETPOST('SOCIETE_ENABLE_PUBLIC');
70
71 $res = dolibarr_set_const($db, "SOCIETE_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
72
73 if (!($res > 0)) {
74 $error++;
75 }
76
77 if (!$error) {
78 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
79 } else {
80 setEventMessages($langs->trans("Error"), null, 'errors');
81 }
82}
83
84
85/*
86 * View
87 */
88
89$form = new Form($db);
90
91//$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
92$help_url = '';
93llxHeader('', $langs->trans("CompanySetup"), $help_url);
94
95$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
96
97print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup');
98
100
101
102
103print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
104print '<input type="hidden" name="action" value="update">';
105print '<input type="hidden" name="token" value="'.newToken().'">';
106
107print dol_get_fiche_head($head, 'publicurl', '', -1, 'company');
108
109
110print '<div class="info">';
111
112print '<span class="opacitymedium">'.$langs->trans("PublicInterfaceCompanyDesc").'</span><br><br>';
113
114$param = '';
115
116$enabledisablehtml = $langs->trans("EnablePublicCompanyPages").' ';
117if (!getDolGlobalString('SOCIETE_ENABLE_PUBLIC')) {
118 // Button off, click to enable
119 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setSOCIETE_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
120 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
121 $enabledisablehtml .= '</a>';
122} else {
123 // Button on, click to disable
124 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setSOCIETE_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
125 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
126 $enabledisablehtml .= '</a>';
127}
128print $enabledisablehtml;
129print '<input type="hidden" id="SOCIETE_ENABLE_PUBLIC" name="SOCIETE_ENABLE_PUBLIC" value="'.(!getDolGlobalString('SOCIETE_ENABLE_PUBLIC') ? 0 : 1).'">';
130
131print '</div>';
132
133
134
135print dol_get_fiche_end();
136
137print '</form>';
138
139
140if (getDolGlobalString('SOCIETE_ENABLE_PUBLIC')) {
141 print '<br>';
142 //print $langs->trans('FollowingLinksArePublic').'<br>';
143 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('BlankSubscriptionForm').'</span><br>';
144 if (isModEnabled('multicompany')) {
145 $entity_qr = '?entity='.$conf->entity;
146 } else {
147 $entity_qr = '';
148 }
149
150 // Define $urlwithroot
151 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
152 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
153 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
154
155 print '<div class="urllink">';
156 print '<input type="text" id="publicurlmember" class="quatrevingtpercentminusx" value="'.$urlwithroot.'/public/company/new.php'.$entity_qr.'">';
157 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/public/company/new.php'.$entity_qr.'">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
158 print '</div>';
159 print ajax_autoselect('publicurlmember');
160}
161
162// End of page
163llxFooter();
164$db->close();
global $dolibarr_main_url_root
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).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage generation of HTML components Only common components must be here.
societe_admin_prepare_head()
Return array head with list of tabs to view object information.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.