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

[PHP] Add event ucp_remind_modify_select_sql

XMLWordPrintable

      Identifer: core.ucp_remind_modify_select_sql

      Location: /includes/ucp/ucp_remind.php, line 50 (in phpbb 3.1.6).

      Parameters: 'email', 'username', 'sql_array'

      Explanation:
      With this event, we can modify the SQL query and change the way the username/email check is performed. The goal is to make an extension that allow password reset by providing only the email adress.

      Here is a code snippet that can be used in place of the line "$sql = ...". It does the exact same job and add the event dispatch. It uses the query builder so that portions of the query are split :

          $sql_array = array(
              'SELECT'		=> 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason',
              'FROM'			=> array(USERS_TABLE => 'u'),
              'WHERE'			=> "user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "' AND
                                  username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"
          );
       
          /**
           * Change SQL query for fetching user data
           *
           * @event core.ucp_remind_modify_select_sql
           * @var string  email       User's email from the form
           * @var string  username    User's username from the form
           * @var array   sql_array   Fully assembled SQL query with keys SELECT, FROM, WHERE
           * @since 3.1.7?
           */
          $vars = array(
              'email',
              'username',
              'sql_array'
          );
          extract($phpbb_dispatcher->trigger_event('core.ucp_remind_modify_select_sql', compact($vars)));
       
          $sql = $db->sql_build_query('SELECT', $sql_array);
      

      For the event call to work, $phpbb_dispatcher has to be declared global (line 33).

            Marc Marc
            kingkeos kingkeos [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: