public function update($values)
 {
     global $wpdb;
     $event_id = $this->id;
     if ($this->validate($values, self::NONCE_UPDATE)) {
         $data = $this->db_in($values);
         $update = $this->_update($data["event_id"], $data["meta_id"], $data["common"], $data["meta"]);
         if ($update) {
             $update_wpdb = clone $wpdb;
             // delete more artist and add new rows
             try {
                 $wpdb->query("DELETE FROM " . WORDTOUR_EVENTS . " WHERE event_id={$event_id} AND event_is_headline=0");
                 if (is_array($data["artists"])) {
                     foreach ($data["artists"] as $artist_id) {
                         $data["common"]["event_id"] = $event_id;
                         $data["common"]["event_meta_id"] = $data["meta_id"];
                         $data["common"]["event_artist_id"] = $artist_id;
                         $data["common"]["event_is_headline"] = 0;
                         $wpdb->insert(WORDTOUR_EVENTS, $data["common"]);
                     }
                 }
             } catch (Exception $e) {
             }
             if (!empty($values["event_thumbnail_id"]) && is_string($values["event_thumbnail_id"])) {
                 $this->update_thumbnail($values["event_thumbnail_id"], "event");
             }
             if (!empty($values["event_category"]) && is_string($values["event_category"])) {
                 $this->update_category($this->dbprepere->json_in($values["event_category"]), "event");
             }
             if (!empty($values["event_videos"]) && is_string($values["event_videos"])) {
                 $this->update_videos($this->dbprepere->json_in($values["event_videos"]), "event");
             }
             if (!empty($values["event_gallery"]) && is_string($values["event_gallery"])) {
                 $this->update_gallery($this->dbprepere->json_in($values["event_gallery"]), "event");
             }
             if (!empty($values["event_genre"]) && is_string($values["event_genre"])) {
                 $this->update_genre($this->dbprepere->json_in($values["event_genre"]), "event");
             }
             $this->retrieve();
             wordtour_add_event_type($this->data["event_type"]);
             $result = array("result" => $this->db_out(null, 0), "html" => $this->admin_html("get_event_row_html"));
             /* Eventbrite */
             if (!empty($this->data["eventbrite_event_id"])) {
                 $eb = new WT_Eventbrite();
                 $eb->update_event($this->id, $this->db_out(null, 0));
                 if ($eb->response) {
                     $result["eventbrite"] = $eb->response;
                 }
             }
             $this->db_result("success", $update_wpdb, $result);
             return true;
         } else {
             $this->db_result("error", $wpdb, array("msg" => "Error updating Event, please try again(<i>" . $wpdb->last_error . "</i>)"));
             return false;
         }
     }
     return false;
 }
Exemple #2
0
function wordtour_settings_eventbrite_panel($collapsed = 0)
{
    wt_dynamic_panel_start(array("title" => "Eventbrite - <a style=\"font-size:12px;font-weight:normal;color:#21759B;text-decoration:none;\" href=\"http://www.eventbrite.com/r/wt/\" target=\"_blank\">Register</a>", "id" => "wordtour-panel-eventbrite"), "eventbrite", $collapsed);
    global $_wt_options;
    $options = $_wt_options->options();
    $eventbrite = new WT_Eventbrite();
    $auto_eventbrite_checked = $eventbrite->is_update() == 1 ? "checked=1" : "";
    $import_button_state = $eventbrite->is_init() == 1 ? "" : "disabled='true'";
    $organizer_id = $eventbrite->get_organizer_id();
    ?>
	<div class="wordtour-field wordtour-field-block">
		<div class="label">User Key *</div>
		<div>
			<input type="text" size="80" name="wordtour_settings[eventbrite_user_key]" value="<?php 
    echo $options["eventbrite_user_key"];
    ?>
"></input>	
		</div>	
	</div>
	<div class="wordtour-field wordtour-field-block">
		<div class="label">Application Key *</div>
		<div>
			<input type="text" size="80" name="wordtour_settings[eventbrite_app_key]" value="<?php 
    echo $options["eventbrite_app_key"];
    ?>
"></input>	
		</div>	
	</div>
	
	<?php 
    if ($organizer_id) {
        ?>
	<div class="wordtour-field wordtour-field-block">
		<div class="label">Organizer ID</div>
		<div>
			<input type="text" size="80" name="wordtour_settings[eventbrite_organizer_id]" value="<?php 
        echo $organizer_id;
        ?>
"></input>	
		</div>	
	</div>
	<?php 
    }
    ?>
	<div class="wordtour-field wordtour-field-block">
		<input style="width:inherit;" type="checkbox" <?php 
    echo $auto_eventbrite_checked;
    ?>
 name="wordtour_settings[eventbrite_auto_update]" value="1"/> Auto Update Event and Venue Info	
	</div>
	
	<div class="wordtour-field wordtour-field-block">
		<button id="eventbrite-import-button" style='width:100%' <?php 
    echo $import_button_state;
    ?>
>Import Event and Venues</button>	
	</div>
	
	
<?php 
    wt_dynamic_panel_end();
}
<?php

