decir/admincp/admin_forums.php
changeset 9 6d9655e02026
parent 7 37387f84fe25
equal deleted inserted replaced
8:850e1b1209a9 9:6d9655e02026
   113         $show_main_menu = false;
   113         $show_main_menu = false;
   114         $form = new Decir_Admin_SmartForm_Forum(DECIR_ADMIN_MODE_CREATE);
   114         $form = new Decir_Admin_SmartForm_Forum(DECIR_ADMIN_MODE_CREATE);
   115         $form->need_category = $need_category;
   115         $form->need_category = $need_category;
   116         $form->category_list = $cats;
   116         $form->category_list = $cats;
   117         echo $form->html();
   117         echo $form->html();
       
   118         break;
       
   119       case 'delete':
       
   120       case 'delete_finish':
       
   121         if ( !isset($parms['fid']) || ( isset($parms['fid']) && !is_int($parms['fid']) ) )
       
   122         {
       
   123           echo '<div class="error-box">Invalid forum ID passed to editor.</div>';
       
   124           break;
       
   125         }
       
   126         
       
   127         // $fid is safe (validated as an integer).
       
   128         $fid =& $parms['fid'];
       
   129         $q = $db->sql_query('SELECT forum_id, forum_name, forum_type FROM ' . table_prefix . 'decir_forums WHERE forum_id = ' . $fid . ';');
       
   130         if ( !$q )
       
   131           $db->_die('Decir admin_forums.php selecting forum data for deletion');
       
   132         
       
   133         $row = $db->fetchrow();
       
   134         $db->free_result();
       
   135         
       
   136         if ( $row['forum_type'] == FORUM_FORUM )
       
   137         {
       
   138           // Provide the option of moving the posts in this forum to another forum
       
   139           $q = $db->sql_query('SELECT forum_id, forum_name FROM ' . table_prefix . "decir_forums WHERE forum_id != {$row['forum_id']} AND forum_type = " . FORUM_FORUM . ';');
       
   140           if ( !$q )
       
   141             $db->_die('Decir admin_forums.php selecting list of possible forums to move topics to');
       
   142           $opt_move = '';
       
   143           if ( $db->numrows() > 0 )
       
   144           {
       
   145             $opt_move .= '<p><label><input type="radio" name="with_content" value="move" /> Move to forum:</label><br />
       
   146                              <select name="move_to">';
       
   147             while ( $drow = $db->fetchrow() )
       
   148             {
       
   149               $opt_move .= "<option value=\"{$drow['forum_id']}\">" . htmlspecialchars($drow['forum_name']) . '</option>';
       
   150             }
       
   151             $opt_move .= "</select></p>";
       
   152           }
       
   153         }
       
   154         else if ( $row['forum_type'] == FORUM_CATEGORY )
       
   155         {
       
   156           // Provide the option of moving the posts in this forum to another forum
       
   157           $q = $db->sql_query('SELECT forum_id, forum_name FROM ' . table_prefix . "decir_forums WHERE forum_id != {$row['forum_id']} AND forum_type = " . FORUM_CATEGORY . ';');
       
   158           if ( !$q )
       
   159             $db->_die('Decir admin_forums.php selecting list of possible categories to move forums to');
       
   160           $opt_move = '';
       
   161           if ( $db->numrows() > 0 )
       
   162           {
       
   163             $opt_move .= '<p><label><input type="radio" name="with_content" value="move" /> Move to category:</label><br />
       
   164                              <select name="move_to">';
       
   165             while ( $drow = $db->fetchrow() )
       
   166             {
       
   167               $opt_move .= "<option value=\"{$drow['forum_id']}\">" . htmlspecialchars($drow['forum_name']) . '</option>';
       
   168             }
       
   169             $opt_move .= "</select></p>";
       
   170           }
       
   171         }
       
   172         else
       
   173         {
       
   174           break;
       
   175         }
       
   176         
       
   177         $forcat = ( $row['forum_type'] == FORUM_FORUM ) ? 'forum' : 'category';
       
   178         echo '<div class="tblholder">
       
   179                 <table border="0" cellspacing="1" cellpadding="4">
       
   180                   <tr>
       
   181                     <th>Deleting ' . $forcat . '</th>
       
   182                   </tr>
       
   183                   <tr>
       
   184                     <td class="row2">
       
   185                       <div style="margin: 0 auto; display: table;">
       
   186                       <p><b>You are about to obliterate the '. $forcat .' "' . htmlspecialchars($row['forum_name']) . '".</b><br />
       
   187                          You can either preserve its contents or delete them. Beware that if you are deleting a<br />
       
   188                          ' . $forcat . ' with a large number of posts in it, this process may take some time.</p>
       
   189                       </div>
       
   190                       <div style="margin: 0 auto; display: table;">
       
   191                       <p><label><input type="radio" checked="checked" name="with_content" value="delete" /> Delete contents</p>
       
   192                       ' . $opt_move . '
       
   193                       </div>
       
   194                     </td>
       
   195                   </tr>
       
   196                   <tr>
       
   197                     <td class="row1" style="text-align: center;">
       
   198                       <button name="act" value="delete_finish;fid=' . $row['forum_id'] . '"><span style="font-weight: bold; color: red;">Delete forum</span></button>
       
   199                       <button name="act" value="noop" style="font-weight: normal;">Cancel</button>
       
   200                     </td>
       
   201                   </tr>
       
   202                 </table>
       
   203               </div>';
       
   204               
       
   205         $show_main_menu = false;
       
   206         
   118         break;
   207         break;
   119       case 'edit':
   208       case 'edit':
   120       case 'edit_finish':
   209       case 'edit_finish':
   121         
   210         
   122         if ( !isset($parms['fid']) || ( isset($parms['fid']) && !is_int($parms['fid']) ) )
   211         if ( !isset($parms['fid']) || ( isset($parms['fid']) && !is_int($parms['fid']) ) )
   326               </tr>';
   415               </tr>';
   327     
   416     
   328     echo '  </table>
   417     echo '  </table>
   329           </div>';
   418           </div>';
   330     $order = /* implode(',', $order_cats) . ';' . */ implode(',', $order_forums);
   419     $order = /* implode(',', $order_cats) . ';' . */ implode(',', $order_forums);
   331     echo '<input type="text" name="forum_order" id="forum_order" value="' . $order . '" />';
   420     echo '<input type="hidden" name="forum_order" id="forum_order" value="' . $order . '" />';
   332     echo "</form>";
   421     echo "</form>";
   333   }
   422   }
   334 }
   423 }
   335 
   424 
   336 /**
   425 /**