Beehive PHP Cross Reference Discussion Forums

Source: /user_rel.php - 397 lines - 17633 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*======================================================================
   4  Copyright Project Beehive Forum 2002
   5  
   6  This file is part of Beehive Forum.
   7  
   8  Beehive Forum is free software; you can redistribute it and/or modify
   9  it under the terms of the GNU General Public License as published by
  10  the Free Software Foundation; either version 3 of the License, or
  11  (at your option) any later version.
  12  
  13  Beehive Forum is distributed in the hope that it will be useful,
  14  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  GNU General Public License for more details.
  17  
  18  You should have received a copy of the GNU General Public License
  19  along with Beehive; if not, write to the Free Software
  20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  21  USA
  22  ======================================================================*/
  23  
  24  // Bootstrap
  25  require_once  'boot.php';
  26  
  27  // Required includes
  28  require_once  BH_INCLUDE_PATH . 'constants.inc.php';
  29  require_once  BH_INCLUDE_PATH . 'fixhtml.inc.php';
  30  require_once  BH_INCLUDE_PATH . 'form.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'header.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'messages.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'perm.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  37  require_once  BH_INCLUDE_PATH . 'user.inc.php';
  38  require_once  BH_INCLUDE_PATH . 'user_rel.inc.php';
  39  require_once  BH_INCLUDE_PATH . 'word_filter.inc.php';
  40  // End Required includes
  41  
  42  // Check we're logged in correctly
  43  if (!session::logged_in()) {
  44      html_guest_error();
  45  }
  46  
  47  // Array to hold error messages.
  48  $error_msg_array = array();
  49  
  50  $user_peer = null;
  51  
  52  // Are we returning somewhere?
  53  if (isset($_GET['msg']) && validate_msg($_GET['msg'])) {
  54      $ret = "messages.php?webtag=$webtag&msg={$_GET['msg']}";
  55  } else if (isset($_GET['ret']) && strlen(trim($_GET['ret'])) > 0) {
  56      $ret = rawurldecode(trim($_GET['ret']));
  57  } else if (isset($_POST['ret']) && strlen(trim($_POST['ret'])) > 0) {
  58      $ret = trim($_POST['ret']);
  59  } else {
  60      $ret = "edit_relations.php?webtag=$webtag";
  61  }
  62  
  63  // validate the return to page
  64  if (isset($ret) && strlen(trim($ret)) > 0) {
  65  
  66      $available_pages = array(
  67          'edit_relations.php',
  68          'messages.php',
  69          'user_profile.php'
  70      );
  71  
  72      $available_pages_preg = implode("|^", array_map('preg_quote_callback', $available_pages));
  73  
  74      if (preg_match("/^$available_pages_preg/u", basename($ret)) < 1) {
  75          $ret = "messages.php?webtag=$webtag";
  76      }
  77  }
  78  
  79  // Return to the page we came from.
  80  if (isset($_POST['cancel'])) {
  81      header_redirect($ret);
  82  }
  83  
  84  // Check the provided peer UID.
  85  if (isset($_GET['uid']) && is_numeric($_GET['uid'])) {
  86  
  87      $peer_uid = $_GET['uid'];
  88  
  89      if (!($user_peer = user_get($peer_uid))) {
  90          html_draw_error(gettext("Invalid username!"));
  91      }
  92  
  93  } else if (isset($_POST['uid']) && is_numeric($_POST['uid'])) {
  94  
  95      $peer_uid = $_POST['uid'];
  96  
  97      if (!($user_peer = user_get($peer_uid))) {
  98          html_draw_error(gettext("Invalid username!"));
  99      }
 100  
 101  } else {
 102  
 103      html_draw_error(gettext("No user specified!"));
 104  }
 105  
 106  // Cannot modify relationship settings for the current account
 107  if (($peer_uid == $_SESSION['UID'])) {
 108      html_draw_error(gettext("You cannot change user relationship for your own user account"));
 109  }
 110  
 111  // Fetch the perms of the peer
 112  $peer_perms = perm_get_user_permissions($peer_uid);
 113  
 114  // Form submt code
 115  if (isset($_POST['save'])) {
 116  
 117      $peer_user_status = (double)(isset($_POST['peer_user_status'])) ? $_POST['peer_user_status'] : 0;
 118      $peer_sig_display = (double)(isset($_POST['peer_sig_display'])) ? $_POST['peer_sig_display'] : 0;
 119      $peer_block_pm = (double)(isset($_POST['peer_block_pm'])) ? $_POST['peer_block_pm'] : 0;
 120  
 121      $peer_relationship = (double)$peer_user_status | $peer_sig_display | $peer_block_pm;
 122  
 123      if (isset($_POST['nickname']) && strlen(trim($_POST['nickname'])) > 0) {
 124  
 125          $peer_nickname = strip_tags(trim($_POST['nickname']));
 126  
 127      } else {
 128  
 129          if (!$peer_nickname = user_get_nickname($peer_uid)) $peer_nickname = "";
 130      }
 131  
 132      if (($peer_perms & USER_PERM_FOLDER_MODERATE) && !(session::check_perm(USER_PERM_CAN_IGNORE_ADMIN, 0))) {
 133          $peer_relationship = ($peer_relationship & USER_IGNORED) ? USER_NORMAL : $peer_relationship;
 134      }
 135  
 136      if (user_rel_update($_SESSION['UID'], $peer_uid, $peer_relationship, $peer_nickname)) {
 137  
 138          header_redirect("$ret&relupdated=true");
 139          exit;
 140  
 141      } else {
 142  
 143          $error_msg_array[] = gettext("Relationship updated failed!");
 144          $valid = false;
 145      }
 146  }
 147  
 148  if (isset($_POST['reset_nickname_x']) || isset($_POST['reset_nickname_y'])) {
 149  
 150      $peer_nickname = user_get_nickname($peer_uid);
 151      $peer_relationship = user_get_peer_relationship($_SESSION['UID'], $peer_uid);
 152  
 153      user_rel_update($_SESSION['UID'], $peer_uid, $peer_relationship, $peer_nickname);
 154  }
 155  
 156  $peer_user_display = format_user_name($user_peer['LOGON'], $user_peer['NICKNAME']);
 157  
 158  html_draw_top(sprintf('title=%s', sprintf(gettext("User Relationship - %s"), $peer_user_display)), 'class=window_title');
 159  
 160  $peer_relationship = user_get_relationship($_SESSION['UID'], $peer_uid);
 161  
 162  $peer_nickname = user_get_peer_nickname($_SESSION['UID'], $peer_uid);
 163  
 164  echo "<h1>", gettext("User Relationship"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" /><a href=\"user_profile.php?webtag=$webtag&amp;uid=$peer_uid\" target=\"_blank\" class=\"popup 650x500\">", word_filter_add_ob_tags($peer_user_display, true), "</a></h1>\n";
 165  
 166  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 167  
 168      html_display_error_array($error_msg_array, '600', 'left');
 169  
 170  } else if (($peer_perms & USER_PERM_FOLDER_MODERATE) && !(session::check_perm(USER_PERM_CAN_IGNORE_ADMIN, 0))) {
 171  
 172      html_display_warning_msg(gettext("You cannot ignore this user, as they are a moderator."), '600', 'left');
 173  }
 174  
 175  if (isset($_POST['preview_signature'])) {
 176  
 177      if (($t_sig_content = user_get_sig($peer_uid)) !== false) {
 178  
 179          $preview_message['RECIPIENTS'] = array();
 180  
 181          $preview_from_user = user_get($peer_uid);
 182  
 183          $preview_message['FROM_LOGON'] = $preview_from_user['LOGON'];
 184          $preview_message['FROM_NICKNAME'] = $preview_from_user['NICKNAME'];
 185          $preview_message['FROM_UID'] = $preview_from_user['UID'];
 186  
 187          $preview_message['CONTENT'] = gettext("Signature Preview");
 188  
 189          $preview_message['CONTENT'] .= "<div class=\"sig\">" . fix_html($t_sig_content) . "</div>";
 190  
 191          $preview_message['CREATED'] = time();
 192  
 193          echo "  <br />\n";
 194          echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n";
 195          echo "    <tr>\n";
 196          echo "      <td align=\"left\">\n";
 197          echo "        <table class=\"box\" width=\"100%\">\n";
 198          echo "          <tr>\n";
 199          echo "            <td align=\"left\" class=\"posthead\">\n";
 200          echo "              <table class=\"posthead\" width=\"100%\">\n";
 201          echo "                <tr>\n";
 202          echo "                  <td align=\"left\" class=\"subhead\">", gettext("Preview"), "</td>\n";
 203          echo "                </tr>\n";
 204          echo "              </table>\n";
 205          echo "              <table class=\"posthead\" width=\"100%\">\n";
 206          echo "                <tr>\n";
 207          echo "                  <td align=\"center\">\n";
 208          echo "                    <table class=\"posthead\" width=\"100%\">\n";
 209          echo "                      <tr>\n";
 210          echo "                        <td align=\"left\">\n";
 211          echo "                          <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
 212          echo "                            <tr>\n";
 213          echo "                              <td align=\"left\"><br />";
 214  
 215          message_display(0, $preview_message, 0, 0, 0, false, false, false, true, true);
 216  
 217          echo "                              </td>\n";
 218          echo "                            </tr>\n";
 219          echo "                          </table>\n";
 220          echo "                        </td>\n";
 221          echo "                      </tr>\n";
 222          echo "                    </table>\n";
 223          echo "                  </td>\n";
 224          echo "                </tr>\n";
 225          echo "              </table>\n";
 226          echo "            </td>\n";
 227          echo "          </tr>\n";
 228          echo "        </table>\n";
 229          echo "      </td>\n";
 230          echo "    </tr>\n";
 231          echo "  </table>\n";
 232          echo "</form>\n";
 233      }
 234  }
 235  
 236  echo "<br />\n";
 237  echo "<form accept-charset=\"utf-8\" name=\"relationship\" action=\"user_rel.php\" method=\"post\" target=\"_self\">\n";
 238  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 239  echo "  ", form_input_hidden("uid", htmlentities_array($peer_uid)), "\n";
 240  echo "  ", form_input_hidden("ret", htmlentities_array($ret)), "\n";
 241  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n";
 242  echo "    <tr>\n";
 243  echo "      <td align=\"left\">\n";
 244  echo "        <table class=\"box\" width=\"100%\">\n";
 245  echo "          <tr>\n";
 246  echo "            <td align=\"left\" class=\"posthead\">\n";
 247  echo "              <table class=\"posthead\" width=\"100%\">\n";
 248  echo "                <tr>\n";
 249  echo "                  <td align=\"left\" class=\"subhead\" colspan=\"2\">", gettext("Nickname"), "</td>\n";
 250  echo "                </tr>\n";
 251  echo "                <tr>\n";
 252  echo "                  <td align=\"center\">\n";
 253  echo "                    <table width=\"95%\">\n";
 254  echo "                      <tr>\n";
 255  echo "                        <td align=\"left\" width=\"200\" valign=\"top\">", gettext("Nickname"), "</td>\n";
 256  echo "                        <td align=\"left\" width=\"400\">", form_input_text("nickname", htmlentities_array($peer_nickname), 32), "&nbsp;", form_submit_image('reload.png', "reset_nickname", "Y", sprintf('title="%s"', gettext("Restore User's Nickname"))), "</td>\n";
 257  echo "                      </tr>\n";
 258  echo "                    </table>\n";
 259  echo "                  </td>\n";
 260  echo "                </tr>\n";
 261  echo "                <tr>\n";
 262  echo "                  <td align=\"left\" colspan=\"2\">&nbsp;</td>\n";
 263  echo "                </tr>\n";
 264  echo "              </table>\n";
 265  echo "            </td>\n";
 266  echo "          </tr>\n";
 267  echo "        </table>\n";
 268  echo "      </td>\n";
 269  echo "    </tr>\n";
 270  echo "  </table>\n";
 271  echo "  <br />\n";
 272  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n";
 273  echo "    <tr>\n";
 274  echo "      <td align=\"left\">\n";
 275  echo "        <table class=\"box\" width=\"100%\">\n";
 276  echo "          <tr>\n";
 277  echo "            <td align=\"left\" class=\"posthead\">\n";
 278  echo "              <table class=\"posthead\" width=\"100%\">\n";
 279  echo "                <tr>\n";
 280  echo "                  <td align=\"left\" class=\"subhead\" colspan=\"2\">", gettext("Relationship"), "</td>\n";
 281  echo "                </tr>\n";
 282  echo "                <tr>\n";
 283  echo "                  <td align=\"center\">\n";
 284  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 285  echo "                      <tr>\n";
 286  echo "                        <td align=\"left\" width=\"150\">", form_radio('peer_user_status', USER_FRIEND, gettext("Friend"), $peer_relationship & USER_FRIEND ? true : false), "</td>\n";
 287  echo "                        <td align=\"left\" width=\"400\">: ", gettext("User's posts marked with a &quot;Friend&quot; icon."), "</td>\n";
 288  echo "                      </tr>\n";
 289  echo "                      <tr>\n";
 290  echo "                        <td align=\"left\" width=\"150\">", form_radio('peer_user_status', USER_NORMAL, gettext("Normal"), !(($peer_relationship & USER_IGNORED) || ($peer_relationship & USER_FRIEND) || ($peer_relationship & USER_IGNORED_COMPLETELY)) ? true : false), "</td>\n";
 291  echo "                        <td align=\"left\" width=\"400\">: ", gettext("User's posts appear as normal."), "</td>\n";
 292  echo "                      </tr>\n";
 293  
 294  if ((($peer_perms & USER_PERM_FOLDER_MODERATE) && (session::check_perm(USER_PERM_CAN_IGNORE_ADMIN, 0))) || !($peer_perms & USER_PERM_FOLDER_MODERATE)) {
 295  
 296      echo "                      <tr>\n";
 297      echo "                        <td align=\"left\" width=\"150\">", form_radio('peer_user_status', USER_IGNORED, gettext("Ignored"), $peer_relationship & USER_IGNORED ? true : false), "</td>\n";
 298      echo "                        <td align=\"left\" width=\"400\">: ", gettext("User's posts are hidden."), "</td>\n";
 299      echo "                      </tr>\n";
 300      echo "                      <tr>\n";
 301      echo "                        <td align=\"left\" width=\"150\">", form_radio('peer_user_status', USER_IGNORED_COMPLETELY, gettext("Ignored Completely"), $peer_relationship & USER_IGNORED_COMPLETELY ? true : false), "</td>\n";
 302      echo "                        <td align=\"left\" width=\"400\">: ", gettext("Threads and posts to or from user will appear deleted."), "</td>\n";
 303      echo "                      </tr>\n";
 304  }
 305  
 306  echo "                    </table>\n";
 307  echo "                  </td>\n";
 308  echo "                </tr>\n";
 309  echo "                <tr>\n";
 310  echo "                  <td align=\"left\" colspan=\"2\">&nbsp;</td>\n";
 311  echo "                </tr>\n";
 312  echo "              </table>\n";
 313  echo "            </td>\n";
 314  echo "          </tr>\n";
 315  echo "        </table>\n";
 316  echo "      </td>\n";
 317  echo "    </tr>\n";
 318  echo "  </table>\n";
 319  echo "  <br />\n";
 320  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n";
 321  echo "    <tr>\n";
 322  echo "      <td align=\"left\">\n";
 323  echo "        <table class=\"box\" width=\"100%\">\n";
 324  echo "          <tr>\n";
 325  echo "            <td align=\"left\" class=\"posthead\">\n";
 326  echo "              <table class=\"posthead\" width=\"100%\">\n";
 327  echo "                <tr>\n";
 328  echo "                  <td align=\"left\" class=\"subhead\" colspan=\"2\">", gettext("Signature"), "</td>\n";
 329  echo "                </tr>\n";
 330  echo "                <tr>\n";
 331  echo "                  <td align=\"center\">\n";
 332  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 333  echo "                      <tr>\n";
 334  echo "                        <td align=\"left\" width=\"150\">", form_radio('peer_sig_display', USER_NORMAL, gettext("Display"), $peer_relationship & USER_IGNORED_SIG ? false : true), "</td>\n";
 335  echo "                        <td align=\"left\" width=\"400\">: ", gettext("User's signature is displayed on their posts."), "</td>\n";
 336  echo "                      </tr>\n";
 337  echo "                      <tr>\n";
 338  echo "                        <td align=\"left\" width=\"150\">", form_radio('peer_sig_display', USER_IGNORED_SIG, gettext("Ignore"), $peer_relationship & USER_IGNORED_SIG ? true : false), "</td>\n";
 339  echo "                        <td align=\"left\" width=\"400\">: ", gettext("User's signature is hidden on their posts."), "</td>\n";
 340  echo "                      </tr>\n";
 341  echo "                    </table>\n";
 342  echo "                  </td>\n";
 343  echo "                </tr>\n";
 344  echo "                <tr>\n";
 345  echo "                  <td align=\"left\" colspan=\"2\">&nbsp;</td>\n";
 346  echo "                </tr>\n";
 347  echo "              </table>\n";
 348  echo "            </td>\n";
 349  echo "          </tr>\n";
 350  echo "        </table>\n";
 351  echo "      </td>\n";
 352  echo "    </tr>\n";
 353  echo "  </table>\n";
 354  echo "  <br />\n";
 355  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n";
 356  echo "    <tr>\n";
 357  echo "      <td align=\"left\">\n";
 358  echo "        <table class=\"box\" width=\"100%\">\n";
 359  echo "          <tr>\n";
 360  echo "            <td align=\"left\" class=\"posthead\">\n";
 361  echo "              <table class=\"posthead\" width=\"100%\">\n";
 362  echo "                <tr>\n";
 363  echo "                  <td align=\"left\" class=\"subhead\" colspan=\"2\">", gettext("Personal Messages"), "</td>\n";
 364  echo "                </tr>\n";
 365  echo "                <tr>\n";
 366  echo "                  <td align=\"center\">\n";
 367  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 368  echo "                      <tr>\n";
 369  echo "                        <td align=\"left\" width=\"150\">", form_radio('peer_block_pm', USER_NORMAL, gettext("Allow"), $peer_relationship & USER_BLOCK_PM ? false : true), "</td>\n";
 370  echo "                        <td align=\"left\" width=\"400\">: ", gettext("Allow user to send personal messages to me"), "</td>\n";
 371  echo "                      </tr>\n";
 372  echo "                      <tr>\n";
 373  echo "                        <td align=\"left\" width=\"150\">", form_radio('peer_block_pm', USER_BLOCK_PM, gettext("Block"), $peer_relationship & USER_BLOCK_PM ? true : false), "</td>\n";
 374  echo "                        <td align=\"left\" width=\"400\">: ", gettext("Block user from sending personal messages to me"), "</td>\n";
 375  echo "                      </tr>\n";
 376  echo "                    </table>\n";
 377  echo "                  </td>\n";
 378  echo "                </tr>\n";
 379  echo "                <tr>\n";
 380  echo "                  <td align=\"left\" colspan=\"2\">&nbsp;</td>\n";
 381  echo "                </tr>\n";
 382  echo "              </table>\n";
 383  echo "            </td>\n";
 384  echo "          </tr>\n";
 385  echo "        </table>\n";
 386  echo "      </td>\n";
 387  echo "    </tr>\n";
 388  echo "    <tr>\n";
 389  echo "      <td align=\"left\">&nbsp;</td>\n";
 390  echo "    </tr>\n";
 391  echo "    <tr>\n";
 392  echo "      <td align=\"center\"><p>", form_submit("save", gettext("Save")), "&nbsp;", form_submit("preview_signature", gettext("Preview Signature")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</p></td>\n";
 393  echo "    </tr>\n";
 394  echo "  </table>\n";
 395  echo "</form>\n";
 396  
 397  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body