Skip to content

Commit 49a4ce9

Browse files
committed
use string for mode in contact module
1 parent 4df12ab commit 49a4ce9

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

adm_program/modules/contacts/contacts_data.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
if (!empty($row['member_email']) && $gSettingsManager->getBool('system_notifications_enabled')) {
275275
// if email is set and systemmails are activated then administrators can send a new password to user
276276
$userAdministration = '<a class="admidio-icon-link openPopup" href="javascript:void(0);"
277-
data-href="'.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $row['usr_uuid'], 'mode' => 5)).'">'.
277+
data-href="'.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $row['usr_uuid'], 'mode' => 'send_login_msg')).'">'.
278278
'<i class="fas fa-key" data-toggle="tooltip" title="' . $gL10n->get('SYS_SEND_USERNAME_PASSWORD') . '"></i></a>';
279279
} else {
280280
// if user has no email or send email is disabled then administrators could set a new password
@@ -310,7 +310,7 @@
310310
|| $contactsOfThisOrganization) // active members may be removed by authorized users
311311
&& $row['usr_uuid'] !== $gCurrentUserUUID) { // no one is allowed to remove their own profile
312312
$userAdministration .= '<a class="admidio-icon-link openPopup" href="javascript:void(0);"
313-
data-href="' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_MODULES . '/contacts/contacts_function.php', array('user_uuid' => $row['usr_uuid'], 'mode' => 6)) . '">' .
313+
data-href="' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_MODULES . '/contacts/contacts_function.php', array('user_uuid' => $row['usr_uuid'], 'mode' => 'delete_msg')) . '">' .
314314
'<i class="fas fa-trash-alt" data-toggle="tooltip" title="' . $gL10n->get('SYS_REMOVE_CONTACT') . '"></i>
315315
</a>';
316316
}

adm_program/modules/contacts/contacts_function.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
/******************************************************************************
1313
* Parameters:
1414
*
15-
* mode: 1 - MessageBox that explains the effects of the deletion
16-
* 2 - remove contact ONLY from the member community
17-
* 3 - delete contact from database
18-
* 4 - send contact e-mail with new access data
19-
* 5 - Ask if access data should be sent
20-
* 6 - Ask if contact should be deleted
15+
* mode: remove - remove contact ONLY from the member community
16+
* delete - delete contact from database
17+
* delete_msg - Ask if contact should be deleted
18+
* delete_explain_msg - MessageBox that explains the effects of the deletion
19+
* send_login - send contact e-mail with new access data
20+
* send_login_msg - Ask if access data should be sent
2121
* user_uuid : UUID of the contact, who should be edited
2222
*
2323
*****************************************************************************/
@@ -28,7 +28,7 @@
2828
$gMessage->showInModalWindow();
2929

3030
// Initialize and check the parameters
31-
$getMode = admFuncVariableIsValid($_GET, 'mode', 'int', array('requireValue' => true, 'validValues' => array(1, 2, 3, 4, 5, 6)));
31+
$getMode = admFuncVariableIsValid($_GET, 'mode', 'string', array('requireValue' => true, 'validValues' => array('delete_explain_msg', 'remove', 'delete', 'send_login', 'send_login_msg', 'delete_msg')));
3232
$getUserUuid = admFuncVariableIsValid($_GET, 'user_uuid', 'string', array('requireValue' => true));
3333

3434
// Only users with user-edit rights are allowed
@@ -38,7 +38,7 @@
3838
}
3939

4040
try {
41-
if (in_array($getMode, array(2, 3, 4))){
41+
if (in_array($getMode, array('remove', 'delete', 'send_login'))){
4242
// check the CSRF token of the form against the session token
4343
SecurityUtils::validateCsrfToken($_POST['admidio-csrf-token']);
4444
}
@@ -47,7 +47,7 @@
4747
exit();
4848
}
4949

50-
if ($getMode === 1) {
50+
if ($getMode === 'delete_explain_msg') {
5151
// ask if contact should only be removed from organization or completely deleted
5252
echo '
5353
<div class="modal-header">
@@ -59,9 +59,9 @@
5959
<p><i class="fas fa-trash-alt"></i>&nbsp;'.$gL10n->get('SYS_REMOVE_CONTACT_DESC', array($gL10n->get('SYS_DELETE'))).'</p>
6060
</div>
6161
<div class="modal-footer">
62-
<button id="btnFormer"type="button" class="btn btn-primary mr-4" onclick="callUrlHideElement(\'row_members_'.$getUserUuid.'\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 2)).'\', \''.$gCurrentSession->getCsrfToken().'\')">
62+
<button id="btnFormer"type="button" class="btn btn-primary mr-4" onclick="callUrlHideElement(\'row_members_'.$getUserUuid.'\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 'remove')).'\', \''.$gCurrentSession->getCsrfToken().'\')">
6363
<i class="fas fa-user-clock"></i>'.$gL10n->get('SYS_FORMER').'</button>
64-
<button id="btnDelete"type="button" class="btn btn-primary" onclick="callUrlHideElement(\'row_members_'.$getUserUuid.'\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 3)).'\', \''.$gCurrentSession->getCsrfToken().'\')">
64+
<button id="btnDelete"type="button" class="btn btn-primary" onclick="callUrlHideElement(\'row_members_'.$getUserUuid.'\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 'delete')).'\', \''.$gCurrentSession->getCsrfToken().'\')">
6565
<i class="fas fa-trash-alt"></i>'.$gL10n->get('SYS_DELETE').'</button>
6666
<div id="status-message" class="mt-4 w-100"></div>
6767
</div>';
@@ -73,7 +73,7 @@
7373
$user = new User($gDb, $gProfileFields);
7474
$user->readDataByUuid($getUserUuid);
7575

76-
if ($getMode === 3 || $getMode === 6) {
76+
if ($getMode === 'delete' || $getMode === 'delete_msg') {
7777
// Check if user is also in other organizations
7878
$sql = 'SELECT COUNT(*) AS count
7979
FROM '.TBL_MEMBERS.'
@@ -90,7 +90,7 @@
9090
$isAlsoInOtherOrgas = $pdoStatement->fetchColumn() > 0;
9191
}
9292

93-
if ($getMode === 2) {
93+
if ($getMode === 'remove') {
9494
try {
9595
// User has to be a member of this organization
9696
// User could not delete himself
@@ -127,7 +127,7 @@
127127
echo json_encode(array('status' => 'error', 'message' => $e->getMessage()));
128128
}
129129
exit();
130-
} elseif ($getMode === 3) {
130+
} elseif ($getMode === 'delete') {
131131
try {
132132
// User must not be in any other organization
133133
// User could not delete himself
@@ -142,7 +142,7 @@
142142
echo json_encode(array('status' => 'error', 'message' => $e->getMessage()));
143143
}
144144
exit();
145-
} elseif ($getMode === 4) {
145+
} elseif ($getMode === 'send_login') {
146146
try {
147147
// If User must be member of this organization than send a new password
148148
if (isMember($user->getValue('usr_id'))) {
@@ -156,26 +156,26 @@
156156
echo json_encode(array('status' => 'error', 'message' => $e->getMessage()));
157157
}
158158
exit();
159-
} elseif ($getMode === 5) {
159+
} elseif ($getMode === 'send_login_msg') {
160160
// Ask to send new login-data
161-
$gMessage->setYesNoButton('callUrlHideElement(\'row_members\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 4)).'\', \''.$gCurrentSession->getCsrfToken().'\')');
161+
$gMessage->setYesNoButton('callUrlHideElement(\'row_members\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 'send_login')).'\', \''.$gCurrentSession->getCsrfToken().'\')');
162162
$gMessage->show($gL10n->get('SYS_SEND_NEW_LOGIN', array($user->getValue('FIRST_NAME') . ' ' . $user->getValue('LAST_NAME'))));
163163
// => EXIT
164-
} elseif ($getMode === 6) {
164+
} elseif ($getMode === 'delete_msg') {
165165
if (!$isAlsoInOtherOrgas && $gCurrentUser->isAdministrator()) {
166166
if (isMember($user->getValue('usr_id'))) {
167167
// User is ONLY member of this organization -> ask if user should make to former member or delete completely
168-
admRedirect(SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 1)));
168+
admRedirect(SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 'delete_explain_msg')));
169169
// => EXIT
170170
} else {
171171
// User is not member of any organization -> ask if delete completely
172-
$gMessage->setYesNoButton('callUrlHideElement(\'row_members_'.$getUserUuid.'\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 3)).'\', \''.$gCurrentSession->getCsrfToken().'\')');
172+
$gMessage->setYesNoButton('callUrlHideElement(\'row_members_'.$getUserUuid.'\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 'delete')).'\', \''.$gCurrentSession->getCsrfToken().'\')');
173173
$gMessage->show($gL10n->get('SYS_USER_DELETE_DESC', array($user->getValue('FIRST_NAME') . ' ' . $user->getValue('LAST_NAME'))), $gL10n->get('SYS_DELETE'));
174174
// => EXIT
175175
}
176176
} else {
177177
// User could only be removed from this organization -> ask so
178-
$gMessage->setYesNoButton('callUrlHideElement(\'row_members_'.$getUserUuid.'\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 2)).'\', \''.$gCurrentSession->getCsrfToken().'\')');
178+
$gMessage->setYesNoButton('callUrlHideElement(\'row_members_'.$getUserUuid.'\', \''.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 'remove')).'\', \''.$gCurrentSession->getCsrfToken().'\')');
179179
$gMessage->show($gL10n->get('SYS_END_MEMBERSHIP_OF_USER', array($user->getValue('FIRST_NAME') . ' ' . $user->getValue('LAST_NAME'), $gCurrentOrganization->getValue('org_longname'))), $gL10n->get('SYS_REMOVE'));
180180
// => EXIT
181181
}

adm_program/modules/profile/profile.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function formSubmitEvent(rolesAreaId = "") {
184184
$("#menu_item_profile_password").attr("class", "nav-link btn btn-secondary openPopup");
185185
186186
$("#menu_item_profile_send_password").attr("href", "javascript:void(0);");
187-
$("#menu_item_profile_send_password").attr("data-href", "'.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => '5')).'");
187+
$("#menu_item_profile_send_password").attr("data-href", "'.SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 'send_login_msg')).'");
188188
$("#menu_item_profile_send_password").attr("class", "nav-link btn btn-secondary openPopup");
189189
190190
$("body").on("hidden.bs.modal", ".modal", function() {
@@ -224,7 +224,7 @@ function formSubmitEvent(rolesAreaId = "") {
224224
$page->addPageFunctionsMenuItem(
225225
'menu_item_profile_send_password',
226226
$gL10n->get('ORG_SEND_NEW_PASSWORD'),
227-
SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => '5')),
227+
SecurityUtils::encodeUrl(ADMIDIO_URL.FOLDER_MODULES.'/contacts/contacts_function.php', array('user_uuid' => $getUserUuid, 'mode' => 'send_login_msg')),
228228
'fa-key'
229229
);
230230
} else {

0 commit comments

Comments
 (0)