Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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

topic_form.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 3.89 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 topic_form
 018  * Form used to send topics as notification emails
 019  */
 020  class topic_form extends form
 021  {
 022      /** @var int */
 023      protected $topic_id;
 024      /** @var array */
 025      protected $topic_row;
 026      /** @var string */
 027      protected $recipient_address;
 028      /** @var string */
 029      protected $recipient_name;
 030      /** @var string */
 031      protected $recipient_lang;
 032   
 033      /**
 034      * Get the data of the topic
 035      *
 036      * @param int $topic_id
 037      * @return    false|array        false if the topic does not exist, array otherwise
 038      */
 039      protected function get_topic_row($topic_id)
 040      {
 041          $sql = 'SELECT forum_id, topic_title
 042              FROM ' . TOPICS_TABLE . '
 043              WHERE topic_id = ' . (int) $topic_id;
 044          $result = $this->db->sql_query($sql);
 045          $row = $this->db->sql_fetchrow($result);
 046          $this->db->sql_freeresult($result);
 047   
 048          return $row;
 049      }
 050   
 051      /**
 052      * {inheritDoc}
 053      */
 054      public function check_allow()
 055      {
 056          $error = parent::check_allow();
 057          if ($error)
 058          {
 059              return $error;
 060          }
 061   
 062          if (!$this->auth->acl_get('u_sendemail'))
 063          {
 064              return 'NO_EMAIL';
 065          }
 066   
 067          if (!$this->topic_row)
 068          {
 069              return 'NO_TOPIC';
 070          }
 071   
 072          if (!$this->auth->acl_get('f_read', $this->topic_row['forum_id']))
 073          {
 074              if ($this->user->data['user_id'] != ANONYMOUS)
 075              {
 076                  send_status_line(403, 'Forbidden');
 077              }
 078              else
 079              {
 080                  send_status_line(401, 'Unauthorized');
 081              }
 082              return 'SORRY_AUTH_READ';
 083          }
 084   
 085          if (!$this->auth->acl_get('f_email', $this->topic_row['forum_id']))
 086          {
 087              return 'NO_EMAIL';
 088          }
 089   
 090          return false;
 091      }
 092   
 093      /**
 094      * {inheritDoc}
 095      */
 096      public function bind(\phpbb\request\request_interface $request)
 097      {
 098          parent::bind($request);
 099   
 100          $this->topic_id = $request->variable('t', 0);
 101          $this->recipient_address = $request->variable('email', '');
 102          $this->recipient_name = $request->variable('name', '', true);
 103          $this->recipient_lang = $request->variable('lang', $this->config['default_lang']);
 104   
 105          $this->topic_row = $this->get_topic_row($this->topic_id);
 106      }
 107   
 108      /**
 109      * {inheritDoc}
 110      */
 111      public function submit(\messenger $messenger)
 112      {
 113          if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address))
 114          {
 115              $this->errors[] = $this->user->lang['EMPTY_ADDRESS_EMAIL'];
 116          }
 117   
 118          if (!$this->recipient_name)
 119          {
 120              $this->errors[] = $this->user->lang['EMPTY_NAME_EMAIL'];
 121          }
 122   
 123          $this->message->set_template('email_notify');
 124          $this->message->set_template_vars(array(
 125              'TOPIC_NAME'    => htmlspecialchars_decode($this->topic_row['topic_title']),
 126              'U_TOPIC'        => generate_board_url() . '/viewtopic.' . $this->phpEx . '?f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id,
 127          ));
 128          $this->message->set_body($this->body);
 129          $this->message->add_recipient(
 130              $this->recipient_name,
 131              $this->recipient_address,
 132              $this->recipient_lang,
 133              NOTIFY_EMAIL
 134          );
 135          $this->message->set_sender_notify_type(NOTIFY_EMAIL);
 136   
 137          parent::submit($messenger);
 138      }
 139   
 140      /**
 141      * {inheritDoc}
 142      */
 143      public function get_return_message()
 144      {
 145          return sprintf($this->user->lang['RETURN_TOPIC'],  '<a href="' . append_sid($this->phpbb_root_path . 'viewtopic.' . $this->phpEx, 'f=' . $this->topic_row['forum_id'] . '&amp;t=' . $this->topic_id) . '">', '</a>');
 146      }
 147   
 148      /**
 149      * {inheritDoc}
 150      */
 151      public function render(\phpbb\template\template $template)
 152      {
 153          parent::render($template);
 154   
 155          $this->user->add_lang('viewtopic');
 156          $template->assign_vars(array(
 157              'EMAIL'                => $this->recipient_address,
 158              'NAME'                => $this->recipient_name,
 159              'S_LANG_OPTIONS'    => language_select($this->recipient_lang),
 160              'MESSAGE'            => $this->body,
 161   
 162              'L_EMAIL_BODY_EXPLAIN'    => $this->user->lang['EMAIL_TOPIC_EXPLAIN'],
 163              'S_POST_ACTION'            => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&amp;t=' . $this->topic_id))
 164          );
 165      }
 166  }
 167