require_once "../../../../wp-load.php";
global $_wt_options, $_wt_time;
$date_format = $_wt_options->options("admin_date_format");
$lastfm_key = $_wt_options->options("lastfm_key");
$flickr_key = $_wt_options->options("flickr_key");
$twitter_key = $_wt_options->options("twitter_api_key");
$facebook_key = $_wt_options->options("facebook_app_id");
$eventbrite = new WT_Eventbrite();
$eventbrite_enabled = $eventbrite->is_init() ? "true" : "false";
?>

; var $CONSTANT = {
	"PLUGIN_AJAX":"<?php 
echo WP_PLUGIN_URL . "/wordtour/admin/plugin-ajax.php";
?>
",
	"ADMIN_URL":"<?php 
echo WT_ADMIN_URL;
?>
",
	"PAGE_EVENTS":"<?php 
echo WT_ADMIN_URL . "page=wordtour/navigation.php";
?>
",
	"PAGE_NEW_EVENT":"<?php 
echo WT_ADMIN_URL . "page=wt_new_event";
?>
",
	"PAGE_ARTISTS":"<?php 
 public function update($values)
 {
     global $wpdb;
     $venue_id = $this->id;
     if ($this->validate($values, self::NONCE_UPDATE)) {
         if ($venue_id) {
             $wpdb->update(WORDTOUR_VENUES, $this->db_in($values), array("venue_id" => $venue_id));
             if ($wpdb->result) {
                 $update_wpdb = clone $wpdb;
                 if (!empty($values["venue_thumbnail_id"]) && is_string($values["venue_thumbnail_id"])) {
                     $this->update_thumbnail($values["venue_thumbnail_id"], "venue");
                 }
                 if (!empty($values["venue_category"]) && is_string($values["venue_category"])) {
                     $this->update_category($this->dbprepere->json_in($values["venue_category"]), "venue");
                 }
                 if (!empty($values["venue_videos"]) && is_string($values["venue_videos"])) {
                     $this->update_videos($this->dbprepere->json_in($values["venue_videos"]), "venue");
                 }
                 if (!empty($values["venue_gallery"]) && is_string($values["venue_gallery"])) {
                     $this->update_gallery($this->dbprepere->json_in($values["venue_gallery"]), "venue");
                 }
                 $this->retrieve();
                 $result = array("result" => $this->db_out(null, 0), "html" => $this->admin_html());
                 /* Eventbrite */
                 $eb = new WT_Eventbrite();
                 if ($eb->is_update()) {
                     $eb->save_venue($this->db_out(null, 0));
                     if ($eb->response) {
                         $result["eventbrite"] = $eb->response;
                     }
                 }
                 /* */
                 $this->db_result("success", $update_wpdb, $result);
                 return true;
             } else {
                 $this->db_result("error", $wpdb, array("msg" => "Error updating venue, please try again<br>" . $wpdb->last_error));
                 return false;
             }
         }
     }
     return false;
 }
             echo json_encode(array("type" => "error", "msg" => "Error publishing event to eventbrite:<p>" . $r["error"]["error_message"] . " (" . $r["error"]["error_type"] . ")</p>"));
             exit;
         } else {
             if ($r["process"]) {
                 $social = new WT_Social();
                 $social_row = $social->get_by_event($_POST["eventbrite_event_id"], "ebevent");
                 echo json_encode(array("type" => "success", "url" => "http://www.eventbrite.com/myevent?eid={$eb_id}", "tickets" => "http://www.eventbrite.com/event/{$eb_id}", "publish_date" => WT_DBPrepere::datetime_short_out($social_row["social_publish_time"]), "eventbrite" => $r));
                 exit;
             }
         }
     } catch (Exception $e) {
     }
     echo json_encode(array("type" => "error", "msg" => "Error connecting to Eventbrite, Please try again later"));
     break;
 case "import-eventbrite-events":
     $eventbrite = new WT_Eventbrite();
     $eventbrite->import($_POST["artist_id"]);
     echo json_encode($eventbrite->response);
     break;
     // GENERAL
 // GENERAL
 case "panel-state":
     if (isset($_POST["page"]) && isset($_POST["panels"])) {
         echo wordtour_update_panel_state($_POST["page"], $_POST["panels"]);
     }
     break;
 case "theme_path":
     global $_wt_options;
     if (isset($_POST["path"]) && !empty($_POST["path"])) {
         $path = trim($_POST["path"]);
         $full_path = realpath(ABSPATH . $path);