function userprotect_display_protections in User protect 7
Same name and namespace in other branches
- 5 userprotect.module \userprotect_display_protections()
- 6 userprotect.module \userprotect_display_protections()
Builds a displayable text string of the protections currently in effect for the specified user.
Parameters
object $account: The user account object.
array $protected: An array of protections the current user is receiving.
Return value
string A text string representing the current protections.
2 calls to userprotect_display_protections()
- userprotect_form_display_protections in ./
userprotect.module - Conditionally displays a user message on edit forms listing current protections.
- userprotect_user_insert in ./
userprotect.module - Implements hook_user_insert().
File
- ./
userprotect.module, line 742 - Main module file for the userprotect module.
Code
function userprotect_display_protections($account, $protected) {
// Get the protections display text.
$display = userprotect_get_protection_display();
$protections = array();
// For each protection, check if any of the user's roles are protected, or the
// user is protected.
foreach ($protected as $protection => $value) {
$protections[] = $display[$protection];
}
// Display if there are protections and it's an admin user.
if (count($protections) && user_access('administer users')) {
$output = t('%user has been protected from the following editing operations: !operations', array(
'%user' => $account->name,
'!operations' => implode(', ', $protections),
));
}
else {
$output = '';
}
return $output;
}