Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standaloneusers - add search kit task to send password reset email #31596

Open
wants to merge 1 commit into
base: 5.81
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).'),
],
];
}