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(); }
public function deletePlace() { if (array_key_exists("action", $_POST) && $_POST['action'] == 'club_calendar_delete_place') { $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-place-" . $uuid)) { echo Calendar\Place::findById($uuid)->delete(); } } wp_die(); }
<span id="dateTo_picker"></span><br /> <span id="divToHelp" class="help-block"></span> </div> </div> </div> </div> <div class="form-group" id="divOrt" class="can-have-error"> <label for="txtPlace" class="col-sm-2 control-label">Ort</label> <div class="col-sm-10"> <div class="row"> <div class="col-sm-10"> <span id="txtPlaceChoose"> <select class="form-control can-have-error combobox" id="txtPlace" data-divid="divOrt"> <option value="">Bitte Ort auswählen ...</option> <?php foreach (\Club\Admin\Calendar\Place::getAll() as $place) { $selected = ""; if ($event->getPlace() != null && $place->getUuid() == $event->getPlace()->getUuid()) { $selected = ' selected="selected"'; } ?> <option<?php echo $selected; ?> value="<?php echo $place->getUuid(); ?> "><?php echo $place->getName(); ?> </option>
<?php $places = \Club\Admin\Calendar\Place::getAll(); ?> <div class="bootstrap-wrapper"> <div class="container"> <h1>Club Termine Orte</h1> <table class="table table-hover table-striped"> <thead> <tr> <td>Name</td> <td>Latitude</td> <td>Longitude</td> <td> </td> </tr> </thead> <tbody> <?php foreach ($places as $place) { ?> <tr id="<?php echo $place->getUuid(); ?> "> <td name="name"><?php echo $place->getName(); ?> </td> <td><?php echo $place->getLat(); ?>
protected static function fromStdClass($obj) { $ret = new self($obj->eventid); $ret->setTitle($obj->title); $ret->setDescripion($obj->desc); $ret->setFrom(\DateTime::createFromFormat('Y-m-d H:i:s', $obj->from, new \DateTimeZone("UTC"))); $ret->setTo(\DateTime::createFromFormat('Y-m-d H:i:s', $obj->to, new \DateTimeZone("UTC"))); $ret->getFrom()->setTimezone(new \DateTimeZone(get_option('timezone_string'))); $ret->getTo()->setTimezone(new \DateTimeZone(get_option('timezone_string'))); $ret->setPlace(Place::findById($obj->placeid)); $ret->setPostId($obj->postid); return $ret; }