diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 08cd24c..10b1e67 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -436,6 +436,7 @@ function rdf_preprocess_username(&$variables) { // element if a link is rendered, or on a span element otherwise. if (isset($variables['link_path'])) { $variables['link_options']['attributes'] = array_merge_recursive($variables['link_options']['attributes'], $attributes); + $variables['link'] = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']); } else { $variables['attributes'] = array_merge_recursive($variables['attributes'], $attributes); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 0d9b5be..7197a22 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -1176,19 +1176,9 @@ function hook_system_info_alter(&$info, $file, $type) { * have inherent security risks across a variety of potential use cases * (for example, the "administer filters" and "bypass node access" * permissions provided by Drupal core). When set to TRUE, a standard - * warning message defined in user_admin_permissions() and output via - * theme_user_permission_description() will be associated with the - * permission and displayed with it on the permission administration page. - * Defaults to FALSE. - * - warning: (optional) A translated warning message to display for this - * permission on the permission administration page. This warning overrides - * the automatic warning generated by 'restrict access' being set to TRUE. - * This should rarely be used, since it is important for all permissions to - * have a clear, consistent security warning that is the same across the - * site. Use the 'description' key instead to provide any information that - * is specific to the permission you are defining. - * - * @see theme_user_permission_description() + * warning message defined in user_admin_permissions() will be displayed + * with the permission on the permission administration page. Defaults + * to FALSE. */ function hook_permission() { return array( diff --git a/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php b/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php index a0b29ee..1bbeec6 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php @@ -140,18 +140,21 @@ public function buildForm(array $form, array &$form_state) { 'warning' => !empty($perm_item['restrict access']) ? $this->t('Warning: Give to trusted roles only; this permission has security implications.') : '', ); $options[$perm] = $perm_item['title']; - $user_permission_description = array( - '#theme' => 'user_permission_description', - '#permission_item' => $perm_item, - '#hide' => $hide_descriptions, - ); + // Show the permission description. + if (!$hide_descriptions) { + $user_permission_description = $perm_item['description']; + // Append warning message. + if (!empty($perm_item['warning'])) { + $user_permission_description .= ' ' . $perm_item['warning'] . ''; + } + } $form['permissions'][$perm]['description'] = array( '#wrapper_attributes' => array( 'class' => array('permission'), ), '#type' => 'item', '#markup' => $perm_item['title'], - '#description' => drupal_render($user_permission_description), + '#description' => $user_permission_description, ); $options[$perm] = ''; foreach ($role_names as $rid => $name) { diff --git a/core/modules/user/templates/username.html.twig b/core/modules/user/templates/username.html.twig new file mode 100644 index 0000000..a41def7 --- /dev/null +++ b/core/modules/user/templates/username.html.twig @@ -0,0 +1,31 @@ +{# +/** + * @file + * Default theme implementation for displaying a username. + * + * Available variables: + * - account: The full account information for the user. + * - name: The user's name, sanitized. + * - extra: Additional text to append to the user's name, sanitized. + * - link: The link fully generated by l() if link_path is set. + * - link_path: The path or URL of the user's profile page, home page, + * or other desired page to link to for more information about the user. + * - link_options: Options to pass to the l() function's $options parameter if + * linking the user's name to the user's page. + * - attributes: HTML attributes to be used if not linking to the user's page. + * + * @see template_preprocess_username() + * + * @ingroup themeable + */ +#} +{% if link %} + {{- link -}} +{% else %} + {# + Modules may have added important attributes so they must be included + in the output. Additional classes may be added as array elements like + {% set attributes.class = attributes.class|merge(["myclass"]) %} + #} + {{ name }}{{ extra }} +{% endif %} diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc deleted file mode 100644 index 9a6ca2a..0000000 --- a/core/modules/user/user.admin.inc +++ /dev/null @@ -1,37 +0,0 @@ -' . $permission_item['warning'] . ''; - } - if (!empty($description)) { - return implode(' ', $description); - } - } -} diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 0c7ac05..7932b85 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -97,15 +97,9 @@ function user_theme() { 'file' => 'user.pages.inc', 'template' => 'user', ), - 'user_permission_description' => array( - 'variables' => array('permission_item' => NULL, 'hide' => NULL), - 'file' => 'user.admin.inc', - ), - 'user_signature' => array( - 'variables' => array('signature' => NULL), - ), 'username' => array( 'variables' => array('account' => NULL, 'attributes' => array()), + 'template' => 'username', ), ); } @@ -610,7 +604,15 @@ function user_template_preprocess_default_variables_alter(&$variables) { } /** - * Preprocesses variables for theme_username(). + * Prepares variables for username templates. + * + * Default template: username.html.twig. + * + * @param array $variables + * An associative array containing: + * - account: The user account to check access for + * (Drupal\user\Plugin\Core\Entity\User). + * - uid: The user uid number. * * Modules that make any changes to variables like 'name' or 'extra' must ensure * that the final string is safe to include directly in the output by using @@ -657,39 +659,13 @@ function template_preprocess_username(&$variables) { $variables['link_options']['html'] = TRUE; // Set a default class. $variables['link_options']['attributes']['class'] = array('username'); -} -/** - * Returns HTML for a username, potentially linked to the user's page. - * - * @param $variables - * An associative array containing: - * - account: The user object to format. - * - name: The user's name, sanitized. - * - extra: Additional text to append to the user's name, sanitized. - * - link_path: The path or URL of the user's profile page, home page, or - * other desired page to link to for more information about the user. - * - link_options: An array of options to pass to the l() function's $options - * parameter if linking the user's name to the user's page. - * - attributes: An array of attributes to instantiate the - * Drupal\Core\Template\Attribute class if not linking to the user's page. - * - * @see template_preprocess_username() - */ -function theme_username($variables) { + // We have a link path, so we should generate a link using l(). + // Additional classes may be added as array elements like + // $variables['link_options']['attributes']['class'][] = 'myclass'; if (isset($variables['link_path'])) { - // We have a link path, so we should generate a link using l(). - // Additional classes may be added as array elements like - // $variables['link_options']['attributes']['class'][] = 'myclass'; - $output = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']); - } - else { - // Modules may have added important attributes so they must be included - // in the output. Additional classes may be added as array elements like - // $variables['attributes']['class'][] = 'myclass'; - $output = '' . $variables['name'] . $variables['extra'] . ''; + $variables['link'] = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']); } - return $output; } /** @@ -1679,29 +1655,6 @@ function user_role_revoke_permissions($rid, array $permissions = array()) { } /** - * Returns HTML for a user signature. - * - * @param $variables - * An associative array containing: - * - signature: The user's signature. - * - * @ingroup themeable - */ -function theme_user_signature($variables) { - $signature = $variables['signature']; - $output = ''; - - if ($signature) { - $output .= '
'; - $output .= '
'; - $output .= $signature; - $output .= '
'; - } - - return $output; -} - -/** * Conditionally create and send a notification email when a certain * operation happens on the given user account. *