| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      /**
 
     | 
  
  
    | 
      3
     | 
    
       *
 
     | 
  
  
    | 
      4
     | 
    
       * @category        admin
 
     | 
  
  
    | 
      5
     | 
    
       * @package         pages
 
     | 
  
  
    | 
      6
     | 
    
       * @author          WebsiteBaker Project
 
     | 
  
  
    | 
      7
     | 
    
       * @copyright       2004-2009, Ryan Djurovich
 
     | 
  
  
    | 
      8
     | 
    
       * @copyright       2009-2010, Website Baker Org. e.V.
 
     | 
  
  
    | 
      9
     | 
    
       * @link			http://www.websitebaker2.org/
 
     | 
  
  
    | 
      10
     | 
    
       * @license         http://www.gnu.org/licenses/gpl.html
 
     | 
  
  
    | 
      11
     | 
    
       * @platform        WebsiteBaker 2.8.x
 
     | 
  
  
    | 
      12
     | 
    
       * @requirements    PHP 4.3.4 and higher
 
     | 
  
  
    | 
      13
     | 
    
       * @version         $Id: save.php 1306 2010-03-19 21:05:49Z Luisehahne $
 
     | 
  
  
    | 
      14
     | 
    
       * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/save.php $
 
     | 
  
  
    | 
      15
     | 
    
       * @lastmodified    $Date: 2010-03-19 22:05:49 +0100 (Fri, 19 Mar 2010) $
 
     | 
  
  
    | 
      16
     | 
    
       *
 
     | 
  
  
    | 
      17
     | 
    
       */
 
     | 
  
  
    | 
      18
     | 
    
      
 
     | 
  
  
    | 
      19
     | 
    
      // Get page & section id
 
     | 
  
  
    | 
      20
     | 
    
      if(!isset($_POST['page_id']) OR !is_numeric($_POST['page_id'])) {
     | 
  
  
    | 
      21
     | 
    
      	header("Location: index.php");
     | 
  
  
    | 
      22
     | 
    
      	exit(0);
 
     | 
  
  
    | 
      23
     | 
    
      } else {
     | 
  
  
    | 
      24
     | 
    
      	$page_id = intval($_POST['page_id']);
 
     | 
  
  
    | 
      25
     | 
    
      }
 
     | 
  
  
    | 
      26
     | 
    
      if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) {
     | 
  
  
    | 
      27
     | 
    
      	header("Location: index.php");
     | 
  
  
    | 
      28
     | 
    
      	exit(0);
 
     | 
  
  
    | 
      29
     | 
    
      } else {
     | 
  
  
    | 
      30
     | 
    
      	$section_id = intval($_POST['section_id']);
 
     | 
  
  
    | 
      31
     | 
    
      }
 
     | 
  
  
    | 
      32
     | 
    
      
 
     | 
  
  
    | 
      33
     | 
    
      // Create new admin object
 
     | 
  
  
    | 
      34
     | 
    
      require('../../config.php');
     | 
  
  
    | 
      35
     | 
    
      require_once(WB_PATH.'/framework/class.admin.php');
 
     | 
  
  
    | 
      36
     | 
    
      $admin = new admin('Pages', 'pages_modify');
     | 
  
  
    | 
      37
     | 
    
      
 
     | 
  
  
    | 
      38
     | 
    
      // Get perms
 
     | 
  
  
    | 
      39
     | 
    
      $sql  = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
 
     | 
  
  
    | 
      40
     | 
    
      $sql .= 'WHERE `page_id` = '.$page_id;
 
     | 
  
  
    | 
      41
     | 
    
      $results = $database->query($sql);
 
     | 
  
  
    | 
      42
     | 
    
      $results_array = $results->fetchRow();
 
     | 
  
  
    | 
      43
     | 
    
      $old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
     | 
  
  
    | 
      44
     | 
    
      $old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
     | 
  
  
    | 
      45
     | 
    
      $in_old_group = FALSE;
 
     | 
  
  
    | 
      46
     | 
    
      foreach($admin->get_groups_id() as $cur_gid)
 
     | 
  
  
    | 
      47
     | 
    
      {
     | 
  
  
    | 
      48
     | 
    
          if (in_array($cur_gid, $old_admin_groups))
 
     | 
  
  
    | 
      49
     | 
    
          {
     | 
  
  
    | 
      50
     | 
    
              $in_old_group = TRUE;
 
     | 
  
  
    | 
      51
     | 
    
          }
 
     | 
  
  
    | 
      52
     | 
    
      }
 
     | 
  
  
    | 
      53
     | 
    
      if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
 
     | 
  
  
    | 
      54
     | 
    
      {
     | 
  
  
    | 
      55
     | 
    
      	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
 
     | 
  
  
    | 
      56
     | 
    
      }
 
     | 
  
  
    | 
      57
     | 
    
      // Get page module
 
     | 
  
  
    | 
      58
     | 
    
      $sql  = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
 
     | 
  
  
    | 
      59
     | 
    
      $sql .= 'WHERE `page_id`='.$page_id.' AND `section_id`='.$section_id;
 
     | 
  
  
    | 
      60
     | 
    
      $module = $database->get_one($sql);
 
     | 
  
  
    | 
      61
     | 
    
      if(!$module)
 
     | 
  
  
    | 
      62
     | 
    
      {
     | 
  
  
    | 
      63
     | 
    
      	$admin->print_error( $database->is_error() ? $database->get_error() : $MESSAGE['PAGES']['NOT_FOUND']);
 
     | 
  
  
    | 
      64
     | 
    
      }
 
     | 
  
  
    | 
      65
     | 
    
      //$results = $database->query($sql);
 
     | 
  
  
    | 
      66
     | 
    
      //if($database->is_error()) {
     | 
  
  
    | 
      67
     | 
    
      //	$admin->print_error($database->get_error());
 
     | 
  
  
    | 
      68
     | 
    
      //}
 
     | 
  
  
    | 
      69
     | 
    
      //if($results->numRows() == 0) {
     | 
  
  
    | 
      70
     | 
    
      //	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
 
     | 
  
  
    | 
      71
     | 
    
      //}
 
     | 
  
  
    | 
      72
     | 
    
      //$results_array = $results->fetchRow();
 
     | 
  
  
    | 
      73
     | 
    
      //$module = $results_array['module'];
 
     | 
  
  
    | 
      74
     | 
    
      
 
     | 
  
  
    | 
      75
     | 
    
      // Update the pages table
 
     | 
  
  
    | 
      76
     | 
    
      $now = time();
 
     | 
  
  
    | 
      77
     | 
    
      $sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
 
     | 
  
  
    | 
      78
     | 
    
      $sql .= '`modified_when` = '.$now.', `modified_by` = '.$admin->get_user_id().' ';
 
     | 
  
  
    | 
      79
     | 
    
      $sql .= 'WHERE `page_id` = '.$page_id;
 
     | 
  
  
    | 
      80
     | 
    
      $database->query($sql);
 
     | 
  
  
    | 
      81
     | 
    
      
 
     | 
  
  
    | 
      82
     | 
    
      // Include the modules saving script if it exists
 
     | 
  
  
    | 
      83
     | 
    
      if(file_exists(WB_PATH.'/modules/'.$module.'/save.php'))
 
     | 
  
  
    | 
      84
     | 
    
      {
     | 
  
  
    | 
      85
     | 
    
      	include_once(WB_PATH.'/modules/'.$module.'/save.php');
 
     | 
  
  
    | 
      86
     | 
    
      }
 
     | 
  
  
    | 
      87
     | 
    
      // Check if there is a db error, otherwise say successful
 
     | 
  
  
    | 
      88
     | 
    
      if($database->is_error())
 
     | 
  
  
    | 
      89
     | 
    
      {
     | 
  
  
    | 
      90
     | 
    
      	$admin->print_error($database->get_error(), $js_back);
 
     | 
  
  
    | 
      91
     | 
    
      } else {
     | 
  
  
    | 
      92
     | 
    
      	$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
 
     | 
  
  
    | 
      93
     | 
    
      }
 
     | 
  
  
    | 
      94
     | 
    
      
 
     | 
  
  
    | 
      95
     | 
    
      // Print admin footer
 
     | 
  
  
    | 
      96
     | 
    
      $admin->print_footer();
 
     | 
  
  
    | 
      97
     | 
    
      
 
     | 
  
  
    | 
      98
     | 
    
      ?>
 
     |