b2evolution PHP Cross Reference Blogging Systems

Source: /skins/contacts.main.php - 256 lines - 9746 bytes - Text - Print

Description: This file is the template that includes required css files to display contacts

   1  <?php
   2  /**

   3   * This file is the template that includes required css files to display contacts

   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: contacts.main.php 6136 2014-03-08 07:59:48Z manuel $

  12   */
  13  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  14  
  15  global $htsrv_url, $Messages, $current_User;
  16  
  17  if( !is_logged_in() )
  18  { // Redirect to the login page for anonymous users
  19      $Messages->add( T_( 'You must log in to manage your contacts.' ) );
  20      header_redirect( get_login_url('cannot see contacts'), 302 );
  21      // will have exited

  22  }
  23  
  24  if( !$current_User->check_status( 'can_view_contacts' ) )
  25  { // user is logged in, but his status doesn't allow to view contacts
  26      if( $current_User->check_status( 'can_be_validated' ) )
  27      { // user is logged in but his/her account was not activated yet
  28          // Redirect to the account activation page

  29          $Messages->add( T_( 'You must activate your account before you can manage your contacts. <b>See below:</b>' ) );
  30          header_redirect( get_activate_info_url(), 302 );
  31          // will have exited

  32      }
  33  
  34      // Redirect to the blog url for users without messaging permission

  35      $Messages->add( 'You are not allowed to view Contacts!' );
  36      header_redirect( $Blog->gen_blogurl(), 302 );
  37  }
  38  
  39  // Get action parameter from request:

  40  param_action();
  41  
  42  if( ( $action != 'report_user' && $action != 'remove_report' ) && ( !$current_User->check_perm( 'perm_messaging', 'reply' ) ) )
  43  { // Redirect to the blog url for users without messaging permission
  44      $Messages->add( 'You are not allowed to view Contacts!' );
  45      header_redirect( $Blog->gen_blogurl(), 302 );
  46      // will have exited

  47  }
  48  
  49  switch( $action )
  50  {
  51      case 'add_user': // Add user to contacts list
  52          // Check that this action request is not a CSRF hacked request:

  53          $Session->assert_received_crumb( 'messaging_contacts' );
  54  
  55          $user_ID = param( 'user_ID', 'integer', 0 );
  56          if( $user_ID > 0 )
  57          {    // Add user to contacts
  58              if( create_contacts_user( $user_ID ) )
  59              {    // Add user to the group
  60                  $group_ID = param( 'group_ID', 'string', '' );
  61                  if( $result = create_contacts_group_users( $group_ID, $user_ID, 'group_ID_combo' ) )
  62                  {    // User has been added to the group
  63                      $Messages->add( sprintf( T_('User has been added to the &laquo;%s&raquo; group.'), $result['group_name'] ), 'success' );
  64                  }
  65                  else
  66                  {    // User has been added ONLY to the contacts list
  67                      $Messages->add( 'User has been added to your contacts.', 'success' );
  68                  }
  69              }
  70              header_redirect( url_add_param( $Blog->gen_blogurl(), 'disp=user&user_ID='.$user_ID, '&' ) );
  71          }
  72          break;
  73  
  74      case 'unblock': // Unblock user
  75          // Check that this action request is not a CSRF hacked request:

  76          $Session->assert_received_crumb( 'messaging_contacts' );
  77  
  78          $user_ID = param( 'user_ID', 'integer', 0 );
  79          if( $user_ID > 0 )
  80          {
  81              set_contact_blocked( $user_ID, 0 );
  82              $Messages->add( T_('Contact was unblocked.'), 'success' );
  83          }
  84          break;
  85  
  86      case 'remove_user': // Remove user from contacts group
  87          // Check that this action request is not a CSRF hacked request:

  88          $Session->assert_received_crumb( 'messaging_contacts' );
  89  
  90          $view = param( 'view', 'string', 'profile' );
  91          $user_ID = param( 'user_ID', 'integer', 0 );
  92          $group_ID = param( 'group_ID', 'integer', 0 );
  93          if( $user_ID > 0 && $group_ID > 0 )
  94          {    // Remove user from selected group
  95              if( remove_contacts_group_user( $group_ID, $user_ID ) )
  96              {    // User has been removed from the group
  97                  if( $view == 'contacts' )
  98                  {    // Redirect to the contacts list
  99                      header_redirect( url_add_param( $Blog->gen_blogurl(), 'disp=contacts', '&' ) );
 100                  }
 101                  else
 102                  {    // Redirect to the user profile page
 103                      header_redirect( url_add_param( $Blog->gen_blogurl(), 'disp=user&user_ID='.$user_ID, '&' ) );
 104                  }
 105              }
 106          }
 107          break;
 108  
 109      case 'add_group': // Add users to the group
 110          // Check that this action request is not a CSRF hacked request:

 111          $Session->assert_received_crumb( 'messaging_contacts' );
 112  
 113          $group = param( 'group', 'string', '' );
 114          $users = param( 'users', 'string', '' );
 115  
 116          if( $result = create_contacts_group_users( $group, $users ) )
 117          {    // Users have been added to the group
 118              $Messages->add( sprintf( T_('%d contacts have been added to the &laquo;%s&raquo; group.'), $result['count_users'], $result['group_name'] ), 'success' );
 119              $redirect_to = url_add_param( $Blog->gen_blogurl(), 'disp=contacts', '&' );
 120  
 121              $item_ID = param( 'item_ID', 'integer', 0 );
 122              if( $item_ID > 0 )
 123              {
 124                  $redirect_to = url_add_param( $redirect_to, 'item_ID='.$item_ID, '&' );
 125              }
 126              header_redirect( $redirect_to );
 127          }
 128          break;
 129  
 130      case 'rename_group': // Rename the group
 131          // Check that this action request is not a CSRF hacked request:

 132          $Session->assert_received_crumb( 'messaging_contacts' );
 133  
 134          $group_ID = param( 'group_ID', 'integer', true );
 135  
 136          if( rename_contacts_group( $group_ID ) )
 137          {
 138              $item_ID = param( 'item_ID', 'integer', 0 );
 139  
 140              $redirect_to = url_add_param( $Blog->gen_blogurl(), 'disp=contacts&g='.$group_ID, '&' );
 141              if( $item_ID > 0 )
 142              {
 143                  $redirect_to = url_add_param( $redirect_to, 'item_ID='.$item_ID, '&' );
 144              }
 145  
 146              $Messages->add( T_('The group has been renamed.'), 'success' );
 147              header_redirect( $redirect_to );
 148          }
 149          break;
 150  
 151      case 'delete_group': // Delete the group
 152          // Check that this action request is not a CSRF hacked request:

 153          $Session->assert_received_crumb( 'messaging_contacts' );
 154  
 155          $group_ID = param( 'group_ID', 'integer', true );
 156  
 157          if( delete_contacts_group( $group_ID ) )
 158          {
 159              $item_ID = param( 'item_ID', 'integer', 0 );
 160  
 161              $redirect_to = url_add_param( $Blog->gen_blogurl(), 'disp=contacts', '&' );
 162              if( $item_ID > 0 )
 163              {
 164                  $redirect_to = url_add_param( $redirect_to, 'item_ID='.$item_ID, '&' );
 165              }
 166  
 167              $Messages->add( T_('The group has been deleted.'), 'success' );
 168              header_redirect( $redirect_to );
 169          }
 170          break;
 171  
 172      case 'report_user': // Report a user
 173          // Check that this action request is not a CSRF hacked request:

 174          $Session->assert_received_crumb( 'messaging_contacts' );
 175  
 176          if( !$current_User->check_status( 'can_report_user' ) )
 177          { // current User status doesn't allow user reporting
 178              // Redirect to the account activation page

 179              $Messages->add( T_( 'You must activate your account before you can report another user. <b>See below:</b>' ) );
 180              header_redirect( get_activate_info_url(), 302 );
 181              // will have exited

 182          }
 183  
 184          $report_status = param( 'report_user_status', 'string', '' );
 185          $report_info = param( 'report_info_content', 'text', '' );
 186          $user_ID = param( 'user_ID', 'integer', 0 );
 187  
 188          if( get_report_status_text( $report_status ) == '' )
 189          { // A report status is incorrect
 190              $Messages->add( T_('Please select the correct report reason!'), 'error' );
 191          }
 192  
 193          if( ! param_errors_detected() )
 194          {
 195              // add report and block contact ( it will be blocked if was already on this user contact list )

 196              add_report_from( $user_ID, $report_status, $report_info );
 197              $blocked_message = '';
 198              if( $current_User->check_perm( 'perm_messaging', 'reply' ) )
 199              { // user has messaging permission, set/add this user as blocked contact
 200                  $contact_status = check_contact( $user_ID );
 201                  if( $contact_status == NULL )
 202                  { // contact doesn't exists yet, create as blocked contact
 203                      create_contacts_user( $user_ID, true );
 204                      $blocked_message = ' '.T_('You have also blocked this user from contacting you in the future.');
 205                  }
 206                  elseif( $contact_status )
 207                  { // contact exists and it's not blocked, set as blocked
 208                      set_contact_blocked( $user_ID, 1 );
 209                      $blocked_message = ' '.T_('You have also blocked this user from contacting you in the future.');
 210                  }
 211              }
 212              $Messages->add( T_('The user was repoted.').$blocked_message, 'success' );
 213          }
 214  
 215          header_redirect( url_add_param( $Blog->gen_blogurl(), 'disp=user&user_ID='.$user_ID ) );
 216          break;
 217  
 218      case 'remove_report': // Remove current User report from the given user
 219          // Check that this action request is not a CSRF hacked request:

 220          $Session->assert_received_crumb( 'messaging_contacts' );
 221  
 222          $user_ID = param( 'user_ID', 'integer', 0 );
 223  
 224          remove_report_from( $user_ID );
 225          $unblocked_message = '';
 226          if( set_contact_blocked( $user_ID, 0 ) )
 227          { // the user was unblocked
 228              $unblocked_message = ' '.T_('You have also unblocked this user. He will be able to contact you again in the future.');
 229          }
 230          $Messages->add( T_('The report was removed.').$unblocked_message, 'success' );
 231          header_redirect( url_add_param( $Blog->gen_blogurl(), 'disp=user&user_ID='.$user_ID ) );
 232          break;
 233  }
 234  
 235  modules_call_method( 'switch_contacts_actions', array( 'action' => $action ) );
 236  
 237  
 238  // var bgxy_expand is used by toggle_filter_area() and toggle_clickopen()

 239  // var htsrv_url is used for AJAX callbacks

 240  add_js_headline( "// Paths used by JS functions:
 241          var bgxy_expand = '".get_icon( 'expand', 'xy' )."';
 242          var bgxy_collapse = '".get_icon( 'collapse', 'xy' )."';" );
 243  
 244  // Require results.css to display contact query results in a table

 245  require_css( 'results.css' ); // Results/tables styles

 246  
 247  require_js( 'form_extensions.js', 'blog' ); // Used for combo_box

 248  
 249  // Require functions.js to show/hide a panel with filters

 250  require_js( 'functions.js', 'blog' );
 251  // Include this file to expand/collapse the filters panel when JavaScript is disabled

 252  require_once $inc_path.'_filters.inc.php';
 253  
 254  require $ads_current_skin_path.'index.main.php';
 255  
 256  ?>

title

Description

title

Description

title

Description

title

title

Body