Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 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;
 }