| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      /**
 
     | 
  
  
    | 
      3
     | 
    
       *
 
     | 
  
  
    | 
      4
     | 
    
       * @category        modules
 
     | 
  
  
    | 
      5
     | 
    
       * @package         news
 
     | 
  
  
    | 
      6
     | 
    
       * @author          WebsiteBaker Project
 
     | 
  
  
    | 
      7
     | 
    
       * @copyright       WebsiteBaker Org. e.V.
 
     | 
  
  
    | 
      8
     | 
    
       * @link            http://websitebaker.org/
 
     | 
  
  
    | 
      9
     | 
    
       * @license         http://www.gnu.org/licenses/gpl.html
 
     | 
  
  
    | 
      10
     | 
    
       * @platform        WebsiteBaker 2.8.3
 
     | 
  
  
    | 
      11
     | 
    
       * @requirements    PHP 5.3.6 and higher
 
     | 
  
  
    | 
      12
     | 
    
       * @version         $Id: delete.php 2 2017-07-02 15:14:29Z Manuela $
 
     | 
  
  
    | 
      13
     | 
    
       * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/news/delete.php $
 
     | 
  
  
    | 
      14
     | 
    
       * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
 
     | 
  
  
    | 
      15
     | 
    
       *
 
     | 
  
  
    | 
      16
     | 
    
       */
 
     | 
  
  
    | 
      17
     | 
    
      
 
     | 
  
  
    | 
      18
     | 
    
      /* -------------------------------------------------------- */
 
     | 
  
  
    | 
      19
     | 
    
      // Must include code to stop this file being accessed directly
 
     | 
  
  
    | 
      20
     | 
    
      if(defined('WB_PATH') == false) { die('Illegale file access /'.basename(__DIR__).'/'.basename(__FILE__).''); }
     | 
  
  
    | 
      21
     | 
    
      /* -------------------------------------------------------- */
 
     | 
  
  
    | 
      22
     | 
    
      function mod_news_delete($database, $page_id, $section_id)
 
     | 
  
  
    | 
      23
     | 
    
      {
     | 
  
  
    | 
      24
     | 
    
      
 
     | 
  
  
    | 
      25
     | 
    
          //get and remove all php files created for the news section
 
     | 
  
  
    | 
      26
     | 
    
          $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` '
 
     | 
  
  
    | 
      27
     | 
    
                . 'WHERE `section_id` = '.$database->escapeString($section_id);
 
     | 
  
  
    | 
      28
     | 
    
          $oPosts = $database->query($sql);
 
     | 
  
  
    | 
      29
     | 
    
          if($oPosts->numRows() > 0) {
     | 
  
  
    | 
      30
     | 
    
              while($aPost = $oPosts->fetchRow(MYSQLI_ASSOC)) {
     | 
  
  
    | 
      31
     | 
    
                  if(is_writable(WB_PATH.PAGES_DIRECTORY.$aPost['link'].PAGE_EXTENSION)) {
     | 
  
  
    | 
      32
     | 
    
                  unlink(WB_PATH.PAGES_DIRECTORY.$aPost['link'].PAGE_EXTENSION);
 
     | 
  
  
    | 
      33
     | 
    
                  }
 
     | 
  
  
    | 
      34
     | 
    
              }
 
     | 
  
  
    | 
      35
     | 
    
          }
 
     | 
  
  
    | 
      36
     | 
    
      
 
     | 
  
  
    | 
      37
     | 
    
          //check to see if any other sections are part of the news page, if only 1 news is there delete it
 
     | 
  
  
    | 
      38
     | 
    
          $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'sections` '
 
     | 
  
  
    | 
      39
     | 
    
                . 'WHERE `page_id` = '.$database->escapeString($page_id);
 
     | 
  
  
    | 
      40
     | 
    
          $oSection = $database->query($sql);
 
     | 
  
  
    | 
      41
     | 
    
          if($oSection->numRows() == 1) {
     | 
  
  
    | 
      42
     | 
    
              $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'pages` '
 
     | 
  
  
    | 
      43
     | 
    
                    . 'WHERE `page_id` = '.$database->escapeString($page_id);
 
     | 
  
  
    | 
      44
     | 
    
              $oPages = $database->query($sql);
 
     | 
  
  
    | 
      45
     | 
    
              $link = $oPages->fetchRow(MYSQLI_ASSOC);
 
     | 
  
  
    | 
      46
     | 
    
              if(is_writable(WB_PATH.PAGES_DIRECTORY.$link['link'].PAGE_EXTENSION)) {
     | 
  
  
    | 
      47
     | 
    
                  unlink(WB_PATH.PAGES_DIRECTORY.$link['link'].PAGE_EXTENSION);
 
     | 
  
  
    | 
      48
     | 
    
              }
 
     | 
  
  
    | 
      49
     | 
    
          }
 
     | 
  
  
    | 
      50
     | 
    
      
 
     | 
  
  
    | 
      51
     | 
    
          $sql  = 'DELETE FROM `'.TABLE_PREFIX.'mod_news_groups` '
 
     | 
  
  
    | 
      52
     | 
    
                . 'WHERE `section_id` = '.$database->escapeString($section_id);
 
     | 
  
  
    | 
      53
     | 
    
          $database->query($sql);
 
     | 
  
  
    | 
      54
     | 
    
          $sql  = 'DELETE FROM `'.TABLE_PREFIX.'mod_news_posts` '
 
     | 
  
  
    | 
      55
     | 
    
                . 'WHERE `section_id` = '.$database->escapeString($section_id);
 
     | 
  
  
    | 
      56
     | 
    
          $database->query($sql);
 
     | 
  
  
    | 
      57
     | 
    
          $sql  = 'DELETE FROM `'.TABLE_PREFIX.'mod_news_comments` '
 
     | 
  
  
    | 
      58
     | 
    
                . 'WHERE `section_id` = '.$database->escapeString($section_id);
 
     | 
  
  
    | 
      59
     | 
    
          $database->query($sql);
 
     | 
  
  
    | 
      60
     | 
    
          $sql  = 'DELETE FROM `'.TABLE_PREFIX.'mod_news_settings` '
 
     | 
  
  
    | 
      61
     | 
    
                . 'WHERE `section_id` = '.$database->escapeString($section_id);
 
     | 
  
  
    | 
      62
     | 
    
          $database->query($sql);
 
     | 
  
  
    | 
      63
     | 
    
      }
 
     | 
  
  
    | 
      64
     | 
    
      
 
     | 
  
  
    | 
      65
     | 
    
      if( !function_exists('mod_news_delete') ){ mod_news_delete($database, $page_id, $section_id );}
     | 
  
  
    | 
      66
     | 
    
      
 
     |