/**
  * Implements the filtering for events that are exportable to facebook
  *
  * @param string $where the where clause currently in use by wordpress
  *
  * @return string the updated where clause
  */
 public function facebook_filter_posts_where($where)
 {
     $type = '';
     $end = '';
     // If we have something to query
     if (isset($_GET[self::FB_SELECT_NAME]) && !empty($_GET[self::FB_SELECT_NAME])) {
         // Let's see what was requested
         switch ($_GET[self::FB_SELECT_NAME]) {
             case Ai1ecFacebookConnectorPlugin::FB_EXPORTED_EVENT:
                 $type = Ai1ecFacebookConnectorPlugin::FB_EXPORTED_EVENT;
                 break;
             case Ai1ecFacebookConnectorPlugin::FB_IMPORTED_EVENT:
                 $type = Ai1ecFacebookConnectorPlugin::FB_IMPORTED_EVENT;
                 break;
             default:
                 $type = '';
                 // Select only events that end in the future.
                 $end = ' and end > NOW()';
                 break;
         }
         $table_name = Ai1ec_Facebook_Factory::get_events_table();
         // update the query
         $where .= " AND ID in ( SELECT post_id from {$table_name} WHERE facebook_status = '{$type}' {$end} ) ";
     }
     return $where;
 }
 /**
  * Get the wordpress post id for this facebook event
  *
  * @return int the wordpress post id
  */
 public function get_wordpress_post_id_from_facebook_event_id()
 {
     global $wpdb;
     $ai1ec_event_Table = Ai1ec_Facebook_Factory::get_events_table();
     $query = $wpdb->prepare("SELECT post_id FROM {$ai1ec_event_Table} where facebook_eid = %s", $this->id);
     $post_id = $wpdb->get_var($query);
     return $post_id;
 }
 /**
  * Private, used to log events to check if cron works
  */
 private function log_number_of_events()
 {
     global $wpdb;
     $event_table = Ai1ec_Facebook_Factory::get_events_table();
     $event_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$event_table};"));
     error_log("There are {$event_count} in the table {$event_table}");
 }
 /**
  * Get the post id from the event id
  *
  * @param int $eid the event id
  *
  * @return int|NULL the post id or NULL if nothing is found.
  */
 private function get_post_id_from_eid($eid)
 {
     global $wpdb;
     $table_name = Ai1ec_Facebook_Factory::get_events_table();
     $query = $wpdb->prepare("SELECT post_id FROM {$table_name} WHERE facebook_eid = %s", $eid);
     return $wpdb->get_var($query);
 }