plugins/admin/PageGroups.php
author Dan
Sun, 05 Aug 2007 15:58:50 -0400
changeset 81 d7fc25acd3f3
parent 80 cb7dde69c301
child 117 7cfdbb2fd17a
permissions -rw-r--r--
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     1
<?php
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     2
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     3
/*
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     5
 * Version 1.0.1 (Loch Ness)
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     6
 * Copyright (C) 2006-2007 Dan Fuhry
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     7
 *
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    10
 *
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    13
 */
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    14
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    15
function page_Admin_PageGroups()
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    16
{
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    17
  global $db, $session, $paths, $template, $plugins; // Common objects
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    18
  if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    19
  {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    20
    echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    21
    return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    22
  }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    23
  
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    24
  if ( isset($_POST['action']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    25
  {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    26
    if ( isset($_POST['action']['create']) || isset($_POST['action']['create_stage2']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    27
    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    28
      switch ( isset($_POST['action']['create_stage2']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    29
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    30
        case true:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    31
          if ( empty($_POST['pg_name']) || empty($_POST['group_type']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    32
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    33
            echo '<div class="error-box">Please enter a name for the page group.</div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    34
            return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    35
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    36
          if ( $_POST['group_type'] == PAGE_GRP_TAGGED && empty($_POST['member_tag']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    37
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    38
            echo '<div class="error-box">Please enter a page tag.</div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    39
            return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    40
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    41
          if ( $_POST['group_type'] == PAGE_GRP_CATLINK && empty($_POST['member_cat']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    42
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    43
            echo '<div class="error-box">Please create a category page before linking a page group to a category.</div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    44
            return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    45
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    46
          if ( $_POST['group_type'] == PAGE_GRP_NORMAL && empty($_POST['member_page_0']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    47
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    48
            echo '<div class="error-box">Please specify at least one page to place in this group.</div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    49
            return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    50
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    51
          if ( $_POST['group_type'] != PAGE_GRP_TAGGED && $_POST['group_type'] != PAGE_GRP_CATLINK && $_POST['group_type'] != PAGE_GRP_NORMAL )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    52
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    53
            echo '<div class="error-box">Umm, you sent an invalid group type. I\'d put a real error message here but this will only be shown if you try to hack the system.</div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    54
            return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    55
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    56
          // All checks passed, create the group
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    57
          switch($_POST['group_type'])
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    58
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    59
            case PAGE_GRP_TAGGED:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    60
              $name = $db->escape($_POST['pg_name']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    61
              $tag  = $db->escape($_POST['member_tag']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    62
              $sql = 'INSERT INTO '.table_prefix.'page_groups(pg_type,pg_name,pg_target) VALUES(' . PAGE_GRP_TAGGED . ', \'' . $name . '\', \'' . $tag . '\');';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    63
              $q = $db->sql_query($sql);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    64
              if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    65
                $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    66
              break;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    67
            case PAGE_GRP_CATLINK:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    68
              $name = $db->escape($_POST['pg_name']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    69
              $cat  = $db->escape($_POST['member_cat']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    70
              $sql = 'INSERT INTO '.table_prefix.'page_groups(pg_type,pg_name,pg_target) VALUES(' . PAGE_GRP_CATLINK . ', \'' . $name . '\', \'' . $cat . '\');';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    71
              $q = $db->sql_query($sql);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    72
              if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    73
                $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    74
              break;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    75
            case PAGE_GRP_NORMAL:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    76
              $name = $db->escape($_POST['pg_name']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    77
              $sql = 'INSERT INTO '.table_prefix.'page_groups(pg_type,pg_name) VALUES(' . PAGE_GRP_NORMAL . ', \'' . $name . '\');';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    78
              $q = $db->sql_query($sql);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    79
              if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    80
                $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    81
              
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    82
              $ins_id = $db->insert_id();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    83
              
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    84
              // Page list
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    85
              $keys = array_keys($_POST);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    86
              $arr_pages = array();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    87
              foreach ( $keys as $val )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    88
              {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    89
                if ( preg_match('/^member_page_([0-9]+?)$/', $val) && !empty($_POST[$val]) && isPage($_POST[$val]) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    90
                {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    91
                  $arr_pages[] = $_POST[$val];
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    92
                }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    93
              }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    94
              $arr_sql = array();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    95
              foreach ( $arr_pages as $page )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    96
              {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    97
                list($id, $ns) = RenderMan::strToPageID($page);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    98
                $id = sanitize_page_id($id);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
    99
                $arr_sql[] = '(' . $ins_id . ',\'' . $db->escape($id) . '\', \'' . $ns . '\')';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   100
              }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   101
              $sql = 'INSERT INTO '.table_prefix.'page_group_members(pg_id,page_id,namespace) VALUES' . implode(',', $arr_sql) . ';';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   102
              $q = $db->sql_query($sql);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   103
              if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   104
                $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   105
              break;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   106
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   107
          echo '<div class="info-box">The page group "' . htmlspecialchars($_POST['pg_name']) . '" has been created.</div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   108
          break;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   109
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   110
      // A little Javascript magic
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   111
      ?>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   112
      <script language="javascript" type="text/javascript">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   113
        function pg_create_typeset(selector)
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   114
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   115
          var pg_normal  = <?php echo PAGE_GRP_NORMAL; ?>;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   116
          var pg_tagged  = <?php echo PAGE_GRP_TAGGED; ?>;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   117
          var pg_catlink = <?php echo PAGE_GRP_CATLINK; ?>;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   118
          var selection = false;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   119
          // Get selection
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   120
          for ( var i = 0; i < selector.childNodes.length; i++ )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   121
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   122
            var child = selector.childNodes[i];
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   123
            if ( !child || child.tagName != 'OPTION' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   124
            {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   125
              continue;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   126
            }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   127
            if ( child.selected )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   128
            {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   129
              selection = child.value;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   130
            }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   131
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   132
          if ( !selection )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   133
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   134
            alert('Cannot get field value');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   135
            return true;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   136
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   137
          selection = parseInt(selection);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   138
          if ( selection != pg_normal && selection != pg_tagged && selection != pg_catlink )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   139
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   140
            alert('Invalid field value');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   141
            return true;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   142
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   143
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   144
          // We have the selection and it's validated; show the appropriate field group
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   145
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   146
          if ( selection == pg_normal )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   147
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   148
            document.getElementById('pg_create_title_catlink').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   149
            document.getElementById('pg_create_catlink_1').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   150
            document.getElementById('pg_create_catlink_2').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   151
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   152
            document.getElementById('pg_create_title_tagged').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   153
            document.getElementById('pg_create_tagged_1').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   154
            document.getElementById('pg_create_tagged_2').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   155
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   156
            document.getElementById('pg_create_title_normal').style.display = 'inline';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   157
            document.getElementById('pg_create_normal_1').style.display = 'block';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   158
            document.getElementById('pg_create_normal_2').style.display = 'block';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   159
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   160
          else if ( selection == pg_catlink )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   161
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   162
            document.getElementById('pg_create_title_catlink').style.display = 'inline';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   163
            document.getElementById('pg_create_catlink_1').style.display = 'block';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   164
            document.getElementById('pg_create_catlink_2').style.display = 'block';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   165
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   166
            document.getElementById('pg_create_title_tagged').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   167
            document.getElementById('pg_create_tagged_1').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   168
            document.getElementById('pg_create_tagged_2').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   169
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   170
            document.getElementById('pg_create_title_normal').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   171
            document.getElementById('pg_create_normal_1').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   172
            document.getElementById('pg_create_normal_2').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   173
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   174
          else if ( selection == pg_tagged )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   175
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   176
            document.getElementById('pg_create_title_catlink').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   177
            document.getElementById('pg_create_catlink_1').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   178
            document.getElementById('pg_create_catlink_2').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   179
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   180
            document.getElementById('pg_create_title_tagged').style.display = 'inline';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   181
            document.getElementById('pg_create_tagged_1').style.display = 'block';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   182
            document.getElementById('pg_create_tagged_2').style.display = 'block';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   183
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   184
            document.getElementById('pg_create_title_normal').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   185
            document.getElementById('pg_create_normal_1').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   186
            document.getElementById('pg_create_normal_2').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   187
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   188
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   189
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   190
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   191
        // Set to pg_normal on page load
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   192
        var pg_createform_init = function()
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   193
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   194
          document.getElementById('pg_create_title_catlink').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   195
          document.getElementById('pg_create_catlink_1').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   196
          document.getElementById('pg_create_catlink_2').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   197
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   198
          document.getElementById('pg_create_title_tagged').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   199
          document.getElementById('pg_create_tagged_1').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   200
          document.getElementById('pg_create_tagged_2').style.display = 'none';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   201
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   202
          document.getElementById('pg_create_title_normal').style.display = 'inline';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   203
          document.getElementById('pg_create_normal_1').style.display = 'block';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   204
          document.getElementById('pg_create_normal_2').style.display = 'block';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   205
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   206
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   207
        addOnloadHook(pg_createform_init);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   208
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   209
        function pg_create_more_fields()
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   210
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   211
          var targettd = document.getElementById('pg_create_normal_2');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   212
          var id = 0;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   213
          for ( var i = 0; i < targettd.childNodes.length; i++ )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   214
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   215
            var child = targettd.childNodes[i];
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   216
            if ( child.tagName == 'INPUT' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   217
            {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   218
              if ( child.type == 'button' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   219
              {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   220
                var newInp = document.createElement('input');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   221
                // <input type="text" name="member_page_1" id="pg_create_member_1" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   222
                newInp.type    = 'text';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   223
                newInp.name    = 'member_page_' + id;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   224
                newInp.id      = 'pg_create_member_' + id;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   225
                newInp.onkeyup = function(e) { return ajaxPageNameComplete(this); };
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   226
                newInp.size    = '30';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   227
                newInp.style.marginTop = '3px';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   228
                targettd.insertBefore(newInp, child);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   229
                targettd.insertBefore(document.createElement('br'), child);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   230
                break;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   231
              }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   232
              else // if ( child.type == 'text' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   233
              {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   234
                id++;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   235
              }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   236
            }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   237
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   238
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   239
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   240
      </script>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   241
      <?php
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   242
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   243
      // Build category list
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   244
      $q = $db->sql_query('SELECT name,urlname FROM '.table_prefix.'pages WHERE namespace=\'Category\';');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   245
      if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   246
        $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   247
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   248
      if ( $db->numrows() < 1 )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   249
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   250
        $catlist = 'There aren\'t any categories on this site.';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   251
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   252
      else
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   253
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   254
        $catlist = '<select name="member_cat">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   255
        while ( $row = $db->fetchrow() )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   256
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   257
          $catlist .= '<option value="' . htmlspecialchars($row['urlname']) . '">' . htmlspecialchars($row['name']) . '</option>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   258
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   259
        $catlist .= '</select>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   260
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   261
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   262
      echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized || !__pg_edit_submitAuthorized) return false;" enctype="multipart/form-data">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   263
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   264
      echo '<div class="tblholder">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   265
            <table border="0" cellspacing="1" cellpadding="4">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   266
              <tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   267
              <th colspan="2">Create page group</th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   268
              </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   269
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   270
      // Name
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   271
      echo '<tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   272
              <td class="row2">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   273
              Group name:<br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   274
              <small>This should be short, descriptive, and human-readable.</small>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   275
              </td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   276
              <td class="row1">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   277
              <input type="text" name="pg_name" size="30" />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   278
              </td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   279
            </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   280
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   281
      // Group type
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   282
      echo '<tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   283
              <td class="row2">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   284
              Group type:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   285
              </td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   286
              <td class="row1">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   287
              <select name="group_type" onchange="pg_create_typeset(this);">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   288
                <option value="' . PAGE_GRP_NORMAL  . '" selected="selected">Static group of pages</option>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   289
                <option value="' . PAGE_GRP_TAGGED  . '">Group of pages with one tag</option>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   290
                <option value="' . PAGE_GRP_CATLINK . '">Link to category</option>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   291
              </select>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   292
              </td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   293
            </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   294
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   295
      // Titles
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   296
      echo '<tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   297
              <th colspan="2">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   298
                <span id="pg_create_title_normal">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   299
                  Static group of pages
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   300
                </span>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   301
                <span id="pg_create_title_tagged">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   302
                  Group of commonly tagged pages
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   303
                </span>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   304
                <span id="pg_create_title_catlink">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   305
                  Mirror a category
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   306
                </span>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   307
              </th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   308
            </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   309
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   310
      echo '<tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   311
              <td class="row2">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   312
                <div id="pg_create_normal_1">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   313
                  Member pages:<br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   314
                  <small>Click the "plus" button to add more fields.</small>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   315
                </div>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   316
                <div id="pg_create_catlink_1">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   317
                  Include pages in this category:<br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   318
                  <small>Pages in subcategories are <u>not</u> included, however subcategory pages themselves are.</small>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   319
                </div>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   320
                <div id="pg_create_tagged_1">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   321
                  Include pages with this tag:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   322
                </div>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   323
              </td>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   324
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   325
      echo '  <td class="row1">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   326
                <div id="pg_create_normal_2" />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   327
                  <input type="text" style="margin-top: 3px;" name="member_page_0" id="pg_create_member_0" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   328
                  <input type="text" style="margin-top: 3px;" name="member_page_1" id="pg_create_member_1" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   329
                  <input type="text" style="margin-top: 3px;" name="member_page_2" id="pg_create_member_2" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   330
                  <input type="text" style="margin-top: 3px;" name="member_page_3" id="pg_create_member_3" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   331
                  <input type="text" style="margin-top: 3px;" name="member_page_4" id="pg_create_member_4" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   332
                  <input type="button" onclick="pg_create_more_fields(); return false;" style="margin-top: 5px;" value="&nbsp;&nbsp;+&nbsp;&nbsp;" />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   333
                </div>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   334
                <div id="pg_create_tagged_2">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   335
                  <input type="text" name="member_tag" size="30" />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   336
                </div>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   337
                <div id="pg_create_catlink_2">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   338
                  ' . $catlist . '
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   339
                </div>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   340
              </td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   341
            </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   342
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   343
      // Submit button
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   344
      echo '<tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   345
              <th class="subhead" colspan="2"><input type="submit" name="action[create_stage2]" value="Create page group" style="font-weight: bold;" /> <input type="submit" name="action[noop]" value="Cancel" style="font-weight: normal;" /></th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   346
            </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   347
            
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   348
      echo '</table>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   349
            </div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   350
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   351
      echo '</form>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   352
      return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   353
    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   354
    else if ( isset($_POST['action']['del']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   355
    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   356
      // Confirmation to delete a group (this is really only a stub)
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   357
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   358
      $delete_id = array_keys($_POST['action']['del']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   359
      $delete_id = intval($delete_id[0]);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   360
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   361
      if ( !empty($delete_id) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   362
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   363
        echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   364
        echo '<input type="hidden" name="delete_id" value="' . $delete_id . '" />';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   365
        echo '<div class="tblholder">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   366
        echo '  <table border="0" cellspacing="1" cellpadding="4">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   367
        echo '    <tr><th>Confirm deletion</th></tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   368
        echo '    <tr><td class="row2" style="text-align: center; padding: 20px 0;">Are you sure you want to delete this page group?</td></tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   369
        echo '    <tr><td class="row1" style="text-align: center;">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   370
        echo '        <input type="submit" name="action[del_confirm]" value="Yes, delete group" style="font-weight: bold;" />';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   371
        echo '        <input type="submit" name="action[noop]" value="Cancel" style="font-weight: normal;" />';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   372
        echo '        </td></tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   373
        echo '  </table>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   374
        echo '</form>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   375
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   376
        return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   377
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   378
    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   379
    else if ( isset($_POST['action']['del_confirm']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   380
    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   381
      $delete_id = intval($_POST['delete_id']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   382
      if ( empty($delete_id) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   383
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   384
        echo 'Hack attempt';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   385
        return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   386
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   387
      // Obtain group name
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   388
      $q = $db->sql_query('SELECT pg_name FROM '.table_prefix.'page_groups WHERE pg_id=' . $delete_id . ';');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   389
      if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   390
        $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   391
      if ( $db->numrows() < 1 )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   392
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   393
        echo 'Page group dun exist.';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   394
        return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   395
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   396
      $row = $db->fetchrow();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   397
      $db->free_result();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   398
      $pg_name = $row['pg_name'];
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   399
      unset($row);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   400
      // Delete the group
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   401
      $q = $db->sql_query('DELETE FROM '.table_prefix.'page_groups WHERE pg_id=' . $delete_id . ';');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   402
      if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   403
        $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   404
      $q = $db->sql_query('DELETE FROM '.table_prefix.'page_group_members WHERE pg_id=' . $delete_id . ';');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   405
      if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   406
        $db->_die();
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   407
      echo "<div class='info-box'>The group ".'"'.htmlspecialchars("$pg_name").'"'." has been deleted.</div>";
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   408
    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   409
    else if ( isset($_POST['action']['edit']) && !isset($_POST['action']['noop']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   410
    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   411
      if ( isset($_POST['action']['edit_save']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   412
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   413
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   414
     
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   415
      if ( isset($_POST['action']['edit']['add_page']) && isset($_GET['src']) && $_GET['src'] == 'ajax' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   416
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   417
        $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   418
        $return = array('successful' => false);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   419
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   420
        //
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   421
        // Add the specified page to the group
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   422
        //
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   423
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   424
        // Get ID of the group
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   425
        $edit_id = intval($_POST['pg_id']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   426
        if ( !$edit_id )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   427
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   428
          $return = array('mode' => 'error', 'text' => 'Hack attempt');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   429
          echo $json->encode($return);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   430
          return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   431
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   432
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   433
        // Run some validation - check that page exists and that it's not already in the group
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   434
        $page = $_POST['new_page'];
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   435
        if ( empty($page) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   436
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   437
          $return = array('mode' => 'error', 'text' => 'Please enter a page title.');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   438
          echo $json->encode($return);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   439
          return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   440
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   441
        
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   442
        /*
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   443
        // We're gonna allow adding nonexistent pages for now
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   444
        if ( !isPage($page) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   445
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   446
          $return = array('mode' => 'error', 'text' => 'The page you are trying to add (' . htmlspecialchars($page) . ') does not exist.');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   447
          echo $json->encode($return);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   448
          return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   449
        }
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   450
        */
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   451
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   452
        list($page_id, $namespace) = RenderMan::strToPageID($page);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   453
        $page_id = sanitize_page_id($page_id);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   454
        
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   455
        if ( !isset($paths->namespace[$namespace]) )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   456
        {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   457
          $return = array('mode' => 'error', 'text' => 'Invalid namespace return from RenderMan::strToPageID()');
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   458
          echo $json->encode($return);
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   459
          return;
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   460
        }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   461
        
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   462
        $q = $db->sql_query('SELECT "x" FROM '.table_prefix.'page_group_members WHERE pg_id=' . $edit_id . ' AND page_id=\'' . $db->escape($page_id) . '\' AND namespace=\'' . $namespace . '\';');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   463
        if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   464
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   465
          $return = array('mode' => 'error', 'text' => $db->get_error());
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   466
          echo $json->encode($return);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   467
          return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   468
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   469
        if ( $db->numrows() > 0 )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   470
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   471
          $return = array('mode' => 'error', 'text' => 'The page you are trying to add is already in this group.');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   472
          echo $json->encode($return);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   473
          return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   474
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   475
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   476
        $q = $db->sql_query('INSERT INTO '.table_prefix.'page_group_members(pg_id, page_id, namespace) VALUES(' . $edit_id . ', \'' . $db->escape($page_id) . '\', \'' . $namespace . '\');');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   477
        if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   478
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   479
          $return = array('mode' => 'error', 'text' => $db->get_error());
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   480
          echo $json->encode($return);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   481
          return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   482
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   483
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   484
        $title = "($namespace) " . get_page_title($paths->nslist[$namespace] . $page_id);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   485
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   486
        $return = array('mode' => 'info', 'text' => 'The page has been added to the specified group.', 'successful' => true, 'title' => $title, 'member_id' => $db->insert_id());
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   487
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   488
        echo $json->encode($return);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   489
        return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   490
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   491
      
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   492
      if ( isset($_POST['action']['edit_save']) && isset($_POST['pg_name']) )
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   493
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   494
        $edit_id = $_POST['action']['edit'];
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   495
        $edit_id = intval($edit_id);
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   496
        if ( !empty($edit_id) )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   497
        {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   498
          // Update group name
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   499
          $new_name = $_POST['pg_name'];
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   500
          if ( empty($new_name) )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   501
          {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   502
            echo '<div class="error-box">Please enter a valid name for this group.</div>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   503
          }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   504
          else
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   505
          {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   506
            $q = $db->sql_query('SELECT pg_name FROM '.table_prefix.'page_groups WHERE pg_id=' . $edit_id . ';');
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   507
            if ( !$q )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   508
              $db->_die();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   509
            $row = $db->fetchrow();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   510
            $db->free_result();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   511
            if ( $new_name != $row['pg_name'] )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   512
            {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   513
              $new_name = $db->escape(trim($new_name));
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   514
              $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_name=\'' . $new_name . '\' WHERE pg_id=' . $edit_id . ';');
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   515
              if ( !$q )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   516
                $db->_die();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   517
              else
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   518
                echo '<div class="info-box">The group name was updated successfully.</div>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   519
            }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   520
            if ( $_POST['pg_type'] == PAGE_GRP_TAGGED )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   521
            {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   522
              $target = $_POST['pg_target'];
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   523
              $target = sanitize_tag($target);
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   524
              if ( empty($target) )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   525
              {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   526
                echo '<div class="error-box">Please enter a valid tag.</div>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   527
              }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   528
              else
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   529
              {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   530
                $target = $db->escape($target);
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   531
                $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   532
                if ( !$q )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   533
                  $db->_die();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   534
                else
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   535
                  echo '<div class="info-box">The affecting tag was updated.</div>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   536
              }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   537
            }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   538
            else if ( $_POST['pg_type'] == PAGE_GRP_CATLINK )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   539
            {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   540
              $target = $_POST['pg_target'];
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   541
              if ( empty($target) )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   542
              {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   543
                echo '<div class="error-box">No category ID specified on POST URI.</div>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   544
              }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   545
              else
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   546
              {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   547
                $target = $db->escape($target);
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   548
                $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   549
                if ( !$q )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   550
                  $db->_die();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   551
                else
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   552
                  echo '<div class="info-box">The affecting category was updated.</div>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   553
              }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   554
            }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   555
          }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   556
        }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   557
      }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   558
      else if ( isset($_POST['action']['edit_save']) )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   559
      {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   560
        $edit_id = $_POST['action']['edit'];
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   561
        $edit_id = intval($edit_id);
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   562
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   563
      else
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   564
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   565
        $edit_id = array_keys($_POST['action']['edit']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   566
        $edit_id = intval($edit_id[0]);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   567
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   568
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   569
      if ( empty($edit_id) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   570
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   571
        echo 'Hack attempt';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   572
        return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   573
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   574
      
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   575
      if ( isset($_POST['action']['edit_save']['do_rm']) && !isset($_POST['pg_name']) )
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   576
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   577
        $vals = array_keys($_POST['action']['edit_save']['rm']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   578
        $good = array();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   579
        foreach ( $vals as $id )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   580
        {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   581
          if ( strval(intval($id)) == $id )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   582
            $good[] = $id;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   583
        }
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   584
        $subquery = ( count($good) > 0 ) ? 'pg_member_id=' . implode(' OR pg_member_id=', $good) : "'foo'='bar'";
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   585
        if ( $subquery == "'foo'='bar'" )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   586
        {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   587
          echo '<div class="warning-box">No pages were selected for deletion, and thus none were deleted.</div>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   588
        }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   589
        else
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   590
        {
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   591
          $sql = 'DELETE FROM '.table_prefix."page_group_members WHERE ( $subquery ) AND pg_id=$edit_id;";
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   592
          if ( !$db->sql_query($sql) )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   593
          {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   594
            $db->_die();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   595
          }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   596
          echo '<div class="info-box">The requested page group members have been deleted.</div>';
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   597
        }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   598
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   599
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   600
      // Fetch information about page group
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   601
      $q = $db->sql_query('SELECT pg_name, pg_type, pg_target FROM '.table_prefix.'page_groups WHERE pg_id=' . $edit_id . ';');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   602
      if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   603
        $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   604
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   605
      if ( $db->numrows() < 1 )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   606
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   607
        echo 'Bad request - can\'t load page group from database.';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   608
        return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   609
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   610
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   611
      $row = $db->fetchrow();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   612
      $db->free_result();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   613
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   614
      echo '<form name="pg_edit_frm" action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   615
      echo '<input type="hidden" name="action[edit]" value="' . $edit_id . '" />';
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   616
      echo '<input type="hidden" name="pg_type" value="' . $row['pg_type'] . '" />';
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   617
      echo '<div class="tblholder">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   618
              <table border="0" cellspacing="1" cellpadding="4">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   619
                <tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   620
                  <th colspan="3">Editing page group: ' . htmlspecialchars($row['pg_name']) . '</th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   621
                </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   622
      // Group name
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   623
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   624
      echo '    <tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   625
                  <td class="row2">Group name:</td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   626
                  <td class="row1" colspan="2"><input type="text" name="pg_name" value="' . htmlspecialchars($row['pg_name']) . '" size="30" /></td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   627
                </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   628
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   629
      $ajax_page_add = false;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   630
                
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   631
      // This is where the going gets tricky.
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   632
      // For static groups, we need to have each page listed out with a removal button, and a form to add new pages.
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   633
      // For category links, we need a select box with each category in it, and
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   634
      // For tag sets, just a text box to enter a new tag.
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   635
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   636
      // You can guess which one I dreaded.
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   637
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   638
      switch ( $row['pg_type'] )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   639
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   640
        case PAGE_GRP_NORMAL:
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   641
          
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   642
          // You have guessed correct.
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   643
          // *Sits in chair for 10 minutes listening to the radio in an effort to put off writing the code you see below*
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   644
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   645
          echo '<tr><th colspan="3" class="subhead"><input type="submit" name="action[edit_save]" value="Save group name" /></th></tr>';
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   646
          echo '</table></div>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   647
          echo '</form>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   648
          echo '<form name="pg_static_rm_frm" action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" enctype="multipart/form-data">';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   649
          echo '<input type="hidden" name="action[edit]" value="' . $edit_id . '" />';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   650
          echo '<div class="tblholder">
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   651
                  <table border="0" cellspacing="1" cellpadding="4">
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   652
                    <tr>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   653
                      <th colspan="3">Remove pages from this group</th>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   654
                    </tr>';
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   655
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   656
          $q = $db->sql_query('SELECT m.pg_member_id,m.page_id,m.namespace FROM '.table_prefix.'page_group_members AS m
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   657
                                 LEFT JOIN '.table_prefix.'pages AS p
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   658
                                   ON ( p.urlname = m.page_id AND p.namespace = m.namespace )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   659
                                 WHERE m.pg_id=' . $edit_id . ';');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   660
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   661
          if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   662
            $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   663
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   664
          $delim = ceil( $db->numrows() / 2 );
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   665
          if ( $delim < 5 )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   666
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   667
            $delim = 0xFFFFFFFE;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   668
            // stupid hack
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   669
            $colspan = '2" id="pg_edit_tackon2me';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   670
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   671
          else
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   672
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   673
            $colspan = "1";
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   674
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   675
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   676
          echo '<tr><td class="row2" rowspan="2"><b>Remove</b> pages:</td><td class="row1" colspan="' . $colspan . '">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   677
          $i = 0;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   678
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   679
          while ( $row = $db->fetchrow() )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   680
          {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   681
            $i++;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   682
            if ( $i == $delim )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   683
            {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   684
              echo '</td><td class="row1" id="pg_edit_tackon2me">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   685
            }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   686
            $page_name = '(' . $row['namespace'] . ') ' . get_page_title($paths->nslist[$row['namespace']] . $row['page_id']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   687
            echo '<label><input type="checkbox" name="action[edit_save][rm][' . $row['pg_member_id'] . ']" /> ' . htmlspecialchars($page_name) . '</label><br />';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   688
          }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   689
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   690
          echo '</td></tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   691
          echo '<tr><th colspan="2" class="subhead" style="width: 70%;"><input type="submit" name="action[edit_save][do_rm]" value="Remove selected" /></th></tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   692
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   693
          // More javascript magic!
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   694
          ?>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   695
          <script type="text/javascript">
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   696
            var __pg_edit_submitAuthorized = true;
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   697
            var __ol_pg_edit_setup = function()
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   698
            {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   699
              var input = document.getElementById('inptext_pg_add_member');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   700
              input.onkeyup = function(e) { ajaxPageNameComplete(this); };
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   701
              input.onkeypress = function(e) { if ( e.keyCode == 13 ) { setTimeout('__pg_edit_ajaxadd(document.getElementById(\'' + this.id + '\'));', 500); } };
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   702
            }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   703
            addOnloadHook(__ol_pg_edit_setup);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   704
            var __pg_edit_objcache = false;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   705
            function __pg_edit_ajaxadd(obj)
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   706
            {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   707
              if ( __pg_edit_objcache )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   708
                return false;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   709
              __pg_edit_objcache = obj;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   710
              
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   711
              if ( obj.nextSibling )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   712
              {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   713
                if ( obj.nextSibling.tagName == 'DIV' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   714
                {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   715
                  obj.parentNode.removeChild(obj.nextSibling);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   716
                }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   717
              }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   718
              
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   719
              // set width on parent, to prevent wrapping of ajax loading image
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   720
              var w = $(obj).Width();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   721
              w = w + 24;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   722
              obj.parentNode.style.width = w + 'px';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   723
              
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   724
              // append the ajaxy loading image
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   725
              var img = document.createElement('img');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   726
              img.src = scriptPath + '/images/loading.gif';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   727
              img.style.marginLeft = '4px';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   728
              insertAfter(obj.parentNode, img, obj);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   729
              
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   730
              var url = makeUrlNS('Admin', 'PageGroups', 'src=ajax');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   731
              var page_add = escape(obj.value);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   732
              var pg_id = document.forms.pg_edit_frm['action[edit]'].value;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   733
              ajaxPost(url, 'action[edit][add_page]=&pg_id=' + pg_id + '&new_page=' + page_add, function()
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   734
                {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   735
                  if ( ajax.readyState == 4 )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   736
                  {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   737
                    var obj = __pg_edit_objcache;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   738
                    __pg_edit_objcache = false;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   739
                    
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   740
                    // kill the loading graphic
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   741
                    obj.parentNode.removeChild(obj.nextSibling);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   742
                    
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   743
                    var resptext = String(ajax.responseText + '');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   744
                    if ( resptext.substr(0, 1) != '{' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   745
                    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   746
                      // This ain't JSON baby.
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   747
                      alert('Invalid JSON response:\n' + resptext);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   748
                      return false;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   749
                    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   750
                    var json = parseJSON(resptext);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   751
                    
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   752
                    var div = document.createElement('div');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   753
                    if ( json.mode == 'info' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   754
                    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   755
                      div.className = 'info-box-mini';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   756
                    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   757
                    else if ( json.mode == 'error' )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   758
                    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   759
                      div.className = 'error-box-mini';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   760
                    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   761
                    div.appendChild(document.createTextNode(json.text));
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   762
                    insertAfter(obj.parentNode, div, obj);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   763
                    
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   764
                    if ( json.successful )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   765
                    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   766
                      var td = document.getElementById('pg_edit_tackon2me');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   767
                      var lbl = document.createElement('label');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   768
                      var check = document.createElement('input');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   769
                      check.type = 'checkbox';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   770
                      check.name = 'action[edit_save][rm][' + json.member_id + ']';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   771
                      lbl.appendChild(check);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   772
                      lbl.appendChild(document.createTextNode(' ' + json.title));
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   773
                      td.appendChild(lbl);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   774
                      td.appendChild(document.createElement('br'));
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   775
                    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   776
                    
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   777
                  }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   778
                });
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   779
            }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   780
          </script>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   781
          <?php
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   782
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   783
          $ajax_page_add = true;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   784
          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   785
          break;
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   786
        case PAGE_GRP_TAGGED:
81
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   787
          echo '<tr>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   788
                  <td class="row2">
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   789
                    Include pages with this tag:
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   790
                  </td>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   791
                  <td class="row1">
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   792
                    <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" />
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   793
                  </td>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   794
                </tr>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   795
          break;
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   796
        case PAGE_GRP_CATLINK:
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   797
          
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   798
          // Build category list
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   799
          $q = $db->sql_query('SELECT name,urlname FROM '.table_prefix.'pages WHERE namespace=\'Category\';');
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   800
          if ( !$q )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   801
            $db->_die();
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   802
          
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   803
          if ( $db->numrows() < 1 )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   804
          {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   805
            $catlist = 'There aren\'t any categories on this site.';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   806
          }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   807
          else
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   808
          {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   809
            $catlist = '<select name="pg_target">';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   810
            while ( $catrow = $db->fetchrow() )
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   811
            {
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   812
              $selected = ( $catrow['urlname'] == $row['pg_target'] ) ? ' selected="selected"' : '';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   813
              $catlist .= '<option value="' . htmlspecialchars($catrow['urlname']) . '"' . $selected . '>' . htmlspecialchars($catrow['name']) . '</option>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   814
            }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   815
            $catlist .= '</select>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   816
          }
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   817
          
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   818
          echo '<tr>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   819
                  <td class="row2">
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   820
                    Include pages that are in this category:<br />
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   821
                    <small><b>Reminder:</b> Enano does not automatically place any access controls on the category. If you
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   822
                           don\'t want users to be able to freely add and remove pages from the category (assuming Wiki Mode is enabled
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   823
                           for the category) then you need to enable protection on the category using the button on the more options menu.
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   824
                           </small>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   825
                  </td>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   826
                  <td class="row1">
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   827
                    ' . $catlist . '
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   828
                  </td>
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   829
                </tr>';
d7fc25acd3f3 Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents: 80
diff changeset
   830
          
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   831
          break;
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   832
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   833
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   834
      if ( $ajax_page_add )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   835
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   836
        echo '<tr><th colspan="3"><input type="submit" name="action[noop]" value="Cancel all changes" /></th></tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   837
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   838
      else
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   839
      {
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   840
        echo '<tr><th colspan="3" class="subhead">
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   841
                <input type="submit" name="action[edit_save]" value="Save and update" />
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   842
                <input type="submit" name="action[noop]" value="Cancel all changes" />
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   843
              </th></tr>';
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   844
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   845
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   846
      echo '  </table>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   847
            </div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   848
      echo '</form>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   849
      
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   850
      if ( $ajax_page_add )
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   851
      {
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   852
        // This needs to be outside of the form.
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   853
        echo '<div class="tblholder"><table border="0" cellspacing="1" cellpadding="4"><tr>';
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   854
        echo '<th colspan="2">On-the-fly tools</th></tr>';
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   855
        echo '<tr>';
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   856
        // Add pages AJAX form
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   857
        echo '<td class="row2">Add page:<br /><small>You can add multiple pages by entering part of a page title, and it will be auto-completed. Press Enter to quickly add the page. This only works if you a really up-to-date browser.</small></td>';
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   858
        echo '<td class="row1"><input type="text" size="30" name="pg_add_member" id="inptext_pg_add_member" /></td>';
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   859
        echo '</tr></table></div>';
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 75
diff changeset
   860
      }
75
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   861
      
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   862
      return;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   863
    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   864
    else if ( isset($_POST['action']['noop']) )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   865
    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   866
      // Do nothing - skip to main form (noop is usually invoked by a cancel button in a form above)
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   867
    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   868
    else
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   869
    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   870
      echo '<div class="error-box">Invalid format of $_POST[action].</div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   871
    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   872
  }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   873
  // No action defined - show default menu
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   874
  
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   875
  echo '<h2>Manage page groups</h2>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   876
  echo '<p>Enano\'s page grouping system allows you to build sets of pages that can be controlled by a single ACL rule. This makes managing features such as a members-only section of your site a lot easier. If you don\'t use the ACL system, you probably don\'t need to use page groups.</p>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   877
  
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   878
  $q = $db->sql_query('SELECT pg_id, pg_type, pg_name, pg_target FROM '.table_prefix.'page_groups;');
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   879
  if ( !$q )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   880
    $db->_die();
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   881
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   882
  echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   883
  
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   884
  echo '<div class="tblholder">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   885
          <table border="0" cellspacing="1" cellpadding="4">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   886
            <tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   887
              <th>Group name</th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   888
              <th>Type</th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   889
              <th>Target</th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   890
              <th colspan="2">Actions</th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   891
            </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   892
  
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   893
  if ( $row = $db->fetchrow() )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   894
  {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   895
    do
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   896
    {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   897
      $name = htmlspecialchars($row['pg_name']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   898
      $type = 'Invalid';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   899
      switch ( $row['pg_type'] )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   900
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   901
        case PAGE_GRP_CATLINK:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   902
          $type = 'Link to category';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   903
          break;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   904
        case PAGE_GRP_TAGGED:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   905
          $type = 'Set of tagged pages';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   906
          break;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   907
        case PAGE_GRP_NORMAL:
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   908
          $type = 'Static set of pages';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   909
          break;
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   910
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   911
      $target = '';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   912
      if ( $row['pg_type'] == PAGE_GRP_TAGGED )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   913
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   914
        $target = 'Tag: ' . htmlspecialchars($row['pg_target']);
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   915
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   916
      else if ( $row['pg_type'] == PAGE_GRP_CATLINK )
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   917
      {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   918
        $target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target'])));
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   919
      }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   920
      $btn_edit = '<input type="submit" name="action[edit][' . $row['pg_id'] . ']" value="Edit" />';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   921
      $btn_del = '<input type="submit" name="action[del][' . $row['pg_id'] . ']" value="Delete" />';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   922
      // stupid jEdit bug/hack
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   923
      $quot = '"';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   924
      echo "<tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   925
              <td class={$quot}row1{$quot}>$name</td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   926
              <td class={$quot}row2{$quot}>$type</td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   927
              <td class={$quot}row1{$quot}>$target</td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   928
              <td class={$quot}row3{$quot} style={$quot}text-align: center;{$quot}>$btn_edit</td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   929
              <td class={$quot}row3{$quot} style={$quot}text-align: center;{$quot}>$btn_del</td>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   930
            </tr>";
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   931
    }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   932
    while ( $row = $db->fetchrow() );
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   933
  }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   934
  else
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   935
  {
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   936
    echo '  <tr><td class="row3" colspan="5" style="text-align: center;">No page groups defined.</td></tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   937
  }
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   938
  
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   939
  echo '    <tr>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   940
              <th class="subhead" colspan="5">
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   941
                <input type="submit" name="action[create]" value="Create new group" />
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   942
              </th>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   943
            </tr>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   944
  
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   945
  echo '  </table>
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   946
        </div>';
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   947
        
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   948
  echo '</form>';          
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   949
    
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   950
}
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   951
1f85c1c609fd Oops, forgot to add PageGroups.php in plugins/admin/
Dan
parents:
diff changeset
   952
?>