Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

user_form.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 3.07 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\message;
015   
016  /**
017  * Class user_form
018  * Allows users to send emails to other users
019  */
020  class user_form extends form
021  {
022      /** @var int */
023      protected $recipient_id;
024      /** @var array */
025      protected $recipient_row;
026      /** @var string */
027      protected $subject;
028   
029      /**
030      * Get the data of the recipient
031      *
032      * @param int $user_id
033      * @return    false|array        false if the user does not exist, array otherwise
034      */
035      protected function get_user_row($user_id)
036      {
037          $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
038              FROM ' . USERS_TABLE . '
039              WHERE user_id = ' . (int) $user_id . '
040                  AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
041          $result = $this->db->sql_query($sql);
042          $row = $this->db->sql_fetchrow($result);
043          $this->db->sql_freeresult($result);
044   
045          return $row;
046      }
047   
048      /**
049      * {inheritDoc}
050      */
051      public function check_allow()
052      {
053          $error = parent::check_allow();
054          if ($error)
055          {
056              return $error;
057          }
058   
059          if (!$this->auth->acl_get('u_sendemail'))
060          {
061              return 'NO_EMAIL';
062          }
063   
064          if ($this->recipient_id == ANONYMOUS || !$this->config['board_email_form'])
065          {
066              return 'NO_EMAIL';
067          }
068   
069          if (!$this->recipient_row)
070          {
071              return 'NO_USER';
072          }
073   
074          // Can we send email to this user?
075          if (!$this->recipient_row['user_allow_viewemail'] && !$this->auth->acl_get('a_user'))
076          {
077              return 'NO_EMAIL';
078          }
079   
080          return false;
081      }
082   
083      /**
084      * {inheritDoc}
085      */
086      public function bind(\phpbb\request\request_interface $request)
087      {
088          parent::bind($request);
089   
090          $this->recipient_id = $request->variable('u', 0);
091          $this->subject = $request->variable('subject', '', true);
092   
093          $this->recipient_row = $this->get_user_row($this->recipient_id);
094      }
095   
096      /**
097      * {inheritDoc}
098      */
099      public function submit(\messenger $messenger)
100      {
101          if (!$this->subject)
102          {
103              $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL'];
104          }
105   
106          if (!$this->body)
107          {
108              $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL'];
109          }
110   
111          $this->message->set_template('profile_send_email');
112          $this->message->set_subject($this->subject);
113          $this->message->set_body($this->body);
114          $this->message->add_recipient_from_user_row($this->recipient_row);
115   
116          parent::submit($messenger);
117      }
118   
119      /**
120      * {inheritDoc}
121      */
122      public function render(\phpbb\template\template $template)
123      {
124          parent::render($template);
125   
126          $template->assign_vars(array(
127              'S_SEND_USER'            => true,
128              'S_POST_ACTION'            => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&amp;u=' . $this->recipient_id),
129   
130              'L_SEND_EMAIL_USER'        => $this->user->lang('SEND_EMAIL_USER', $this->recipient_row['username']),
131              'USERNAME_FULL'            => get_username_string('full', $this->recipient_row['user_id'], $this->recipient_row['username'], $this->recipient_row['user_colour']),
132              'SUBJECT'                => $this->subject,
133              'MESSAGE'                => $this->body,
134          ));
135      }
136  }
137