|
12 | 12 | /******************************************************************************
|
13 | 13 | * Parameters:
|
14 | 14 | *
|
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 |
21 | 21 | * user_uuid : UUID of the contact, who should be edited
|
22 | 22 | *
|
23 | 23 | *****************************************************************************/
|
|
28 | 28 | $gMessage->showInModalWindow();
|
29 | 29 |
|
30 | 30 | // 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'))); |
32 | 32 | $getUserUuid = admFuncVariableIsValid($_GET, 'user_uuid', 'string', array('requireValue' => true));
|
33 | 33 |
|
34 | 34 | // Only users with user-edit rights are allowed
|
|
38 | 38 | }
|
39 | 39 |
|
40 | 40 | try {
|
41 |
| - if (in_array($getMode, array(2, 3, 4))){ |
| 41 | + if (in_array($getMode, array('remove', 'delete', 'send_login'))){ |
42 | 42 | // check the CSRF token of the form against the session token
|
43 | 43 | SecurityUtils::validateCsrfToken($_POST['admidio-csrf-token']);
|
44 | 44 | }
|
|
47 | 47 | exit();
|
48 | 48 | }
|
49 | 49 |
|
50 |
| -if ($getMode === 1) { |
| 50 | +if ($getMode === 'delete_explain_msg') { |
51 | 51 | // ask if contact should only be removed from organization or completely deleted
|
52 | 52 | echo '
|
53 | 53 | <div class="modal-header">
|
|
59 | 59 | <p><i class="fas fa-trash-alt"></i> '.$gL10n->get('SYS_REMOVE_CONTACT_DESC', array($gL10n->get('SYS_DELETE'))).'</p>
|
60 | 60 | </div>
|
61 | 61 | <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().'\')"> |
63 | 63 | <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().'\')"> |
65 | 65 | <i class="fas fa-trash-alt"></i>'.$gL10n->get('SYS_DELETE').'</button>
|
66 | 66 | <div id="status-message" class="mt-4 w-100"></div>
|
67 | 67 | </div>';
|
|
73 | 73 | $user = new User($gDb, $gProfileFields);
|
74 | 74 | $user->readDataByUuid($getUserUuid);
|
75 | 75 |
|
76 |
| -if ($getMode === 3 || $getMode === 6) { |
| 76 | +if ($getMode === 'delete' || $getMode === 'delete_msg') { |
77 | 77 | // Check if user is also in other organizations
|
78 | 78 | $sql = 'SELECT COUNT(*) AS count
|
79 | 79 | FROM '.TBL_MEMBERS.'
|
|
90 | 90 | $isAlsoInOtherOrgas = $pdoStatement->fetchColumn() > 0;
|
91 | 91 | }
|
92 | 92 |
|
93 |
| -if ($getMode === 2) { |
| 93 | +if ($getMode === 'remove') { |
94 | 94 | try {
|
95 | 95 | // User has to be a member of this organization
|
96 | 96 | // User could not delete himself
|
|
127 | 127 | echo json_encode(array('status' => 'error', 'message' => $e->getMessage()));
|
128 | 128 | }
|
129 | 129 | exit();
|
130 |
| -} elseif ($getMode === 3) { |
| 130 | +} elseif ($getMode === 'delete') { |
131 | 131 | try {
|
132 | 132 | // User must not be in any other organization
|
133 | 133 | // User could not delete himself
|
|
142 | 142 | echo json_encode(array('status' => 'error', 'message' => $e->getMessage()));
|
143 | 143 | }
|
144 | 144 | exit();
|
145 |
| -} elseif ($getMode === 4) { |
| 145 | +} elseif ($getMode === 'send_login') { |
146 | 146 | try {
|
147 | 147 | // If User must be member of this organization than send a new password
|
148 | 148 | if (isMember($user->getValue('usr_id'))) {
|
|
156 | 156 | echo json_encode(array('status' => 'error', 'message' => $e->getMessage()));
|
157 | 157 | }
|
158 | 158 | exit();
|
159 |
| -} elseif ($getMode === 5) { |
| 159 | +} elseif ($getMode === 'send_login_msg') { |
160 | 160 | // 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().'\')'); |
162 | 162 | $gMessage->show($gL10n->get('SYS_SEND_NEW_LOGIN', array($user->getValue('FIRST_NAME') . ' ' . $user->getValue('LAST_NAME'))));
|
163 | 163 | // => EXIT
|
164 |
| -} elseif ($getMode === 6) { |
| 164 | +} elseif ($getMode === 'delete_msg') { |
165 | 165 | if (!$isAlsoInOtherOrgas && $gCurrentUser->isAdministrator()) {
|
166 | 166 | if (isMember($user->getValue('usr_id'))) {
|
167 | 167 | // 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'))); |
169 | 169 | // => EXIT
|
170 | 170 | } else {
|
171 | 171 | // 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().'\')'); |
173 | 173 | $gMessage->show($gL10n->get('SYS_USER_DELETE_DESC', array($user->getValue('FIRST_NAME') . ' ' . $user->getValue('LAST_NAME'))), $gL10n->get('SYS_DELETE'));
|
174 | 174 | // => EXIT
|
175 | 175 | }
|
176 | 176 | } else {
|
177 | 177 | // 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().'\')'); |
179 | 179 | $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'));
|
180 | 180 | // => EXIT
|
181 | 181 | }
|
|
0 commit comments