home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / calendar / do_event_aed.php < prev    next >
Encoding:
PHP Script  |  2003-05-15  |  1.4 KB  |  48 lines

  1. <?php /* CALENDAR $Id: do_event_aed.php,v 1.5 2003/05/15 00:12:00 korinek Exp $ */
  2. $obj = new CEvent();
  3. $msg = '';
  4.  
  5. $del = dPgetParam( $_POST, 'del', 0 );
  6.  
  7. // bind the POST parameter to the object record
  8. if (!$obj->bind( $_POST )) {
  9.     $AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
  10.     $AppUI->redirect();
  11. }
  12.  
  13. // configure the date and times to insert into the db table
  14. if ($obj->event_start_date) {
  15.     $date = new CDate( $obj->event_start_date.$_POST['start_time'] );
  16.     $obj->event_start_date = $date->format( FMT_DATETIME_MYSQL );
  17. }
  18. if ($obj->event_end_date) {
  19.     $date = new CDate( $obj->event_end_date.$_POST['end_time'] );
  20.     $obj->event_end_date = $date->format( FMT_DATETIME_MYSQL );
  21. }
  22.  
  23. // prepare (and translate) the module name ready for the suffix
  24. $AppUI->setMsg( 'Event' );
  25. if ($del) {
  26.     if (!$obj->canDelete( $msg )) {
  27.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  28.         $AppUI->redirect();
  29.     }
  30.     if (($msg = $obj->delete())) {
  31.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  32.     } else {
  33.         $AppUI->setMsg( "deleted", UI_MSG_ALERT, true );
  34.     }
  35.     $AppUI->redirect( 'm=calendar' );
  36. } else {
  37.     $isNotNew = @$_POST['event_id'];
  38.     if (!$isNotNew) {
  39.         $obj->event_owner = $AppUI->user_id;
  40.     }
  41.     if (($msg = $obj->store())) {
  42.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  43.     } else {
  44.         $AppUI->setMsg( $isNotNew ? 'updated' : 'added', UI_MSG_OK, true );
  45.     }
  46. }
  47. $AppUI->redirect();
  48. ?>