/** * This function is called from ChurchCal when Event was created, updated or deleted * Each event will be iterated through and then decide wheater to create, update or delete event * @param array $params */ function churchservice_operateEventFromChurchCal($params) { $newIds = array(); // shall it be copied? Only when I copy a event in Cal if (getVar("copychurchservice", false) == "true") { $newIds = churchservice_copyEventByCalId($params["orig_id"], $params["id"], $params["startdate"], true); } else { if (!empty($params["csevents"])) { foreach ($params["csevents"] as $key => $csevent) { if (empty($csevent["id"])) { $newId = churchservice_createEvent($params, $csevent); $newIds[$key] = $newId; } else { churchservice_updateEvent($params, $csevent); } } } } return $newIds; }
function churchservice_createEventFromChurchCal($params, $source = null) { $o = _convertCTDateTimeToObjects($params); foreach (getAllDatesWithRepeats(_convertCTDateTimeToObjects($params), -1000, +1000) as $d) { $params["startdate"] = $d->format('Y-m-d H:i:s'); $enddate = clone $d; $enddate->modify("+{$o->diff} seconds"); $params["enddate"] = $enddate->format('Y-m-d H:i:s'); // Wenn es kopiert werden soll if (isset($params["copychurchservice"]) && $params["copychurchservice"] == "true") { churchservice_copyEventByCalId($params["orig_id"], $params["cal_id"], $params["startdate"], true); } else { if (isset($params["eventTemplate"])) { churchservice_saveEvent($params, "churchcal"); } } } }