/**
  * Returns the category and tag for the current object
  * 
  * @return array an associativ array with the category and tag
  */
 public function get_category_and_tag()
 {
     global $wpdb;
     $table_name = Ai1ec_Facebook_Factory::get_plugin_table();
     $query = $wpdb->prepare("SELECT category, tag, comments_enabled, map_display_enabled\r\n\t\t\t FROM {$table_name}\r\n\t\t\t WHERE user_id = %s", $this->_id);
     return $wpdb->get_row($query, ARRAY_A);
 }
 /**
  * Loads data about subscription, tag and category in the object.
  */
 private function check_if_user_is_subscribed()
 {
     global $wpdb;
     $table_name = Ai1ec_Facebook_Factory::get_plugin_table();
     $query = $wpdb->prepare("SELECT subscribed, category, tag FROM {$table_name} WHERE user_id = %s", $this->_id);
     $user = $wpdb->get_row($query, ARRAY_A);
     $this->_subscribed = (int) $user['subscribed'] === 1 ? TRUE : FALSE;
     $this->_tag = $user['tag'];
     $this->_category = $user['category'];
 }
 /**
  * Gets the subscribers data from the db
  *
  * @param string $type the type to get
  *
  * @param $current_id The id of the currently logged on user which must be excluded from subscribers and multiselects
  *
  * @return array the results
  */
 private function get_data_for_subscribed_items($type, $current_id)
 {
     global $wpdb;
     $table_name = Ai1ec_Facebook_Factory::get_plugin_table();
     $data = $wpdb->get_results($wpdb->prepare("\n\t\t\t\tSELECT\n\t\t\t\t\tuser_id,\n\t\t\t\t\tuser_name,\n\t\t\t\t\tuser_pic,\n\t\t\t\t\tcategory,\n\t\t\t\t\ttag,\n\t\t\t\t\tcomments_enabled,\n\t\t\t\t\tmap_display_enabled\n\t\t\t\tFROM\n\t\t\t\t\t{$table_name}\n\t\t\t\tWHERE\n\t\t\t\t\tsubscribed = 1 AND\n\t\t\t\t\ttype = %s AND\n\t\t\t\t\tuser_id != %s\n\t\t\t\tORDER BY\n\t\t\t\t\tuser_name ASC\n\t\t\t\t", $type, $current_id), ARRAY_A);
     return $data;
 }
 /**
  * (non-PHPdoc)
  * @see Ai1ec_Connector_Plugin::run_uninstall_procedures()
  */
 public function run_uninstall_procedures()
 {
     // delete our scheduled crons
     $this->disable_cron_functions();
     // Clean up opions
     delete_option(self::FB_OPTION_DB_VERSION);
     delete_option(self::FB_OPTION_CRON_VERSION);
     delete_option(self::FB_OPTION_CRON_NOTICE);
     // Delete tables
     global $wpdb;
     $plugin_table = Ai1ec_Facebook_Factory::get_plugin_table();
     $user_events_table = Ai1ec_Facebook_Factory::get_user_events_table();
     $wpdb->query("DROP TABLE IF EXISTS {$plugin_table}");
     $wpdb->query("DROP TABLE IF EXISTS {$user_events_table}");
 }
 /**
  * Loads the ids of the user that are subscribed for the current type. This is used by the CRON
  *
  * @return TRUE if at least one fgo was loaded, false otherwise
  */
 public function load_subscribers_for_type()
 {
     global $wpdb;
     $table_name = Ai1ec_Facebook_Factory::get_plugin_table();
     $query = $wpdb->prepare("SELECT user_id\n\t\t\t\t\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\t\t\t\t\tWHERE subscribed = 1 AND type = %s", $this->_type);
     $ids = $wpdb->get_col($query);
     $this->_ids = $ids;
     if (count($ids) > 0) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  * Loads the ids of the user that are subscribed for the current type. This is used by the CRON
  *
  * @return TRUE if at least one fgo was loaded, false otherwise
  */
 public function load_subscribers_for_type()
 {
     global $wpdb;
     $table_name = Ai1ec_Facebook_Factory::get_plugin_table();
     $query = $wpdb->prepare('SELECT user_id FROM ' . $table_name . ' WHERE subscribed = 1 AND type = %s', $this->_type);
     $ids = $wpdb->get_col($query);
     $this->_ids = $ids;
     if (count($ids) > 0) {
         return true;
     }
     return false;
 }