Exemplo n.º 1
0
 public function import($artist_id = 0)
 {
     $results = array();
     if (!$artist_id || empty($artist_id)) {
         $this->is_valid_response('{"error": {"error_type": "Artist Missing", "error_message": "Can\\"t import events without an artist"}}');
     } else {
         // get list of all venues
         $venues = wt_file_get_contents("http://www.eventbrite.com/json/user_list_venues?app_key={$this->app_key}&user_key={$this->user_key}");
         $venues_parents = array();
         if ($this->is_valid_response($venues)) {
             $social = new WT_Social();
             try {
                 if (!$this->response["venues"]) {
                     throw new Exception("Connection Error");
                 }
                 foreach ($this->response["venues"] as $v) {
                     $venue_id = 0;
                     $social_regist = $social->get_by_ref_id($v["venue"]["id"], "venue", "ebvenue");
                     if (!$social_regist) {
                         $venue_params = array("_nonce" => wp_create_nonce(WT_Venue::NONCE_INSERT), "venue_name" => $v["venue"]["name"], "venue_city" => $v["venue"]["city"], "venue_country" => get_country_by_code($v["venue"]["country_code"]), "venue_state" => get_state_by_code($v["venue"]["region"]), "venue_zip" => $v["venue"]["postal_code"], "venue_address" => $v["venue"]["address"], "venue_tour_status" => 1, "venue_gallery_status" => 1, "venue_video_status" => 1, "venue_flickr_status" => 1, "venue_post_status" => 1);
                         $venue = new WT_Venue();
                         $venue->insert($venue_params, 0);
                         if ($venue->data) {
                             $venue_id = $venue->data["venue_id"];
                             $social->insert(wp_create_nonce(WT_SOCIAL::NONCE_INSERT), "ebvenue", $venue->data["venue_id"], $v["venue"]["id"], "venue");
                         } else {
                             $results["venues"][] = array("venue" => $v["venue"], "msg" => $venue->db_response());
                         }
                     } else {
                         $venue_id = $social_regist["social_parent_id"];
                     }
                     if ($venue_id) {
                         $venues_parents[$v["venue"]["id"]] = $venue_id;
                     }
                 }
                 $events = wt_file_get_contents("http://www.eventbrite.com/json/user_list_events?app_key={$this->app_key}&user_key={$this->user_key}");
                 if ($this->is_valid_response($events)) {
                     if (!$this->response["events"]) {
                         throw new Exception("Connection Error");
                     }
                     foreach ($this->response["events"] as $e) {
                         if ($e["event"]["status"] != "Canceled") {
                             $social_regist = $social->get_by_ref_id($e["event"]["id"], "event", "ebevent");
                             if (!$social_regist) {
                                 $event_params = array("_nonce" => wp_create_nonce(WT_Event::NONCE_INSERT), "event_title" => $e["event"]["title"], "event_notes" => $e["event"]["description"], "event_start_date" => mysql2date("Y-m-d", $e["event"]["start_date"]), "event_start_time" => mysql2date("H:i:s", $e["event"]["start_date"]), "event_end_date" => mysql2date("Y-m-d", $e["event"]["end_date"]), "event_end_time" => mysql2date("H:i:s", $e["event"]["end_date"]), "event_venue_id" => $venues_parents[$e["event"]["venue"]["id"]], "event_artist_id" => $artist_id, "event_published" => 1, 'event_status' => $e["event"]["status"] == "Canceled" ? "cancelled" : "active", "tkts_url" => $e["event"]["url"], "tkts_price" => $e["ticket"]["price"] . $e["ticket"]["currency"], 'comment_status' => 1, 'rsvp_status' => 1, 'gallery_status' => 1, 'flickr_status' => 1, 'post_status' => 1, 'video_status' => 1);
                                 $event = new WT_Event();
                                 $event->insert($event_params, 0);
                                 if ($event->data) {
                                     $event_id = $event->data["event_id"];
                                     $social->insert(wp_create_nonce(WT_SOCIAL::NONCE_INSERT), "ebevent", $event->data["event_id"], $e["event"]["id"], "event");
                                 } else {
                                     $results["events"][] = array("event" => $e["event"], "msg" => $event->db_response());
                                 }
                             }
                         }
                     }
                     $this->response = array("type" => "success", "log" => $results);
                     return 1;
                 }
             } catch (Exception $e) {
                 $this->is_valid_response(0);
             }
         }
     }
     $this->response = array("type" => "error", "log" => $this->response);
 }
Exemplo n.º 2
0
     }
     break;
     // EVENTS
 // EVENTS
 case "get_event":
     $event = new WT_Event($_POST["event_id"]);
     if (!empty($_POST["event_id"])) {
         $event->retrieve();
     } else {
         $event->defaults();
     }
     echo json_encode($event->db_out(null, 0));
     break;
 case "insert_event":
     $event = new WT_Event();
     $event->insert($_POST);
     $event->db_response("json");
     break;
 case "update_event":
     $event = new WT_Event($_POST["event_id"]);
     $event->update($_POST);
     $event->db_response("json");
     break;
 case "quickupdate_event":
     $event = new WT_Event($_POST["event_id"]);
     $event->quick_update($_POST);
     $event->db_response("json");
     break;
 case "delete_event":
     $event = new WT_Event($_POST["event_id"]);
     $event->delete($_POST["_nonce"]);