Beehive PHP Cross Reference Discussion Forums

Source: /edit_relations.php - 270 lines - 10854 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 . 'form.inc.php';
  30  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'header.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'user.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'user_rel.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'word_filter.inc.php';
  37  // End Required includes
  38  
  39  // Check we're logged in correctly
  40  if (!session::logged_in()) {
  41      html_guest_error();
  42  }
  43  
  44  // Array to hold error messages
  45  $error_msg_array = array();
  46  
  47  // Start output here
  48  html_draw_top(sprintf('title=%s', gettext("My Controls - User Relationships")), "basetarget=_blank", 'class=window_title');
  49  
  50  echo "<h1>", gettext("User Relationships"), "</h1>\n";
  51  
  52  if (isset($_GET['page']) && is_numeric($_GET['page'])) {
  53      $page = $_GET['page'];
  54  } else if (isset($_POST['page']) && is_numeric($_POST['page'])) {
  55      $page = $_POST['page'];
  56  } else {
  57      $page = 1;
  58  }
  59  
  60  if (isset($_POST['search_keyword']) && strlen(trim($_POST['search_keyword'])) > 0) {
  61  
  62      $page = 1;
  63  
  64      $search_keyword = trim($_POST['search_keyword']);
  65  
  66  } else if (isset($_GET['search_keyword']) && strlen(trim($_GET['search_keyword'])) > 0) {
  67  
  68      $search_keyword = trim($_GET['search_keyword']);
  69  
  70  } else {
  71  
  72      $search_keyword = '';
  73  }
  74  
  75  if (isset($_POST['clear_search'])) {
  76      $search_keyword = '';
  77  }
  78  
  79  if (isset($_POST['delete'])) {
  80  
  81      $valid = true;
  82  
  83      if (isset($_POST['delete_relationships']) && is_array($_POST['delete_relationships'])) {
  84  
  85          foreach ($_POST['delete_relationships'] as $peer_uid => $delete_relationship) {
  86  
  87              if (($delete_relationship == "Y")) {
  88  
  89                  if (!user_rel_update($_SESSION['UID'], $peer_uid, 0)) {
  90  
  91                      $valid = false;
  92                      $error_msg_array[] = gettext("Failed to remove selected relationship");
  93                  }
  94              }
  95          }
  96  
  97          if ($valid) {
  98  
  99              $redirect = "edit_relations.php?webtag=$webtag&relupdated=true";
 100              header_redirect($redirect, gettext("Relationships Updated!"));
 101              exit;
 102          }
 103      }
 104  }
 105  
 106  // Check if we're searching for a user or simply listing the existing relationships.
 107  if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
 108      $user_peers_array = user_search_relationships($search_keyword, $page, $_SESSION['UID']);
 109  } else {
 110      $user_peers_array = user_get_relationships($_SESSION['UID'], $page);
 111  }
 112  
 113  // Output any messages.
 114  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 115  
 116      html_display_error_array($error_msg_array, '700', 'left');
 117  
 118  } else if (isset($_GET['relupdated'])) {
 119  
 120      html_display_success_msg(gettext("Relationships Updated!"), '700', 'left');
 121  
 122  } else if (sizeof($user_peers_array['user_array']) < 1) {
 123  
 124      if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
 125  
 126          html_display_warning_msg(gettext("Search Returned No Results"), '700', 'left');
 127  
 128      } else {
 129  
 130          html_display_warning_msg(gettext("You have no user relationships set up. Add a new user by searching below."), '700', 'left');
 131      }
 132  }
 133  
 134  echo "<br />\n";
 135  echo "<form accept-charset=\"utf-8\" name=\"prefs\" action=\"edit_relations.php\" method=\"post\" target=\"_self\">\n";
 136  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 137  echo "  ", form_input_hidden("page", htmlentities_array($page)), "\n";
 138  echo "  ", form_input_hidden("search_keyword", htmlentities_array($search_keyword)), "\n";
 139  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 140  echo "    <tr>\n";
 141  echo "      <td align=\"left\">\n";
 142  echo "        <table class=\"box\" width=\"100%\">\n";
 143  echo "          <tr>\n";
 144  echo "            <td align=\"left\" class=\"posthead\">\n";
 145  echo "              <table class=\"posthead\" width=\"100%\">\n";
 146  echo "                <tr>\n";
 147  echo "                  <td align=\"left\" class=\"subhead\" width=\"20\">&nbsp;</td>\n";
 148  echo "                  <td align=\"left\" class=\"subhead\" width=\"200\">", gettext("User"), "</td>\n";
 149  echo "                  <td align=\"center\" class=\"subhead\">", gettext("Relationship"), "</td>\n";
 150  echo "                  <td align=\"center\" class=\"subhead\">", gettext("Signature"), "</td>\n";
 151  echo "                  <td align=\"center\" class=\"subhead\">", gettext("Personal Messages"), "</td>\n";
 152  echo "                </tr>\n";
 153  
 154  if (sizeof($user_peers_array['user_array']) > 0) {
 155  
 156      foreach ($user_peers_array['user_array'] as $user_peer) {
 157  
 158          echo "                <tr>\n";
 159          echo "                  <td align=\"center\">", form_checkbox("delete_relationships[{$user_peer['UID']}]", "Y"), "</td>\n";
 160          echo "                  <td align=\"left\">&nbsp;<a href=\"user_rel.php?webtag=$webtag&amp;uid={$user_peer['UID']}&amp;ret=edit_relations.php%3Fwebtag%3D$webtag\" target=\"_self\">", word_filter_add_ob_tags(format_user_name($user_peer['LOGON'], $user_peer['PEER_NICKNAME']), true), "</a></td>\n";
 161  
 162          if ($user_peer['RELATIONSHIP'] & USER_FRIEND) {
 163  
 164              echo "                  <td align=\"center\"><img src=\"", html_style_image("friend.png"), "\" alt=\"", gettext("Friend"), "\" title=\"", gettext("Friend"), "\" /></td>\n";
 165  
 166          } else if ($user_peer['RELATIONSHIP'] & USER_IGNORED) {
 167  
 168              echo "                  <td align=\"center\"><img src=\"", html_style_image("enemy.png"), "\" alt=\"", gettext("Ignored"), "\" title=\"", gettext("Ignored"), "\" /></td>\n";
 169  
 170          } else if ($user_peer['RELATIONSHIP'] & USER_IGNORED_COMPLETELY) {
 171  
 172              echo "                  <td align=\"center\"><img src=\"", html_style_image("enemy.png"), "\" alt=\"", gettext("Ignored Completely"), "\" title=\"", gettext("Ignored Completely"), "\" /><img src=\"", html_style_image("enemy.png"), "\" alt=\"", gettext("Ignored Completely"), "\" title=\"", gettext("Ignored Completely"), "\" /></td>\n";
 173  
 174          } else {
 175  
 176              echo "                  <td align=\"center\">", gettext("Normal"), "</td>\n";
 177          }
 178  
 179          if ($user_peer['RELATIONSHIP'] & USER_IGNORED_SIG) {
 180  
 181              echo "                  <td align=\"center\"><img src=\"", html_style_image("enemy.png"), "\" alt=\"", gettext("Ignored"), "\" title=\"", gettext("Ignored"), "\" /></td>\n";
 182  
 183          } else {
 184  
 185              echo "                  <td align=\"center\"><img src=\"", html_style_image("friend.png"), "\" alt=\"", gettext("Display"), "\" title=\"", gettext("Display"), "\" /></td>\n";
 186          }
 187  
 188          if ($user_peer['RELATIONSHIP'] & USER_BLOCK_PM) {
 189  
 190              echo "                  <td align=\"center\"><img src=\"", html_style_image("enemy.png"), "\" alt=\"", gettext("Block"), "\" title=\"", gettext("Block"), "\" /></td>\n";
 191  
 192          } else {
 193  
 194              echo "                  <td align=\"center\"><img src=\"", html_style_image("friend.png"), "\" alt=\"", gettext("Allow"), "\" title=\"", gettext("Allow"), "\" /></td>\n";
 195          }
 196  
 197          echo "                </tr>\n";
 198      }
 199  }
 200  
 201  echo "                <tr>\n";
 202  echo "                  <td align=\"left\">&nbsp;</td>\n";
 203  echo "                </tr>\n";
 204  echo "              </table>\n";
 205  echo "            </td>\n";
 206  echo "          </tr>\n";
 207  echo "        </table>\n";
 208  echo "      </td>\n";
 209  echo "    </tr>\n";
 210  
 211  if (sizeof($user_peers_array['user_array']) > 0) {
 212  
 213      echo "    <tr>\n";
 214      echo "      <td align=\"left\">&nbsp;</td>\n";
 215      echo "    </tr>\n";
 216      echo "    <tr>\n";
 217      echo "      <td class=\"postbody\" align=\"center\">";
 218  
 219      html_page_links("edit_relations.php?webtag=$webtag&search_keyword=$search_keyword", $page, $user_peers_array['user_count'], 10, "page");
 220  
 221      echo "      </td>\n";
 222      echo "    </tr>\n";
 223      echo "    <tr>\n";
 224      echo "      <td align=\"left\">&nbsp;</td>\n";
 225      echo "    </tr>\n";
 226      echo "    <tr>\n";
 227      echo "      <td colspan=\"2\" align=\"center\">", form_submit("delete", gettext("Delete Selected")), "</td>\n";
 228      echo "    </tr>\n";
 229  }
 230  
 231  echo "  </table>\n";
 232  echo "</form>\n";
 233  echo "<br />\n";
 234  echo "<form accept-charset=\"utf-8\" method=\"post\" action=\"edit_relations.php\" target=\"_self\">\n";
 235  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 236  echo "  ", form_input_hidden("page", htmlentities_array($page)), "\n";
 237  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 238  echo "    <tr>\n";
 239  echo "      <td align=\"left\" class=\"posthead\">\n";
 240  echo "        <table class=\"box\" width=\"100%\">\n";
 241  echo "          <tr>\n";
 242  echo "            <td align=\"left\" class=\"posthead\">\n";
 243  echo "              <table class=\"posthead\" width=\"100%\">\n";
 244  echo "                <tr>\n";
 245  echo "                  <td class=\"subhead\" align=\"left\">", gettext("Search"), "</td>\n";
 246  echo "                </tr>\n";
 247  echo "              </table>\n";
 248  echo "              <table class=\"posthead\" width=\"100%\">\n";
 249  echo "                <tr>\n";
 250  echo "                  <td align=\"center\">\n";
 251  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 252  echo "                      <tr>\n";
 253  echo "                        <td class=\"posthead\" align=\"left\">", gettext("Username"), ": ", form_input_text('search_keyword', htmlentities_array($search_keyword), 30, 64), " ", form_submit('search', gettext("Search")), " ", form_submit('clear_search', gettext("Clear")), "</td>\n";
 254  echo "                      </tr>\n";
 255  echo "                      <tr>\n";
 256  echo "                        <td align=\"left\">&nbsp;</td>\n";
 257  echo "                      </tr>\n";
 258  echo "                    </table>\n";
 259  echo "                  </td>\n";
 260  echo "                </tr>\n";
 261  echo "              </table>\n";
 262  echo "            </td>\n";
 263  echo "          </tr>\n";
 264  echo "        </table>\n";
 265  echo "      </td>\n";
 266  echo "    </tr>\n";
 267  echo "  </table>\n";
 268  echo "</form>\n";
 269  
 270  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body