aboutsummaryrefslogtreecommitdiffstats
path: root/mod/profile.php
blob: 91623b8662a86b6742a5da4832b8d70e55f5c92e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php

function profile_init(&$a) {

	$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;

}


function profile_aside(&$a) {

	require_once('include/contact_widgets.php');
	require_once('include/items.php');

	if(argc() > 1)
		$which = argv(1);
	else {
		notice( t('Requested profile is not available.') . EOL );
		$a->error = 404;
		return;
	}

	$profile = 0;
	$channel = $a->get_channel();

	if((local_user()) && (argc() > 2) && (argv(2) === 'view')) {
		$which = $channel['channel_address'];
		$profile = argv(1);		
	}


	$x = q("select uid as profile_uid from channel where address = '%s' limit 1",
		dbesc(argv(1)
	);
	if($x) {
		$a->profile = $x[0];
		$channel_display = get_pconfig($a->profile['profile_uid'],'system','channel_format');
		if(! $channel_display)
			profile_load($a,$which,$profile);
		if($channel_display === 'full')
			$a->page['template'] = 'full';
		else {
			$a->set_widget('archive',posted_date_widget($a->get_baseurl(true) . '/channel/' . $a->profile['nickname'],$a->profile['profile_uid'],true));	
			$a->set_widget('categories',categories_widget($a->get_baseurl(true) . '/channel/' . $a->profile['nickname'],$cat));
		}
	}
}


function profile_content(&$a, $update = 0) {

	if(get_config('system','block_public') && (! get_account_id()) && (! remote_user())) {
			return login();
	}


	require_once("include/bbcode.php");
	require_once('include/security.php');
	require_once('include/conversation.php');
	require_once('include/acl_selectors.php');
	require_once('include/items.php');

	$groups = array();

	$tab = 'profile';
	$o = '';

	if($a->profile['profile_uid'] == local_user()) {
		nav_set_selected('home');
	}

	$contact = null;
	$remote_contact = false;

	$contact_id = 0;

	if(is_array($_SESSION['remote'])) {
		foreach($_SESSION['remote'] as $v) {
			if($v['uid'] == $a->profile['profile_uid']) {
				$contact_id = $v['cid'];
				break;
			}
		}
	}

	if($contact_id) {
		$groups = init_groups_visitor($contact_id);
		$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
			intval($contact_id),
			intval($a->profile['profile_uid'])
		);
		if(count($r)) {
			$contact = $r[0];
			$remote_contact = true;
		}
	}

	if(! $remote_contact) {
		if(local_user()) {
			$contact_id = $_SESSION['cid'];
			$contact = $a->contact;
		}
	}

	$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);

	if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
		notice( t('Access to this profile has been restricted.') . EOL);
		return;
	}


	$o .= profile_tabs($a, $is_owner, $a->profile['channel_address']);


	require_once('include/profile_advanced.php');
	$o .= advanced_profile($a);
	call_hooks('profile_advanced',$o);
	return $o;

}