[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_module/mod_calendar/inc/ -> processing.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  
  31  // try
  32  
  33  if(isset($_GET['edit'])) {
  34      $plugin['id']        = intval($_GET['edit']);
  35  } else {
  36      $plugin['id']        = 0;
  37  }
  38  
  39  
  40  // process post form
  41  if(isset($_POST['calendar_title'])) {
  42  
  43      $plugin['data'] = array(
  44      
  45                  'calendar_id'            => intval($_POST['calendar_id']),
  46                  'calendar_title'        => clean_slweg($_POST['calendar_title']),
  47                  'calendar_created'        => date('Y-m-d H:i:s'),
  48                  'calendar_changed'        => date('Y-m-d H:i:s'),
  49                  'calendar_tag'            => clean_slweg($_POST['calendar_tag']),
  50                  'calendar_lang'            => isset($_POST['calendar_lang']) ? preg_replace('/[^a-z\-]/', '', strtolower($_POST['calendar_lang'])) : '',
  51                  'calendar_teaser'        => clean_slweg($_POST['calendar_teaser']),
  52                  'calendar_text'            => slweg($_POST['calendar_text']),
  53                  'calendar_object'        => array(),
  54                  'calendar_status'        => empty($_POST['calendar_status']) ? 0 : 1,
  55                  'calendar_start_date'    => clean_slweg($_POST['calendar_start_date']),
  56                  'calendar_start_time'    => clean_slweg($_POST['calendar_start_time']),
  57                  'calendar_end_date'        => clean_slweg($_POST['calendar_end_date']),
  58                  'calendar_end_time'        => clean_slweg($_POST['calendar_end_time']),
  59                  'calendar_allday'        => empty($_POST['calendar_allday']) ? 0 : 1,
  60                  'calendar_range'        => intval($_POST['calendar_range']),
  61                  'calendar_where'        => clean_slweg($_POST['calendar_where']),
  62                  'calendar_refid'        => clean_slweg($_POST['calendar_refid']),
  63                  'calendar_duplicate'    => empty($_POST['calendar_duplicate']) ? 0 : 1,
  64                  'calendar_rangestart'    => clean_slweg($_POST['calendar_range_start']),
  65                  'calendar_rangeend'        => clean_slweg($_POST['calendar_range_end']),
  66                  'calendar_image'        => array(
  67                  
  68                              'id'        => intval($_POST['cnt_image_id']), 
  69                              'name'        => clean_slweg($_POST['cnt_image_name']),
  70                              'zoom'        => empty($_POST['cnt_image_zoom']) ? 0 : 1,
  71                              'lightbox'    => empty($_POST['cnt_image_lightbox']) ? 0 : 1,
  72                              'caption'    => clean_slweg($_POST['cnt_image_caption']),
  73                              'link'        =>clean_slweg($_POST['cnt_image_link'])                
  74                                              )
  75      
  76                                  );
  77  
  78      // clean up date/time
  79      include_once($phpwcms['modules'][$module]['path'].'inc/processing.datetime.inc.php');
  80      
  81      if($plugin['data']['calendar_range'] > 7) {
  82          $plugin['data']['calendar_range'] = 0;
  83      }
  84  
  85      if(empty($plugin['data']['calendar_title'])) {
  86      
  87          $plugin['error']['calendar_title'] = 1;
  88      
  89      }
  90  
  91      
  92      if(!isset($glossary['error'])) {
  93      
  94          if($plugin['data']['calendar_duplicate']) {
  95              $plugin['data']['calendar_id'] = 0;
  96          }
  97          
  98          $plugin['data']['calendar_object']['image'] = $plugin['data']['calendar_image'];
  99          
 100          if($plugin['data']['calendar_id']) {
 101          
 102              // UPDATE
 103              $sql  = 'UPDATE '.DB_PREPEND.'phpwcms_calendar SET ';
 104              
 105              $sql .= "calendar_created='".aporeplace($plugin['data']['calendar_created'])."', ";
 106              $sql .= "calendar_changed='".aporeplace($plugin['data']['calendar_changed'])."', ";
 107              $sql .= "calendar_status=".$plugin['data']['calendar_status'].", ";
 108              $sql .= "calendar_start='".aporeplace($plugin['data']['calendar_start'])."', ";
 109              $sql .= "calendar_end='".aporeplace($plugin['data']['calendar_end'])."', ";
 110              $sql .= "calendar_allday=".$plugin['data']['calendar_allday'].", ";
 111              $sql .= "calendar_range=".$plugin['data']['calendar_range'].", ";
 112              $sql .= "calendar_range_start='".aporeplace($plugin['data']['calendar_range_start'])."', ";
 113              $sql .= "calendar_range_end='".aporeplace($plugin['data']['calendar_range_end'])."', ";
 114              $sql .= "calendar_title='".aporeplace($plugin['data']['calendar_title'])."', ";
 115              $sql .= "calendar_where='".aporeplace($plugin['data']['calendar_where'])."', ";
 116              $sql .= "calendar_teaser='".aporeplace($plugin['data']['calendar_teaser'])."', ";
 117              $sql .= "calendar_text='".aporeplace($plugin['data']['calendar_text'])."', ";
 118              $sql .= "calendar_tag='".aporeplace($plugin['data']['calendar_tag'])."', ";
 119              $sql .= "calendar_object='".aporeplace(serialize($plugin['data']['calendar_object']))."', ";
 120              $sql .= "calendar_refid='".aporeplace($plugin['data']['calendar_refid'])."', ";
 121              $sql .= "calendar_lang='".aporeplace($plugin['data']['calendar_lang'])."' ";
 122              
 123              $sql .= "WHERE calendar_id=".$plugin['data']['calendar_id'];
 124              
 125              if(@_dbQuery($sql, 'UPDATE')) {
 126              
 127                  _dbSaveCategories($plugin['data']['calendar_tag'], 'calendar', $plugin['data']['calendar_id'], ',');
 128              
 129                  if(isset($_POST['save'])) {
 130                      
 131                      headerRedirect(decode_entities(MODULE_HREF));
 132                      
 133                  }
 134              
 135              } else {
 136              
 137                  $plugin['error']['update'] = mysql_error();
 138              
 139              }
 140              
 141          
 142          } else {
 143          
 144              // INSERT
 145              $sql  = 'INSERT INTO '.DB_PREPEND.'phpwcms_calendar (';
 146              
 147              $sql .= 'calendar_created, calendar_changed, calendar_status, ';
 148              $sql .= 'calendar_start, calendar_end, calendar_allday, calendar_range, ';
 149              $sql .= 'calendar_range_start, calendar_range_end, calendar_title, ';
 150              $sql .= 'calendar_where, calendar_teaser, calendar_text, calendar_tag, ';
 151              $sql .= 'calendar_object, calendar_refid, calendar_lang) VALUES (';
 152              
 153              $sql .= "'".aporeplace($plugin['data']['calendar_created'])."', ";
 154              $sql .= "'".aporeplace($plugin['data']['calendar_changed'])."', ";
 155              $sql .= $plugin['data']['calendar_status'].", ";
 156              $sql .= "'".aporeplace($plugin['data']['calendar_start'])."', ";
 157              $sql .= "'".aporeplace($plugin['data']['calendar_end'])."', ";
 158              $sql .= $plugin['data']['calendar_allday'].", ";
 159              $sql .= $plugin['data']['calendar_range'].", ";
 160              $sql .= "'".aporeplace($plugin['data']['calendar_range_start'])."', ";
 161              $sql .= "'".aporeplace($plugin['data']['calendar_range_end'])."', ";
 162              $sql .= "'".aporeplace($plugin['data']['calendar_title'])."', ";
 163              $sql .= "'".aporeplace($plugin['data']['calendar_where'])."', ";
 164              $sql .= "'".aporeplace($plugin['data']['calendar_teaser'])."', ";
 165              $sql .= "'".aporeplace($plugin['data']['calendar_text'])."', ";
 166              $sql .= "'".aporeplace($plugin['data']['calendar_tag'])."', ";
 167              $sql .= "'".aporeplace(serialize($plugin['data']['calendar_object']))."', ";
 168              $sql .= "'".aporeplace($plugin['data']['calendar_refid'])."', ";
 169              $sql .= "'".aporeplace($plugin['data']['calendar_lang'])."'";
 170  
 171              $sql .= ')';
 172              
 173              if($sql = @_dbQuery($sql, 'INSERT')) {
 174              
 175                  $plugin['data']['calendar_id'] = $sql['INSERT_ID'];
 176              
 177                  _dbSaveCategories($plugin['data']['calendar_tag'], 'calendar', $plugin['data']['calendar_id'], ',');
 178              
 179                  if(isset($_POST['save'])) {
 180                      
 181                      headerRedirect(decode_entities(MODULE_HREF));
 182                      
 183                  } else {
 184                  
 185                      headerRedirect(decode_entities(MODULE_HREF).'&edit='.$plugin['data']['calendar_id']);        
 186                  }
 187              
 188              } else {
 189              
 190                  $plugin['error']['update'] = mysql_error();
 191              
 192              }
 193          
 194          
 195          }
 196      }
 197  
 198  }
 199  
 200  // try to read entry from database
 201  if($plugin['id'] && !isset($plugin['error'])) {
 202  
 203      $sql  = 'SELECT *, ';
 204      $sql .= "DATE_FORMAT(calendar_start, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_start_date, ";
 205      $sql .= "DATE_FORMAT(calendar_end,   '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_end_date, ";
 206      $sql .= "DATE_FORMAT(calendar_start, '%H:%i') AS calendar_start_time, ";
 207      $sql .= "DATE_FORMAT(calendar_end,   '%H:%i') AS calendar_end_time, ";
 208      $sql .= "DATE_FORMAT(calendar_range_start, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_rangestart, ";
 209      $sql .= "DATE_FORMAT(calendar_range_end, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_rangeend ";
 210      $sql .= 'FROM '.DB_PREPEND.'phpwcms_calendar WHERE calendar_id='.$plugin['id'];
 211      $plugin['data'] = _dbQuery($sql);
 212      $plugin['data'] = $plugin['data'][0];
 213      
 214      $plugin['data']['calendar_object'] = @unserialize($plugin['data']['calendar_object']);
 215      
 216      if(is_array($plugin['data']['calendar_object'])) {
 217          if(isset($plugin['data']['calendar_object']['image'])) {
 218              $plugin['data']['calendar_image'] = $plugin['data']['calendar_object']['image'];
 219          }
 220      }
 221  
 222  }
 223  
 224  // default values
 225  if(empty($plugin['data'])) {
 226  
 227      if(isset($_GET['defaultdate'])) {
 228      
 229          $plugin['default_date']    = explode('-', clean_slweg($_GET['defaultdate']));
 230          
 231          $plugin['default_date'][0]    = empty($plugin['default_date'][0]) ? gmdate('d') : $plugin['default_date'][0];
 232          $plugin['default_date'][1]    = empty($plugin['default_date'][1]) ? gmdate('m') : $plugin['default_date'][1];
 233          $plugin['default_date'][2]    = empty($plugin['default_date'][2]) ? gmdate('Y') : $plugin['default_date'][2];
 234          
 235          $plugin['default_date']        = gmmktime(0, 0, 0, $plugin['default_date'][1], $plugin['default_date'][0], $plugin['default_date'][2]);
 236          $plugin['default_date_end']    = $plugin['default_date']+3600;
 237          
 238          $plugin['default_date']        = gmdate('d'.$BLM['date_delimiter'].'m'.$BLM['date_delimiter'].'Y', $plugin['default_date']);
 239          $plugin['default_date_end']    = gmdate('d'.$BLM['date_delimiter'].'m'.$BLM['date_delimiter'].'Y', $plugin['default_date_end']);
 240      
 241      } else {
 242      
 243          $plugin['default_date']        = gmdate('d'.$BLM['date_delimiter'].'m'.$BLM['date_delimiter'].'Y');
 244          $plugin['default_date_end']    = gmdate('d'.$BLM['date_delimiter'].'m'.$BLM['date_delimiter'].'Y', time()+3600);
 245      
 246      }
 247  
 248  
 249      $plugin['data'] = array(
 250      
 251                  'calendar_id'            => 0,
 252                  'calendar_title'        => '',
 253                  'calendar_created'        => '',
 254                  'calendar_changed'        => gmdate('Y-m-d H:i:s'),
 255                  'calendar_tag'            => '',
 256                  'calendar_teaser'        => '',
 257                  'calendar_text'            => '',
 258                  'calendar_object'        => array(),
 259                  'calendar_status'        => 0,
 260                  'calendar_start_date'    => $plugin['default_date'],
 261                  'calendar_end_date'        => $plugin['default_date_end'],
 262                  'calendar_start_time'    => gmdate('H:00'),
 263                  'calendar_end_time'        => gmdate('H:00', time()+3600),
 264                  'calendar_allday'        => 0,
 265                  'calendar_range'        => 0,
 266                  'calendar_where'        => '',
 267                  'calendar_refid'        => '',
 268                  'calendar_duplicate'    => 0,
 269                  'calendar_rangestart'    => '',
 270                  'calendar_rangeend'        => '',
 271                  'calendar_lang'            => ''
 272                                  );
 273  
 274  }
 275  
 276  if(!isset($plugin['data']['calendar_image'])) {
 277      $plugin['data']['calendar_image'] = array('id'=>0, 'name'=>'', 'zoom'=>0, 'lightbox'=>0, 'caption'=>'', 'link'=>'');
 278  } else {
 279      $plugin['data']['calendar_image'] = array_merge( 
 280                      array('id'=>0, 'name'=>'', 'zoom'=>0, 'lightbox'=>0, 'caption'=>'', 'link'=>''),
 281                      $plugin['data']['calendar_image']
 282              );
 283  }
 284  
 285  
 286  
 287  ?>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7