Merge pull request #1765 from annando/1507-redmatrix-network-name

Show "Redmatrix" as contact network
This commit is contained in:
Tobias Diekershoff 2015-07-16 14:34:54 +02:00
commit 5b96c7b3e3
10 changed files with 36 additions and 30 deletions

View File

@ -505,7 +505,7 @@
} }
require_once('include/contact_selectors.php'); require_once('include/contact_selectors.php');
$network_name = network_to_name($uinfo[0]['network']); $network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']);
$ret = Array( $ret = Array(
'id' => intval($r[0]['id']), 'id' => intval($r[0]['id']),
@ -996,9 +996,9 @@
$status_info["entities"] = $converted["entities"]; $status_info["entities"] = $converted["entities"];
if (($lastwall['item_network'] != "") AND ($status["source"] == 'web')) if (($lastwall['item_network'] != "") AND ($status["source"] == 'web'))
$status_info["source"] = network_to_name($lastwall['item_network']); $status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
elseif (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network']) != $status_info["source"])) elseif (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"]))
$status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network']).')'); $status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')');
// "uid" and "self" are only needed for some internal stuff, so remove it from here // "uid" and "self" are only needed for some internal stuff, so remove it from here
unset($status_info["user"]["uid"]); unset($status_info["user"]["uid"]);
@ -1095,9 +1095,9 @@
$user_info["status"]["entities"] = $converted["entities"]; $user_info["status"]["entities"] = $converted["entities"];
if (($lastwall['item_network'] != "") AND ($user_info["status"]["source"] == 'web')) if (($lastwall['item_network'] != "") AND ($user_info["status"]["source"] == 'web'))
$user_info["status"]["source"] = network_to_name($lastwall['item_network']); $user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
if (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network']) != $user_info["status"]["source"])) if (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"]))
$user_info["status"]["source"] = trim($user_info["status"]["source"].' ('.network_to_name($lastwall['item_network']).')'); $user_info["status"]["source"] = trim($user_info["status"]["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')');
} }
@ -2214,9 +2214,9 @@
$status["entities"] = $converted["entities"]; $status["entities"] = $converted["entities"];
if (($item['item_network'] != "") AND ($status["source"] == 'web')) if (($item['item_network'] != "") AND ($status["source"] == 'web'))
$status["source"] = network_to_name($item['item_network']); $status["source"] = network_to_name($item['item_network'], $user_info['url']);
else if (($item['item_network'] != "") AND (network_to_name($item['item_network']) != $status["source"])) else if (($item['item_network'] != "") AND (network_to_name($item['item_network'], $user_info['url']) != $status["source"]))
$status["source"] = trim($status["source"].' ('.network_to_name($item['item_network']).')'); $status["source"] = trim($status["source"].' ('.network_to_name($item['item_network'], $user_info['url']).')');
// Retweets are only valid for top postings // Retweets are only valid for top postings

View File

@ -1,5 +1,5 @@
<?php <?php
require_once('include/diaspora.php');
function contact_profile_assign($current,$foreign_net) { function contact_profile_assign($current,$foreign_net) {
@ -70,7 +70,7 @@ function contact_poll_interval($current, $disabled = false) {
} }
function network_to_name($s) { function network_to_name($s, $profile = "") {
$nets = array( $nets = array(
NETWORK_DFRN => t('Friendica'), NETWORK_DFRN => t('Friendica'),
@ -97,6 +97,10 @@ function network_to_name($s) {
$search = array_keys($nets); $search = array_keys($nets);
$replace = array_values($nets); $replace = array_values($nets);
return str_replace($search,$replace,$s); $networkname = str_replace($search,$replace,$s);
if (($s == NETWORK_DIASPORA) AND ($profile != "") AND diaspora_is_redmatrix($profile))
$networkname = t("Redmatrix");
return $networkname;
} }

View File

@ -175,7 +175,7 @@ if(! function_exists('profile_sidebar')) {
if (($profile['network'] != "") AND ($profile['network'] != NETWORK_DFRN)) { if (($profile['network'] != "") AND ($profile['network'] != NETWORK_DFRN)) {
require_once('include/contact_selectors.php'); require_once('include/contact_selectors.php');
if ($profile['url'] != "") if ($profile['url'] != "")
$profile['network_name'] = '<a href="'.$profile['url'].'">'.network_to_name($profile['network'])."</a>"; $profile['network_name'] = '<a href="'.$profile['url'].'">'.network_to_name($profile['network'], $profile['url'])."</a>";
else else
$profile['network_name'] = network_to_name($profile['network']); $profile['network_name'] = network_to_name($profile['network']);
} else } else

View File

@ -2977,9 +2977,6 @@ function item_is_remote_self($contact, &$datarray) {
$datarray['private'] = 0; $datarray['private'] = 0;
} }
//if (!isset($datarray["app"]) OR ($datarray["app"] == ""))
// $datarray["app"] = network_to_name($contact['network']);
if ($contact['network'] != NETWORK_FEED) { if ($contact['network'] != NETWORK_FEED) {
// Store the original post // Store the original post
$r = item_store($datarray2, false, false); $r = item_store($datarray2, false, false);

View File

@ -92,6 +92,10 @@ function onepoll_run(&$argv, &$argc){
); );
if(! count($contacts)) { if(! count($contacts)) {
// Maybe it is a Redmatrix account. Then we can fetch their contacts via poco
$contacts = q("SELECT `id`, `poco` FROM `contact` WHERE `id` = %d AND `poco` != ''", intval($contact_id));
if ($contacts)
poco_load($contacts[0]['id'],$importer_uid,0,$contacts[0]['poco']);
return; return;
} }

View File

@ -124,8 +124,9 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
$keywords = implode(", ", $tag); $keywords = implode(", ", $tag);
// If you query a Friendica server for its profiles, the network has to be Friendica // If you query a Friendica server for its profiles, the network has to be Friendica
if ($uid == 0) // To-Do: It could also be a Redmatrix server
$network = NETWORK_DFRN; //if ($uid == 0)
// $network = NETWORK_DFRN;
poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid, $uid, $zcid); poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid, $uid, $zcid);

View File

@ -505,7 +505,7 @@ function contacts_content(&$a) {
$poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2)); $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2));
$nettype = sprintf( t('Network type: %s'),network_to_name($contact['network'])); $nettype = sprintf( t('Network type: %s'),network_to_name($contact['network'], $contact["url"]));
$common = count_common_friends(local_user(),$contact['id']); $common = count_common_friends(local_user(),$contact['id']);
$common_text = (($common) ? sprintf( tt('%d contact in common','%d contacts in common', $common),$common) : ''); $common_text = (($common) ? sprintf( tt('%d contact in common','%d contacts in common', $common),$common) : '');
@ -806,7 +806,7 @@ function _contact_detail_for_template($rr){
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'itemurl' => $rr['url'], 'itemurl' => $rr['url'],
'url' => $url, 'url' => $url,
'network' => network_to_name($rr['network']), 'network' => network_to_name($rr['network'], $rr['url']),
); );
} }

