Skip to content

Commit 53f96c0

Browse files
committed
NEW Add option SELLYOURSAAS_DASHBOARD_OFF to disallow login/access to
dashboard
1 parent be0e35c commit 53f96c0

File tree

6 files changed

+99
-11
lines changed

6 files changed

+99
-11
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
## Unreleased
55

6+
* NEW Add option SELLYOURSAAS_DASHBOARD_OFF to disallow login/access to dashboard
67
* NEW Add warning on support page if contact info are not complete
78
* NEW Add badge with number of deployment server on tab title of deployment servers.
89
* NEW Add the tab for histori of events info on a deployment server card.

admin/setup.php

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
* \brief Page administration module SellYourSaas
2222
*/
2323

24+
/**
25+
* @var Conf $conf
26+
* @var DoliDB $db
27+
*/
2428

2529
if (! defined('NOSCANPOSTFORINJECTION')) {
2630
define('NOSCANPOSTFORINJECTION', '1');
@@ -231,12 +235,12 @@
231235
print '<span class="opacitymedium">'.$langs->trans("Prerequisites")." :</span><br>\n";
232236
print 'Function <b>idn_to_ascii</b> available: '.(function_exists('idn_to_ascii') ? img_picto('', 'tick', 'class="paddingrightonly"').yn(1) : img_picto('', 'warning', 'class="paddingrightonly"').yn(0)).'<br>';
233237
print 'Function <b>checkdnsrr</b> available: '.(function_exists('checkdnsrr') ? img_picto('', 'tick', 'class="paddingrightonly"').yn(1) : img_picto('', 'warning', 'class="paddingrightonly"').yn(0)).'<br>';
234-
print 'Parameter <b>allow_url_fopen</b> is on: '.(ini_get('allow_url_fopen') ? img_picto('', 'tick', 'class="paddingrightonly"').yn(1) : img_picto('', 'warning', 'class="paddingrightonly"').yn(0)).'<br>';
238+
print 'Parameter <b>allow_url_fopen</b> is on: '.(ini_get('allow_url_fopen') ? img_picto('', 'tick', 'class="paddingrightonly"').yn(1).' (may be used by deployed applications)' : img_picto('', 'warning', 'class="paddingrightonly"').yn(0)).'<br>';
235239
$arrayoffunctionsdisabled = explode(',', ini_get('disable_functions'));
236240
if (in_array('exec', $arrayoffunctionsdisabled)) {
237241
print "Parameter <b>disable_functions</b>: ".img_picto('', 'error', 'class="paddingrightonly"')." Bad. Must not contain 'exec'<br>";
238242
} else {
239-
print 'Parameter <b>disable_functions</b>: '.img_picto('', 'tick', 'class="paddingrightonly"').' does not contains: exec<br>';
243+
print 'Parameter <b>disable_functions</b>: '.img_picto('', 'tick', 'class="paddingrightonly"').' does not contains: exec (used by Dolibarr)<br>';
240244
}
241245
if (in_array('popen', $arrayoffunctionsdisabled)) {
242246
print "Parameter <b>disable_functions</b>: ".img_picto('', 'error', 'class="paddingrightonly"')." Bad. Must not contain 'popen'<br>";
@@ -299,28 +303,32 @@
299303
}
300304

301305
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("SellYourSaasMainEmail").'</td>';
302-
print '<td>';
306+
print '<td class="nowraponall">';
307+
print img_picto('', 'email', 'class="pictofixedwidth"');
303308
print '<input type="text" name="SELLYOURSAAS_MAIN_EMAIL" value="'.getDolGlobalString('SELLYOURSAAS_MAIN_EMAIL').'" class="minwidth300">';
304309
print '</td>';
305310
print '<td><span class="opacitymedium small">[email protected]</span></td>';
306311
print '</tr>';
307312

308313
print '<tr class="oddeven"><td>'.$langs->trans("SellYourSaasMainEmail").' (Premium)</td>';
309-
print '<td>';
314+
print '<td class="nowraponall">';
315+
print img_picto('', 'email', 'class="pictofixedwidth"');
310316
print '<input type="text" name="SELLYOURSAAS_MAIN_EMAIL_PREMIUM" value="'.getDolGlobalString('SELLYOURSAAS_MAIN_EMAIL_PREMIUM').'" class="minwidth300">';
311317
print '</td>';
312318
print '<td><span class="opacitymedium small">[email protected]</span></td>';
313319
print '</tr>';
314320

315321
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("SellYourSaasSupervisionEmail").'</td>';
316-
print '<td>';
322+
print '<td class="nowraponall">';
323+
print img_picto('', 'email', 'class="pictofixedwidth"');
317324
print '<input type="text" name="SELLYOURSAAS_SUPERVISION_EMAIL" value="'.getDolGlobalString('SELLYOURSAAS_SUPERVISION_EMAIL').'" class="minwidth300">';
318325
print '</td>';
319326
print '<td><span class="opacitymedium small">[email protected]</span></td>';
320327
print '</tr>';
321328

322329
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("SellYourSaasNoReplyEmail").'</td>';
323-
print '<td>';
330+
print '<td class="nowraponall">';
331+
print img_picto('', 'email', 'class="pictofixedwidth"');
324332
print '<input type="text" name="SELLYOURSAAS_NOREPLY_EMAIL" value="'.getDolGlobalString('SELLYOURSAAS_NOREPLY_EMAIL').'" class="minwidth300">';
325333
print '</td>';
326334
print '<td><span class="opacitymedium small">[email protected]</span></td>';
@@ -371,7 +379,14 @@
371379
*/
372380

373381
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("SellYourSaasAccountUrl").'</td>';
374-
print '<td>';
382+
print '<td class="nowraponall">';
383+
if (getDolGlobalString('SELLYOURSAAS_ACCOUNT_URL')) {
384+
print '<a href="'.getDolGlobalString('SELLYOURSAAS_ACCOUNT_URL').'" target="_blank">';
385+
}
386+
print img_picto('', 'url', 'class="pictofixedwidth"');
387+
if (getDolGlobalString('SELLYOURSAAS_ACCOUNT_URL')) {
388+
print '</a>';
389+
}
375390
print '<input class="minwidth300" type="text" name="SELLYOURSAAS_ACCOUNT_URL" value="'.getDolGlobalString('SELLYOURSAAS_ACCOUNT_URL').'">';
376391
print '</td>';
377392
print '<td><span class="opacitymedium small wordbreak">https://myaccount.mysaasdomainname.com<br>Note: The virtual host for this domain must point to <strong>'.dol_buildpath('sellyoursaas/myaccount').'</strong></span></td>';
@@ -381,10 +396,17 @@
381396
print '<!-- suffix = '.$suffix.' -->'."\n";
382397

383398
print '<tr class="oddeven"><td>'.($service ? $service.' - ' : '').$langs->trans("SellYourSaasPricesUrl").'</td>';
384-
print '<td>';
399+
print '<td class="nowraponall">';
385400
$constname = 'SELLYOURSAAS_PRICES_URL'.$suffix;
401+
if (getDolGlobalString($constname)) {
402+
print '<a href="'.getDolGlobalString($constname).'" target="_blank">';
403+
}
404+
print img_picto('', 'url', 'class="pictofixedwidth"');
405+
if (getDolGlobalString($constname)) {
406+
print '</a>';
407+
}
386408
print '<!-- constname = '.$constname.' -->';
387-
print '<input class="minwidth300" type="text" name="SELLYOURSAAS_PRICES_URL'.$suffix.'" value="'.getDolGlobalString('SELLYOURSAAS_PRICES_URL'.$suffix).'">';
409+
print '<input class="minwidth300" type="text" name="SELLYOURSAAS_PRICES_URL'.$suffix.'" value="'.getDolGlobalString($constname).'">';
388410
print '</td>';
389411
print '<td><span class="opacitymedium small">https://myaccount.mysaasdomainname.com/prices.html</span></td>';
390412
print '</tr>';

backoffice/index.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@
110110
dolibarr_set_const($db, "SELLYOURSAAS_ANNOUNCE", GETPOST("SELLYOURSAAS_ANNOUNCE", 'none'), 'chaine', 0, '', $conf->entity);
111111
}
112112

