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

New PHP event core.mcp_warn_user_modify_template_vars + template event mcp_warn_user_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_user_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-user page
          *
          * @event core.mcp_warn_user_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
          * @since to be filled in by the phpBB dev team at merge time
          */
          $vars = array('user_row', 'user_rank_data', 'avatar_img');
          extract($phpbb_dispatcher->trigger_event('core.mcp_warn_user_modify_template_vars', compact($vars)));

          // OK, they didn't submit a warning so lets build the page for them to do so
          $template->assign_vars(array(
              'U_POST_ACTION'        => $this->u_action,

              'RANK_TITLE'        => $user_rank_data['title'],
              ...

      LOCATION (template)
      ====================
      styles/prosilver/template/mcp_warn_user.html, immediately after the
      RANK_IMG line, inside the same details list as JOINED/POSTS/WARNINGS:

          <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_user_rank_after %}
              <dt>{L_JOINED}

      {L_COLON}

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

      PURPOSE
      =======
      mcp_warn.php only fires trigger_event() calls (core.mcp_warn_user_before,
      core.mcp_warn_user_after) inside the branch that handles an actual
      warning submission. On a normal page load - a moderator simply opening
      the "warn this user" page - neither event fires, so there is no hook
      between fetching $user_row and the final assign_vars() call, and the
      template has no event tag anywhere near the user summary block 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.

      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

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

              Created:
              Updated:
              Resolved: