[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/admin/plugins/calendar/ -> index.php (source)

   1  <?php
   2  
   3  /* Reminder: always indent with 4 spaces (no tabs). */
   4  // +---------------------------------------------------------------------------+
   5  // | Calendar Plugin 1.0                                                       |
   6  // +---------------------------------------------------------------------------+
   7  // | index.php                                                                 |
   8  // |                                                                           |
   9  // | Geeklog Calendar Plugin administration page.                              |
  10  // +---------------------------------------------------------------------------+
  11  // | Copyright (C) 2000-2006 by the following authors:                         |
  12  // |                                                                           |
  13  // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
  14  // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
  15  // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
  16  // |          Dirk Haun         - dirk AT haun-online DOT de                   |
  17  // +---------------------------------------------------------------------------+
  18  // |                                                                           |
  19  // | This program is free software; you can redistribute it and/or             |
  20  // | modify it under the terms of the GNU General Public License               |
  21  // | as published by the Free Software Foundation; either version 2            |
  22  // | of the License, or (at your option) any later version.                    |
  23  // |                                                                           |
  24  // | This program is distributed in the hope that it will be useful,           |
  25  // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
  26  // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
  27  // | GNU General Public License for more details.                              |
  28  // |                                                                           |
  29  // | You should have received a copy of the GNU General Public License         |
  30  // | along with this program; if not, write to the Free Software Foundation,   |
  31  // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
  32  // |                                                                           |
  33  // +---------------------------------------------------------------------------+
  34  //
  35  // $Id: index.php,v 1.26 2006/09/03 09:43:36 dhaun Exp $
  36  
  37  require_once  ('../../../lib-common.php');
  38  require_once  ('../../auth.inc.php');
  39  
  40  // Uncomment the line below if you need to debug the HTTP variables being passed
  41  // to the script.  This will sometimes cause errors but it will allow you to see
  42  // the data being passed in a POST operation
  43  // COM_debug($_POST);
  44  
  45  $display = '';
  46  
  47  // Ensure user even has the rights to access this page
  48  if (!SEC_hasRights('calendar.edit')) {
  49      $display .= COM_siteHeader('menu', $MESSAGE[30]);
  50      $display .= COM_startBlock ($MESSAGE[30], '',
  51                                  COM_getBlockTemplate ('_msg_block', 'header'));
  52      $display .= $MESSAGE[35];
  53      $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
  54      $display .= COM_siteFooter();
  55  
  56      // Log attempt to error.log
  57      COM_accessLog("User {$_USER['username']} tried to illegally access the event administration screen.");
  58  
  59      echo $display;
  60  
  61      exit;
  62  }
  63  
  64  
  65  /**
  66  * Shows event editor
  67  *
  68  * @param    string  $mode   Indicates if this is a submission or a regular entry
  69  * @param    array   $A      array holding the event's details
  70  * @param    string  $msg    an optional error message to display
  71  * @return   string          HTML for event editor or error message
  72  *
  73  */
  74  function CALENDAR_editEvent ($mode, $A, $msg = '')
  75  {
  76      global $_CONF, $_GROUPS, $_TABLES, $_USER, $_CA_CONF, $LANG_CAL_1,
  77             $LANG_CAL_ADMIN, $LANG10, $LANG12, $LANG_ACCESS, $LANG_ADMIN,
  78             $MESSAGE;
  79  
  80      $retval = '';
  81  
  82      if (!empty ($msg)) {
  83          $retval .= COM_startBlock ($LANG_CAL_ADMIN[2], '',
  84                          COM_getBlockTemplate ('_msg_block', 'header'));
  85          $retval .= $msg;
  86          $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
  87      }
  88  
  89      $event_templates = new Template($_CONF['path'] . 'plugins/calendar/templates/admin');
  90      $event_templates->set_file('editor','eventeditor.thtml');
  91      $event_templates->set_var('site_url', $_CONF['site_url']);
  92      $event_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
  93      $event_templates->set_var('layout_url',$_CONF['layout_url']);
  94      $event_templates->set_var('lang_allowed_html', COM_allowedHTML());
  95      $event_templates->set_var('lang_postmode', $LANG_CAL_ADMIN[3]);
  96  
  97      if ($mode <> 'editsubmission' AND !empty($A['eid'])) {
  98          // Get what level of access user has to this object
  99          $access = SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']);
 100          if ($access == 0 OR $access == 2) {
 101              // Uh, oh!  User doesn't have access to this object
 102              $retval .= COM_startBlock ($LANG_ACCESS['accessdenied'], '',
 103                                 COM_getBlockTemplate ('_msg_block', 'header'));
 104              $retval .= $LANG_CAL_ADMIN[17];
 105              $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 106              COM_accessLog("User {$_USER['username']} tried to illegally submit or edit event $eid.");
 107              return $retval;
 108          }
 109      } else {
 110          $A['owner_id'] = $_USER['uid'];
 111          if (isset ($_GROUPS['Calendar Admin'])) {
 112              $A['group_id'] = $_GROUPS['Calendar Admin'];
 113          } else {
 114              $A['group_id'] = SEC_getFeatureGroup ('calendar.edit');
 115          }
 116          SEC_setDefaultPermissions ($A, $_CA_CONF['default_permissions']);
 117          $access = 3;
 118      }
 119  
 120      if ($mode == 'editsubmission') {
 121          $event_templates->set_var('post_options', COM_optionList($_TABLES['postmodes'],'code,name','plaintext'));
 122      } else {
 123          if (!isset ($A['postmode'])) {
 124              $A['postmode'] = $_CONF['postmode'];
 125          }
 126          $event_templates->set_var('post_options', COM_optionList($_TABLES['postmodes'],'code,name',$A['postmode']));
 127      }
 128  
 129      $retval .= COM_startBlock($LANG_CAL_ADMIN[1], '',
 130                                COM_getBlockTemplate ('_admin_block', 'header'));
 131  
 132      if (!empty($A['eid'])) {
 133          $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete']
 134                     . '" name="mode"%s>';
 135          $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
 136          $event_templates->set_var ('delete_option',
 137                                     sprintf ($delbutton, $jsconfirm));
 138          $event_templates->set_var ('delete_option_no_confirmation',
 139                                     sprintf ($delbutton, ''));
 140      } else { // new event
 141          $A['eid'] = COM_makesid ();
 142          $A['title'] = '';
 143          $A['description'] = '';
 144          $A['url'] = '';
 145          $A['hits'] = 0;
 146  
 147          // in case a start date/time has been passed from the calendar,
 148          // pick it up for the end date/time
 149          if (empty ($A['dateend'])) {
 150              $A['dateend'] = $A['datestart'];
 151          }
 152          if (empty ($A['timeend'])) {
 153              $A['timeend'] = $A['timestart'];
 154          }
 155          $A['event_type'] = '';
 156          $A['location'] = '';
 157          $A['address1'] = '';
 158          $A['address2'] = '';
 159          $A['city'] = '';
 160          $A['state'] = '';
 161          $A['zipcode'] = '';
 162          $A['allday'] = 0;
 163      }
 164  
 165      $event_templates->set_var('event_id', $A['eid']);
 166      $event_templates->set_var('lang_eventtitle', $LANG_ADMIN['title']);
 167      $A['title'] = str_replace('{','&#123;',$A['title']);
 168      $A['title'] = str_replace('}','&#125;',$A['title']);
 169      $A['title'] = str_replace('"','&quot;',$A['title']);
 170      $event_templates->set_var('event_title', stripslashes ($A['title']));
 171  
 172      $event_templates->set_var('lang_eventtype', $LANG_CAL_1[37]);
 173      $event_templates->set_var('lang_editeventtypes', $LANG12[50]);
 174      $event_templates->set_var('type_options',
 175                                CALENDAR_eventTypeList ($A['event_type']));
 176  
 177      $event_templates->set_var('lang_eventurl', $LANG_CAL_ADMIN[4]);
 178      $event_templates->set_var('max_url_length', 255);
 179      $event_templates->set_var('event_url', $A['url']);
 180      $event_templates->set_var('lang_includehttp', $LANG_CAL_ADMIN[9]);
 181      $event_templates->set_var('lang_eventstartdate', $LANG_CAL_ADMIN[5]);
 182      //$event_templates->set_var('event_startdate', $A['datestart']);
 183      $event_templates->set_var('lang_starttime', $LANG_CAL_1[30]);
 184  
 185      // Combine date/time for easier manipulation
 186      $A['datestart'] = trim ($A['datestart'] . ' ' . $A['timestart']);
 187      if (empty ($A['datestart'])) {
 188          $start_stamp = time ();
 189      } else {
 190          $start_stamp = strtotime ($A['datestart']);
 191      }   
 192      $A['dateend'] = trim ($A['dateend'] . ' ' . $A['timeend']);
 193      if (empty ($A['dateend'])) {
 194          $end_stamp = time ();
 195      } else {
 196          $end_stamp = strtotime ($A['dateend']);
 197      }
 198      $start_month = date('m', $start_stamp);
 199      $start_day = date('d', $start_stamp);
 200      $start_year = date('Y', $start_stamp);
 201      $end_month = date('m', $end_stamp);
 202      $end_day = date('d', $end_stamp);
 203      $end_year = date('Y', $end_stamp);
 204  
 205      $start_hour = date ('H', $start_stamp);
 206      $start_minute = intval (date ('i', $start_stamp) / 15) * 15;
 207      if ($start_hour >= 12) {
 208          $startampm = 'pm';
 209      } else {
 210          $startampm = 'am';
 211      }
 212      $start_hour_24 = $start_hour % 24;
 213      if ($start_hour > 12) {
 214          $start_hour = $start_hour - 12;
 215      } else if ($start_hour == 0) {
 216          $start_hour = 12;
 217      }
 218  
 219      $end_hour = date('H', $end_stamp);
 220      $end_minute = intval (date('i', $end_stamp) / 15) * 15;
 221      if ($end_hour >= 12) {
 222          $endampm = 'pm';
 223      } else {
 224          $endampm = 'am';
 225      }
 226      $end_hour_24 = $end_hour % 24;
 227      if ($end_hour > 12) {
 228          $end_hour = $end_hour - 12;
 229      } else if ($end_hour == 0) {
 230          $end_hour = 12;
 231      }
 232  
 233      $month_options = COM_getMonthFormOptions ($start_month);
 234      $event_templates->set_var ('startmonth_options', $month_options);
 235  
 236      $month_options = COM_getMonthFormOptions ($end_month);
 237      $event_templates->set_var ('endmonth_options', $month_options);
 238  
 239      $day_options = COM_getDayFormOptions ($start_day);
 240      $event_templates->set_var ('startday_options', $day_options);
 241  
 242      $day_options = COM_getDayFormOptions ($end_day);
 243      $event_templates->set_var ('endday_options', $day_options);
 244  
 245      $year_options = COM_getYearFormOptions ($start_year);
 246      $event_templates->set_var ('startyear_options', $year_options);
 247  
 248      $year_options = COM_getYearFormOptions ($end_year);
 249      $event_templates->set_var ('endyear_options', $year_options);
 250  
 251      if (isset ($_CA_CONF['hour_mode']) && ($_CA_CONF['hour_mode'] == 24)) {
 252          $hour_options = COM_getHourFormOptions ($start_hour_24, 24);
 253          $event_templates->set_var ('starthour_options', $hour_options);
 254  
 255          $hour_options = COM_getHourFormOptions ($end_hour_24, 24);
 256          $event_templates->set_var ('endhour_options', $hour_options);
 257  
 258          $event_templates->set_var ('hour_mode', 24);
 259      } else {
 260          $hour_options = COM_getHourFormOptions ($start_hour);
 261          $event_templates->set_var ('starthour_options', $hour_options);
 262  
 263          $hour_options = COM_getHourFormOptions ($end_hour);
 264          $event_templates->set_var ('endhour_options', $hour_options);
 265  
 266          $event_templates->set_var ('hour_mode', 12);
 267      }
 268  
 269      $event_templates->set_var ('startampm_selection', 
 270                          COM_getAmPmFormSelection ('start_ampm', $startampm));
 271      $event_templates->set_var ('endampm_selection', 
 272                          COM_getAmPmFormSelection ('end_ampm', $endampm));
 273  
 274      $event_templates->set_var ('startminute_options',
 275                                 COM_getMinuteFormOptions ($start_minute, 15));
 276      $event_templates->set_var ('endminute_options',
 277                                 COM_getMinuteFormOptions ($end_minute, 15));
 278  
 279      $event_templates->set_var('lang_enddate', $LANG12[13]);
 280      $event_templates->set_var('lang_eventenddate', $LANG_CAL_ADMIN[6]);
 281      $event_templates->set_var('event_enddate', $A['dateend']);
 282      $event_templates->set_var('lang_enddate', $LANG12[13]);
 283      $event_templates->set_var('lang_endtime', $LANG_CAL_1[29]);
 284      $event_templates->set_var('lang_alldayevent', $LANG_CAL_1[31]);
 285      if ($A['allday'] == 1) {
 286          $event_templates->set_var('allday_checked', 'checked="checked"');
 287      }
 288      $event_templates->set_var('lang_location',$LANG12[51]);
 289      $event_templates->set_var('event_location', stripslashes ($A['location']));
 290      $event_templates->set_var('lang_addressline1',$LANG12[44]);
 291      $event_templates->set_var('event_address1', stripslashes ($A['address1']));
 292      $event_templates->set_var('lang_addressline2',$LANG12[45]);
 293      $event_templates->set_var('event_address2', stripslashes ($A['address2']));
 294      $event_templates->set_var('lang_city',$LANG12[46]);
 295      $event_templates->set_var('event_city', stripslashes ($A['city']));
 296      $event_templates->set_var('lang_state',$LANG12[47]);
 297      $event_templates->set_var('state_options', CALENDAR_stateList($A['state']));
 298      $event_templates->set_var('lang_zipcode',$LANG12[48]);
 299      $event_templates->set_var('event_zipcode', $A['zipcode']);
 300      $event_templates->set_var('lang_eventlocation', $LANG_CAL_ADMIN[7]);
 301      $event_templates->set_var('event_location', stripslashes ($A['location']));
 302      $event_templates->set_var('lang_eventdescription', $LANG_CAL_ADMIN[8]);
 303      $event_templates->set_var('event_description', stripslashes ($A['description']));
 304      $event_templates->set_var('lang_hits', $LANG10[30]);
 305      $event_templates->set_var('hits', COM_numberFormat ($A['hits']));
 306      $event_templates->set_var('lang_save', $LANG_ADMIN['save']);
 307      $event_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
 308  
 309      // user access info
 310      $event_templates->set_var('lang_accessrights',$LANG_ACCESS['accessrights']);
 311      $event_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
 312      $ownername = COM_getDisplayName ($A['owner_id']);
 313      $event_templates->set_var('owner_username', DB_getItem($_TABLES['users'],
 314                                'username', "uid = {$A['owner_id']}"));
 315      $event_templates->set_var('owner_name', $ownername);
 316      $event_templates->set_var('owner', $ownername);
 317      $event_templates->set_var('owner_id', $A['owner_id']);
 318      $event_templates->set_var('lang_group', $LANG_ACCESS['group']);
 319      $event_templates->set_var('group_dropdown',
 320                                SEC_getGroupDropdown ($A['group_id'], $access));
 321      $event_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
 322      $event_templates->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
 323      $event_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']));
 324      $event_templates->parse('output', 'editor');
 325      $retval .= $event_templates->finish($event_templates->get_var('output'));
 326      $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'));
 327  
 328      return $retval;
 329  }
 330  
 331  /**
 332  * Saves an event to the database
 333  *
 334  * @param    string  $eid            Event ID
 335  * @param    string  $title          Event Title
 336  * @param    string  $url            URL for the event
 337  * @param    string  $datestart      Date the event begins on
 338  * @param    string  $dateend        Date the event ends on
 339  * @param    string  $location       Where the event will be held at
 340  * @param    string  $description    Description about the event
 341  * @param    string  $postmode       Is this HTML or plain text?
 342  * @param    string  $owner_id       ID of owner
 343  * @param    string  $group_id       ID of group event belongs to
 344  * @param    string  $perm_owner     Permissions the owner has on event
 345  * @param    string  $perm_group     Permissions the groups has on the event
 346  * @param    string  $perm_members   Permisssions members have on the event
 347  * @param    string  $perm_anon      Permissions anonymous users have
 348  * @return   string                  HTML redirect or error message
 349  *
 350  */
 351  function CALENDAR_saveEvent ($eid, $title, $event_type, $url, $allday,
 352                               $start_month, $start_day, $start_year, $start_hour,
 353                               $start_minute, $start_ampm, $end_month, $end_day,
 354                               $end_year, $end_hour, $end_minute, $end_ampm,
 355                               $location, $address1, $address2, $city, $state,
 356                               $zipcode, $description, $postmode, $owner_id,
 357                               $group_id, $perm_owner, $perm_group, $perm_members,
 358                               $perm_anon, $hour_mode)
 359  {
 360      global $_CONF, $_TABLES, $_USER, $LANG_CAL_ADMIN, $MESSAGE;
 361  
 362      $retval = '';
 363  
 364      // Convert array values to numeric permission values
 365      list($perm_owner,
 366          $perm_group,
 367          $perm_members,
 368          $perm_anon) = SEC_getPermissionValues($perm_owner,
 369                                                $perm_group,
 370                                                $perm_members,
 371                                                $perm_anon);
 372  
 373      $access = 0;
 374      if (DB_count ($_TABLES['events'], 'eid', $eid) > 0) {
 375          $result = DB_query ("SELECT owner_id,group_id,perm_owner,perm_group,"
 376                             ."perm_members,perm_anon FROM {$_TABLES['events']} "
 377                             ."WHERE eid = '{$eid}'");
 378          $A = DB_fetchArray ($result);
 379          $access = SEC_hasAccess ($A['owner_id'], $A['group_id'],
 380                  $A['perm_owner'], $A['perm_group'], $A['perm_members'],
 381                  $A['perm_anon']);
 382      } else {
 383          $access = SEC_hasAccess ($owner_id, $group_id, $perm_owner, $perm_group,
 384                  $perm_members, $perm_anon);
 385      }
 386      if (($access < 3) || !SEC_inGroup ($group_id)) {
 387          $retval .= COM_siteHeader('menu', $MESSAGE[30]);
 388          $retval .= COM_startBlock ($MESSAGE[30], '',
 389                              COM_getBlockTemplate ('_msg_block', 'header'));
 390          $retval .= $MESSAGE[31];
 391          $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 392          $retval .= COM_siteFooter();
 393          COM_accessLog ("User {$_USER['username']} tried to illegally submit or edit event $eid.");
 394          return $retval;
 395      }
 396  
 397      if ($hour_mode == 24) {
 398          // to avoid having to mess with the tried and tested code below, map
 399          // the 24-hour values onto their 12-hour counterparts and use those
 400          if ($start_hour >= 12) {
 401              $start_ampm = 'pm';
 402              $start_hour = $start_hour - 12;
 403          } else {
 404              $start_ampm = 'am';
 405              $start_hour = $start_hour;
 406          }
 407          if ($start_hour == 0) {
 408              $start_hour = 12;
 409          }
 410          if ($end_hour >= 12) {
 411              $end_ampm = 'pm';
 412              $end_hour = $end_hour - 12;
 413          } else {
 414              $end_ampm = 'am';
 415              $end_hour = $end_hour;
 416          }
 417          if ($end_hour == 0) {
 418              $end_hour = 12;
 419          }
 420      }
 421  
 422      if ($allday == 'on') {
 423          $allday = 1;
 424      } else {
 425          $allday = 0;
 426      }
 427  
 428      // Make sure start date is before end date
 429      if (checkdate ($start_month, $start_day, $start_year)) {
 430          $datestart = $start_year . '-' . $start_month . '-' . $start_day;
 431          $timestart = $start_hour . ':' . $start_minute . ':00';
 432      } else {
 433          $retval .= COM_siteHeader ('menu', $LANG_CAL_ADMIN[2]);
 434          $retval .= COM_startBlock ($LANG_CAL_ADMIN[2], '',
 435                              COM_getBlockTemplate ('_msg_block', 'header'));
 436          $retval .= $LANG_CAL_ADMIN[23];
 437          $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 438          $retval .= COM_siteFooter ();
 439  
 440          return $retval;
 441      }
 442      if (checkdate ($end_month, $end_day, $end_year)) {
 443          $dateend = $end_year . '-' . $end_month . '-' . $end_day;
 444          $timeend = $end_hour . ':' . $end_minute . ':00';
 445      } else {
 446          $retval .= COM_siteHeader ('menu', $LANG_CAL_ADMIN[2]);
 447          $retval .= COM_startBlock ($LANG_CAL_ADMIN[2], '',
 448                              COM_getBlockTemplate ('_msg_block', 'header'));
 449          $retval .= $LANG_CAL_ADMIN[24];
 450          $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 451          $retval .= COM_siteFooter ();
 452  
 453          return $retval;
 454      }
 455      if ($allday == 0) {
 456          if ($dateend < $datestart) {
 457              $retval .= COM_siteHeader ('menu', $LANG_CAL_ADMIN[2]);
 458              $retval .= COM_startBlock ($LANG_CAL_ADMIN[2], '',
 459                                  COM_getBlockTemplate ('_msg_block', 'header'));
 460              $retval .= $LANG_CAL_ADMIN[25];
 461              $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 462              $retval .= COM_siteFooter ();
 463  
 464              return $retval;
 465          }
 466      } else {
 467          if ($dateend < $datestart) {
 468              // Force end date to be same as start date
 469              $dateend = $datestart;
 470          }
 471      }
 472  
 473      // clean 'em up
 474      if ($postmode == 'html') {
 475          $description = COM_checkHTML (COM_checkWords ($description));
 476      } else {
 477          $postmode = 'plaintext';
 478          $description = htmlspecialchars (COM_checkWords ($description));
 479      }
 480      $description = addslashes ($description);
 481      $title = addslashes (COM_checkHTML (COM_checkWords ($title)));
 482      $location = addslashes (COM_checkHTML (COM_checkWords ($location)));
 483      $address1 = addslashes (COM_checkHTML (COM_checkWords ($address1)));
 484      $address2 = addslashes (COM_checkHTML (COM_checkWords ($address2)));
 485      $city = addslashes (COM_checkHTML (COM_checkWords ($city)));
 486      $zipcode =  addslashes (COM_checkHTML (COM_checkWords ($zipcode)));
 487      $event_type = addslashes (strip_tags (COM_checkWords ($event_type)));
 488      $url = addslashes (strip_tags ($url));
 489  
 490      if ($allday == 0) {
 491          // Add 12 to make time on 24 hour clock if needed
 492          if ($start_ampm == 'pm' AND $start_hour <> 12) {
 493              $start_hour = $start_hour + 12;
 494          }
 495          // If 12AM set hour to 00
 496          if ($start_ampm == 'am' AND $start_hour == 12) {
 497              $start_hour = '00';
 498          }
 499          // Add 12 to make time on 24 hour clock if needed
 500          if ($end_ampm == 'pm' AND $end_hour <> 12) {
 501             $end_hour = $end_hour + 12;
 502          }
 503          // If 12AM set hour to 00
 504          if ($end_ampm == 'am' AND $end_hour == 12) {
 505              $end_hour = '00';
 506          }
 507          $timestart = $start_hour . ':' . $start_minute . ':00';
 508          $timeend = $end_hour . ':' . $end_minute . ':00';
 509      }
 510  
 511      if (!empty ($eid) AND !empty ($description) AND !empty ($title)) {
 512          DB_delete ($_TABLES['eventsubmission'], 'eid', $eid);
 513  
 514          DB_save($_TABLES['events'],
 515                 'eid,title,event_type,url,allday,datestart,dateend,timestart,'
 516                 .'timeend,location,address1,address2,city,state,zipcode,description,'
 517                 .'postmode,owner_id,group_id,perm_owner,perm_group,perm_members,'
 518                 .'perm_anon',
 519                 "'$eid','$title','$event_type','$url',$allday,'$datestart',"
 520                 ."'$dateend','$timestart','$timeend','$location','$address1',"
 521                 ."'$address2','$city','$state','$zipcode','$description','$postmode',"
 522                 ."$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon");
 523          if (DB_count ($_TABLES['personal_events'], 'eid', $eid) > 0) {
 524              $result = DB_query ("SELECT uid FROM {$_TABLES['personal_events']} "
 525                                 ."WHERE eid = '{$eid}'");
 526              $numrows = DB_numRows ($result);
 527              for ($i = 1; $i <= $numrows; $i++) {
 528                  $P = DB_fetchArray ($result);
 529                  DB_save ($_TABLES['personal_events'],
 530                          'eid,title,event_type,datestart,dateend,address1,address2,'
 531                         .'city,state,zipcode,allday,url,description,postmode,'
 532                         .'group_id,owner_id,perm_owner,perm_group,perm_members,'
 533                         .'perm_anon,uid,location,timestart,timeend',
 534                          "'$eid','$title','$event_type','$datestart','$dateend',"
 535                         ."'$address1','$address2','$city','$state','$zipcode',"
 536                         ."$allday,'$url','$description','$postmode',$group_id,"
 537                         ."$owner_id,$perm_owner,$perm_group,$perm_members,"
 538                         ."$perm_anon,{$P['uid']},'$location','$timestart','$timeend'");
 539              }
 540          }
 541          COM_rdfUpToDateCheck ('geeklog', 'calendar', $eid);
 542  
 543          return COM_refresh ($_CONF['site_admin_url']
 544                             .'/plugins/calendar/index.php?msg=17');
 545      } else {
 546          $retval .= COM_siteHeader ('menu', $LANG_CAL_ADMIN[2]);
 547          $retval .= COM_startBlock ($LANG_CAL_ADMIN[2], '',
 548                              COM_getBlockTemplate ('_msg_block', 'header'));
 549          $retval .= $LANG_CAL_ADMIN[10];
 550          $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 551          $retval .= COM_siteFooter ();
 552  
 553          return $retval;
 554      }
 555  }
 556  
 557  
 558  // MAIN
 559  $mode = '';
 560  if (isset($_REQUEST['mode'])) {
 561      $mode = $_REQUEST['mode'];
 562  }
 563  
 564  if (($mode == $LANG_ADMIN['delete']) && !empty ($LANG_ADMIN['delete'])) {
 565      $eid = COM_applyFilter ($_REQUEST['eid']);
 566      if (!isset ($eid) || empty ($eid) || ($eid == 0)) {
 567          COM_errorLog ('Attempted to delete event eid=\''
 568                        . $eid . "'");
 569          $display .= COM_refresh ($_CONF['site_admin_url'] . '/plugins/calendar/index.php');
 570      } else {
 571          $display .= CALENDAR_deleteEvent ($eid);
 572      }
 573  } else if (($mode == $LANG_ADMIN['save']) && !empty ($LANG_ADMIN['save'])) {
 574      if (!isset ($_POST['allday'])) {
 575          $_POST['allday'] = '';
 576      }
 577      $hour_mode = 12;
 578      if (isset ($_POST['hour_mode']) && ($_POST['hour_mode'] == 24)) {
 579          $hour_mode = 24;
 580      }
 581      $display .= CALENDAR_saveEvent (COM_applyFilter ($_POST['eid']),
 582              $_POST['title'], $_POST['event_type'],
 583              $_POST['url'], COM_applyFilter ($_POST['allday']),
 584              COM_applyFilter ($_POST['start_month'], true),
 585              COM_applyFilter ($_POST['start_day'], true),
 586              COM_applyFilter ($_POST['start_year'], true),
 587              COM_applyFilter ($_POST['start_hour'], true),
 588              COM_applyFilter ($_POST['start_minute'], true), $_POST['start_ampm'],
 589              COM_applyFilter ($_POST['end_month'], true),
 590              COM_applyFilter ($_POST['end_day'], true),
 591              COM_applyFilter ($_POST['end_year'], true),
 592              COM_applyFilter ($_POST['end_hour'], true),
 593              COM_applyFilter ($_POST['end_minute'], true), $_POST['end_ampm'],
 594              $_POST['location'], $_POST['address1'], $_POST['address2'],
 595              $_POST['city'], $_POST['state'], $_POST['zipcode'],
 596              $_POST['description'], $_POST['postmode'] ,
 597              COM_applyFilter ($_POST['owner_id'], true),
 598              COM_applyFilter ($_POST['group_id'], true),
 599              $_POST['perm_owner'], $_POST['perm_group'],
 600              $_POST['perm_members'], $_POST['perm_anon'], $hour_mode);
 601  } else if ($mode == 'editsubmission') {
 602      $id = COM_applyFilter ($_REQUEST['id']);
 603      $result = DB_query ("SELECT * FROM {$_TABLES['eventsubmission']} WHERE eid ='$id'");
 604      $A = DB_fetchArray ($result);
 605      $A['hits'] = 0;
 606      $display .= COM_siteHeader ('menu', $LANG_CAL_ADMIN[1]);
 607      $display .= CALENDAR_editEvent ($mode, $A);
 608      $display .= COM_siteFooter ();
 609  } else if ($mode == 'clone') {
 610      $eid = COM_applyFilter ($_REQUEST['eid']);
 611      $result = DB_query ("SELECT * FROM {$_TABLES['events']} WHERE eid ='$eid'");
 612      $A = DB_fetchArray ($result);
 613      $A['eid'] = COM_makesid ();
 614      $A['owner_id'] = $_USER['uid'];
 615      $display .= COM_siteHeader ('menu', $LANG_CAL_ADMIN[1]);
 616      $display .= CALENDAR_editEvent ($mode, $A);
 617      $display .= COM_siteFooter ();
 618  } else if ($mode == 'edit') {
 619      $eid = '';
 620      if (isset ($_REQUEST['eid'])) {
 621          $eid = COM_applyFilter ($_REQUEST['eid']);
 622      }
 623      if (empty ($eid)) {
 624          $A = array ();
 625          $A['datestart'] = '';
 626          $A['timestart'] = '';
 627          if (isset ($_REQUEST['datestart'])) {
 628              $A['datestart'] = COM_applyFilter ($_REQUEST['datestart']);
 629          }
 630          if (isset ($_REQUEST['timestart'])) {
 631              $A['timestart'] = COM_applyFilter ($_REQUEST['timestart']);
 632          }
 633      } else {
 634          $result = DB_query ("SELECT * FROM {$_TABLES['events']} WHERE eid ='$eid'");
 635          $A = DB_fetchArray ($result);
 636      }
 637      $display .= COM_siteHeader ('menu', $LANG_CAL_ADMIN[1]);
 638      $display .= CALENDAR_editEvent ($mode, $A);
 639      $display .= COM_siteFooter ();
 640  } else { // 'cancel' or no mode at all
 641      $display .= COM_siteHeader ('menu', $LANG_CAL_ADMIN[11]);
 642      if (isset ($_REQUEST['msg'])) {
 643          $display .= COM_showMessage (COM_applyFilter ($_REQUEST['msg'],
 644                                                        true), 'calendar');
 645      }
 646      $display .= CALENDAR_listevents();
 647      $display .= COM_siteFooter ();
 648  }
 649  
 650  echo $display;
 651  
 652  ?>


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics