You are here

function userprotect_display_protections in User protect 5

Same name and namespace in other branches
  1. 6 userprotect.module \userprotect_display_protections()
  2. 7 userprotect.module \userprotect_display_protections()

Builds a displayable text string of the protections currently in effect for the specified user.

Parameters

$account The user account object.:

$protected An array of protections the current user is receiving.:

Return value

A text string representing the current protections.

2 calls to userprotect_display_protections()
userprotect_form_alter in ./userprotect.module
Alters forms for user protection.
userprotect_user in ./userprotect.module
Implementation of hook_user().

File

./userprotect.module, line 955

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;
}