public function handle_ajax($action, $simple_social_inbox_wp) { switch ($action) { case 'send-message-reply': if (!headers_sent()) { header('Content-type: text/javascript'); } if (isset($_REQUEST['social_twitter_id']) && !empty($_REQUEST['social_twitter_id']) && isset($_REQUEST['id']) && (int) $_REQUEST['id'] > 0) { $ucm_twitter = new ucm_twitter_account($_REQUEST['social_twitter_id']); if ($ucm_twitter->get('social_twitter_id') == $_REQUEST['social_twitter_id']) { $ucm_twitter_message = new ucm_twitter_message($ucm_twitter, $_REQUEST['id']); if ($ucm_twitter_message->get('social_twitter_message_id') == $_REQUEST['id']) { $return = array(); $message = isset($_POST['message']) && $_POST['message'] ? $_POST['message'] : ''; $debug = isset($_POST['debug']) && $_POST['debug'] ? $_POST['debug'] : false; if ($message) { ob_start(); //$twitter_message->send_reply( $message, $debug ); $new_twitter_message = new ucm_twitter_message($ucm_twitter, false); $new_twitter_message->create_new(); $new_twitter_message->update('reply_to_id', $ucm_twitter_message->get('social_twitter_message_id')); $new_twitter_message->update('social_twitter_id', $ucm_twitter->get('social_twitter_id')); $new_twitter_message->update('summary', $message); //$new_twitter_message->update('type','pending'); $new_twitter_message->update('data', json_encode($_POST)); $new_twitter_message->update('user_id', get_current_user_id()); // do we send this one now? or schedule it later. $new_twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_PENDINGSEND); if (isset($_FILES['picture']['tmp_name']) && is_uploaded_file($_FILES['picture']['tmp_name'])) { $new_twitter_message->add_attachment($_FILES['picture']['tmp_name']); } $worked = $new_twitter_message->send_queued(isset($_POST['debug']) && $_POST['debug']); $return['message'] = ob_get_clean(); if ($debug) { // just return message } else { if ($worked) { // success, redicet! //set_message( _l( 'Message sent and conversation archived.' ) ); //$return['redirect'] = module_social_twitter::link_open_message_view( $social_twitter_id ); $return['redirect'] = 'admin.php?page=simple_social_inbox_main'; //$return['success'] = 1; } else { // failed, no debug, force debug and show error. } } } echo json_encode($return); } } } break; case 'modal': if (isset($_REQUEST['socialtwittermessageid']) && (int) $_REQUEST['socialtwittermessageid'] > 0) { $ucm_twitter_message = new ucm_twitter_message(false, $_REQUEST['socialtwittermessageid']); if ($ucm_twitter_message->get('social_twitter_message_id') == $_REQUEST['socialtwittermessageid']) { $social_twitter_id = $ucm_twitter_message->get('twitter_account')->get('social_twitter_id'); $social_twitter_message_id = $ucm_twitter_message->get('social_twitter_message_id'); include trailingslashit($simple_social_inbox_wp->dir) . 'pages/twitter_message.php'; } } break; case 'set-answered': if (!headers_sent()) { header('Content-type: text/javascript'); } if (isset($_REQUEST['social_twitter_message_id']) && (int) $_REQUEST['social_twitter_message_id'] > 0) { $ucm_twitter_message = new ucm_twitter_message(false, $_REQUEST['social_twitter_message_id']); if ($ucm_twitter_message->get('social_twitter_message_id') == $_REQUEST['social_twitter_message_id']) { $ucm_twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_ANSWERED); ?> jQuery('.socialtwitter_message_action[data-id=<?php echo (int) $ucm_twitter_message->get('social_twitter_message_id'); ?> ]').parents('tr').first().hide(); <?php // if this is a direct message, we also archive all other messages in it. if ($ucm_twitter_message->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) { $from = preg_replace('#[^0-9]#', '', $ucm_twitter_message->get('twitter_from_id')); $to = preg_replace('#[^0-9]#', '', $ucm_twitter_message->get('twitter_to_id')); if ($from && $to) { $sql = "SELECT * FROM `" . _SIMPLE_SOCIAL_DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND `status` = " . (int) _SOCIAL_MESSAGE_STATUS_UNANSWERED . " AND social_twitter_id = " . (int) $ucm_twitter_message->get('twitter_account')->get('social_twitter_id') . " AND ( (`twitter_from_id` = '{$from}' AND `twitter_to_id` = '{$to}') OR (`twitter_from_id` = '{$to}' AND `twitter_to_id` = '{$from}') ) "; global $wpdb; $others = $wpdb->get_results($sql, ARRAY_A); if (count($others)) { foreach ($others as $other_message) { $ucm_twitter_message = new ucm_twitter_message(false, $other_message['social_twitter_message_id']); if ($ucm_twitter_message->get('social_twitter_message_id') == $other_message['social_twitter_message_id']) { $ucm_twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_ANSWERED); ?> jQuery('.socialtwitter_message_action[data-id=<?php echo (int) $ucm_twitter_message->get('social_twitter_message_id'); ?> ]').parents('tr').first().hide(); <?php } } } } } } } break; case 'set-unanswered': if (!headers_sent()) { header('Content-type: text/javascript'); } if (isset($_REQUEST['social_twitter_message_id']) && (int) $_REQUEST['social_twitter_message_id'] > 0) { $ucm_twitter_message = new ucm_twitter_message(false, $_REQUEST['social_twitter_message_id']); if ($ucm_twitter_message->get('social_twitter_message_id') == $_REQUEST['social_twitter_message_id']) { $ucm_twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_UNANSWERED); ?> jQuery('.socialtwitter_message_action[data-id=<?php echo (int) $ucm_twitter_message->get('social_twitter_message_id'); ?> ]').parents('tr').first().hide(); <?php } } break; } return false; }
/** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!module_social::can_i('edit', 'Twitter', 'Social', 'social')) { die('No access to Twitter accounts'); } $social_twitter_id = isset($_REQUEST['social_twitter_id']) ? (int) $_REQUEST['social_twitter_id'] : 0; $twitter_account = new ucm_twitter_account($social_twitter_id); if ($twitter_account->get('social_twitter_id') && $twitter_account->get('social_twitter_id') == $social_twitter_id) { // do a quick oauth. require_once 'includes/plugin_social_twitter/includes/tmhOAuth.php'; class dtbaker_tmhOAuth extends tmhOAuth { public function __construct($config = array()) { $this->config = array_merge(array('consumer_key' => module_config::c('social_twitter_api_key', ''), 'consumer_secret' => module_config::c('social_twitter_api_secret', ''), 'user_agent' => 'UCM Twitter 0.1'), $config); parent::__construct($this->config); } } $tmhOAuth = new dtbaker_tmhOAuth(); function php_self($dropqs = true) { $protocol = 'http'; if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
<?php /** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (module_social::can_i('view', 'Twitter Comments', 'Social', 'social')) { $social_twitter_id = isset($_REQUEST['social_twitter_id']) ? (int) $_REQUEST['social_twitter_id'] : 0; $twitter = new ucm_twitter_account($social_twitter_id); if ($social_twitter_id && $twitter->get('social_twitter_id') == $social_twitter_id) { $module->page_title = $twitter->get('account_name'); $header = array('title' => $twitter->get('account_name'), 'type' => 'h2', 'main' => true, 'button' => array()); if (module_social::can_i('create', 'Twitter Comments', 'Social', 'social')) { $header['button'] = array('url' => module_social_twitter::link_open_twitter_message($social_twitter_id, false), 'title' => _l('Compose Tweet'), 'type' => 'add', 'class' => 'socialtwitter_message_open social_modal', 'id' => 'socialtwitter_message_compose'); } print_heading($header); $search = isset($_REQUEST['search']) && is_array($_REQUEST['search']) ? $_REQUEST['search'] : array(); if (!isset($search['status'])) { $search['status'] = _SOCIAL_MESSAGE_STATUS_UNANSWERED; } $all_messages = $twitter->get_messages($search); ?> <script type="text/javascript"> $(function(){ $('#socialtwitter_message_compose').attr('data-modal-title','<?php _e('Compose Tweet');
?> </div> <div id="twitter_message_holder"> <?php $twitter_message->full_message_output(module_social::can_i('create', 'Twitter Comments', 'Social', 'social')); ?> </div> </form> <?php } } } if ($social_twitter_id && !$social_twitter_message_id && module_social::can_i('create', 'Twitter Comments', 'Social', 'social')) { $twitter = new ucm_twitter_account($social_twitter_id); if ($social_twitter_id && $twitter->get('social_twitter_id') == $social_twitter_id) { $module->page_title = $twitter->get('twitter_name'); /* @var $pages ucm_twitter_page[] */ $pages = $twitter->get('pages'); //print_r($pages); ?> <form action="<?php echo module_social_twitter::link_open_message_view($social_twitter_id); ?> " method="post" enctype="multipart/form-data"> <input type="hidden" name="_process" value="send_twitter_message"> <?php module_form::print_form_auth(); ?> <?php
public function process() { if ("save_twitter" == $_REQUEST['_process']) { $social_twitter_id = isset($_REQUEST['social_twitter_id']) ? (int) $_REQUEST['social_twitter_id'] : 0; $twitter = new ucm_twitter_account($social_twitter_id); if (isset($_POST['butt_del']) && module_social::can_i('delete', 'Twitter', 'Social', 'social')) { if (module_form::confirm_delete('social_twitter_id', "Really delete this Twitter account from the system? All messages will be lost.", self::link_open($_REQUEST['social_twitter_id']))) { $twitter->delete(); set_message("Twitter account deleted successfully"); redirect_browser(self::link_open(false)); } } $twitter->save_data($_POST); $social_twitter_id = $twitter->get('social_twitter_id'); if (isset($_POST['butt_save_connect'])) { $redirect = $this->link_open($social_twitter_id, false, false, 'twitter_account_connect'); } else { set_message('Twitter account saved successfully'); $redirect = $this->link_open($social_twitter_id); } redirect_browser($redirect); exit; } else { if ("send_twitter_message" == $_REQUEST['_process']) { if (module_form::check_secure_key()) { // queue the message into the twitter_message table // if there's a scheduled date in the past we send it in the past, no date we send straight away, date in the future we leave it in the db table for the cron job to pick up. //print_r($_POST);exit; $send_time = false; // 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(input_date($date, true)); } else { if (isset($_POST['schedule_date']) && !empty($_POST['schedule_date'])) { $send_time = strtotime(input_date($_POST['schedule_date'], true)); } } //echo print_date($send_time,true); //echo '<br>'; //echo date('c',$send_time); //exit; $send_accounts = isset($_POST['compose_account_id']) && is_array($_POST['compose_account_id']) ? $_POST['compose_account_id'] : array(); $page_count = 0; $last_twitter_account_id = false; if ($send_accounts) { foreach ($send_accounts as $twitter_account_id => $tf) { if (!$tf) { continue; } // see if this is an available account. $twitter_account = new ucm_twitter_account($twitter_account_id); //todo: check permissiont o access thi saccount if ($twitter_account->get('social_twitter_id') == $twitter_account_id) { // push to db! then send. $last_twitter_account_id = $twitter_account_id; $twitter_message = new ucm_twitter_message($twitter_account, false); $twitter_message->create_new(); $twitter_message->update('social_twitter_id', $twitter_account->get('social_twitter_id')); $twitter_message->update('summary', isset($_POST['message']) ? $_POST['message'] : ''); $twitter_message->update('type', 'pending'); $twitter_message->update('data', json_encode($_POST)); $twitter_message->update('user_id', module_security::get_loggedin_id()); // do we send this one now? or schedule it later. $twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_PENDINGSEND); if ($send_time) { // schedule for sending at a different time (now or in the past) $twitter_message->update('message_time', $send_time); } else { // send it now. $twitter_message->update('message_time', 0); } if (isset($_FILES['picture']['tmp_name']) && is_uploaded_file($_FILES['picture']['tmp_name'])) { $twitter_message->add_attachment($_FILES['picture']['tmp_name']); } $twitter_message->send_queued(isset($_POST['debug']) && $_POST['debug']); $page_count++; } else { // log error? } } } set_message(_l('Message delivered successfully to %s Twitter accounts', $page_count)); $redirect = $this->link_open_message_view($last_twitter_account_id); redirect_browser($redirect); } exit; } else { if ("ajax_social_twitter" == $_REQUEST['_process']) { // ajax functions from wdsocial. copied from the datafeed.php sample files. header('Content-type: text/javascript'); if (module_form::check_secure_key()) { $social_twitter_id = isset($_REQUEST['social_twitter_id']) ? (int) $_REQUEST['social_twitter_id'] : 0; $twitter = new ucm_twitter_account($social_twitter_id); if ($social_twitter_id && $twitter->get('social_twitter_id') == $social_twitter_id) { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false; $message_id = isset($_REQUEST['social_twitter_message_id']) ? (int) $_REQUEST['social_twitter_message_id'] : 0; $twitter_message = new ucm_twitter_message(); $twitter_message->load($message_id); if ($twitter_message->get('social_twitter_id') == $social_twitter_id && $twitter_message->get('social_twitter_message_id') == $message_id) { switch ($action) { case "send-message-reply": if (module_social::can_i('create', 'Twitter Comments', 'Social', 'social')) { $return = array(); $message = isset($_POST['message']) && $_POST['message'] ? $_POST['message'] : ''; $debug = isset($_POST['debug']) && $_POST['debug'] ? $_POST['debug'] : false; if ($message) { ob_start(); //$twitter_message->send_reply( $message, $debug ); $new_twitter_message = new ucm_twitter_message($twitter, false); $new_twitter_message->create_new(); $new_twitter_message->update('reply_to_id', $twitter_message->get('social_twitter_message_id')); $new_twitter_message->update('social_twitter_id', $twitter->get('social_twitter_id')); $new_twitter_message->update('summary', $message); //$new_twitter_message->update('type','pending'); $new_twitter_message->update('data', json_encode($_POST)); $new_twitter_message->update('user_id', module_security::get_loggedin_id()); // do we send this one now? or schedule it later. $new_twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_PENDINGSEND); if (isset($_FILES['picture']['tmp_name']) && is_uploaded_file($_FILES['picture']['tmp_name'])) { $new_twitter_message->add_attachment($_FILES['picture']['tmp_name']); } $worked = $new_twitter_message->send_queued(isset($_POST['debug']) && $_POST['debug']); $return['message'] = ob_get_clean(); if ($debug) { // just return message } else { if ($worked) { // success, redicet! set_message(_l('Message sent and conversation archived.')); $return['redirect'] = module_social_twitter::link_open_message_view($social_twitter_id); } else { // failed, no debug, force debug and show error. } } } echo json_encode($return); } break; case "set-answered": if (module_social::can_i('edit', 'Twitter Comments', 'Social', 'social')) { $twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_ANSWERED); ?> $('.twitter_message_row[data-id=<?php echo $message_id; ?> ]').hide(); <?php // if this is a direct message, we also archive all other messages in it. if ($twitter_message->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) { $from = preg_replace('#[^0-9]#', '', $twitter_message->get('twitter_from_id')); $to = preg_replace('#[^0-9]#', '', $twitter_message->get('twitter_to_id')); if ($from && $to) { $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND `status` = " . (int) _SOCIAL_MESSAGE_STATUS_UNANSWERED . " AND social_twitter_id = " . (int) $twitter_message->get('twitter_account')->get('social_twitter_id') . " AND ( (`twitter_from_id` = '{$from}' AND `twitter_to_id` = '{$to}') OR (`twitter_from_id` = '{$to}' AND `twitter_to_id` = '{$from}') ) "; $others = qa($sql); if (count($others)) { foreach ($others as $other_message) { $ucm_twitter_message = new ucm_twitter_message(false, $other_message['social_twitter_message_id']); if ($ucm_twitter_message->get('social_twitter_message_id') == $other_message['social_twitter_message_id']) { $ucm_twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_ANSWERED); ?> $('.twitter_message_row[data-id=<?php echo $ucm_twitter_message->get('social_twitter_message_id'); ?> ]').hide(); <?php } } } } } } break; case "set-unanswered": if (module_social::can_i('edit', 'Twitter Comments', 'Social', 'social')) { $twitter_message->update('status', _SOCIAL_MESSAGE_STATUS_UNANSWERED); ?> $('.twitter_message_row[data-id=<?php echo $message_id; ?> ]').hide(); <?php } break; } //echo 'The status is '.$twitter_message->get('status'); } } } exit; } } } }
* Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!module_social::can_i('edit', 'Twitter', 'Social', 'social')) { die('No access to Twitter accounts'); } $social_twitter_id = isset($_REQUEST['social_twitter_id']) ? (int) $_REQUEST['social_twitter_id'] : 0; $twitter = new ucm_twitter_account($social_twitter_id); $heading = array('type' => 'h3', 'title' => 'Twitter Account'); ?> <form action="" method="post"> <input type="hidden" name="_process" value="save_twitter"> <input type="hidden" name="social_twitter_id" value="<?php echo $twitter->get('social_twitter_id'); ?> "> <?php module_form::print_form_auth(); $fieldset_data = array('heading' => $heading, 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array(array('title' => _l('Account Name'), 'field' => array('type' => 'text', 'name' => 'account_name', 'value' => $twitter->get('account_name'), 'help' => 'Choose a name for this account. This name will be shown here in the system.')))); // check if this is active, if not prmopt the user to re-connect. if ($twitter->is_active()) { $fieldset_data['elements'][] = array('title' => _l('Last Checked'), 'fields' => array(print_date($twitter->get('last_checked'), true), '(<a href="' . module_social_twitter::link_open_twitter_account_refresh($social_twitter_id) . '" target="_blank">' . _l('Refresh') . '</a>)')); $fieldset_data['elements'][] = array('title' => _l('Twitter Name'), 'fields' => array(htmlspecialchars($twitter->get('twitter_name')))); $fieldset_data['elements'][] = array('title' => _l('Twitter ID'), 'fields' => array(htmlspecialchars($twitter->get('twitter_id')))); $fieldset_data['elements'][] = array('title' => _l('Import DM\'s'), 'fields' => array(array('type' => 'checkbox', 'value' => $twitter->get('import_dm'), 'name' => 'import_dm', 'help' => 'Enable this to import Direct Messages from this twitter account'))); $fieldset_data['elements'][] = array('title' => _l('Import Mentions'), 'fields' => array(array('type' => 'checkbox', 'value' => $twitter->get('import_mentions'), 'name' => 'import_mentions', 'help' => 'Enable this to import any tweets that mention your name'))); $fieldset_data['elements'][] = array('title' => _l('Import Tweets'), 'fields' => array(array('type' => 'checkbox', 'name' => 'import_tweets', 'value' => $twitter->get('import_tweets'), 'help' => 'Enable this to import any tweets that originated from this account'))); } else {
$accounts = module_social_twitter::get_accounts(); foreach ($accounts as $account) { $twitter_account = new ucm_twitter_account($account['social_twitter_id']); ?> <tr class="<?php echo $c++ % 2 ? "odd" : "even"; ?> "> <td class="row_action"> <img src="<?php echo _BASE_HREF; ?> includes/plugin_social_twitter/images/twitter-logo.png" class="twitter_icon"> <?php echo htmlspecialchars($twitter_account->get('account_name')); ?> <br/> </td> <td> <a href="<?php echo module_social_twitter::link_open_twitter_message($account['social_twitter_id'], false); ?> " class="socialtwitter_message_open social_modal btn btn-success btn-sm" data-modal-title="<?php echo _l('Compose Tweet'); ?> "><?php _e('Compose Tweet'); ?> </a> </td>