external user popup bugfixes

This commit is contained in:
Hannes Mannerheim 2014-11-24 16:10:59 +01:00
parent 2950f0a23b
commit 2d1ed0e038
3 changed files with 44 additions and 6 deletions

View File

@ -67,14 +67,48 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction
// get local profile
$local_profile = Profile::getKV('profileurl',$profileurl);
if($local_profile) {
$this->profile->local = $this->twitterUserArray($local_profile);
$username = $this->profile->local['screen_name'];
// if profile url is not ending with nickname, this is probably a single user instance
if(!substr($profileurl, -strlen($username))===$username) {
$instanceurl = $profileurl;
error_log('1');
}
// multi user instance
else {
error_log('2');
$instanceurl = substr($profileurl, 0, strrpos($profileurl, '/'));
}
}
// we don't know this user
else {
// if profile url ends with '/' this is probably an unknown single user instance
if(substr($profileurl, -1)==='/') {
$instanceurl = $profileurl;
$username = 1;
error_log('3');
}
// multi user instance
else {
$username = substr($profileurl, strrpos($profileurl, '/')+1);
$instanceurl = substr($profileurl, 0, strrpos($profileurl, '/'));
error_log('4');
}
}
// get profile from external instance
$instanceurl = substr($profileurl, 0, strrpos($profileurl, '/'));
$username = substr($profileurl, strrpos($profileurl, '/')+1);
$apicall = $instanceurl.'/api/users/show.json?id='.$username;
$apicall = $instanceurl.'/api/users/show.json?id='.$username;
error_log('apicall:'.$apicall);
stream_context_set_default(array('http' => array('method' => 'GET')));
$this->profile->external = json_decode(file_get_contents($apicall));

View File

@ -715,7 +715,7 @@ class QvitterAction extends ApiAction
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lib/jquery.minicolors.min.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lib/jquery.jWindowCrop.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lib/load-image.min.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/dom-functions.js?v=40"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/dom-functions.js?v=41"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/misc-functions.js?v=40"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/ajax-functions.js?v=40"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lan.js?v=40"></script>

View File

@ -1139,6 +1139,10 @@ function popUpAction(popupId, heading, bodyHtml, footerHtml){
function convertNewGNUSocialURItoURL(obj) {
if(typeof obj.uri == 'undefined') {
obj.uri = '';
}
if(obj.uri.substring(0,4) != 'http') {
// guess the url if we only have the non-url uri
@ -1779,7 +1783,7 @@ function buildQueetHtml(obj, idInStream, extraClassesThisRun, requeeted_by) {
// in-groups html
var in_groups_html = '';
if(obj.statusnet_in_groups !== false && typeof obj.statusnet_in_groups != 'undefined') {
if(typeof obj.statusnet_in_groups != 'undefined' && obj.statusnet_in_groups !== false && typeof obj.statusnet_in_groups === 'object') {
$.each(obj.statusnet_in_groups,function(){
in_groups_html = '<span class="in-groups"><a class="h-card group" href="' + obj.statusnet_in_groups.url + '">!' + obj.statusnet_in_groups.nickname + '</a></span>';
});
@ -1805,7 +1809,7 @@ function buildQueetHtml(obj, idInStream, extraClassesThisRun, requeeted_by) {
var requeetedByHtml = '<a data-user-id="' + requeeted_by.user.id + '" href="' + requeeted_by.user.statusnet_profile_url + '"> <b>' + requeeted_by.user.name + '</b></a>';
requeetHtml = '<div class="context" id="requeet-' + requeeted_by.id + '"><span class="with-icn"><i class="badge-requeeted"></i><span class="requeet-text"> ' + window.sL.requeetedBy.replace('{requeeted-by}',requeetedByHtml) + '</span></span></div>';
}
obj = convertNewGNUSocialURItoURL(obj);
// external