| 831 | 
           florian | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           ////////////////////////////////////////////////////////////////////////////////
  | 
        
        
            | 
            | 
           4 | 
           //                                                                            //
  | 
        
        
            | 
            | 
           5 | 
           //   Copyright (C) 2006  Phorum Development Team                              //
  | 
        
        
            | 
            | 
           6 | 
           //   http://www.phorum.org                                                    //
  | 
        
        
            | 
            | 
           7 | 
           //                                                                            //
  | 
        
        
            | 
            | 
           8 | 
           //   This program is free software. You can redistribute it and/or modify     //
  | 
        
        
            | 
            | 
           9 | 
           //   it under the terms of either the current Phorum License (viewable at     //
  | 
        
        
            | 
            | 
           10 | 
           //   phorum.org) or the Phorum License that was distributed with this file    //
  | 
        
        
            | 
            | 
           11 | 
           //                                                                            //
  | 
        
        
            | 
            | 
           12 | 
           //   This program is distributed in the hope that it will be useful,          //
  | 
        
        
            | 
            | 
           13 | 
           //   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
  | 
        
        
            | 
            | 
           14 | 
           //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
  | 
        
        
            | 
            | 
           15 | 
           //                                                                            //
  | 
        
        
            | 
            | 
           16 | 
           //   You should have received a copy of the Phorum License                    //
  | 
        
        
            | 
            | 
           17 | 
           //   along with this program.                                                 //
  | 
        
        
            | 
            | 
           18 | 
           ////////////////////////////////////////////////////////////////////////////////
  | 
        
        
            | 
            | 
           19 | 
              | 
        
        
            | 
            | 
           20 | 
           if(!defined("PHORUM_ADMIN")) return;
  | 
        
        
            | 
            | 
           21 | 
              | 
        
        
            | 
            | 
           22 | 
           $parent_id = (int)(isset($_GET["parent_id"])) ? $_GET["parent_id"] : 0;
  | 
        
        
            | 
            | 
           23 | 
           $parent_parent_id = (int)(isset($_GET["pparent"])) ? $_GET["pparent"] : 0;
  | 
        
        
            | 
            | 
           24 | 
              | 
        
        
            | 
            | 
           25 | 
           $forums=phorum_db_get_forums(0, $parent_id);
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           // change the display-order
  | 
        
        
            | 
            | 
           28 | 
           if(isset($_GET['display_up']) || isset($_GET['display_down'])) {
  | 
        
        
            | 
            | 
           29 | 
              | 
        
        
            | 
            | 
           30 | 
               // load all the forums up for ordering
  | 
        
        
            | 
            | 
           31 | 
               foreach($forums as $forum_id=>$forum_data){
  | 
        
        
            | 
            | 
           32 | 
                   $forum_order[]=$forum_id;
  | 
        
        
            | 
            | 
           33 | 
               }
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
               // find the one we are moving
  | 
        
        
            | 
            | 
           36 | 
               $key=array_search(isset($_GET['display_up'])?$_GET['display_up']:$_GET['display_down'], $forum_order);
  | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
               $newkey=NULL;
  | 
        
        
            | 
            | 
           39 | 
              | 
        
        
            | 
            | 
           40 | 
               // set the new key for it
  | 
        
        
            | 
            | 
           41 | 
               if($key>0 && isset($_GET['display_up'])){
  | 
        
        
            | 
            | 
           42 | 
                   $newkey=$key-1;
  | 
        
        
            | 
            | 
           43 | 
               }
  | 
        
        
            | 
            | 
           44 | 
              | 
        
        
            | 
            | 
           45 | 
               if($key<count($forum_order)-1 && isset($_GET['display_down'])){
  | 
        
        
            | 
            | 
           46 | 
                   $newkey=$key+1;
  | 
        
        
            | 
            | 
           47 | 
               }
  | 
        
        
            | 
            | 
           48 | 
              | 
        
        
            | 
            | 
           49 | 
               // if we have a newkey, make the move
  | 
        
        
            | 
            | 
           50 | 
               if(isset($newkey)){
  | 
        
        
            | 
            | 
           51 | 
                   $tmp=$forum_order[$key];
  | 
        
        
            | 
            | 
           52 | 
                   $forum_order[$key]=$forum_order[$newkey];
  | 
        
        
            | 
            | 
           53 | 
                   $forum_order[$newkey]=$tmp;
  | 
        
        
            | 
            | 
           54 | 
              | 
        
        
            | 
            | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
                   // loop through all the forums and updated the ones that changed.
  | 
        
        
            | 
            | 
           57 | 
                   // We have to look at them all because the default value for
  | 
        
        
            | 
            | 
           58 | 
                   // display order is 0 for all forums.  So, in an unsorted forlder
  | 
        
        
            | 
            | 
           59 | 
                   // all the values are set to 0 until you move one.
  | 
        
        
            | 
            | 
           60 | 
                   foreach($forum_order as $new_display_order=>$forum_id){
  | 
        
        
            | 
            | 
           61 | 
                       if($forums[$forum_id]["display_order"]!=$new_display_order){
  | 
        
        
            | 
            | 
           62 | 
                           $forums[$forum_id]["display_order"]=$new_display_order;
  | 
        
        
            | 
            | 
           63 | 
                           phorum_db_update_forum($forums[$forum_id]);
  | 
        
        
            | 
            | 
           64 | 
                       }
  | 
        
        
            | 
            | 
           65 | 
                   }
  | 
        
        
            | 
            | 
           66 | 
              | 
        
        
            | 
            | 
           67 | 
                   // get a fresh forum list with updated order.
  | 
        
        
            | 
            | 
           68 | 
                   $forums=phorum_db_get_forums(0, $parent_id);
  | 
        
        
            | 
            | 
           69 | 
               }
  | 
        
        
            | 
            | 
           70 | 
              | 
        
        
            | 
            | 
           71 | 
           }
  | 
        
        
            | 
            | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
           foreach($forums as $forum_id => $forum){
  | 
        
        
            | 
            | 
           74 | 
              | 
        
        
            | 
            | 
           75 | 
              | 
        
        
            | 
            | 
           76 | 
              | 
        
        
            | 
            | 
           77 | 
               if($forum["folder_flag"]){
  | 
        
        
            | 
            | 
           78 | 
                   $type="Folder";
  | 
        
        
            | 
            | 
           79 | 
                   $actions="<a href=\"$_SERVER[PHP_SELF]?module=default&parent_id=$forum_id&pparent=$parent_id\">Browse</a> • <a href=\"$_SERVER[PHP_SELF]?module=editfolder&forum_id=$forum_id\">Edit</a> • <a href=\"$_SERVER[PHP_SELF]?module=deletefolder&forum_id=$forum_id\">Delete</a>";
  | 
        
        
            | 
            | 
           80 | 
                   $editurl="$_SERVER[PHP_SELF]?module=editfolder&forum_id=$forum_id";
  | 
        
        
            | 
            | 
           81 | 
               } else {
  | 
        
        
            | 
            | 
           82 | 
                   $type="Forum";
  | 
        
        
            | 
            | 
           83 | 
                   $actions="<a href=\"$_SERVER[PHP_SELF]?module=editforum&forum_id=$forum_id\">Edit</a> • <a href=\"$_SERVER[PHP_SELF]?module=deleteforum&forum_id=$forum_id\">Delete</a>";
  | 
        
        
            | 
            | 
           84 | 
                   $editurl="$_SERVER[PHP_SELF]?module=editforum&forum_id=$forum_id";
  | 
        
        
            | 
            | 
           85 | 
               }
  | 
        
        
            | 
            | 
           86 | 
              | 
        
        
            | 
            | 
           87 | 
               $rows.="<tr><td class=\"PhorumAdminTableRow\"><a href=\"$editurl\">$forum[name]</a><br />$forum[description]</td><td class=\"PhorumAdminTableRow\">$type</td><td class=\"PhorumAdminTableRow\"><a href=\"$_SERVER[PHP_SELF]?module=default&display_up=$forum_id&parent_id=$parent_id\">Up</a> • <a href=\"$_SERVER[PHP_SELF]?module=default&display_down=$forum_id&parent_id=$parent_id\">Down</a></td><td class=\"PhorumAdminTableRow\">$actions</td></tr>\n";
  | 
        
        
            | 
            | 
           88 | 
           }
  | 
        
        
            | 
            | 
           89 | 
              | 
        
        
            | 
            | 
           90 | 
           if(empty($rows)){
  | 
        
        
            | 
            | 
           91 | 
               $rows="<tr><td colspan=\"4\" class=\"PhorumAdminTableRow\">There are no forums or folders in this folder.</td></tr>\n";
  | 
        
        
            | 
            | 
           92 | 
           }
  | 
        
        
            | 
            | 
           93 | 
              | 
        
        
            | 
            | 
           94 | 
           if($parent_id>0){
  | 
        
        
            | 
            | 
           95 | 
               $folder_data=phorum_get_folder_info();
  | 
        
        
            | 
            | 
           96 | 
              | 
        
        
            | 
            | 
           97 | 
               $path=$folder_data[$parent_id];
  | 
        
        
            | 
            | 
           98 | 
           } else {
  | 
        
        
            | 
            | 
           99 | 
               $path="Choose a forum or folder.";
  | 
        
        
            | 
            | 
           100 | 
           }
  | 
        
        
            | 
            | 
           101 | 
              | 
        
        
            | 
            | 
           102 | 
              | 
        
        
            | 
            | 
           103 | 
              | 
        
        
            | 
            | 
           104 | 
           ?>
  | 
        
        
            | 
            | 
           105 | 
              | 
        
        
            | 
            | 
           106 | 
           <div class="PhorumAdminTitle"><?php echo "$path    <a href=\"$_SERVER[PHP_SELF]?module=default&parent_id={$parent_parent_id}\"><span class=\"PhorumAdminTitle\">Go Up</span></a>";?></div>
  | 
        
        
            | 
            | 
           107 | 
           <table border="0" cellspacing="2" cellpadding="3" width="100%">
  | 
        
        
            | 
            | 
           108 | 
           <tr>
  | 
        
        
            | 
            | 
           109 | 
               <td class="PhorumAdminTableHead">Name</td>
  | 
        
        
            | 
            | 
           110 | 
               <td class="PhorumAdminTableHead">Type</td>
  | 
        
        
            | 
            | 
           111 | 
               <td class="PhorumAdminTableHead">Move</td>
  | 
        
        
            | 
            | 
           112 | 
               <td class="PhorumAdminTableHead">Actions</td>
  | 
        
        
            | 
            | 
           113 | 
           </tr>
  | 
        
        
            | 
            | 
           114 | 
           <?php echo $rows; ?>
  | 
        
        
            | 
            | 
           115 | 
           </table>
  |