Ejemplo n.º 1
0
 protected function validate(&$data, $nonce_name)
 {
     global $wpdb;
     # check in parent class if nonce is legal
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid && is_array($data)) {
         $is_valid = true;
         if (empty($data["album_title"])) {
             $is_valid = false;
             $this->add_db_result("album_title", "required", "Album is missing");
         }
         if (!empty($data["album_buy_amazon"]) && !is_valid_url($data["album_buy_amazon"])) {
             $is_valid = false;
             $this->add_db_result("album_buy_amazon", "required", "Amazon url in not valid, the required format is http://buy_link_url");
         }
         if (!empty($data["album_buy_amazon_mp3"]) && !is_valid_url($data["album_buy_amazon_mp3"])) {
             $is_valid = false;
             $this->add_db_result("album_buy_amazon_mp3", "required", "Amazon MP3 url in not valid, the required format is http://buy_link_url");
         }
         if (!empty($data["album_buy_itunes"]) && !is_valid_url($data["album_buy_itunes"])) {
             $is_valid = false;
             $this->add_db_result("album_buy_itunes", "required", "iTunes url in not valid, the required format is http://buy_link_url");
         }
         if (!empty($data["album_buy_link_1"]) && !is_valid_url($data["album_buy_link_1"])) {
             $is_valid = false;
             $this->add_db_result("album_buy_link_1", "required", "Buy Link 1 url in not valid, the required format is http://buy_link_url");
         }
         if (!empty($data["album_buy_link_2"]) && !is_valid_url($data["album_buy_link_2"])) {
             $is_valid = false;
             $this->add_db_result("album_buy_link_2", "required", "Buy Link 2 url in not valid, the required format is http://buy_link_url");
         }
         if (!empty($data["album_buy_link_3"]) && !is_valid_url($data["album_buy_link_3"])) {
             $is_valid = false;
             $this->add_db_result("album_buy_link_3", "required", "Buy Link 3 url in not valid, the required format is http://buy_link_url");
         }
         if (empty($data["artist_name"])) {
             $is_valid = false;
             $this->add_db_result("artist_name", "required", "Artist is missing");
         } else {
             if (!is_numeric($data["track__name"])) {
                 $is_artist = $wpdb->get_row("SELECT artist_id FROM " . WORDTOUR_ARTISTS . " WHERE UPPER(artist_name)='" . trim(strtoupper($data["artist_name"]) . "'"), "ARRAY_A");
                 if ($is_artist) {
                     $data["album_artist_id"] = $is_artist["artist_id"];
                 } else {
                     $is_valid = false;
                     $this->add_db_result("artist_name", "required", "Artist '{$data['artist_name']}' doesn't exist");
                 }
             }
         }
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }
Ejemplo n.º 2
0
 protected function validate(&$data, $nonce_name)
 {
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid && is_array($data)) {
         $is_valid = true;
         if (empty($data["tour_name"])) {
             $is_valid = false;
             $this->add_db_result("tour_name", "required", "Name is missing");
         }
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }
Ejemplo n.º 3
0
 protected function validate(&$data, $nonce_name)
 {
     # check in parent class if nonce is legal
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid && is_array($data)) {
         $is_valid = true;
         if (empty($data["venue_name"])) {
             $is_valid = false;
             $this->add_db_result("venue_name", "required", "Name is missing");
         }
         if (empty($data["venue_country"])) {
             $is_valid = false;
             $this->add_db_result("venue_country", "required", "Country is missing");
         } else {
             $country_code = get_country_by_name($data["venue_country"]);
             if (!$country_code) {
                 $is_valid = false;
                 $this->add_db_result("venue_country", "field", "Country doesn't exist");
             }
         }
         if (!empty($data["venue_state"]) && $country_code == "US") {
             $state_code = get_state_by_name($data["venue_state"]);
             if (!$state_code) {
                 $state_code = get_state_by_code(strtoupper($data["venue_state"]));
             }
             if (!$state_code) {
                 $is_valid = false;
                 $this->add_db_result("venue_state", "field", "The U.S State code is invalid.");
             }
         } else {
             if ($country_code == "US") {
                 $is_valid = false;
                 $this->add_db_result("venue_state", "field", "State is missing");
             }
         }
         if (!empty($data["venue_url"]) && !is_valid_url($data["venue_url"])) {
             $is_valid = false;
             $this->add_db_result("venue_url", "required", "Venue website in not valid, the required format is http://your_website_url");
         }
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }
Ejemplo n.º 4
0
 protected function validate(&$data, $nonce_name)
 {
     global $wpdb;
     # check in parent class if nonce is legal
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid && is_array($data)) {
         $is_valid = true;
         if (empty($data["track_title"])) {
             $is_valid = false;
             $this->add_db_result("track_title", "required", "Title is missing");
         }
         if (!isset($data["track_artist_id"])) {
             if (empty($data["artist_name"])) {
                 $is_valid = false;
                 $this->add_db_result("artist_name", "required", "Artist is missing");
             } else {
                 if (!is_numeric($data["artist_name"])) {
                     $is_artist = $wpdb->get_row("SELECT artist_id FROM " . WORDTOUR_ARTISTS . " WHERE UPPER(artist_name)='" . trim(strtoupper($data["artist_name"]) . "'"), "ARRAY_A");
                     if ($is_artist) {
                         $data["track_artist_id"] = $is_artist["artist_id"];
                     } else {
                         $is_valid = false;
                         $this->add_db_result("artist_name", "required", "Artist '{$data['artist_name']}' doesn't exist");
                     }
                 }
             }
         } else {
             if ($data["track_artist_id"] == 0 || empty($data["track_artist_id"])) {
                 $is_valid = false;
                 $this->add_db_result("artist_name", "required", "Artist is missing");
             }
         }
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }
Ejemplo n.º 5
0
 public function publish($nonce = 0)
 {
     global $wpdb;
     $event_id = $this->id;
     if (parent::validate($nonce, self::NONCE_PUBLISH)) {
         $wpdb->update(WORDTOUR_EVENTS, array("event_published" => 1), array("event_id" => $event_id), array("%d"), array("%d"));
         if ($wpdb->result) {
             $this->retrieve();
             $this->db_result("success", null, array("result" => $this->db_out(), "html" => $this->admin_html("get_event_row_html")));
         } else {
             $this->db_result("error", null, array("msg" => "Error as occured, please try again (<i>" . $wpdb->last_error . "</i>)"));
         }
     }
     return false;
 }
