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["gallery_name"])) { $is_valid = false; $this->add_db_result("gallery_name", "required", "Name is missing"); } if (!$is_valid) { $this->db_result("error", null, array("data" => $this->db_response_msg)); } } return $is_valid; }
public function update($nonce = 0, $social_id = 0, $type = "", $id = 0, $ref_id = 0, $parent_type = "event") { global $wpdb; if (parent::validate($nonce, self::NONCE_INSERT)) { if ($id) { $wpdb->update(WORDTOUR_SOCIAL, array('social_parent_id' => $id, 'social_parent_type' => $parent_type, 'social_type' => $type, 'social_publish_time' => current_time("mysql", 0), 'social_ref_id' => $ref_id), array("social_id" => $social_id), array('%d', '%s', '%s', '%s', '%d'), array('%d')); if ($wpdb->result) { $update_wpdb = clone $wpdb; $this->retrieve(); $this->db_result("success", $update_wpdb, array("result" => $this->db_out($this->data))); return true; } else { $this->db_result("error", $wpdb, array("msg" => "Update was succesfull, unfortontly database didnt updated with recent changes(<i>" . $wpdb->last_error . "</i>)")); return false; } return $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WORDTOUR_SOCIAL . " WHERE social_parent_id={$id} AND social_type='{$type}'"), "ARRAY_A"); } } return 0; }
protected function validate(&$data, $nonce_name) { # check in parent class if nonce is legal $is_valid = parent::validate($data["_post_nonce"], $nonce_name); if ($is_valid) { // if(empty($data["post_title"])) { // $is_valid = false ; // $this->add_db_result("post_title","required","Title is missing"); // } // // if(empty($data["post_event_id"])) { // $is_valid = false ; // $this->add_db_result("post_event_id","required","Event Id is missing"); // } if (!$is_valid) { $this->db_result("error", null, array("data" => $this->db_response_msg)); } } return $is_valid; }
public function delete_all($comment_id = array(), $nonce = "") { global $wpdb; if (parent::validate($nonce, self::NONCE_DELETE)) { $result = array(); foreach ($comment_id as $id) { $this->id = $id; $this->delete(null, $id, 0); $result[$id] = $this->db_result; } $this->db_result = $result; } return false; }