delete from the wp side as well as from the red side
This commit is contained in:
parent
6f6fcddfc3
commit
ef53c72a70
@ -1080,19 +1080,35 @@ require_once('include/photos.php');
|
|||||||
|
|
||||||
// params
|
// params
|
||||||
$id = intval(argv(3));
|
$id = intval(argv(3));
|
||||||
|
if($id) {
|
||||||
|
// first prove that we own the item
|
||||||
|
|
||||||
// first prove that we own the item
|
$r = q("select * from item where id = %d and uid = %d limit 1",
|
||||||
|
intval($id),
|
||||||
$r = q("select * from item where id = %d and uid = %d limit 1",
|
intval($user_info['uid'])
|
||||||
intval($id),
|
);
|
||||||
intval($user_info['uid'])
|
if(! $r)
|
||||||
);
|
return false;
|
||||||
|
|
||||||
if($r) {
|
|
||||||
logger('API: api_statuses_destroy: '.$id);
|
|
||||||
require_once('include/items.php');
|
|
||||||
drop_item($id, false);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if($_REQUEST['namespace'] && $_REQUEST['remote_id']) {
|
||||||
|
$r = q("select * from item_id where service = '%s' and sid = '%s' and uid = %d limit 1",
|
||||||
|
dbesc($_REQUEST['namespace']),
|
||||||
|
dbesc($_REQUEST['remote_id']),
|
||||||
|
intval($user_info['uid'])
|
||||||
|
);
|
||||||
|
if(! $r)
|
||||||
|
return false;
|
||||||
|
$id = $r[0]['iid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(! $id)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
logger('API: api_statuses_destroy: '.$id);
|
||||||
|
require_once('include/items.php');
|
||||||
|
drop_item($id, false);
|
||||||
|
|
||||||
|
|
||||||
if ($type == 'xml')
|
if ($type == 'xml')
|
||||||
$ok = "true";
|
$ok = "true";
|
||||||
@ -1114,7 +1130,7 @@ require_once('include/photos.php');
|
|||||||
if (api_user()===false) return false;
|
if (api_user()===false) return false;
|
||||||
|
|
||||||
$user_info = api_get_user($a);
|
$user_info = api_get_user($a);
|
||||||
// get last newtork messages
|
// get last network messages
|
||||||
|
|
||||||
|
|
||||||
// params
|
// params
|
||||||
|
@ -85,12 +85,8 @@ function post_to_red_post($post_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$message_namespace = 'wordpress';
|
|
||||||
|
|
||||||
$message_id = site_url() . '/' . $post_id;
|
$message_id = site_url() . '/' . $post_id;
|
||||||
|
|
||||||
$message = $post->post_title . "<br /><br />" . $message;
|
|
||||||
|
|
||||||
if (isset($tag_string)) {
|
if (isset($tag_string)) {
|
||||||
$message .= "<br />$tag_string";
|
$message .= "<br />$tag_string";
|
||||||
}
|
}
|
||||||
@ -99,8 +95,6 @@ function post_to_red_post($post_id) {
|
|||||||
|
|
||||||
$url = $seed_location . '/api/statuses/update';
|
$url = $seed_location . '/api/statuses/update';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$headers = array('Authorization' => 'Basic '.base64_encode("$user_name:$password"));
|
$headers = array('Authorization' => 'Basic '.base64_encode("$user_name:$password"));
|
||||||
$body = array(
|
$body = array(
|
||||||
'title' => xpost_to_html2bbcode($post->post_title),
|
'title' => xpost_to_html2bbcode($post->post_title),
|
||||||
@ -117,20 +111,49 @@ function post_to_red_post($post_id) {
|
|||||||
$request = new WP_Http;
|
$request = new WP_Http;
|
||||||
$result = $request->request($url , array( 'method' => 'POST', 'body' => $body, 'headers' => $headers));
|
$result = $request->request($url , array( 'method' => 'POST', 'body' => $body, 'headers' => $headers));
|
||||||
|
|
||||||
// if($result['response']['code'] == 200) {
|
}
|
||||||
// $j = json_decode($result['body'],true);
|
|
||||||
// if($j && $j['id']) {
|
}
|
||||||
// // store the red id in case we need to delete it in the future.
|
}
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
function post_to_red_delete_post($post_id) {
|
||||||
// logger('post_to_red returns: ' . print_r($result,true));
|
|
||||||
|
$post = get_post($post_id);
|
||||||
|
|
||||||
|
// if meta has been set
|
||||||
|
if (get_post_meta($post_id, "post_to_red", true) == 1) {
|
||||||
|
|
||||||
|
$user_name = post_to_red_get_acct_name();
|
||||||
|
$password = post_to_red_get_password();
|
||||||
|
$seed_location = post_to_red_get_seed_location();
|
||||||
|
$channel = post_to_red_get_channel_name();
|
||||||
|
|
||||||
|
if ((isset($user_name)) && (isset($password)) && (isset($seed_location))) {
|
||||||
|
|
||||||
|
$message_id = site_url() . '/' . $post_id;
|
||||||
|
$url = $seed_location . '/api/statuses/destroy';
|
||||||
|
|
||||||
|
$headers = array('Authorization' => 'Basic '.base64_encode("$user_name:$password"));
|
||||||
|
$body = array(
|
||||||
|
'namespace' => 'wordpress',
|
||||||
|
'remote_id' => $message_id,
|
||||||
|
);
|
||||||
|
if($channel)
|
||||||
|
$body['channel'] = $channel;
|
||||||
|
|
||||||
|
// post:
|
||||||
|
$request = new WP_Http;
|
||||||
|
$result = $request->request($url , array( 'method' => 'POST', 'body' => $body, 'headers' => $headers));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function post_to_red_displayAdminContent() {
|
function post_to_red_displayAdminContent() {
|
||||||
|
|
||||||
$seed_url = post_to_red_get_seed_location();
|
$seed_url = post_to_red_get_seed_location();
|
||||||
@ -239,6 +262,7 @@ add_action("admin_menu", "post_to_red_admin");
|
|||||||
add_action('publish_post', 'post_to_red_post');
|
add_action('publish_post', 'post_to_red_post');
|
||||||
add_action('add_meta_boxes', 'post_to_red_post_checkbox');
|
add_action('add_meta_boxes', 'post_to_red_post_checkbox');
|
||||||
add_action('save_post', 'post_to_red_post_field_data');
|
add_action('save_post', 'post_to_red_post_field_data');
|
||||||
|
add_action('before_delete_post', 'post_to_red_delete_post');
|
||||||
|
|
||||||
// from:
|
// from:
|
||||||
// http://www.docgate.com/tutorial/php/how-to-convert-html-to-bbcode-with-php-script.html
|
// http://www.docgate.com/tutorial/php/how-to-convert-html-to-bbcode-with-php-script.html
|
||||||
|
Reference in New Issue
Block a user