/**
  * delete deletes the given entry
  * 
  * @param int $cid entry-id for calendar
  * @return string html-string
  */
 private function delete()
 {
     // check rights
     if (Rights::check_rights($this->get('cid'), 'calendar')) {
         // check cid and pid given
         if ($this->get('cid') !== false && $this->get('pid') !== false) {
             // check cid and pid exists
             if (Calendar::check_id($this->get('cid')) && Preset::check_preset($this->get('pid'), 'calendar')) {
                 // pagecaption
                 $this->tpl->assign('pagecaption', parent::lang('class.AnnouncementView#page#caption#delete'));
                 // prepare return
                 $return = '';
                 // smarty-templates
                 $sConfirmation = new JudoIntranetSmarty();
                 $form = new HTML_QuickForm2('confirm', 'post', array('name' => 'confirm', 'action' => 'announcement.php?id=delete&cid=' . $this->get('cid') . '&pid=' . $this->get('pid')));
                 // add button
                 $form->addElement('submit', 'yes', array('value' => parent::lang('class.AnnouncementView#delete#form#yes')));
                 // smarty-link
                 $link = array('params' => '', 'href' => 'calendar.php?id=listall', 'title' => parent::lang('class.AnnouncementView#delete#title#cancel'), 'content' => parent::lang('class.AnnouncementView#delete#form#cancel'));
                 $sConfirmation->assign('link', $link);
                 $sConfirmation->assign('spanparams', 'id="cancel"');
                 $sConfirmation->assign('message', parent::lang('class.AnnouncementView#delete#message#confirm'));
                 $sConfirmation->assign('form', $form);
                 // validate
                 if ($form->validate()) {
                     // get calendar-object
                     $calendar = new Calendar($this->get('cid'));
                     // get preset
                     $preset = new Preset($this->get('pid'), 'calendar', $this->get('cid'));
                     // get fields
                     $fields = $preset->get_fields();
                     // delete values of the fields
                     if (Calendar::check_ann_value($calendar->get_id(), $calendar->get_preset_id()) === true) {
                         foreach ($fields as $field) {
                             // delete value
                             $field->delete_value();
                         }
                     }
                     // set preset to 0
                     $calendar->update(array('preset_id' => 0));
                     // smarty
                     $sConfirmation->assign('message', parent::lang('class.AnnouncementView#delete#message#done'));
                     $sConfirmation->assign('form', '');
                     // write entry
                     try {
                         $calendar->write_db('update');
                     } catch (Exception $e) {
                         $GLOBALS['Error']->handle_error($e);
                         $output = $GLOBALS['Error']->to_html($e);
                     }
                 }
                 // smarty return
                 return $sConfirmation->fetch('smarty.confirmation.tpl');
             } else {
                 // error
                 $errno = $GLOBALS['Error']->error_raised('WrongParams', 'entry:cid_or_pid', 'cid_or_pid');
                 $GLOBALS['Error']->handle_error($errno);
                 return $GLOBALS['Error']->to_html($errno);
             }
         } else {
             // error
             $errno = $GLOBALS['Error']->error_raised('MissingParams', 'entry:cid_or_pid', 'cid_or_pid');
             $GLOBALS['Error']->handle_error($errno);
             return $GLOBALS['Error']->to_html($errno);
         }
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
 /**
  * delete deletes the given entry
  * 
  * @param int $cid entry-id for calendar
  * @return string html-string
  */
 private function delete($cid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.CalendarView#page#caption#delete') . ": {$cid}");
     // check rights
     if (Rights::check_rights($cid, 'calendar')) {
         // prepare return
         $output = '';
         // smarty-templates
         $sConfirmation = new JudoIntranetSmarty();
         $form = new HTML_QuickForm2('confirm', 'post', array('name' => 'confirm', 'action' => 'calendar.php?id=delete&cid=' . $this->get('cid')));
         // add button
         $form->addElement('submit', 'yes', array('value' => parent::lang('class.CalendarView#delete#form#yes')));
         // smarty-link
         $link = array('params' => '', 'href' => 'calendar.php?id=listall', 'title' => parent::lang('class.CalendarView#delete#title#cancel'), 'content' => parent::lang('class.CalendarView#delete#form#cancel'));
         $sConfirmation->assign('link', $link);
         $sConfirmation->assign('spanparams', 'id="cancel"');
         $sConfirmation->assign('message', parent::lang('class.CalendarView#delete#message#confirm'));
         $sConfirmation->assign('form', $form);
         // validate
         if ($form->validate()) {
             // get calendar-object
             $calendar = new Calendar($cid);
             // disable entry
             $calendar->update(array('valid' => 0));
             // smarty
             $sConfirmation->assign('message', parent::lang('class.CalendarView#delete#message#done'));
             $sConfirmation->assign('form', '');
             // write entry
             try {
                 $calendar->write_db('update');
             } catch (Exception $e) {
                 $GLOBALS['Error']->handle_error($e);
                 return $GLOBALS['Error']->to_html($e);
             }
         }
         // smarty return
         return $sConfirmation->fetch('smarty.confirmation.tpl');
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
Пример #3
0
$dt = $cal->timestamp2ICal($time, FALSE);
print "dt: {$dt}\n";
$time = $cal->iCal2Timestamp(substr($dt, 0, strpos($dt, 'T')));
$dt = $cal->timestamp2ICal($time, TRUE);
print "dt: {$dt}\n";
$r = new RRuleParser('FREQ=HOURLY;INTERVAL=3;UNTIL=20070101T170000Z', '20070101T090000Z', '20070101T090000Z');
$r = new RRuleParser('FREQ=WEEKLY;COUNT=12;INTERVAL=2', '20070101T140000Z', '20070101T120000Z');
print "{$r}\n";
print_r($r->getEventDates('20070301T140000Z', '20070501T140000Z'));
$r = new RRuleParser('FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1', '20070101T000100Z', '20070101T001100Z');
//DTSTART;TZID=US-Eastern:19970105T083000
print "{$r}\n";
$r = new RRuleParser('FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30', '20070101T000100Z', '20070101T001100Z');
print "{$r}\n";
print_r($r->getEventDates('20060101T000100Z', '20060101T001100Z'));
$r = new RRuleParser('FREQ=DAILY;COUNT=10;INTERVAL=2', '20070101T000100Z', '20070101T001100Z');
print "{$r}\n";
foreach ($cal as $obj) {
    var_dump($obj->getBaseComponent());
}
$bak = $cal['3ba46312e910765bf7059a53909d149b'];
print_r($bak);
print_r(new Icalendar(array('SUMMARY' => 'test')));
$cal['3ba46312e910765bf7059a53909d149b'] = new Icalendar(array('SUMMARY' => 'test'));
print_r($cal['3ba46312e910765bf7059a53909d149b']);
unset($cal['3ba46312e910765bf7059a53909d149b']);
var_dump($cal['3ba46312e910765bf7059a53909d149b']);
$cal['3ba46312e910765bf7059a53909d149b'] = $bak;
var_dump($cal['3ba46312e910765bf7059a53909d149b']);
$cal->update();
print_r($cal['3ba46312e910765bf7059a53909d149b']);