113+
if ($action == 'setSELLYOURSAAS_DASHBOARD_OFF') {
114+
if (GETPOST('value')) {
115+
dolibarr_set_const($db, 'SELLYOURSAAS_DASHBOARD_OFF', 1, 'chaine', 0, '', $conf->entity);
116+
dolibarr_set_const($db, 'SELLYOURSAAS_DISABLE_NEW_INSTANCES', 1, 'chaine', 0, '', $conf->entity);
117+
} else {
118+
dolibarr_set_const($db, 'SELLYOURSAAS_DASHBOARD_OFF', 0, 'chaine', 0, '', $conf->entity);
119+
}
120+
}
113121
if ($action == 'setSELLYOURSAAS_DISABLE_NEW_INSTANCES') {
114122
if (GETPOST('value')) {
115123
dolibarr_set_const($db, 'SELLYOURSAAS_DISABLE_NEW_INSTANCES', 1, 'chaine', 0, '', $conf->entity);
@@ -265,6 +273,23 @@
265273
print '<td>';
266274
print $langs->trans('Website').' & '.$langs->trans('CustomerAccountArea');
267275
print '</td></tr>';
276+
print '<tr class="oddeven"><td>';
277+
$enabledisabledashboard='';
278+
if (!getDolGlobalString('SELLYOURSAAS_DASHBOARD_OFF')) {
279+
// Button off, click to enable
280+
$enabledisabledashboard.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setSELLYOURSAAS_DASHBOARD_OFF&token='.newToken().'&value=1'.$param.'">';
281+
$enabledisabledashboard.=img_picto($langs->trans("Enabled"), 'switch_on', '', false, 0, 0, '', 'valignmiddle paddingright');
282+
$enabledisabledashboard.='</a>';
283+
} else {
284+
// Button on, click to disable
285+
$enabledisabledashboard.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setSELLYOURSAAS_DASHBOARD_OFF&token='.newToken().'&value=0'.$param.'">';
286+
$enabledisabledashboard.=img_picto($langs->trans('Disabled'), 'switch_off', '', false, 0, 0, '', 'error valignmiddle paddingright');
287+
$enabledisabledashboard.='</a>';
288+
}
289+
print $enabledisabledashboard;
290+
print $langs->trans("EnableDashboards");
291+
print '</td></tr>';
292+
268293
print '<tr class="oddeven"><td>';
269294
$enabledisablehtml='';
270295
if (getDolGlobalString('SELLYOURSAAS_DISABLE_NEW_INSTANCES')) {
@@ -291,6 +316,7 @@
291316
}
292317

293318
print '</td></tr>';
319+
294320
print '<tr class="oddeven"><td>';
295321
$enabledisableannounce='';
296322
if (!getDolGlobalString('SELLYOURSAAS_ANNOUNCE_ON')) {

langs/en_US/sellyoursaas.lang

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ TooManyInstancesForSameIpvpn=You reach the limit of the number of instances crea
497497
TooManyInstancesForSameIpThisHour=You reach the limit of the number of instances created in one hour from the same location. Please try later (Your IP is %s).
498498
TooManyRequestPleaseTryLater=Too many pending requests. Please try later.
499499
InstanceCreationBlockedForSecurityPurpose=Creation of your instance has been blocked for security purpose. It seems you come from a non legitimate network or traffic analysis flags suspecious activity. Please contact us (<b>%s</b>) if you think this is an error (your last point IP is %s, abuse code: %s)
500+
EnableDashboards=Enable dashboards (customer, reseller). Login forbidden if off.
500501
EnableNewInstance=Enable new registration/instances
501502
CustomerAccountArea=Customer accounts area
502503
MasterServer=Master server
@@ -951,3 +952,5 @@ MyModuleCustomersBilling=My module customer billing
951952
SupplierModule=Module
952953
YouAreAModuleProvider=You are a module provider
953954
YouAreTheProviderOfTheFollowingModules=You provides the following modules
955+
DashboardServiceIsTemporarlyOffline=Dashboard access is temporarly offline for maintenance purpose.
956+
PleaseGoBackInFewHours=Please go back in few hours...

myaccount/index.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@
9494
if (! $res) {
9595
die("Include of main fails. Try to create a link from mydolibarr/htdocs/main.inc.php to .../sellyoursaas/myaccount/main.inc.php");
9696
}
97-
97+
/**
98+
* @var Conf $conf
99+
* @var DoliDB $db
100+
* @var Translate $langs
101+
* @var Societe $mysoc
102+
*/
98103
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
99104
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
100105
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -213,7 +218,7 @@
213218
}
214219

215220
$_SESSION=array();
216-
$_SESSION['dol_loginmesg']=$langs->trans("SorryAccountDeleted", $sellyoursaasemail);
221+
$_SESSION['dol_loginmesg'] = $langs->trans("SorryAccountDeleted", $sellyoursaasemail);
217222
//header("Location: index.php?username=".urlencode(GETPOST('username','alpha')));
218223
header("Location: index.php?usernamebis=".urlencode(GETPOST('username', 'alpha')));
219224
exit;
@@ -2309,6 +2314,7 @@
23092314

23102315
$form = new Form($db);
23112316

2317+
23122318
if ($welcomecid > 0) {
23132319
// Here $_POST is empty, $GET has just welcomecid=..., $_SESSION['dol_loginsellyoursaas'] is socid =382
23142320
/*var_dump($_POST);
@@ -2378,6 +2384,19 @@
23782384

23792385
llxHeader($head, $langs->trans("MyAccount"), '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'myaccount');
23802386

2387+
2388+
// Test if dashboard is allowed or not
2389+
if (getDolGlobalString('SELLYOURSAAS_DASHBOARD_OFF')) {
2390+
print '<center><div class="warning"><br><br><br>';
2391+
print $langs->trans("DashboardServiceIsTemporarlyOffline");
2392+
print '<br>';
2393+
print $langs->trans("PleaseGoBackInFewHours");
2394+
print '<br><br><br></div></center>';
2395+
2396+
llxFooter();
2397+
exit;
2398+
}
2399+
23812400
?>
23822401

23832402
<div id="waitMask" style="display:none;">

myaccount/tpl/loginmyaccount.tpl.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
*/
1717

1818
// Need global variable to be defined by caller (like dol_loginfunction)
19+
// $conf
1920
// $title
2021
// $urllogo
2122
// $focus_element
23+
// $captcha_refresh
2224
// Caller can also set $morelogincontent = array(['options']=>array('js'=>..., 'table'=>...);
2325

2426
// Protection to avoid direct call of template
@@ -207,6 +209,21 @@
207209
</div>
208210
<?php
209211
}
212+
213+
214+
// Test if dashboard is allowed or not
215+
if (getDolGlobalString('SELLYOURSAAS_DASHBOARD_OFF')) {
216+
print '<center><div class="warning"><br><br><br>';
217+
print $langs->trans("DashboardServiceIsTemporarlyOffline");
218+
print '<br>';
219+
print $langs->trans("PleaseGoBackInFewHours");
220+
print '<br><br><br></div></center>';
221+
222+
print '</body>';
223+
print '</html>';
224+
exit;
225+
}
226+
210227
?>
211228

212229

0 commit comments

Comments
 (0)