| @@ -20,8 +20,9 @@ | ||
| 20 | 20 | |
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | 23 | parent::__construct(); |
| 24 | + | |
| 24 | 25 | $this->breadcrumb[acym_translation('ACYM_SUBSCRIBERS')] = acym_completeLink('users'); |
| 25 | 26 | $this->loadScripts = [ |
| 26 | 27 | 'edit' => ['datepicker'], |
| 27 | 28 | 'all' => ['vue-applications' => ['entity_select']], |
| @@ -27,15 +28,16 @@ | ||
| 27 | 28 | 'all' => ['vue-applications' => ['entity_select']], |
| 28 | 29 | ]; |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - public function getAll() | |
| 32 | + public function getAll(): array | |
| 32 | 33 | { |
| 33 | 34 | $userClass = new UserClass(); |
| 35 | + | |
| 34 | 36 | return $userClass->getAll(); |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | - public function clean() | |
| 39 | + public function clean(): void | |
| 38 | 40 | { |
| 39 | 41 | if (acym_isAcyCheckerInstalled()) { |
| 40 | 42 | if (ACYM_CMS === 'joomla') { |
| 41 | 43 | acym_redirect(acym_route('index.php?option=com_acychecker', false)); |
| @@ -46,9 +48,9 @@ | ||
| 46 | 48 | acym_redirect(acym_completeLink('dashboard&task=acychecker', false, true)); |
| 47 | 49 | } |
| 48 | 50 | } |
| 49 | 51 | |
| 50 | - public function getUserInfoAjax() | |
| 52 | + public function getUserInfoAjax(): void | |
| 51 | 53 | { |
| 52 | 54 | $userId = acym_getVar('int', 'userId', 0); |
| 53 | 55 | |
| 54 | 56 | if (empty($userId)) { |
| @@ -62,6 +64,29 @@ | ||
| 62 | 64 | acym_sendAjaxResponse(acym_translation('ACYM_SUBSCRIBER_NOT_CUSTOM_FIELD'), [], false); |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | acym_sendAjaxResponse('', $user); |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Search user emails to suggest (autocomplete on send a test) | |
| 72 | + * Users without access will not see autocomplete results, they can still type emails manually | |
| 73 | + */ | |
| 74 | + public function searchTestReceiversAjax(): void | |
| 75 | + { | |
| 76 | + if (!acym_isAllowed('users')) { | |
| 77 | + echo json_encode([]); | |
| 78 | + exit; | |
| 79 | + } | |
| 80 | + | |
| 81 | + $search = acym_getVar('string', 'search', ''); | |
| 82 | + $userClass = new UserClass(); | |
| 83 | + $users = $userClass->getUsersLikeEmail($search); | |
| 84 | + | |
| 85 | + $return = []; | |
| 86 | + foreach ($users as $oneUser) { | |
| 87 | + $return[] = [$oneUser->id, $oneUser->email]; | |
| 88 | + } | |
| 89 | + echo json_encode($return); | |
| 90 | + exit; | |
| 66 | 91 | } |
| 67 | 92 | } |