View File

@ -43,13 +43,13 @@ function nogroup_content(&$a) {
'id' => $rr['id'], 'id' => $rr['id'],
'alt_text' => $alt_text, 'alt_text' => $alt_text,
'dir_icon' => $dir_icon, 'dir_icon' => $dir_icon,
'thumb' => $rr['thumb'], 'thumb' => $rr['thumb'],
'name' => $rr['name'], 'name' => $rr['name'],
'username' => $rr['name'], 'username' => $rr['name'],
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'itemurl' => $rr['url'], 'itemurl' => $rr['url'],
'url' => $url, 'url' => $url,
'network' => network_to_name($rr['network']), 'network' => network_to_name($rr['network'], $url),
); );
} }
} }
@ -59,8 +59,8 @@ function nogroup_content(&$a) {
'$header' => t('Contacts who are not members of a group'), '$header' => t('Contacts who are not members of a group'),
'$contacts' => $contacts, '$contacts' => $contacts,
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ));
return $o; return $o;
} }

View File

@ -68,7 +68,7 @@ function viewcontacts_content(&$a) {
'url' => $url, 'url' => $url,
'sparkle' => '', 'sparkle' => '',
'itemurl' => $rr['url'], 'itemurl' => $rr['url'],
'network' => network_to_name($rr['network']), 'network' => network_to_name($rr['network'], $rr['url']),
); );
} }

View File

@ -4,6 +4,7 @@ if(class_exists('Item'))
require_once('object/BaseObject.php'); require_once('object/BaseObject.php');
require_once('include/text.php'); require_once('include/text.php');
require_once('include/diaspora.php');
require_once('boot.php'); require_once('boot.php');
/** /**
@ -82,7 +83,6 @@ class Item extends BaseObject {
*/ */
public function get_template_data($alike, $dlike, $thread_level=1) { public function get_template_data($alike, $dlike, $thread_level=1) {
require_once("mod/proxy.php"); require_once("mod/proxy.php");
require_once("include/diaspora.php");
$result = array(); $result = array();
@ -368,7 +368,7 @@ class Item extends BaseObject {
'postopts' => $langstr, 'postopts' => $langstr,
'edited' => $edited, 'edited' => $edited,
'network' => $item["item_network"], 'network' => $item["item_network"],
'network_name' => network_to_name($item['item_network']), 'network_name' => network_to_name($item['item_network'], $profile_link),
); );
$arr = array('item' => $item, 'output' => $tmp_item); $arr = array('item' => $item, 'output' => $tmp_item);