set theme for un-viewable profile
This commit is contained in:
parent
b2dc95f383
commit
5bd71e4e4d
@ -486,12 +486,12 @@ function profile_load(&$a, $nickname, $profile = '') {
|
|||||||
// get the current observer
|
// get the current observer
|
||||||
$observer = $a->get_observer();
|
$observer = $a->get_observer();
|
||||||
|
|
||||||
|
$can_view_profile = true;
|
||||||
|
|
||||||
// Can the observer see our profile?
|
// Can the observer see our profile?
|
||||||
require_once('include/permissions.php');
|
require_once('include/permissions.php');
|
||||||
if(! perm_is_allowed($user[0]['channel_id'],$observer['xchan_hash'],'view_profile')) {
|
if(! perm_is_allowed($user[0]['channel_id'],$observer['xchan_hash'],'view_profile')) {
|
||||||
// permission denied
|
$can_view_profile = false;
|
||||||
notice( t(' Sorry, you don\'t have the permission to view this profile. ') . EOL);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $profile) {
|
if(! $profile) {
|
||||||
@ -502,10 +502,10 @@ function profile_load(&$a, $nickname, $profile = '') {
|
|||||||
if($r)
|
if($r)
|
||||||
$profile = $r[0]['abook_profile'];
|
$profile = $r[0]['abook_profile'];
|
||||||
}
|
}
|
||||||
$r = null;
|
$p = null;
|
||||||
|
|
||||||
if($profile) {
|
if($profile) {
|
||||||
$r = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
|
$p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
|
||||||
LEFT JOIN channel ON profile.uid = channel.channel_id
|
LEFT JOIN channel ON profile.uid = channel.channel_id
|
||||||
WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1",
|
WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1",
|
||||||
dbesc($nickname),
|
dbesc($nickname),
|
||||||
@ -513,7 +513,7 @@ function profile_load(&$a, $nickname, $profile = '') {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $r) {
|
if(! $p) {
|
||||||
$r = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
|
$r = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
|
||||||
LEFT JOIN channel ON profile.uid = channel.channel_id
|
LEFT JOIN channel ON profile.uid = channel.channel_id
|
||||||
WHERE channel.channel_address = '%s' and not ( channel_pageflags & %d )
|
WHERE channel.channel_address = '%s' and not ( channel_pageflags & %d )
|
||||||
@ -523,7 +523,7 @@ function profile_load(&$a, $nickname, $profile = '') {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $r) {
|
if(! $p) {
|
||||||
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
|
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
|
||||||
notice( t('Requested profile is not available.') . EOL );
|
notice( t('Requested profile is not available.') . EOL );
|
||||||
$a->error = 404;
|
$a->error = 404;
|
||||||
@ -532,37 +532,42 @@ function profile_load(&$a, $nickname, $profile = '') {
|
|||||||
|
|
||||||
// fetch user tags if this isn't the default profile
|
// fetch user tags if this isn't the default profile
|
||||||
|
|
||||||
if(! $r[0]['is_default']) {
|
if(! $p[0]['is_default']) {
|
||||||
$x = q("select `keywords` from `profile` where uid = %d and `is_default` = 1 limit 1",
|
$x = q("select `keywords` from `profile` where uid = %d and `is_default` = 1 limit 1",
|
||||||
intval($profile_uid)
|
intval($profile_uid)
|
||||||
);
|
);
|
||||||
if($x)
|
if($x && $can_view_profile)
|
||||||
$r[0]['keywords'] = $x[0]['keywords'];
|
$p[0]['keywords'] = $x[0]['keywords'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($r[0]['keywords']) {
|
if($p[0]['keywords']) {
|
||||||
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$r[0]['keywords']);
|
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$p[0]['keywords']);
|
||||||
if(strlen($keywords))
|
if(strlen($keywords) && $can_view_profile)
|
||||||
$a->page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords,ENT_COMPAT,'UTF-8') . '" />' . "\r\n" ;
|
$a->page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords,ENT_COMPAT,'UTF-8') . '" />' . "\r\n" ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->profile = $r[0];
|
if($can_view_profile) {
|
||||||
|
$a->profile = $p[0];
|
||||||
$online = get_online_status($nickname);
|
$online = get_online_status($nickname);
|
||||||
$a->profile['online_status'] = $online['result'];
|
$a->profile['online_status'] = $online['result'];
|
||||||
|
|
||||||
$a->profile_uid = $r[0]['profile_uid'];
|
$a->profile_uid = $p[0]['profile_uid'];
|
||||||
|
|
||||||
$a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname();
|
$a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(local_user()) {
|
||||||
$a->profile['channel_mobile_theme'] = get_pconfig(local_user(),'system', 'mobile_theme');
|
$a->profile['channel_mobile_theme'] = get_pconfig(local_user(),'system', 'mobile_theme');
|
||||||
$_SESSION['theme'] = $a->profile['channel_theme'];
|
|
||||||
$_SESSION['mobile_theme'] = $a->profile['channel_mobile_theme'];
|
$_SESSION['mobile_theme'] = $a->profile['channel_mobile_theme'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load/reload current theme info
|
* load/reload current theme info
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$_SESSION['theme'] = $p[0]['channel_theme'];
|
||||||
|
|
||||||
$a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
|
$a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
|
||||||
|
|
||||||
$theme_info_file = "view/theme/".current_theme()."/php/theme.php";
|
$theme_info_file = "view/theme/".current_theme()."/php/theme.php";
|
||||||
@ -570,6 +575,12 @@ function profile_load(&$a, $nickname, $profile = '') {
|
|||||||
require_once($theme_info_file);
|
require_once($theme_info_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(! $can_view_profile) {
|
||||||
|
// permission denied
|
||||||
|
notice( t(' Sorry, you don\'t have the permission to view this profile. ') . EOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2014-02-23.597
|
2014-02-24.598
|
||||||
|
Reference in New Issue
Block a user