[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/message/ -> admin_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 admin_form
  18  * Displays a message to the user and allows him to send an email
  19  */
  20  class admin_form extends form
  21  {
  22      /** @var \phpbb\config\db_text */
  23      protected $config_text;
  24  
  25      /** @var string */
  26      protected $subject;
  27      /** @var string */
  28      protected $sender_name;
  29      /** @var string */
  30      protected $sender_address;
  31  
  32      /**
  33      * Construct
  34      *
  35      * @param \phpbb\auth\auth $auth
  36      * @param \phpbb\config\config $config
  37      * @param \phpbb\config\db_text $config_text
  38      * @param \phpbb\db\driver\driver_interface $db
  39      * @param \phpbb\user $user
  40      * @param string $phpbb_root_path
  41      * @param string $phpEx
  42      */
  43  	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx)
  44      {
  45          parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx);
  46          $this->config_text = $config_text;
  47      }
  48  
  49      /**
  50      * {inheritDoc}
  51      */
  52  	public function check_allow()
  53      {
  54          $error = parent::check_allow();
  55          if ($error)
  56          {
  57              return $error;
  58          }
  59  
  60          if (!$this->config['contact_admin_form_enable'])
  61          {
  62              return 'NO_CONTACT_PAGE';
  63          }
  64  
  65          return false;
  66      }
  67  
  68      /**
  69      * {inheritDoc}
  70      */
  71  	public function bind(\phpbb\request\request_interface $request)
  72      {
  73          parent::bind($request);
  74  
  75          $this->subject = $request->variable('subject', '', true);
  76          $this->sender_address = $request->variable('email', '');
  77          $this->sender_name = $request->variable('name', '', true);
  78      }
  79  
  80      /**
  81      * {inheritDoc}
  82      */
  83  	public function submit(\messenger $messenger)
  84      {
  85          if (!$this->subject)
  86          {
  87              $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL'];
  88          }
  89          if (!$this->body)
  90          {
  91              $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL'];
  92          }
  93  
  94          if ($this->user->data['is_registered'])
  95          {
  96              $this->message->set_sender_from_user($this->user);
  97              $this->sender_name = $this->user->data['username'];
  98              $this->sender_address = $this->user->data['user_email'];
  99          }
 100          else
 101          {
 102              if (!$this->sender_name)
 103              {
 104                  $this->errors[] = $this->user->lang['EMPTY_SENDER_NAME'];
 105              }
 106  
 107              if (!function_exists('validate_data'))
 108              {
 109                  require($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx);
 110              }
 111  
 112              $validate_array = validate_data(
 113                  array(
 114                      'email' => $this->sender_address,
 115                  ),
 116                  array(
 117                      'email' => array(
 118                          array('string', false, 6, 60),
 119                          array('email'),
 120                      ),
 121                  )
 122              );
 123  
 124              foreach ($validate_array as $error)
 125              {
 126                  $this->errors[] = $this->user->lang[$error];
 127              }
 128  
 129              $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name);
 130              $this->message->set_sender_notify_type(NOTIFY_EMAIL);
 131          }
 132  
 133          $this->message->set_template('contact_admin');
 134          $this->message->set_subject($this->subject);
 135          $this->message->set_body($this->body);
 136          $this->message->add_recipient(
 137              $this->user->lang['ADMINISTRATOR'],
 138              $this->config['board_contact'],
 139              $this->config['default_lang'],
 140              NOTIFY_EMAIL
 141          );
 142  
 143          $this->message->set_template_vars(array(
 144              'FROM_EMAIL_ADDRESS'    => $this->sender_address,
 145              'FROM_IP_ADDRESS'        => $this->user->ip,
 146              'S_IS_REGISTERED'        => $this->user->data['is_registered'],
 147  
 148              'U_FROM_PROFILE'        => generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=viewprofile&u=' . $this->user->data['user_id'],
 149          ));
 150  
 151          parent::submit($messenger);
 152      }
 153  
 154      /**
 155      * {inheritDoc}
 156      */
 157  	public function render(\phpbb\template\template $template)
 158      {
 159          $l_admin_info = $this->config_text->get('contact_admin_info');
 160          if ($l_admin_info)
 161          {
 162              $contact_admin_data            = $this->config_text->get_array(array(
 163                  'contact_admin_info',
 164                  'contact_admin_info_uid',
 165                  'contact_admin_info_bitfield',
 166                  'contact_admin_info_flags',
 167              ));
 168  
 169              $l_admin_info = generate_text_for_display(
 170                  $contact_admin_data['contact_admin_info'],
 171                  $contact_admin_data['contact_admin_info_uid'],
 172                  $contact_admin_data['contact_admin_info_bitfield'],
 173                  $contact_admin_data['contact_admin_info_flags']
 174              );
 175          }
 176  
 177          $template->assign_vars(array(
 178              'S_CONTACT_ADMIN'    => true,
 179              'S_CONTACT_FORM'    => $this->config['contact_admin_form_enable'],
 180              'S_IS_REGISTERED'    => $this->user->data['is_registered'],
 181              'S_POST_ACTION'        => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=contactadmin'),
 182  
 183              'CONTACT_INFO'        => $l_admin_info,
 184              'MESSAGE'            => $this->body,
 185              'SUBJECT'            => $this->subject,
 186              'NAME'                => $this->sender_name,
 187              'EMAIL'                => $this->sender_address,
 188          ));
 189  
 190          parent::render($template);
 191      }
 192  }


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