b2evolution PHP Cross Reference Blogging Systems

Source: /skins/msgform.main.php - 185 lines - 6442 bytes - Text - Print

Description: This file is the template that includes required css files to display msgform ( contact form )

   1  <?php
   2  /**

   3   * This file is the template that includes required css files to display msgform ( contact form )

   4   *

   5   * b2evolution - {@link http://b2evolution.net/}

   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   7   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}

   8   *

   9   * @package evoskins

  10   *

  11   * @version $Id: $

  12   */
  13  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  14  
  15  global $Messages, $current_User, $disp;
  16  
  17  // get expected message form type

  18  $msg_type = param( 'msg_type', 'string', '' );
  19  // initialize

  20  $recipient_User = NULL;
  21  $Comment = NULL;
  22  $allow_msgform = NULL;
  23  
  24  // get possible params

  25  $recipient_id = param( 'recipient_id', 'integer', 0, true );
  26  $comment_id = param( 'comment_id', 'integer', 0, true );
  27  $post_id = param( 'post_id', 'integer', 0, true );
  28  $subject = param( 'subject', 'string', '' );
  29  
  30  // try to init recipient_User

  31  if( !empty( $recipient_id ) )
  32  {
  33      $UserCache = & get_UserCache();
  34      $recipient_User = & $UserCache->get_by_ID( $recipient_id );
  35  }
  36  elseif( !empty( $comment_id ) )
  37  { // comment id is set, try to get comment author user
  38      $CommentCache = & get_CommentCache();
  39      $Comment = $CommentCache->get_by_ID( $comment_id, false );
  40  
  41      if( $Comment = $CommentCache->get_by_ID( $comment_id, false ) )
  42      {
  43          $recipient_User = & $Comment->get_author_User();
  44          if( empty( $recipient_User ) && ( $Comment->allow_msgform ) && ( is_email( $Comment->get_author_email() ) ) )
  45          { // set allow message form to email because comment author (not registered) accepts email
  46              $allow_msgform = 'email';
  47              param( 'recipient_address', 'string', $Comment->get_author_email() );
  48              param( 'recipient_name', 'string', $Comment->get_author_name() );
  49          }
  50      }
  51  }
  52  
  53  if( $recipient_User )
  54  { // recipient User is set
  55      // get_msgform_possibility returns NULL (false), only if there is no messaging option between current_User and recipient user

  56      $allow_msgform = $recipient_User->get_msgform_possibility();
  57      if( $allow_msgform == 'login' )
  58      { // user must login first to be able to send a message to this User
  59          $disp = 'login';
  60          param( 'action', 'string', 'req_login' );
  61          // override redirect to param

  62          param( 'redirect_to', 'url', regenerate_url(), true, true );
  63          $Messages->add( T_( 'You must log in before you can contact this user' ) );
  64      }
  65      elseif( ( $allow_msgform == 'PM' ) && check_user_status( 'can_be_validated' ) )
  66      { // user is not activated
  67          if( $recipient_User->accepts_email() )
  68          { // recipient User accepts email allow to send email
  69              $allow_msgform = 'email';
  70              $msg_type = 'email';
  71              $activateinfo_link = 'href="'.get_activate_info_url().'"';
  72              $Messages->add( sprintf( T_( 'You must activate your account before you can send a private message to %s. However you can send them an email if you\'d like. <a %s>More info &raquo;</a>' ), $recipient_User->get( 'login' ), $activateinfo_link ), 'warning' );
  73          }
  74          else
  75          { // Redirect to the activate info page for not activated users
  76              $Messages->add( T_( 'You must activate your account before you can contact a user. <b>See below:</b>' ) );
  77              header_redirect( get_activate_info_url(), 302 );
  78              // will have exited

  79          }
  80      }
  81      elseif( ( $msg_type == 'PM' ) && ( $allow_msgform == 'email' ) )
  82      { // only email is allowed but user expect private message form
  83          if( ( !empty( $current_User ) ) && ( $recipient_id == $current_User->ID ) )
  84          {
  85              $Messages->add( T_( 'You cannot send a private message to yourself. However you can send yourself an email if you\'d like.' ), 'warning' );
  86          }
  87          else
  88          {
  89              $Messages->add( sprintf( T_( 'You cannot send a private message to %s. However you can send them an email if you\'d like.' ), $recipient_User->get( 'login' ) ), 'warning' );
  90          }
  91      }
  92      elseif( ( $msg_type != 'email' ) && ( $allow_msgform == 'PM' ) )
  93      { // private message form should be displayed, change display to create new individual thread with the given recipient user
  94          // check if creating new PM is allowed

  95          if( check_create_thread_limit( true ) )
  96          { // thread limit reached
  97              header_redirect();
  98              // exited here

  99          }
 100  
 101          // Load classes

 102          load_class( 'messaging/model/_thread.class.php', 'Thread' );
 103          load_class( 'messaging/model/_message.class.php', 'Message' );
 104  
 105          // Set global variable to auto define the FB autocomplete plugin field

 106          $recipients_selected = array( array(
 107                  'id'    => $recipient_User->ID,
 108                  'title' => $recipient_User->login,
 109              ) );
 110  
 111          init_tokeninput_js( 'blog' );
 112  
 113          $disp = 'threads';
 114          $edited_Thread = new Thread();
 115          $edited_Message = new Message();
 116          $edited_Message->Thread = & $edited_Thread;
 117          $edited_Thread->recipients = $recipient_User->login;
 118          param( 'action', 'string', 'new', true );
 119          param( 'thrdtype', 'string', 'individual', true );
 120      }
 121  
 122      if( $allow_msgform == 'email' )
 123      { // set recippient user param
 124          set_param( 'recipient_id', $recipient_User->ID );
 125      }
 126  }
 127  
 128  if( $allow_msgform == NULL )
 129  { // should be Prevented by UI
 130      if( !empty( $recipient_User ) )
 131      {
 132          $Messages->add( T_( 'The user does not want to get contacted through the message form.' ) );
 133      }
 134      elseif( !empty( $Comment ) )
 135      {
 136          $Messages->add( T_( 'This commentator does not want to get contacted through the message form.' ) );
 137      }
 138      header_redirect();
 139      // exited here

 140  }
 141  
 142  if( $allow_msgform == 'PM' || $allow_msgform == 'email' )
 143  { // Some message form is available
 144      // Get the suggested subject for the email:

 145      if( empty($subject) )
 146      { // no subject provided by param:
 147          if( ! empty($comment_id) )
 148          {
 149              $row = $DB->get_row( '
 150                  SELECT post_title
 151                    FROM T_items__item, T_comments
 152                   WHERE comment_ID = '.$DB->quote($comment_id).'
 153                     AND post_ID = comment_post_ID' );
 154  
 155              if( $row )
 156              {
 157                  $subject = T_('Re:').' '.sprintf( /* TRANS: Used as mail subject; %s gets replaced by an item's title */ T_( 'Comment on %s' ), $row->post_title );
 158              }
 159          }
 160  
 161          if( empty($subject) && ! empty($post_id) )
 162          {
 163              $row = $DB->get_row( '
 164                      SELECT post_title
 165                        FROM T_items__item
 166                       WHERE post_ID = '.$post_id );
 167              if( $row )
 168              {
 169                  $subject = T_('Re:').' '.$row->post_title;
 170              }
 171          }
 172      }
 173      if( $allow_msgform == 'PM' )
 174      {
 175          $edited_Thread->title = $subject;
 176      }
 177      else
 178      {
 179          param( 'subject', 'string', $subject, true );
 180      }
 181  }
 182  
 183  require $ads_current_skin_path.'index.main.php';
 184  
 185  ?>

title

Description

title

Description

title

Description

title

title

Body