/** * change existing cycledate, changes also corresponding single dates * * @param array assoc, see CycleData, metadate_id must be in $data['cycle_id'] * @return number|boolean */ function editCycle($data = array()) { $cycle = $this->cycles[$data['cycle_id']]; $new_start = mktime((int) $data['start_stunde'], (int) $data['start_minute']); $new_end = mktime((int) $data['end_stunde'], (int) $data['end_minute']); $old_start = mktime($cycle->getStartStunde(), $cycle->getStartMinute()); $old_end = mktime($cycle->getEndStunde(), $cycle->getEndMinute()); if ($new_start >= $old_start && $new_end <= $old_end && $data['day'] == $cycle->day && $data['endWeek'] == $cycle->end_offset) { // Zeitraum wurde verkuerzt, Raumbuchungen bleiben erhalten... if ($this->setCycleData($data, $cycle)) { $termine = $cycle->getSingleDates(); foreach ($termine as $key => $val) { $tos = $val->getStartTime(); $toe = $val->getEndTime(); if ($toe > time()) { $t_start = mktime((int) $data['start_stunde'], (int) $data['start_minute'], 0, date('m', $tos), date('d', $tos), date('Y', $tos)); $t_end = mktime((int) $data['end_stunde'], (int) $data['end_minute'], 0, date('m', $toe), date('d', $toe), date('Y', $toe)); $termine[$key]->setTime($t_start, $t_end); $termine[$key]->store(); } else { unset($termine[$key]); } } $this->sortCycleData(); } return sizeof($termine); } else { if ($this->setCycleData($data, $cycle)) { // collect all existing themes (issues) for this cycle: $issues = array(); $issue_objects = array(); $singledate_count = 0; // loop through the single dates and look for themes (issues) $termine = $cycle->getSingleDates(); foreach ($termine as $key => $termin) { // get all isues of this date ( zero, one, or more, if the expert view is activated) // and store them at the relative position of this single date $issues[$singledate_count] = $termin->getIssueIDs(); $singledate_count++; } // remove all SingleDates in the future for this CycleData $count = CycleDataDB::deleteNewerSingleDates($data['cycle_id'], time(), true); // create new SingleDates $this->createSingleDates(array('metadate_id' => $cycle->getMetaDateId(), 'startAfterTimeStamp' => time())); // clear all loaded SingleDates so no odd ones remain. The Seminar-Class will load them fresh when needed $cycle->termine = NULL; // read all new single dates $termine = $cycle->getSingleDates(); // new dates counter $new_singledate_count = 0; // loop through the single dates and add the themes (issues) foreach ($termine as $key => $termin) { // check, if there are issues for this single date if ($issues[$new_singledate_count] != NULL) { // add all issues: foreach ($issues[$new_singledate_count] as $issue_key => $issue_id) { $termin->addIssueID($issue_id); $termin->store(); } } unset($issues[$new_singledate_count]); $new_singledate_count++; } // delete issues, that are not assigned to a single date because of to few dates // (only if the schedule expert view is off) if (!Config::get()->RESOURCES_ENABLES_EXPERT_SCHEDULE_VIEW) { if ($new_singledate_count < $singledate_count) { for ($i = $new_singledate_count; $i < $singledate_count; $i++) { if ($issues[$i] != NULL) { foreach ($issues[$i] as $issue_id) { // delete this issue IssueDB::deleteIssue($issue_id); } } } } } $this->sortCycleData(); return $count; } } return FALSE; }
function delete() { $dates = IssueDB::getDatesforIssue($this->issue_id); $titles = array(); $title = ''; foreach ($dates as $termin_id => $termin_data) { $titles[] = date('d.m.y, H:i', $termin_data['date']) . ' - ' . date('H:i', $termin_data['end_time']); } if (sizeof($titles) > 0) { $title = implode(', ', $titles) . ', ' . $this->getTitle() . ' ' . _("(Thema gelöscht)"); } else { $title = $this->getTitle() . ' ' . _("(Thema gelöscht)"); } $description = _("Dateiordner bezieht sich auf ein nicht mehr vorhandenes Thema."); IssueDB::deleteIssue($this->issue_id, $this->seminar_id, $title, $description); }