Merge pull request #872 from annando/master

API: Supporting twidere, better supporting of the network field in the item table
This commit is contained in:
fabrixxm 2013-12-27 00:15:44 -08:00
commit 7b5018fb76
12 changed files with 97 additions and 84 deletions

View file

@ -331,16 +331,18 @@
'location' => NULL,
'description' => NULL,
'profile_image_url' => $r[0]["avatar"],
'profile_image_url_https' => $r[0]["avatar"],
'url' => $r[0]["url"],
'protected' => false,
'followers_count' => 0,
'friends_count' => 0,
'created_at' => '',
'created_at' => api_date(0),
'favourites_count' => 0,
'utc_offset' => 0,
'time_zone' => 'UTC',
'statuses_count' => 0,
'following' => 1,
'following' => false,
'verified' => false,
'statusnet_blocking' => false,
'notifications' => false,
'statusnet_profile_url' => $r[0]["url"],
@ -430,6 +432,7 @@
'location' => ($usr) ? $usr[0]['default-location'] : NULL,
'description' => (($profile) ? $profile[0]['pdesc'] : NULL),
'profile_image_url' => $uinfo[0]['micro'],
'profile_image_url_https' => $uinfo[0]['micro'],
'url' => $uinfo[0]['url'],
'protected' => false,
'followers_count' => intval($countfollowers),

View file

