From: Michael Vogel Date: Fri, 27 Dec 2013 00:58:21 +0000 (+0100) Subject: Better handling of the network field in the item table. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4b0e370c4c2ec606833aa326fba49922a7c470ab;p=friendica.git Better handling of the network field in the item table. --- diff --git a/include/diaspora.php b/include/diaspora.php index abc518cd59..f40566267d 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -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]'; diff --git a/include/ostatus_conversation.php b/include/ostatus_conversation.php index 1185c01f95..65c0d67871 100644 --- a/include/ostatus_conversation.php +++ b/include/ostatus_conversation.php @@ -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"]; diff --git a/include/plugin.php b/include/plugin.php index 9002c7bce4..32962cd0c6 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -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"; diff --git a/mod/display.php b/mod/display.php index 538dc6454f..efae937e16 100644 --- a/mod/display.php +++ b/mod/display.php @@ -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` diff --git a/mod/item.php b/mod/item.php index 14acc5d0f3..805701dc34 100644 --- a/mod/item.php +++ b/mod/item.php @@ -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']) diff --git a/mod/network.php b/mod/network.php index de5e45e6e1..a8faeb459e 100644 --- a/mod/network.php +++ b/mod/network.php @@ -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` diff --git a/mod/profile.php b/mod/profile.php index f0f5d3623e..28e93b2947 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -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` diff --git a/object/Item.php b/object/Item.php index 0a793e5f32..9003c93c11 100644 --- a/object/Item.php +++ b/object/Item.php @@ -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); diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index e1f9b3def9..03aaf89400 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -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 { diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index e6d5bfb5d7..d51014a969 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -62,6 +62,9 @@ {{if $item.plink}}{{$item.ago}}{{else}} {{$item.ago}} {{/if}} {{if $item.lock}}{{$item.lock}} {{/if}} + + {{$item.network_name}} +
diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 7da0731f78..db343d1277 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -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 + EOT; }