public function delete()
 {
     if ($this->shub_message_id) {
         shub_delete_from_db('shub_message', 'shub_message_id', $this->shub_message_id);
     }
 }
 public function delete()
 {
     if ($this->{$this->db_primary_key}) {
         shub_delete_from_db($this->db_table, $this->db_primary_key, $this->{$this->db_primary_key});
     }
 }
 public function delete()
 {
     if ($this->shub_item_id) {
         // delete all the messages for this item.
         $messages = shub_get_multiple('shub_message', array('shub_item_id' => $this->shub_item_id), 'shub_message_id');
         foreach ($messages as $message) {
             if ($message && isset($message['shub_item_id']) && $message['shub_item_id'] == $this->shub_item_id) {
                 shub_delete_from_db('shub_message', 'shub_message_id', $message['shub_message_id']);
                 shub_delete_from_db('shub_message_comment', 'shub_message_id', $message['shub_message_id']);
                 shub_delete_from_db('shub_message_link', 'shub_message_id', $message['shub_message_id']);
                 shub_delete_from_db('shub_message_read', 'shub_message_id', $message['shub_message_id']);
             }
         }
         shub_delete_from_db('shub_item', 'shub_item_id', $this->shub_item_id);
     }
 }
 public function delete()
 {
     if ($this->shub_product_id) {
         shub_delete_from_db('shub_product', 'shub_product_id', $this->shub_product_id);
     }
 }
 public function init()
 {
     if (isset($_REQUEST['_process'])) {
         // fix up WordPress bork:
         // todo: don't overwrite default superglobals, run stripslashes every time before we use the content, because another plugin might be stripslashing already
         $_POST = stripslashes_deep($_POST);
         $_GET = stripslashes_deep($_GET);
         $_REQUEST = stripslashes_deep($_REQUEST);
         $process_action = $_REQUEST['_process'];
         $process_options = array();
         $shub_message_id = false;
         if ($process_action == 'send_shub_message' && check_admin_referer('shub_send-message')) {
             // we are sending a social message! yay!
             $send_time = time();
             // default: now
             if (isset($_POST['schedule_date']) && isset($_POST['schedule_time']) && !empty($_POST['schedule_date']) && !empty($_POST['schedule_time'])) {
                 $date = $_POST['schedule_date'];
                 $time_hack = $_POST['schedule_time'];
                 $time_hack = str_ireplace('am', '', $time_hack);
                 $time_hack = str_ireplace('pm', '', $time_hack);
                 $bits = explode(':', $time_hack);
                 if (strpos($_POST['schedule_time'], 'pm')) {
                     $bits[0] += 12;
                 }
                 // add the time if it exists
                 $date .= ' ' . implode(':', $bits) . ':00';
                 $send_time = strtotime($date);
                 //echo $date."<br>".$send_time."<br>".shub_print_date($send_time,true);exit;
             } else {
                 if (isset($_POST['schedule_date']) && !empty($_POST['schedule_date'])) {
                     $send_time = strtotime($_POST['schedule_date']);
                 }
             }
             // wack a new entry into the shub_message database table and pass that onto our message_managers below
             $shub_message_id = shub_update_insert('shub_message_id', false, 'shub_message', array('post_id' => isset($_POST['post_id']) ? $_POST['post_id'] : 0, 'sent_time' => $send_time));
             if ($shub_message_id) {
                 $process_options['shub_message_id'] = $shub_message_id;
                 $process_options['send_time'] = $send_time;
             } else {
                 die('Failed to create social message');
             }
             /* @var $message_manager shub_facebook */
             $message_count = 0;
             foreach ($this->message_managers as $name => $message_manager) {
                 $message_count += $message_manager->handle_process($process_action, $process_options);
             }
             if ($shub_message_id && !$message_count) {
                 // remove the gobal social message as nothing worked.
                 shub_delete_from_db('shub_message', 'shub_message_id', $shub_message_id);
             } else {
                 if ($shub_message_id) {
                     shub_update_insert('shub_message_id', $shub_message_id, 'shub_message', array('message_count' => $message_count));
                 }
             }
             if (isset($_POST['debug']) && $_POST['debug']) {
                 echo "<br><hr> Successfully sent {$message_count} messages <hr><br><pre>";
                 print_r($_POST);
                 print_r($process_options);
                 echo "</pre><hr><br>Completed";
                 exit;
             }
             header("Location: admin.php?page=support_hub_sent");
             exit;
         } else {
             if ($process_action == 'save_general_settings') {
                 if (check_admin_referer('save-general-settings')) {
                     if (isset($_POST['possible_shub_manager_enabled'])) {
                         foreach ($_POST['possible_shub_manager_enabled'] as $id => $tf) {
                             if (isset($_POST['shub_manager_enabled'][$id]) && $_POST['shub_manager_enabled'][$id]) {
                                 update_option('shub_manager_enabled_' . $id, 1);
                             } else {
                                 update_option('shub_manager_enabled_' . $id, 0);
                             }
                         }
                         header("Location: admin.php?page=support_hub_settings");
                         exit;
                     }
                 }
             } else {
                 if ($process_action == 'save_log_settings') {
                     if (check_admin_referer('save-log-settings')) {
                         if (!empty($_POST['enable_logging'])) {
                             update_option('shub_logging_enabled', time() + 3600 * 24);
                         }
                         if (!empty($_POST['remove_logs'])) {
                             global $wpdb;
                             $wpdb->query($wpdb->prepare("DELETE FROM `" . _support_hub_DB_PREFIX . "shub_log` WHERE log_time <= %d", $_POST['remove_logs']));
                         }
                         header("Location: admin.php?page=support_hub_settings&tab=logs");
                         exit;
                     }
                 } else {
                     if ($process_action == 'save_encrypted_vault') {
                         if (check_admin_referer('save-encrypted-vault') && !empty($_POST['public_key']) && !empty($_POST['private_key'])) {
                             update_option('shub_encrypt_public_key', $_POST['public_key']);
                             update_option('shub_encrypt_private_key', $_POST['private_key']);
                             header("Location: admin.php?page=support_hub_settings&tab=extra");
                             exit;
                         }
                     } else {
                         if ($process_action == 'save_extra_details') {
                             $shub_extra_id = !empty($_REQUEST['shub_extra_id']) ? (int) $_REQUEST['shub_extra_id'] : 0;
                             if (check_admin_referer('save-extra' . $shub_extra_id)) {
                                 $shub_extra = new SupportHubExtra($shub_extra_id);
                                 if (isset($_REQUEST['butt_delete'])) {
                                     $shub_extra->delete();
                                     header("Location: admin.php?page=support_hub_settings&tab=extra");
                                     exit;
                                 }
                                 if (!$shub_extra->get('shub_extra_id')) {
                                     $shub_extra->create_new();
                                 }
                                 $shub_extra->update($_POST);
                                 $shub_extra_id = $shub_extra->get('shub_extra_id');
                                 header("Location: admin.php?page=support_hub_settings&tab=extra");
                                 //&shub_extra_id=" . $shub_extra_id );
                                 exit;
                             }
                         } else {
                             if ($process_action == 'save_product_details') {
                                 $shub_product_id = !empty($_REQUEST['shub_product_id']) ? (int) $_REQUEST['shub_product_id'] : 0;
                                 if (check_admin_referer('save-product' . $shub_product_id)) {
                                     $shub_product = new SupportHubProduct($shub_product_id);
                                     if (isset($_REQUEST['butt_delete'])) {
                                         $shub_product->delete();
                                         header("Location: admin.php?page=support_hub_settings&tab=products");
                                         exit;
                                     }
                                     if (!$shub_product->get('shub_product_id')) {
                                         $shub_product->create_new();
                                     }
                                     $shub_product->update($_POST);
                                     $shub_product_id = $shub_product->get('shub_product_id');
                                     header("Location: admin.php?page=support_hub_settings&tab=products");
                                     //&shub_product_id=" . $shub_product_id );
                                     exit;
                                 }
                             } else {
                                 // just process each request normally:
                                 /* @var $message_manager shub_facebook */
                                 foreach ($this->message_managers as $name => $message_manager) {
                                     $message_manager->handle_process($process_action, $process_options);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function delete()
 {
     if ($this->shub_extra_data_id) {
         shub_delete_from_db('shub_extra_data', 'shub_extra_data_id', $this->shub_extra_data_id);
     }
 }
 public function delete()
 {
     if ($this->shub_account_id) {
         // delete all the items for this twitter account.
         $items = $this->get('items');
         foreach ($items as $item) {
             $item->delete();
         }
         shub_delete_from_db('shub_account', 'shub_account_id', $this->shub_account_id);
     }
 }