public function saveEvent() { if (array_key_exists("action", $_POST) && $_POST['action'] == 'club_calendar_save_event') { $id = null; $event = null; if (array_key_exists("uuid", $_POST)) { $id = $_POST["uuid"]; $event = \Club\Admin\Calendar\Event::findById($id); } else { $event = new \Club\Admin\Calendar\Event($id); } $event->fromPost($_POST, $this->getDateFormat()); $place = null; $newPlace = array_key_exists("newPlace", $_POST) ? filter_var(strtolower($_POST["newPlace"]), FILTER_VALIDATE_BOOLEAN) : false; if (!$newPlace) { $id = $_POST["place"]; $place = \Club\Admin\Calendar\Place::findById($id); } else { $place = new \Club\Admin\Calendar\Place(); $place->setName($_POST["place"]); $place->setLat($_POST["lat"]); $place->setLng($_POST["lng"]); $place->save(false); } $event->setPlace($place); $shortCode = "[club_event event_id=" . $event->getUuid() . " type=event]"; $postId = wp_insert_post(array("ID" => $event->getPostId(), "post_title" => $event->getTitle(), "post_content" => $shortCode, "post_type" => "club_event", "post_status" => "publish", "guid" => $event->getUuid())); $event->setPostId($postId); $event->save($id == null ? false : true); echo json_encode($event); } wp_die(); }
<?php $event = \Club\Admin\Calendar\Event::findById($atts['event_id']); ?> <div class="bootstrap-wrapper"> <div class="container-no-padding container"> <div class="row"> <div class="col-xs-2"> <strong>Wann:</strong> </div> <div class="col-xs-10"> <?php echo $event->getFromFormated(); ?> bis <?php echo $event->getToFormated(); ?> </div> </div> <div class="row"> <div class="col-xs-2"> <strong>Ort:</strong> </div> <div class="col-xs-10"> <?php echo $event->getPlace()->getName(); ?> </div> </div> <?php
public function deleteEvent() { if (array_key_exists("action", $_POST) && $_POST['action'] == 'club_calendar_delete_evnet') { $nonce = array_key_exists("nonce", $_POST) ? $_POST["nonce"] : null; $uuid = array_key_exists("uuid", $_POST) ? $_POST["uuid"] : null; if (wp_verify_nonce($nonce, "club-delete-event-" . $uuid)) { echo Calendar\Event::findById($uuid)->delete(); } } wp_die(); }
<?php use Ramsey\Uuid\Uuid; use Club\Admin\Calendar\Event; $uuid = filter_input(INPUT_GET, "uuid"); $edit = false; $event = null; if (!Uuid::isValid($uuid)) { $uuid = null; $event = new Event(); } else { $event = Event::findById($uuid); $edit = true; } $defaultFormat = ""; $momentFormat = ""; $module = \Club\Club::getInstance()->getModules()->getModuleInstance("calendar"); if ($module != NULL) { $defaultFormat = $module->getDateFormat(); $momentFormat = $module->getDateFormat("moment"); } ?> <div class="bootstrap-wrapper"> <div class="container"> <h1>Club Termine</h1> <form class="form-horizontal"> <div class="form-group" id="divTitle" class="can-have-error"> <label for="txtTitle" class="col-sm-2 control-label">Title</label> <div class="col-sm-10"> <input type="text" class="form-control can-have-error" value="<?php