-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfields.php
186 lines (159 loc) · 7.21 KB
/
fields.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
/**
***********************************************************************************************
* Overview and maintenance of key fields
*
* @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
*
***********************************************************************************************
*/
require_once(__DIR__ . '/../../adm_program/system/common.php');
require_once(__DIR__ . '/common_function.php');
require_once(__DIR__ . '/classes/configtable.php');
require_once(__DIR__ . '/classes/keys.php');
$pPreferences = new ConfigTablePKM();
$pPreferences->read();
// only authorized user are allowed to start this module
if (!isUserAuthorizedForPreferences())
{
$gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
// => EXIT
}
// set module headline
$headline = $gL10n->get('PLG_KEYMANAGER_KEYFIELDS');
$gNavigation->addUrl(CURRENT_URL, $headline);
unset($_SESSION['fields_request']);
$keys = new Keys($gDb, $gCurrentOrgId);
// create html page object
$page = new HtmlPage('plg-keymanager-fields', $headline);
$page->addJavascript('
/**
* @param {string} direction
* @param {int} kmfID
*/
function moveCategory(direction, kmfID) {
var actRow = document.getElementById("row_kmf_" + kmfID);
var childs = actRow.parentNode.childNodes;
var prevNode = null;
var nextNode = null;
var actRowCount = 0;
var actSequence = 0;
var secondSequence = 0;
$(".admidio-icon-link .fas").tooltip("hide");
// erst einmal aktuelle Sequenz und vorherigen/naechsten Knoten ermitteln
for (var i = 0; i < childs.length; i++) {
if (childs[i].tagName === "TR") {
actRowCount++;
if (actSequence > 0 && nextNode === null) {
nextNode = childs[i];
}
if (childs[i].id === "row_kmf_" + kmfID) {
actSequence = actRowCount;
}
if (actSequence === 0) {
prevNode = childs[i];
}
}
}
// entsprechende Werte zum Hoch- bzw. Runterverschieben ermitteln
if (direction === "UP") {
if (prevNode !== null) {
actRow.parentNode.insertBefore(actRow, prevNode);
secondSequence = actSequence - 1;
}
} else {
if (nextNode !== null) {
actRow.parentNode.insertBefore(nextNode, actRow);
secondSequence = actSequence + 1;
}
}
if (secondSequence > 0) {
// Nun erst mal die neue Position von dem gewaehlten Feld aktualisieren
$.get("' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . '/keymanager/fields_function.php', array('mode' => 4)) . '&kmf_id=" + kmfID + "&sequence=" + direction);
}
}
');
$page->addPageFunctionsMenuItem('admMenuItemPreferencesLists', $gL10n->get('PLG_KEYMANAGER_KEYFIELD_CREATE'), ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER .'/fields_edit_new.php', 'fa-plus-circle');
// Create table
$table = new HtmlTable('tbl_profile_fields', $page, true);
$table->setMessageIfNoRowsFound('ORG_NO_FIELD_CREATED');
// create array with all column heading values
$columnHeading = array(
$gL10n->get('SYS_FIELD'),
' ',
$gL10n->get('SYS_DESCRIPTION'),
'<i class="fas fa-asterisk" data-toggle="tooltip" title="'.$gL10n->get('SYS_REQUIRED_INPUT').'"></i>',
$gL10n->get('ORG_DATATYPE'),
' '
);
$table->addRowHeadingByArray($columnHeading);
// Intialize variables
$description = '';
$mandatory = '';
$kmfSystem = '';
foreach ($keys->mKeyFields as $keyField)
{
$kmfId = (int) $keyField->getValue('kmf_id');
// cut long text strings and provide tooltip
if($keyField->getValue('kmf_description') === '')
{
$fieldDescription = ' ';
}
else
{
$fieldDescription = $keyField->getValue('kmf_description', 'database');
if(strlen($fieldDescription) > 60)
{
// read first 60 chars of text, then search for last space and cut the text there. After that add a "more" link
$textPrev = substr($fieldDescription, 0, 60);
$maxPosPrev = strrpos($textPrev, ' ');
$fieldDescription = substr($textPrev, 0, $maxPosPrev).
' <span class="collapse" id="viewdetails'.$kmfId.'">'.substr($fieldDescription, $maxPosPrev).'.
</span> <a class="admidio-icon-link" data-toggle="collapse" data-target="#viewdetails'.$kmfId.'"><i class="fas fa-angle-double-right" data-toggle="tooltip" title="'.$gL10n->get('SYS_MORE').'"></i></a>';
}
}
if ($keyField->getValue('kmf_mandatory') == 1)
{
$mandatory = '<i class="fas fa-asterisk" data-toggle="tooltip" title="'.$gL10n->get('SYS_REQUIRED_INPUT').'"></i>';
}
else
{
$mandatory = '<i class="fas fa-asterisk admidio-opacity-reduced" data-toggle="tooltip" title="'.$gL10n->get('SYS_REQUIRED_INPUT').': '.$gL10n->get('SYS_NO').'"></i>';
}
$keyFieldText = array(
'CHECKBOX' => $gL10n->get('SYS_CHECKBOX'),
'DATE' => $gL10n->get('SYS_DATE'),
'DROPDOWN' => $gL10n->get('SYS_DROPDOWN_LISTBOX'),
'RADIO_BUTTON' => $gL10n->get('SYS_RADIO_BUTTON'),
'TEXT' => $gL10n->get('SYS_TEXT').' (100)',
'TEXT_BIG' => $gL10n->get('SYS_TEXT').' (4000)',
'NUMBER' => $gL10n->get('SYS_NUMBER'),
'DECIMAL' => $gL10n->get('SYS_DECIMAL_NUMBER'));
$kmfSystem = '';
if ($keyField->getValue('kmf_system') == 1)
{
$kmfSystem .= '<i class="fas fa-trash invisible"></i>';
}
else
{
$kmfSystem .= '<a class="admidio-icon-link" href="'.SecurityUtils::encodeUrl(ADMIDIO_URL. FOLDER_PLUGINS . PLUGIN_FOLDER .'/fields_delete.php', array('kmf_id' => $kmfId)).'">
<i class="fas fa-trash-alt" data-toggle="tooltip" title="'.$gL10n->get('SYS_DELETE').'"></i></a>';
}
// create array with all column values
$columnValues = array(
'<a href="'.SecurityUtils::encodeUrl(ADMIDIO_URL. FOLDER_PLUGINS . PLUGIN_FOLDER .'/fields_edit_new.php', array('kmf_id' => $kmfId)).'">'. convlanguagePKM($keyField->getValue('kmf_name')).'</a> ',
'<a class="admidio-icon-link" href="javascript:void(0)" onclick="moveCategory(\''.TableUserField::MOVE_UP.'\', '.$kmfId.')">
<i class="fas fa-chevron-circle-up" data-toggle="tooltip" title="' . $gL10n->get('SYS_MOVE_UP', array('SYS_PROFILE_FIELD')) . '"></i></a>
<a class="admidio-icon-link" href="javascript:void(0)" onclick="moveCategory(\''.TableUserField::MOVE_DOWN.'\', '.$kmfId.')">
<i class="fas fa-chevron-circle-down" data-toggle="tooltip" title="' . $gL10n->get('SYS_MOVE_DOWN', array('SYS_PROFILE_FIELD')) . '"></i></a>',
$fieldDescription,
$mandatory,
$keyFieldText[$keyField->getValue('kmf_type')],
$kmfSystem
);
$table->addRowByArray($columnValues, 'row_kmf_'.$kmfId);
}
$page->addHtml($table->show());
$page->show();