[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/message/ -> topic_form.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\message;
  15  
  16  /**
  17  * Class topic_form
  18  * Form used to send topics as notification emails
  19  */
  20  class topic_form extends form
  21  {
  22      /** @var int */
  23      protected $topic_id;
  24      /** @var array */
  25      protected $topic_row;
  26      /** @var string */
  27      protected $recipient_address;
  28      /** @var string */
  29      protected $recipient_name;
  30      /** @var string */
  31      protected $recipient_lang;
  32  
  33      /**
  34      * Get the data of the topic
  35      *
  36      * @param int $topic_id
  37      * @return    false|array        false if the topic does not exist, array otherwise
  38      */
  39  	protected function get_topic_row($topic_id)
  40      {
  41          $sql = 'SELECT forum_id, topic_title
  42              FROM ' . TOPICS_TABLE . '
  43              WHERE topic_id = ' . (int) $topic_id;
  44          $result = $this->db->sql_query($sql);
  45          $row = $this->db->sql_fetchrow($result);
  46          $this->db->sql_freeresult($result);
  47  
  48          return $row;
  49      }
  50  
  51      /**
  52      * {inheritDoc}
  53      */
  54  	public function check_allow()
  55      {
  56          $error = parent::check_allow();
  57          if ($error)
  58          {
  59              return $error;
  60          }
  61  
  62          if (!$this->auth->acl_get('u_sendemail'))
  63          {
  64              return 'NO_EMAIL';
  65          }
  66  
  67          if (!$this->topic_row)
  68          {
  69              return 'NO_TOPIC';
  70          }
  71  
  72          if (!$this->auth->acl_get('f_read', $this->topic_row['forum_id']))
  73          {
  74              return 'SORRY_AUTH_READ';
  75          }
  76  
  77          if (!$this->auth->acl_get('f_email', $this->topic_row['forum_id']))
  78          {
  79              return 'NO_EMAIL';
  80          }
  81  
  82          return false;
  83      }
  84  
  85      /**
  86      * {inheritDoc}
  87      */
  88  	public function bind(\phpbb\request\request_interface $request)
  89      {
  90          parent::bind($request);
  91  
  92          $this->topic_id = $request->variable('t', 0);
  93          $this->recipient_address = $request->variable('email', '');
  94          $this->recipient_name = $request->variable('name', '', true);
  95          $this->recipient_lang = $request->variable('lang', $this->config['default_lang']);
  96  
  97          $this->topic_row = $this->get_topic_row($this->topic_id);
  98      }
  99  
 100      /**
 101      * {inheritDoc}
 102      */
 103  	public function submit(\messenger $messenger)
 104      {
 105          if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address))
 106          {
 107              $this->errors[] = $this->user->lang['EMPTY_ADDRESS_EMAIL'];
 108          }
 109  
 110          if (!$this->recipient_name)
 111          {
 112              $this->errors[] = $this->user->lang['EMPTY_NAME_EMAIL'];
 113          }
 114  
 115          $this->message->set_template('email_notify');
 116          $this->message->set_template_vars(array(
 117              'TOPIC_NAME'    => htmlspecialchars_decode($this->topic_row['topic_title']),
 118              'U_TOPIC'        => generate_board_url() . '/viewtopic.' . $this->phpEx . '?f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id,
 119          ));
 120          $this->message->set_body($this->body);
 121          $this->message->add_recipient(
 122              $this->recipient_name,
 123              $this->recipient_address,
 124              $this->recipient_lang,
 125              NOTIFY_EMAIL
 126          );
 127          $this->message->set_sender_notify_type(NOTIFY_EMAIL);
 128  
 129          parent::submit($messenger);
 130      }
 131  
 132      /**
 133      * {inheritDoc}
 134      */
 135  	public function get_return_message()
 136      {
 137          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>');
 138      }
 139  
 140      /**
 141      * {inheritDoc}
 142      */
 143  	public function render(\phpbb\template\template $template)
 144      {
 145          parent::render($template);
 146  
 147          $this->user->add_lang('viewtopic');
 148          $template->assign_vars(array(
 149              'EMAIL'                => $this->recipient_address,
 150              'NAME'                => $this->recipient_name,
 151              'S_LANG_OPTIONS'    => language_select($this->recipient_lang),
 152              'MESSAGE'            => $this->body,
 153  
 154              'L_EMAIL_BODY_EXPLAIN'    => $this->user->lang['EMAIL_TOPIC_EXPLAIN'],
 155              'S_POST_ACTION'            => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&amp;t=' . $this->topic_id))
 156          );
 157      }
 158  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1