Merge remote-tracking branch 'upstream/develop' into 1512-contact-rework

Conflicts:
	mod/contacts.php
	mod/crepair.php
This commit is contained in:
Michael Vogel 2015-12-03 14:38:04 +01:00
commit 1a170c8743
26 changed files with 269 additions and 177 deletions

View file

@ -45,39 +45,9 @@ if(! function_exists('profile_load')) {
return;
}
if(remote_user() && count($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $visitor) {
if($visitor['uid'] == $user[0]['uid']) {
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($visitor['cid'])
);
if(count($r))
$profile = $r[0]['profile-id'];
break;
}
}
}
$pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile);
$r = null;
if($profile) {
$profile_int = intval($profile);
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr` AS faddr, `user`.* FROM `profile`
INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d AND `contact`.`self` = 1 LIMIT 1",
dbesc($nickname),
intval($profile_int)
);
}
if((!$r) && (!count($r))) {
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr` AS faddr, `user`.* FROM `profile`
INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 AND `contact`.`self` = 1 LIMIT 1",
dbesc($nickname)
);
}
if(($r === false) || (!count($r)) && !count($profiledata)) {
if(($pdata === false) || (!count($pdata)) && !count($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
notice( t('Requested profile is not available.') . EOL );
$a->error = 404;
@ -86,16 +56,16 @@ if(! function_exists('profile_load')) {
// fetch user tags if this isn't the default profile
if(!$r[0]['is-default']) {
if(!$pdata['is-default']) {
$x = q("SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
intval($r[0]['profile_uid'])
intval($pdata['profile_uid'])
);
if($x && count($x))
$r[0]['pub_keywords'] = $x[0]['pub_keywords'];
$pdata['pub_keywords'] = $x[0]['pub_keywords'];
}
$a->profile = $r[0];
$a->profile_uid = $r[0]['profile_uid'];
$a->profile = $pdata;
$a->profile_uid = $pdata['profile_uid'];
$a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme');
$a->profile['network'] = NETWORK_DFRN;
@ -147,6 +117,58 @@ if(! function_exists('profile_load')) {
}
/**
* @brief Get all profil data of a local user
* If the viewer is an authenticated remote viewer, the profile displayed is the
* one that has been configured for his/her viewing in the Contact manager.
* Passing a non-zero profile ID can also allow a preview of a selected profile
* by the owner
*
* @param string $nickname
* @param int $uid
* @param int $profile
* ID of the profile
* @returns array
* Includes all available profile data
*/
function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
if(remote_user() && count($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $visitor) {
if($visitor['uid'] == $uid) {
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($visitor['cid'])
);
if(count($r))
$profile = $r[0]['profile-id'];
break;
}
}
}
$r = null;
if($profile) {
$profile_int = intval($profile);
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.* FROM `profile`
INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d AND `contact`.`self` = 1 LIMIT 1",
dbesc($nickname),
intval($profile_int)
);
}
if((!$r) && (!count($r))) {
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.* FROM `profile`
INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 AND `contact`.`self` = 1 LIMIT 1",
dbesc($nickname)
);
}
return $r[0];
}
/**
*
* Function: profile_sidebar
@ -161,8 +183,6 @@ if(! function_exists('profile_load')) {
* Exceptions: Returns empty string if passed $profile is wrong type or not populated
*
*/
if(! function_exists('profile_sidebar')) {
function profile_sidebar($profile, $block = 0) {
$a = get_app();
@ -170,7 +190,7 @@ if(! function_exists('profile_sidebar')) {
$o = '';
$location = false;
$address = false;
$pdesc = true;
// $pdesc = true;
if((! is_array($profile)) && (! count($profile)))
return $o;
@ -178,12 +198,8 @@ if(! function_exists('profile_sidebar')) {
$profile['picdate'] = urlencode($profile['picdate']);
if (($profile['network'] != "") AND ($profile['network'] != NETWORK_DFRN)) {
require_once('include/contact_selectors.php');
if ($profile['url'] != "")
$profile['network_name'] = '<a href="'.$profile['url'].'">'.network_to_name($profile['network'], $profile['url'])."</a>";
else
$profile['network_name'] = network_to_name($profile['network']);
} else
$profile['network_name'] = format_network_name($profile['network'],$profile['url']);
} else
$profile['network_name'] = "";
call_hooks('profile_sidebar_enter', $profile);
@ -270,6 +286,16 @@ if(! function_exists('profile_sidebar')) {
);
}
// check if profile is a forum
if((x($profile['page-flags']) == 2)
|| (x($profile['page-flags']) == 5)
|| (x($profile['forum']))
|| (x($profile['prv']))
|| (x($profile['community'])))
$account_type = t('Forum');
else
$account_type = "";
if((x($profile,'address') == 1)
|| (x($profile,'locality') == 1)
|| (x($profile,'region') == 1)
@ -344,9 +370,10 @@ if(! function_exists('profile_sidebar')) {
'$remoteconnect' => $remoteconnect,
'$subscribe_feed' => $subscribe_feed,
'$wallmessage' => $wallmessage,
'$account_type' => $account_type,
'$location' => $location,
'$gender' => $gender,
'$pdesc' => $pdesc,
// '$pdesc' => $pdesc,
'$marital' => $marital,
'$homepage' => $homepage,
'$about' => $about,

View file

@ -1250,8 +1250,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
if ($notify)
$guid_prefix = "";
else
$guid_prefix = $arr['network'];
else {
$parsed = parse_url($arr["author-link"]);
$guid_prefix = hash("crc32", $parsed["host"]);
}
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
$arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid(32, $guid_prefix));
@ -2320,6 +2322,9 @@ function edited_timestamp_is_newer($existing, $update) {
function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) {
if ($contact['network'] === NETWORK_OSTATUS) {
if ($pass < 2) {
// Test - remove before flight
//$tempfile = tempnam(get_temppath(), "ostatus2");
//file_put_contents($tempfile, $xml);
logger("Consume OStatus messages ", LOGGER_DEBUG);
ostatus_import($xml,$importer,$contact, $hub);
}

View file

@ -1282,6 +1282,14 @@ function ostatus_add_author($doc, $owner, $profile) {
return $author;
}
/*
To-Do: Picture attachments should look like this:
<a href="https://status.pirati.ca/attachment/572819" title="https://status.pirati.ca/file/heluecht-20151202T222602-rd3u49p.gif"
class="attachment thumbnail" id="attachment-572819" rel="nofollow external">https://status.pirati.ca/attachment/572819</a>
*/
function ostatus_entry($doc, $item, $owner, $toplevel = false) {
$a = get_app();

View file

@ -2289,32 +2289,23 @@ function formatBytes($bytes, $precision = 2) {
}
/**
* @brief Translate the PAGE type flags in human readable string
* @brief translate and format the networkname of a contact
*
* @param int $page_type
* @return string $trans_type
* @param string $network
* Networkname of the contact (e.g. dfrn, rss and so on)
* @param sting $url
* The contact url
* @return string
*/
function page_type_translate($page_type) {
function format_network_name($network, $url = 0) {
if ($network != "") {
require_once('include/contact_selectors.php');
if ($url != "")
$network_name = '<a href="'.$url.'">'.network_to_name($network, $url)."</a>";
else
$network_name = network_to_name($network);
// ToDo: we need a good interpretable translation for PAGE_SOAPBOX
// and PAGE_PRVGROUP
switch ($page_type) {
case PAGE_NORMAL:
$trans_type = t('Normal Account');
break;
case PAGE_SOAPBOX:
$trans_type = t('Fan Page');
break;
case PAGE_COMMUNITY:
$trans_type = t('Community Forum');
break;
case PAGE_FREELOVE:
$trans_type = t('Open Forum');
break;
case PAGE_PRVGROUP:
$trans_type = t('Private Forum');
break;
return $network_name;
}
return $trans_type;
}