Ejemplo n.º 6
0
 protected function validate(&$data, $nonce_name)
 {
     # check in parent class if nonce is legal
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid && is_array($data)) {
         $is_valid = true;
         if (empty($data["artist_name"])) {
             $is_valid = false;
             $this->add_db_result("artist_name", "required", "Name is missing");
         }
         if (!empty($data["artist_website_url"]) && !is_valid_url($data["artist_website_url"])) {
             $is_valid = false;
             $this->add_db_result("artist_website_url", "required", "Artist website url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_flickr"]) && !is_valid_url($data["artist_flickr"])) {
             $is_valid = false;
             $this->add_db_result("artist_flickr", "required", "Flickr url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_youtube"]) && !is_valid_url($data["artist_youtube"])) {
             $is_valid = false;
             $this->add_db_result("artist_youtube", "required", "YouTube url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_vimeo"]) && !is_valid_url($data["artist_vimeo"])) {
             $is_valid = false;
             $this->add_db_result("artist_vimeo", "required", "Vimeo url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_facebook"]) && !is_valid_url($data["artist_facebook"])) {
             $is_valid = false;
             $this->add_db_result("artist_facebook", "required", "Facebook url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_twitter"]) && !is_valid_url($data["artist_twitter"])) {
             $is_valid = false;
             $this->add_db_result("artist_twitter", "required", "Twitter url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_myspace"]) && !is_valid_url($data["artist_myspace"])) {
             $is_valid = false;
             $this->add_db_result("artist_myspace", "required", "MySpace url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_lastfm"]) && !is_valid_url($data["artist_lastfm"])) {
             $is_valid = false;
             $this->add_db_result("artist_lastfm", "required", "Last.FM url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_reverbnation"]) && !is_valid_url($data["artist_reverbnation"])) {
             $is_valid = false;
             $this->add_db_result("artist_reverbnation", "required", "ReverbNation url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_tumblr"]) && !is_valid_url($data["artist_tumblr"])) {
             $is_valid = false;
             $this->add_db_result("artist_tumblr", "required", "Tumblr url in not valid, the required format is http://your_website_url");
         }
         if (!empty($data["artist_bandcamp"]) && !is_valid_url($data["artist_bandcamp"])) {
             $is_valid = false;
             $this->add_db_result("artist_bandcamp", "required", "BandCamp url in not valid, the required format is http://your_website_url");
         }
         //			if(!empty($data["artist_email"]) && !is_valid_email($data["artist_email"])) {
         //				$is_valid = false ;
         //				$this->add_db_result("artist_email","required","Email address is not valid, the required format is http://your_website_url");
         //			}
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }