b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_msgform.disp.php - 122 lines - 4062 bytes - Summary - Text - Print

Description: This is the template that displays the message user form

   1  <?php
   2  /**
   3   * This is the template that displays the message user form
   4   *
   5   * This file is not meant to be called directly.
   6   * It is meant to be called by an include in the main.page.php template.
   7   * To display a feedback, you should call a stub AND pass the right parameters
   8   * For example: /blogs/index.php?disp=msgform&recipient_id=n
   9   * Note: don't code this URL by hand, use the template functions to generate it!
  10   *
  11   * b2evolution - {@link http://b2evolution.net/}
  12   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  13   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  14   *
  15   * @package evoskins
  16   *
  17   * @todo dh> A user/blog might want to accept only mails from logged in users (fp>yes!)
  18   * @todo dh> For logged in users the From name and address should be not editable/displayed
  19   *           (the same as when commenting). (fp>yes!!!)
  20   * @todo dh> Display recipient's avatar?! fp> of course! :p
  21   */
  22  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  23  
  24  global $cookie_name, $cookie_email;
  25  
  26  global $DB;
  27  
  28  // Parameters
  29  /* TODO: dh> params should get remembered, e.g. if somebody clicks on the
  30   *       login/logout link from the msgform page.
  31   *       BUT, for the logout link remembering it here is too late normally.. :/
  32   */
  33  $redirect_to = param( 'redirect_to', 'url', '' ); // pass-through (hidden field)
  34  $recipient_id = param( 'recipient_id', 'integer', 0 );
  35  $post_id = param( 'post_id', 'integer', 0 );
  36  $comment_id = param( 'comment_id', 'integer', 0 );
  37  $subject = param( 'subject', 'string', '' );
  38  
  39  
  40  // User's preferred name or the stored value in her cookie (from commenting):
  41  $email_author = '';
  42  // User's email address or the stored value in her cookie (from commenting):
  43  $email_author_address = '';
  44  if( is_logged_in() )
  45  {
  46      $email_author = $current_User->get_preferred_name();
  47      $email_author_address = $current_User->email;
  48  }
  49  if( ! strlen( $email_author ) )
  50  { // Try to get params from $_COOKIE through the param() function
  51      $email_author = param_cookie( $cookie_name, 'string', '' );
  52      $email_author_address = param_cookie( $cookie_email, 'string', '' );
  53  }
  54  
  55  $recipient_User = NULL;
  56  // Get the name and email address of the recipient
  57  if( empty($recipient_id) )
  58  {
  59      $recipient_name = param( 'recipient_name', 'string', '' );
  60      $recipient_address = param( 'recipient_address', 'string', '' );
  61  }
  62  else
  63  { // If the email is to a registered user get the email address from the users table
  64      $UserCache = & get_UserCache();
  65      $recipient_User = & $UserCache->get_by_ID( $recipient_id );
  66  
  67      if( $recipient_User )
  68      { // recipient User found
  69          $recipient_name = $recipient_User->get('preferredname');
  70          $recipient_address = $recipient_User->get('email');
  71      }
  72  }
  73  
  74  if( empty($recipient_address) )
  75  {    // We should never have called this in the first place!
  76      // Could be that commenter did not provide an email, etc...
  77      echo 'No recipient specified!';
  78      return;
  79  }
  80  
  81  // Form to send email
  82  if( !empty( $Blog ) && ( $Blog->get_ajax_form_enabled() ) )
  83  {
  84      if( empty( $subject ) )
  85      {
  86          $subject = '';
  87      }
  88      // init params
  89      $json_params = array(
  90          'action' => 'get_msg_form',
  91          'subject' => $subject,
  92          'recipient_id' => $recipient_id,
  93          'recipient_name' => $recipient_name,
  94          'email_author' => $email_author,
  95          'email_author_address' => $email_author_address,
  96          'blog' => $Blog->ID,
  97          'comment_id' => $comment_id,
  98          'redirect_to' => $redirect_to,
  99          'params' => $params );
 100  
 101      // generate form wtih ajax request
 102      display_ajax_form( $json_params );
 103  }
 104  else
 105  {
 106      if( ! empty( $recipient_User ) )
 107      { // Get identity link for existed users
 108          $recipient_link = $recipient_User->get_identity_link( array( 'link_text' => 'nickname' ) );
 109      }
 110      else
 111      { // Get login name for anonymous user
 112          $gender_class = '';
 113          if( check_setting( 'gender_colored' ) )
 114          { // Set a gender class if the setting is ON
 115              $gender_class = ' nogender';
 116          }
 117          $recipient_link = '<span class="user anonymous'.$gender_class.'" rel="bubbletip_comment_'.$comment_id.'">'.$recipient_name.'</span>';
 118      }
 119      require  '_contact_msg.form.php';
 120  }
 121  
 122  ?>

title

Description

title

Description

title

Description

title

title

Body