-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreferences_function.php
125 lines (101 loc) · 4.12 KB
/
preferences_function.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
***********************************************************************************************
* Verarbeiten der Einstellungen des Admidio-Plugins KeyManager
*
* @copyright The Admidio Team
* @see https://www.admidio.org/
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 only
***********************************************************************************************
*/
/******************************************************************************
* Parameters:
*
* mode: 1 - Save preferences
* 2 - show dialog for deinstallation
* 3 - deinstallation
* form - The name of the form preferences that were submitted.
*
*****************************************************************************/
require_once(__DIR__ . '/../../adm_program/system/common.php');
require_once(__DIR__ . '/common_function.php');
require_once(__DIR__ . '/classes/configtable.php');
$pPreferences = new ConfigTablePKM();
$pPreferences->read();
// only authorized user are allowed to start this module
if (!isUserAuthorizedForPreferences())
{
$gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
}
// Initialize and check the parameters
$getMode = admFuncVariableIsValid($_GET, 'mode', 'numeric', array('defaultValue' => 1));
$getForm = admFuncVariableIsValid($_GET, 'form', 'string');
// in ajax mode only return simple text on error
if ($getMode === 1)
{
$gMessage->showHtmlTextOnly(true);
}
switch ($getMode)
{
case 1:
try
{
switch ($getForm)
{
case 'interface_pff':
$pPreferences->config['Optionen']['interface_pff'] = $_POST['interface_pff'];
break;
case 'profile_addin':
$pPreferences->config['Optionen']['profile_addin'] = $_POST['profile_addin'];
break;
case 'export':
$pPreferences->config['Optionen']['file_name'] = $_POST['file_name'];
$pPreferences->config['Optionen']['add_date'] = isset($_POST['add_date']) ? 1 : 0;
break;
case 'access_preferences':
if (isset($_POST['access_preferences']))
{
$pPreferences->config['access']['preferences'] = array_filter($_POST['access_preferences']);
}
else
{
$pPreferences->config['access']['preferences'] = array();
}
break;
default:
$gMessage->show($gL10n->get('SYS_INVALID_PAGE_VIEW'));
}
}
catch(AdmException $e)
{
$e->showText();
}
$pPreferences->save();
echo 'success';
break;
case 2:
$headline = $gL10n->get('PLG_KEYMANAGER_DEINSTALLATION');
// create html page object
$page = new HtmlPage('plg-keymanager-deinstallation', $headline);
// add current url to navigation stack
$gNavigation->addUrl(CURRENT_URL, $headline);
$page->addHtml('<p class="lead">'.$gL10n->get('PLG_KEYMANAGER_DEINSTALLATION_FORM_DESC').'</p>');
// show form
$form = new HtmlForm('deinstallation_form', SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER .'/preferences_function.php', array('mode' => 3)), $page);
$radioButtonEntries = array('0' => $gL10n->get('PLG_KEYMANAGER_DEINST_ACTORGONLY'), '1' => $gL10n->get('PLG_KEYMANAGER_DEINST_ALLORG') );
$form->addRadioButton('deinst_org_select',$gL10n->get('PLG_KEYMANAGER_ORG_CHOICE'), $radioButtonEntries, array('defaultValue' => '0'));
$form->addSubmitButton('btn_deinstall', $gL10n->get('PLG_KEYMANAGER_DEINSTALLATION'), array('icon' => 'fa-trash-alt', 'class' => 'offset-sm-3'));
// add form to html page and show page
$page->addHtml($form->show(false));
$page->show();
break;
case 3:
$gNavigation->clear();
$gMessage->setForwardUrl($gHomepage);
$resMes = $gL10n->get('PLG_KEYMANAGER_DEINST_STARTMESSAGE');
$resMes .= $pPreferences->deleteKeyData($_POST['deinst_org_select']);
$resMes .= $pPreferences->deleteConfigData($_POST['deinst_org_select']);
$resMes .= $gL10n->get('PLG_KEYMANAGER_DEINST_ENDMESSAGE');
$gMessage->show($resMes );
break;
}