aboutsummaryrefslogtreecommitdiff
path: root/mod/uservalidationbyemail/actions/validate.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/uservalidationbyemail/actions/validate.php')
-rw-r--r--mod/uservalidationbyemail/actions/validate.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/mod/uservalidationbyemail/actions/validate.php b/mod/uservalidationbyemail/actions/validate.php
new file mode 100644
index 000000000..c50053dce
--- /dev/null
+++ b/mod/uservalidationbyemail/actions/validate.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Validate a user or users by guid
+ *
+ * @package Elgg.Core.Plugin
+ * @subpackage UserValidationByEmail
+ */
+
+$user_guids = get_input('user_guids');
+$error = FALSE;
+
+if (!$user_guids) {
+ register_error(elgg_echo('uservalidationbyemail:errors:unknown_users'));
+ forward(REFERRER);
+}
+
+$access = access_get_show_hidden_status();
+access_show_hidden_entities(TRUE);
+
+foreach ($user_guids as $guid) {
+ $user = get_entity($guid);
+ if (!$user instanceof ElggUser) {
+ $error = TRUE;
+ continue;
+ }
+
+ // only validate if not validated
+ $is_validated = uservalidationbyemail_get_user_validation_status($guid);
+ $validate_success = uservalidationbyemail_set_user_validation_status($guid, TRUE);
+
+ if (!$is_validated || !$validate_success || !$user->enable()) {
+ $error = TRUE;
+ continue;
+ }
+}
+
+access_show_hidden_entities($access);
+
+if (count($user_guids) == 1) {
+ $message_txt = elgg_echo('uservalidationbyemail:messages:validated_user');
+ $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_validate_user');
+} else {
+ $message_txt = elgg_echo('uservalidationbyemail:messages:validated_users');
+ $error_txt = elgg_echo('uservalidationbyemail:errors:could_not_validate_users');
+}
+
+if ($error) {
+ register_error($error_txt);
+} else {
+ system_message($message_txt);
+}
+
+forward(REFERRER); \ No newline at end of file