3 function profile_init(&$a) {
5 if((get_config('system','block_public')) && (! local_user()) && (! remote_user()))
11 notice( t('No profile') . EOL );
17 if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
18 $which = $a->user['nickname'];
19 $profile = $a->argv[1];
22 profile_load($a,$which,$profile);
24 if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] & PAGE_COMMUNITY)) {
25 $a->page['htmlhead'] .= '<meta name="friendika.community" content="true" />';
27 if(x($a->profile,'openidserver'))
28 $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
29 if(x($a->profile,'openid')) {
30 $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
31 $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
34 $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
35 $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
37 $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
39 $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
40 $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
41 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
42 $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
43 header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
45 $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
46 foreach($dfrn_pages as $dfrn)
47 $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
52 function profile_content(&$a, $update = 0) {
54 if(get_config('system','block_public') && (! local_user()) && (! remote_user())) {
58 if($a->profile['hidewall'] && (! local_user()) && (! remote_user())) {
59 notice( t('Access to this profile has been restricted.') . EOL);
63 require_once("include/bbcode.php");
64 require_once('include/security.php');
65 require_once('include/conversation.php');
66 require_once('include/acl_selectors.php');
73 // Ensure we've got a profile owner if updating.
74 $a->profile['profile_uid'] = $update;
77 if($a->profile['profile_uid'] == local_user())
78 $o .= '<script> $(document).ready(function() { $(\'#nav-home-link\').addClass(\'nav-selected\'); });</script>';
82 $remote_contact = false;
85 $contact_id = $_SESSION['visitor_id'];
86 $groups = init_groups_visitor($contact_id);
87 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
89 intval($a->profile['profile_uid'])
93 $remote_contact = true;
97 if(! $remote_contact) {
99 $contact_id = $_SESSION['cid'];
100 $contact = $a->contact;
104 $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
108 $tab = notags(trim($_GET['tab']));
110 $tpl = get_markup_template('profile_tabs.tpl');
112 $o .= replace_macros($tpl,array(
113 '$url' => $a->get_baseurl() . '/' . $a->cmd,
114 '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname'],
115 '$status' => t('Status'),
116 '$profile' => t('Profile'),
117 '$photos' => t('Photos')
121 if($tab === 'profile') {
122 require_once('include/profile_advanced.php');
123 $o .= advanced_profile($a);
124 call_hooks('profile_advanced',$o);
128 $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
129 $commvisitor = (($commpage && $remote_contact == true) ? true : false);
131 $celeb = ((($a->profile['page-flags'] == PAGE_SOAPBOX) || ($a->profile['page-flags'] == PAGE_COMMUNITY)) ? true : false);
133 if(can_write_wall($a,$a->profile['profile_uid'])) {
136 'is_owner' => $is_owner,
137 'allow_location' => ((($is_owner || $commvisitor) && $a->profile['allow_location']) ? true : false),
138 'default_location' => (($is_owner) ? $a->user['default-location'] : ''),
139 'nickname' => $a->profile['nickname'],
140 'lockstate' => (((is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
141 'acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''),
143 'visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'),
144 'profile_uid' => $a->profile['profile_uid']
147 $o .= status_editor($a,$x);
150 // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
151 // because browser prefetching might change it on us. We have to deliver it with the page.
153 if($tab === 'posts') {
154 $o .= '<div id="live-profile"></div>' . "\r\n";
155 $o .= "<script> var profile_uid = " . $a->profile['profile_uid']
156 . "; var netargs = ''; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
160 // Construct permissions
162 // default permissions - anonymous user
164 $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
166 // Profile owner - everything is visible
171 // Oh - while we're here... reset the Unseen messages
173 $r = q("UPDATE `item` SET `unseen` = 0
174 WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d",
175 intval($_SESSION['uid'])
180 // authenticated visitor - here lie dragons
181 // If $remotecontact is true, we know that not only is this a remotely authenticated
182 // person, but that it is *our* contact, which is important in multi-user mode.
184 elseif($remote_contact) {
185 $gs = '<<>>'; // should be impossible to match
187 foreach($groups as $g)
188 $gs .= '|<' . intval($g) . '>';
190 $sql_extra = sprintf(
191 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
192 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
193 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
194 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
196 intval($_SESSION['visitor_id']),
197 intval($_SESSION['visitor_id']),
203 $r = q("SELECT COUNT(*) AS `total`
204 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
205 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
206 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
207 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
209 intval($a->profile['profile_uid'])
214 $a->set_pager_total($r[0]['total']);
215 $a->set_pager_itemspage(40);
218 $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
219 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
220 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
221 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
222 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
224 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
225 intval($a->profile['profile_uid']),
226 intval($a->pager['start']),
227 intval($a->pager['itemspage'])
231 $parents_arr = array();
236 $parents_arr[] = $rr['item_id'];
237 $parents_str = implode(', ', $parents_arr);
239 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
240 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`,
241 `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
242 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
243 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
244 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
245 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
246 AND `item`.`parent` IN ( %s )
248 ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
249 intval($a->profile['profile_uid']),
254 if($is_owner && ! $update)
255 $o .= get_birthdays();
259 $o .= conversation($a,$r,'profile',$update);
265 $o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';