Skip to content

Commit

Permalink
standaloneusers - add search kit task to send password reset email to…
Browse files Browse the repository at this point in the history
… user
  • Loading branch information
ufundo committed Dec 11, 2024
1 parent 5015448 commit b2437ea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@
'action' => '',
'condition' => [],
],
[
'task' => 'send_password_reset',
'entity' => 'User',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-lock',
'text' => E::ts('Send Password Reset'),
'style' => 'warning',
'path' => '',
'action' => '',
'condition' => [],
],
],
'type' => 'menu',
'alignment' => 'text-right',
Expand Down
25 changes: 25 additions & 0 deletions ext/standaloneusers/standaloneusers.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,28 @@ function standaloneusers_civicrm_navigationMenu(&$menu) {
'permission' => 'cms:administer users',
]);
}

/**
* Implements search tasks hook to add the `sendPasswordReset` action
*
* @param array $tasks
* @param bool $checkPermissions
* @param int|null $userId
*/
function standaloneusers_civicrm_searchKitTasks(array &$tasks, bool $checkPermissions, ?int $userId) {
if ($checkPermissions && !CRM_Core_Permission::check('cms:administer users', $userId)) {
return;
}
$tasks['User']['send_password_reset'] = [
'title' => E::ts('Send Password Reset'),
'icon' => 'fa-lock',
'apiBatch' => [
'action' => 'sendPasswordResetEmail',
'params' => NULL,
'confirmMsg' => E::ts('Send password reset email to %1 user(s)?'),
'runMsg' => E::ts('Sending password reset email(s) to %1 user(s)...'),
'successMsg' => E::ts('Password reset emails sent to %1 user(s). Note that reset links are valid for 1 hour.'),
'errorMsg' => E::ts('An error occurred while attempting to send password reset email(s).'),
],
];
}

0 comments on commit b2437ea

Please sign in to comment.