Beehive PHP Cross Reference Discussion Forums

Source: /admin_prof_sect.php - 405 lines - 16829 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 . 'admin.inc.php';
  29  require_once  BH_INCLUDE_PATH . 'constants.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 . 'profile.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'session.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  // Check we have Admin / Moderator access
  45  if (!(session::check_perm(USER_PERM_ADMIN_TOOLS, 0))) {
  46      html_draw_error(gettext("You do not have permission to use this section."));
  47  }
  48  
  49  // Perform additional admin login.
  50  admin_check_credentials();
  51  
  52  // Array for holding error messages
  53  $error_msg_array = array();
  54  
  55  $t_name_new = null;
  56  $t_new_name = null;
  57  
  58  if (isset($_GET['page']) && is_numeric($_GET['page'])) {
  59      $page = ($_GET['page'] > 0) ? $_GET['page'] : 1;
  60  } else if (isset($_POST['page']) && is_numeric($_POST['page'])) {
  61      $page = ($_POST['page'] > 0) ? $_POST['page'] : 1;
  62  } else {
  63      $page = 1;
  64  }
  65  
  66  // Cancel button clicked.
  67  if (isset($_POST['cancel'])) {
  68  
  69      header_redirect("admin_prof_sect.php?webtag=$webtag");
  70      exit;
  71  }
  72  
  73  if (isset($_POST['delete_sections'])) {
  74  
  75      $valid = true;
  76  
  77      if (isset($_POST['delete_section']) && is_array($_POST['delete_section'])) {
  78  
  79          foreach ($_POST['delete_section'] as $psid => $delete_section) {
  80  
  81              if ($valid && $delete_section == "Y" && $profile_name = profile_section_get_name($psid)) {
  82  
  83                  if (profile_section_delete($psid)) {
  84  
  85                      admin_add_log_entry(DELETE_PROFILE_SECT, array($profile_name));
  86  
  87                  } else {
  88  
  89                      $error_msg_array[] = gettext("Failed to remove profile sections");
  90                      $valid = false;
  91                  }
  92              }
  93          }
  94  
  95          if ($valid) {
  96  
  97              header_redirect("admin_prof_sect.php?webtag=$webtag&deleted=true");
  98              exit;
  99          }
 100      }
 101  
 102  } else if (isset($_POST['addsectionsubmit'])) {
 103  
 104      $valid = true;
 105  
 106      if (isset($_POST['t_name_new']) && strlen(trim($_POST['t_name_new'])) > 0) {
 107          $t_name_new = trim($_POST['t_name_new']);
 108      } else {
 109          $error_msg_array[] = gettext("Must specify a profile section name");
 110          $valid = false;
 111      }
 112  
 113      if ($valid) {
 114  
 115          if (($new_psid = profile_section_create($t_name_new)) !== false) {
 116  
 117              header_redirect("admin_prof_sect.php?webtag=$webtag&added=true");
 118              exit;
 119          }
 120      }
 121  
 122  } else if (isset($_POST['editfeedsubmit'])) {
 123  
 124      $valid = true;
 125  
 126      if (isset($_POST['psid']) && is_numeric($_POST['psid'])) {
 127          $psid = $_POST['psid'];
 128      } else {
 129          $error_msg_array[] = gettext("Must specify a profile section ID");
 130          $valid = false;
 131      }
 132  
 133      if (isset($_POST['t_name_new']) && strlen(trim($_POST['t_name_new'])) > 0) {
 134          $t_new_name = trim($_POST['t_name_new']);
 135      } else {
 136          $error_msg_array[] = gettext("Must specify a profile section name");
 137          $valid = false;
 138      }
 139  
 140      if ($valid) {
 141  
 142          if (profile_section_update($psid, $t_new_name)) {
 143  
 144              $t_section_name = profile_section_get_name($psid);
 145  
 146              if ($t_new_name != $t_section_name) {
 147                  admin_add_log_entry(CHANGE_PROFILE_SECT, array($t_section_name, $t_new_name));
 148              }
 149  
 150              header_redirect("admin_prof_sect.php?webtag=$webtag&edited=true");
 151              exit;
 152          }
 153      }
 154  
 155  } else if (isset($_POST['addsection'])) {
 156  
 157      $redirect = "admin_prof_sect.php?webtag=$webtag&page=$page&addsection=true";
 158      header_redirect($redirect);
 159      exit;
 160  
 161  } else if (isset($_POST['viewitems']) && is_array($_POST['viewitems'])) {
 162  
 163      list($psid) = array_keys($_POST['viewitems']);
 164      $redirect = "admin_prof_items.php?webtag=$webtag&psid=$psid&sect_page=$page";
 165      header_redirect($redirect);
 166      exit;
 167  }
 168  
 169  if (isset($_POST['move_up']) && is_array($_POST['move_up'])) {
 170  
 171      list($psid) = array_keys($_POST['move_up']);
 172      profile_section_move_up($psid);
 173  }
 174  
 175  if (isset($_POST['move_down']) && is_array($_POST['move_down'])) {
 176  
 177      list($psid) = array_keys($_POST['move_down']);
 178      profile_section_move_down($psid);
 179  }
 180  
 181  if (isset($_GET['addsection']) || isset($_POST['addsection'])) {
 182  
 183      html_draw_top(sprintf('title=%s', gettext("Admin - Manage Profile Sections - Add new profile section")), 'class=window_title', 'main_css=admin.css');
 184  
 185      echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Profile Sections"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Add new profile section"), "</h1>\n";
 186  
 187      if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 188          html_display_error_array($error_msg_array, '700', 'center');
 189      }
 190  
 191      echo "<br />\n";
 192      echo "<div align=\"center\">\n";
 193      echo "  <form accept-charset=\"utf-8\" name=\"thread_options\" action=\"admin_prof_sect.php\" method=\"post\" target=\"_self\">\n";
 194      echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 195      echo "  ", form_input_hidden('addsection', 'true'), "\n";
 196      echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 197      echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 198      echo "    <tr>\n";
 199      echo "      <td align=\"left\">\n";
 200      echo "        <table class=\"box\" width=\"100%\">\n";
 201      echo "          <tr>\n";
 202      echo "            <td align=\"left\" class=\"posthead\">\n";
 203      echo "              <table class=\"posthead\" width=\"100%\">\n";
 204      echo "                <tr>\n";
 205      echo "                  <td align=\"left\" class=\"subhead\">", gettext("Section Name"), "</td>\n";
 206      echo "                </tr>\n";
 207      echo "                <tr>\n";
 208      echo "                  <td align=\"center\">\n";
 209      echo "                    <table class=\"posthead\" width=\"95%\">\n";
 210      echo "                      <tr>\n";
 211      echo "                        <td align=\"left\" width=\"200\" class=\"posthead\">", gettext("Section Name"), ":</td>\n";
 212      echo "                        <td align=\"left\">", form_input_text("t_name_new", (isset($_POST['t_name_new']) ? htmlentities_array($_POST['t_name_new']) : ""), 52, 64), "</td>\n";
 213      echo "                      </tr>\n";
 214      echo "                      <tr>\n";
 215      echo "                        <td align=\"left\">&nbsp;</td>\n";
 216      echo "                        <td align=\"left\">&nbsp;</td>\n";
 217      echo "                      </tr>\n";
 218      echo "                    </table>\n";
 219      echo "                  </td>\n";
 220      echo "                </tr>\n";
 221      echo "              </table>\n";
 222      echo "            </td>\n";
 223      echo "          </tr>\n";
 224      echo "        </table>\n";
 225      echo "      </td>\n";
 226      echo "    </tr>\n";
 227      echo "    <tr>\n";
 228      echo "      <td align=\"left\">&nbsp;</td>\n";
 229      echo "    </tr>\n";
 230      echo "    <tr>\n";
 231      echo "      <td align=\"center\">", form_submit("addsectionsubmit", gettext("Add")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</td>\n";
 232      echo "    </tr>\n";
 233      echo "  </table>\n";
 234      echo "  </form>\n";
 235      echo "</div>\n";
 236  
 237      html_draw_bottom();
 238  
 239  } else if (isset($_POST['psid']) || isset($_GET['psid'])) {
 240  
 241      if (isset($_POST['psid']) && is_numeric($_POST['psid'])) {
 242  
 243          $psid = $_POST['psid'];
 244  
 245      } else if (isset($_GET['psid']) && is_numeric($_GET['psid'])) {
 246  
 247          $psid = $_GET['psid'];
 248  
 249      } else {
 250  
 251          html_draw_error(gettext("Invalid profile section ID or section not found"), 'admin_prof_sect.php', 'get', array('back' => gettext("Back")));
 252      }
 253  
 254      if (!$profile_section = profile_get_section($psid)) {
 255          html_draw_error(gettext("Invalid profile section ID or section not found"), 'admin_prof_sect.php', 'get', array('back' => gettext("Back")));
 256      }
 257  
 258      html_draw_top(sprintf('title=%s', sprintf(gettext("Admin - Manage Profile Sections - %s"), $profile_section['NAME'])), 'class=window_title', 'main_css=admin.css');
 259  
 260      echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Profile Sections"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", word_filter_add_ob_tags($profile_section['NAME'], true), "</h1>\n";
 261  
 262      if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 263          html_display_error_array($error_msg_array, '700', 'center');
 264      }
 265  
 266      echo "<br />\n";
 267      echo "<div align=\"center\">\n";
 268      echo "  <form accept-charset=\"utf-8\" name=\"thread_options\" action=\"admin_prof_sect.php\" method=\"post\" target=\"_self\">\n";
 269      echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 270      echo "  ", form_input_hidden('psid', htmlentities_array($psid)), "\n";
 271      echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 272      echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\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\">", gettext("Section Name"), "</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=\"200\" class=\"posthead\">", gettext("Section Name"), ":</td>\n";
 287      echo "                        <td align=\"left\">", form_input_text("t_name_new", (isset($_POST['t_name_new']) ? htmlentities_array($_POST['t_name_new']) : htmlentities_array($profile_section['NAME'])), 52, 64), "</td>\n";
 288      echo "                      </tr>\n";
 289      echo "                      <tr>\n";
 290      echo "                        <td align=\"left\">&nbsp;</td>\n";
 291      echo "                        <td align=\"left\">&nbsp;</td>\n";
 292      echo "                      </tr>\n";
 293      echo "                    </table>\n";
 294      echo "                  </td>\n";
 295      echo "                </tr>\n";
 296      echo "              </table>\n";
 297      echo "            </td>\n";
 298      echo "          </tr>\n";
 299      echo "        </table>\n";
 300      echo "      </td>\n";
 301      echo "    </tr>\n";
 302      echo "    <tr>\n";
 303      echo "      <td align=\"left\">&nbsp;</td>\n";
 304      echo "    </tr>\n";
 305      echo "    <tr>\n";
 306      echo "      <td align=\"center\">", form_submit("editfeedsubmit", gettext("Save")), "&nbsp;", form_submit("viewitems[$psid]", gettext("View items")), "&nbsp;", form_submit("cancel", gettext("Back")), "</td>\n";
 307      echo "    </tr>\n";
 308      echo "  </table>\n";
 309      echo "  </form>\n";
 310      echo "</div>\n";
 311  
 312      html_draw_bottom();
 313  
 314  } else {
 315  
 316      html_draw_top(sprintf('title=%s', gettext("Admin - Manage Profile Sections")), 'class=window_title', 'main_css=admin.css');
 317  
 318      $profile_sections = profile_sections_get_by_page($page);
 319  
 320      echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Profile Sections"), "</h1>\n";
 321  
 322      if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 323  
 324          html_display_error_array($error_msg_array, '86%', 'center');
 325  
 326      } else if (isset($_GET['added'])) {
 327  
 328          html_display_success_msg(gettext("Successfully added profile section"), '86%', 'center');
 329  
 330      } else if (isset($_GET['edited'])) {
 331  
 332          html_display_success_msg(gettext("Successfully edited profile section"), '86%', 'center');
 333  
 334      } else if (isset($_GET['deleted'])) {
 335  
 336          html_display_success_msg(gettext("Successfully removed selected profile sections"), '86%', 'center');
 337  
 338      } else if (sizeof($profile_sections['profile_sections_array']) < 1) {
 339  
 340          html_display_warning_msg(gettext("No existing profile sections found. To add a profile section click the 'Add New' button below."), '86%', 'center');
 341      }
 342  
 343      echo "<br />\n";
 344      echo "<div align=\"center\">\n";
 345      echo "<form accept-charset=\"utf-8\" name=\"f_sections\" action=\"admin_prof_sect.php\" method=\"post\">\n";
 346      echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 347      echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 348      echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"86%\">\n";
 349      echo "    <tr>\n";
 350      echo "      <td align=\"left\">\n";
 351      echo "        <table class=\"box\" width=\"100%\">\n";
 352      echo "          <tr>\n";
 353      echo "            <td align=\"left\" class=\"posthead\">\n";
 354      echo "              <table class=\"posthead\" width=\"100%\">\n";
 355      echo "                <tr>\n";
 356      echo "                  <td class=\"subhead\" align=\"left\" width=\"25\">&nbsp;</td>\n";
 357      echo "                  <td class=\"subhead\" align=\"left\">", gettext("Section Name"), "</td>\n";
 358      echo "                  <td class=\"subhead\" align=\"left\" width=\"50\">&nbsp;</td>\n";
 359      echo "                  <td class=\"subhead\" align=\"center\">", gettext("Items"), "</td>\n";
 360      echo "                </tr>\n";
 361  
 362      if (sizeof($profile_sections['profile_sections_array']) > 0) {
 363  
 364          foreach ($profile_sections['profile_sections_array'] as $profile_section) {
 365  
 366              echo "                <tr>\n";
 367              echo "                  <td valign=\"top\" align=\"center\" width=\"25\">", form_checkbox("delete_section[{$profile_section['PSID']}]", "Y"), "</td>\n";
 368              echo "                  <td valign=\"top\" align=\"left\"><a href=\"admin_prof_sect.php?webtag=$webtag&amp;page=$page&amp;psid={$profile_section['PSID']}\">", word_filter_add_ob_tags($profile_section['NAME'], true), "</a></td>\n";
 369              echo "                  <td align=\"center\" width=\"50\" style=\"white-space: nowrap\">", form_submit_image('move_up.png', "move_up[{$profile_section['PSID']}]", "Move Up", "title=\"Move Up\"", "move_up_ctrl"), form_submit_image('move_down.png', "move_down[{$profile_section['PSID']}]", "Move Down", "title=\"Move Down\"", "move_down_ctrl"), "</td>\n";
 370              echo "                  <td valign=\"top\" align=\"center\" width=\"100\"><a href=\"admin_prof_items.php?webtag=$webtag&amp;psid={$profile_section['PSID']}&amp;sect_page=$page&amp;viewitems=yes\">", htmlentities_array($profile_section['ITEM_COUNT']), "</a></td>\n";
 371              echo "                </tr>\n";
 372          }
 373      }
 374  
 375      echo "                <tr>\n";
 376      echo "                  <td align=\"left\" colspan=\"4\">&nbsp;</td>\n";
 377      echo "                </tr>\n";
 378      echo "              </table>\n";
 379      echo "            </td>\n";
 380      echo "          </tr>\n";
 381      echo "        </table>\n";
 382      echo "      </td>\n";
 383      echo "    </tr>\n";
 384      echo "    <tr>\n";
 385      echo "      <td align=\"left\">&nbsp;</td>\n";
 386      echo "    </tr>\n";
 387      echo "    <tr>\n";
 388      echo "      <td class=\"postbody\" align=\"center\">";
 389  
 390      html_page_links("admin_prof_sect.php?webtag=$webtag", $page, $profile_sections['profile_sections_count'], 10);
 391  
 392      echo "      </td>\n";
 393      echo "    </tr>\n";
 394      echo "    <tr>\n";
 395      echo "      <td align=\"left\">&nbsp;</td>\n";
 396      echo "    </tr>\n";
 397      echo "    <tr>\n";
 398      echo "      <td align=\"center\">", form_submit("addsection", gettext("Add New")), "&nbsp;", form_submit("delete_sections", gettext("Delete Selected")), "</td>\n";
 399      echo "    </tr>\n";
 400      echo "  </table>\n";
 401      echo "</form>\n";
 402      echo "</div>\n";
 403  
 404      html_draw_bottom();
 405  }

title

Description

title

Description

title

Description

title

title

Body