@ -642,7 +642,7 @@ function diaspora_request($importer,$xml) {
return;
}
$ret = find_diaspora_person_by_handle($sender_handle);
@ -868,6 +868,7 @@ function diaspora_post($importer,$xml,$msg) {
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
$datarray['wall'] = 0;
$datarray['network'] = NETWORK_DIASPORA;
$datarray['guid'] = $guid;
$datarray['uri'] = $datarray['parent-uri'] = $message_id;
$datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
@ -1032,6 +1033,7 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
$datarray['wall'] = 0;
$datarray['network'] = NETWORK_DIASPORA;
$datarray['guid'] = $guid;
$datarray['uri'] = $datarray['parent-uri'] = $message_id;
$datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
@ -1136,10 +1138,11 @@ function diaspora_asphoto($importer,$xml,$msg) {
$datarray = array();
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
$datarray['wall'] = 0;
$datarray['network'] = NETWORK_DIASPORA;
$datarray['guid'] = $guid;
$datarray['uri'] = $datarray['parent-uri'] = $message_id;
$datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
@ -1153,7 +1156,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
$datarray['author-link'] = $contact['url'];
$datarray['author-avatar'] = $contact['thumb'];
$datarray['body'] = $body;
$datarray['app'] = 'Diaspora/Cubbi.es';
$message_id = item_store($datarray);
@ -1312,6 +1315,7 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray['contact-id'] = $contact['id'];
$datarray['type'] = 'remote-comment';
$datarray['wall'] = $parent_item['wall'];
$datarray['network'] = NETWORK_DIASPORA;
$datarray['gravity'] = GRAVITY_COMMENT;
$datarray['guid'] = $guid;
$datarray['uri'] = $message_id;
@ -1332,7 +1336,7 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray['tag'] = $str_tags;
// We can't be certain what the original app is if the message is relayed.
if(($parent_item['origin']) && (! $parent_author_signature))
if(($parent_item['origin']) && (! $parent_author_signature))
$datarray['app'] = 'Diaspora';
$message_id = item_store($datarray);
@ -1894,6 +1898,7 @@ EOT;
$arr['uri'] = $uri;
$arr['uid'] = $importer['uid'];
$arr['guid'] = $guid;
$arr['network'] = NETWORK_DIASPORA;
$arr['contact-id'] = $contact['id'];
$arr['type'] = 'activity';
$arr['wall'] = $parent_item['wall'];
@ -1909,7 +1914,7 @@ EOT;
$arr['author-name'] = $person['name'];
$arr['author-link'] = $person['url'];
$arr['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $parent_item['author-link'] . ']' . $parent_item['author-name'] . '[/url]';
$plink = '[url=' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . ']' . $post_type . '[/url]';

View file

@ -146,6 +146,7 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
}
$arr = array();
$arr["network"] = NETWORK_OSTATUS;
$arr["uri"] = $single_conv->id;
$arr["plink"] = $single_conv->id;
$arr["uid"] = $message["uid"];

View file

@ -328,10 +328,10 @@ function get_theme_info($theme){
$info[$k]=$v;
}
}
}
}
}
return $info;
}}
@ -351,7 +351,7 @@ function get_theme_screenshot($theme) {
if (! function_exists('uninstall_theme')){
function uninstall_theme($theme){
logger("Addons: uninstalling theme " . $theme);
@include_once("view/theme/$theme/theme.php");
if(function_exists("{$theme}_uninstall")) {
$func = "{$theme}_uninstall";

View file

@ -134,7 +134,7 @@ function display_content(&$a, $update = 0) {
return '';
}
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
@ -163,7 +163,7 @@ function display_content(&$a, $update = 0) {
if($r) {
$item_uri = $r[0]['uri'];
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`

View file

@ -3,17 +3,17 @@
/**
*
* This is the POST destination for most all locally posted
* text stuff. This function handles status, wall-to-wall status,
* local comments, and remote coments that are posted on this site
* text stuff. This function handles status, wall-to-wall status,
* local comments, and remote coments that are posted on this site
* (as opposed to being delivered in a feed).
* Also processed here are posts and comments coming through the
* statusnet/twitter API.
* All of these become an "item" which is our basic unit of
* Also processed here are posts and comments coming through the
* statusnet/twitter API.
* All of these become an "item" which is our basic unit of
* information.
* Posts that originate externally or do not fall into the above
* posting categories go through item_store() instead of this function.
* Posts that originate externally or do not fall into the above
* posting categories go through item_store() instead of this function.
*
*/
*/
require_once('include/crypto.php');
require_once('include/enotify.php');
@ -200,6 +200,7 @@ function item_post(&$a) {
$body = escape_tags(trim($_REQUEST['body']));
$private = $orig_post['private'];
$pubmail_enable = $orig_post['pubmail'];
$network = $orig_post['network'];
}
else {
@ -234,6 +235,7 @@ function item_post(&$a) {
$verb = notags(trim($_REQUEST['verb']));
$emailcc = notags(trim($_REQUEST['emailcc']));
$body = escape_tags(trim($_REQUEST['body']));
$network = notags(trim($_REQUEST['network']));
$naked_body = preg_replace('/\[(.+?)\]/','',$body);
@ -275,6 +277,12 @@ function item_post(&$a) {
if($parent_item) {
$private = 0;
// for non native networks use the network of the original post as network of the item
if (($parent_item['network'] != NETWORK_DIASPORA)
AND ($parent_item['network'] != NETWORK_OSTATUS)
AND ($network == ""))
$network = $parent_item['network'];
if(($parent_item['private'])
|| strlen($parent_item['allow_cid'])
|| strlen($parent_item['allow_gid'])
@ -288,7 +296,6 @@ function item_post(&$a) {
$str_contact_deny = $parent_item['deny_cid'];
$str_group_deny = $parent_item['deny_gid'];
}
$pubmail_enable = ((x($_REQUEST,'pubmail_enable') && intval($_REQUEST['pubmail_enable']) && (! $private)) ? 1 : 0);
// if using the API, we won't see pubmail_enable - figure out if it should be set
@ -519,7 +526,7 @@ function item_post(&$a) {
&& ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) {
$body = '@' . $parent_contact['nick'] . ' ' . $body;
$tags[] = '@' . $parent_contact['nick'];
}
}
$tagged = array();
@ -584,13 +591,16 @@ function item_post(&$a) {
if(! strlen($verb))
$verb = ACTIVITY_POST ;
if ($network == "")
$network = NETWORK_DFRN;
$gravity = (($parent) ? 6 : 0 );
// even if the post arrived via API we are considering that it
// originated on this site by default for determining relayability.
$origin = ((x($_REQUEST,'origin')) ? intval($_REQUEST['origin']) : 1);
$notify_type = (($parent) ? 'comment-new' : 'wall-new' );
$uri = (($message_id) ? $message_id : item_new_uri($a->get_hostname(),$profile_uid));
@ -604,6 +614,7 @@ function item_post(&$a) {
$datarray['type'] = $post_type;
$datarray['wall'] = $wall;
$datarray['gravity'] = $gravity;
$datarray['network'] = $network;
$datarray['contact-id'] = $contact_id;
$datarray['owner-name'] = $contact_record['name'];
$datarray['owner-link'] = $contact_record['url'];
@ -709,15 +720,16 @@ function item_post(&$a) {
$post_id = 0;
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
`tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file` )
VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )",
VALUES( '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )",
dbesc($datarray['guid']),
intval($datarray['uid']),
dbesc($datarray['type']),
intval($datarray['wall']),
intval($datarray['gravity']),
dbesc($datarray['network']),
intval($datarray['contact-id']),
dbesc($datarray['owner-name']),
dbesc($datarray['owner-link']),
@ -1103,7 +1115,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
if(count($r)) {
$profile = $r[0]['url'];
//set newname to nick, find alias
if($r[0]['network'] === 'stat') {
if(($r[0]['network'] === NETWORK_OSTATUS) OR ($r[0]['network'] === NETWORK_TWITTER)) {
$newname = $r[0]['nick'];
$stat = true;
if($r[0]['alias'])

View file

@ -746,7 +746,7 @@ function network_content(&$a, $update = 0) {
if($nouveau) {
// "New Item View" - show all items unthreaded in reverse created date order
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
@ -786,7 +786,7 @@ function network_content(&$a, $update = 0) {
// Fetch a page full of parent items for this page
if($update) {
$r = q("SELECT `item`.`parent` AS `item_id`, `contact`.`uid` AS `contact_uid`
$r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
@ -797,7 +797,7 @@ function network_content(&$a, $update = 0) {
);
}
else {
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
$r = q("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
@ -832,7 +832,7 @@ function network_content(&$a, $update = 0) {
foreach ($parents_arr AS $parents_str) {
$thread_items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
$thread_items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`

View file

@ -217,7 +217,8 @@ function profile_content(&$a, $update = 0) {
if($update) {
$r = q("SELECT distinct(parent) AS `item_id`, `contact`.`uid` AS `contact-uid`
$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
@ -278,7 +279,8 @@ function profile_content(&$a, $update = 0) {
// FROM `item` FORCE INDEX (created, uid) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
$r = q("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
@ -299,7 +301,7 @@ function profile_content(&$a, $update = 0) {
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`,
`contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`

View file

@ -322,7 +322,9 @@ class Item extends BaseObject {
'wait' => t('Please wait'),
'thread_level' => $thread_level,
'postopts' => $langstr,
'edited' => $edited
'edited' => $edited,
'network' => $item["item_network"],
'network_name' => network_to_name($item['item_network']),
);
$arr = array('item' => $item, 'output' => $tmp_item);

View file

@ -480,8 +480,9 @@ div.jGrowl div.info {
padding-left: 58px;
}
div.jGrowl div.jGrowl-notification {
margin-top: 40px;
div.jGrowl.top-right {
top: 40px;
z-index: 90;
}
/* header */
@ -533,7 +534,8 @@ nav {
top: 0px;
padding: 0px;
padding-left: 0px;
background: #2d2d2d;
/* background: #2d2d2d; */
background: rgb(36, 76, 94);
/*background: #364A84;
background: -moz-linear-gradient(top, #516499 0%, #364a84 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#516499), color-stop(100%,#364a84));
@ -1160,6 +1162,14 @@ border-bottom: 1px solid #D2D2D2;
color: #999;
font-size: 12px;
}
.wall-item-network {
color: #999;
font-size: 12px;
text-align: right;
float: right;
}
.wall-item-location {
width: 350px;
float: left;
@ -1396,8 +1406,8 @@ border-bottom: 1px solid #D2D2D2;
.shiny {
/* border-right: 10px solid #fce94f; */
border-right: 1px solid #A7C7F7;
padding-right: 12px;
/* border-right: 1px solid #A7C7F7;
padding-right: 12px; */
}
#profile-jot-form #profile-jot-text {

View file

@ -62,6 +62,9 @@
{{if $item.plink}}<a title="{{$item.plink.title}}" href="{{$item.plink.href}}" style="color: #999">{{$item.ago}}</a>{{else}} {{$item.ago}} {{/if}}
{{if $item.lock}}<span class="fakelink" style="color: #999" onclick="lockview(event,{{$item.id}});">{{$item.lock}}</span> {{/if}}
</span>
<span class="wall-item-network">
{{$item.network_name}}
</span>
</div>
<div itemprop="description" class="wall-item-content">

View file

@ -11,10 +11,29 @@
function vier_init(&$a) {
set_template_engine($a, 'smarty3');
$baseurl = $a->get_baseurl();
$a->theme_info = array();
$a->page['htmlhead'] .= <<< EOT
<script type="text/javascript" src="$baseurl/view/theme/vier/js/jquery.divgrow-1.3.1.f1.min.js"></script>
<script>
function collapseHeight(elems) {
var elemName = '.wall-item-body:not(.divmore)';
if(typeof elems != 'undefined') {
elemName = elems + ' ' + elemName;
}
$(elemName).each(function() {
if($(this).height() > 450) {
$('html').height($('html').height());
$(this).divgrow({ initialHeight: 400, showBrackets: false, speed: 0 });
$(this).addClass('divmore');
$('html').height('auto');
}
});
}
function insertFormatting(comment,BBcode,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
@ -32,7 +51,7 @@ function insertFormatting(comment,BBcode,id) {
selected = document.selection.createRange();
if (BBcode == "url"){
selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
} else
} else
selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
} else if (textarea.selectionStart || textarea.selectionStart == "0") {
var start = textarea.selectionStart;
@ -62,50 +81,6 @@ function cmtBbOpen(id) {
function cmtBbClose(id) {
$("#comment-edit-bb-" + id).hide();
}
/*
$(document).ready(function() {
$('html').click(function() { $("#nav-notifications-menu" ).hide(); });
$('.group-edit-icon').hover(
function() {
$(this).addClass('icon'); $(this).removeClass('iconspacer');},
function() {
$(this).removeClass('icon'); $(this).addClass('iconspacer');}
);
$('.sidebar-group-element').hover(
function() {
id = $(this).attr('id');
$('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
function() {
id = $(this).attr('id');
$('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
);
$('.savedsearchdrop').hover(
function() {
$(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
function() {
$(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
);
$('.savedsearchterm').hover(
function() {
id = $(this).attr('id');
$('#drop-' + id).addClass('icon'); $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
function() {
id = $(this).attr('id');
$('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
);
});
*/
</script>
EOT;
}