Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-17726

New PHP event core.mcp_warn_post_modify_template_vars + template event mcp_warn_post_rank_after

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.0.0-b1, 3.3.20-RC1
    • 3.3.20-RC1
    • Events
    • None

      TYPE
      ====
      PHP event + template event

      LOCATION (PHP)
      ==============
      includes/mcp/mcp_warn.php, function mcp_warn_post_view(), immediately
      before the final $template->assign_vars() call (after $user_rank_data
      and $avatar_img are computed):

          $user_rank_data = phpbb_get_user_rank($user_row, $user_row['user_posts']);
          $avatar_img = phpbb_get_user_avatar($user_row);

          /**
          * Modify user data before it is assigned to the template on the MCP warn-post page
          *
          * @event core.mcp_warn_post_modify_template_vars
          * @var array    user_row        The entire user row
          * @var array    user_rank_data    Array with rank title/img for this user
          * @var string    avatar_img        Rendered avatar HTML for this user
          * @var int        post_id            The post id for which the warning is being considered
          * @since to be filled in by the phpBB dev team at merge time
          */
          $vars = array('user_row', 'user_rank_data', 'avatar_img', 'post_id');
          extract($phpbb_dispatcher->trigger_event('core.mcp_warn_post_modify_template_vars', compact($vars)));

          $template->assign_vars(array(
              'U_POST_ACTION'        => $this->u_action,

              'POST'                => $message,
              ...

      LOCATION (template)
      ====================
      styles/prosilver/template/mcp_warn_post.html, immediately after the
      RANK_IMG line, inside the same details list as JOINED/POSTS/WARNINGS -
      identical position to mcp_warn_user_rank_after in mcp_warn_user.html,
      since both templates share the same details-block structure:

          <dl class="details">
              <!-- IF RANK_TITLE --><dt>{L_RANK}

      {L_COLON}</dt><dd>{RANK_TITLE}</dd><!-- ENDIF -->
              <!-- IF RANK_IMG -><dt><!- IF RANK_TITLE -> <!- ELSE -->{L_RANK}{L_COLON}

      <!-- ENDIF -></dt><dd>{RANK_IMG}</dd><!- ENDIF -->
              {% EVENT mcp_warn_post_rank_after %}
              <dt>{L_JOINED}

      {L_COLON}

      </dt><dd>{JOINED}</dd>

      PURPOSE
      =======
      mcp_warn.php only fires trigger_event() (core.mcp_warn_post_before,
      core.mcp_warn_post_after) inside the branch that handles an actual
      warning submission. On a normal page load - a moderator opening "warn
      user for this post" - no event fires between fetching $user_row and
      the final assign_vars() call, and the template has no event tag near
      the rank output either.

      USE CASE
      ========
      phpbbmodders/displaygroupsrank (shows extra rank images for every group
      a user belongs to, alongside their normal rank) covers the profile
      page, topic posts, PM view, the member list, and the team page through
      existing events, but cannot cover this page at all without a new one.
      Same gap as core.mcp_warn_user_modify_template_vars (see that RFC),
      one function over.

      VARIABLES
      =========

      • user_row (array, read-only) - the entire user row
      • user_rank_data (array, read-only) - rank title/img for this user
      • avatar_img (string, read-only) - rendered avatar HTML for this user
      • post_id (int, read-only) - the post id for which the warning is being
          considered

            Marc Marc
            bonelifer bonelifer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: