3 function profile_init(&$a) {
8 notice( t('No profile') . EOL );
14 if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
15 $which = $a->user['nickname'];
16 $profile = $a->argv[1];
19 profile_load($a,$which,$profile);
21 if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] & PAGE_COMMUNITY)) {
22 $a->page['htmlhead'] .= '<meta name="friendika.community" content="true" />';
24 if(x($a->profile,'openidserver'))
25 $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
26 if(x($a->profile,'openid')) {
27 $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
28 $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
31 $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
32 $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
34 $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
36 $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
37 $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
38 $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
39 $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
40 header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
42 $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
43 foreach($dfrn_pages as $dfrn)
44 $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
49 function profile_content(&$a, $update = 0) {
51 require_once("include/bbcode.php");
52 require_once('include/security.php');
60 // Ensure we've got a profile owner if updating.
61 $a->profile['profile_uid'] = $update;
64 if($a->profile['profile_uid'] == local_user())
65 $o .= '<script> $(document).ready(function() { $(\'#nav-home-link\').addClass(\'nav-selected\'); });</script>';
69 $remote_contact = false;
72 $contact_id = $_SESSION['visitor_id'];
73 $groups = init_groups_visitor($contact_id);
74 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
76 intval($a->profile['profile_uid'])
80 $remote_contact = true;
84 if(! $remote_contact) {
86 $contact_id = $_SESSION['cid'];
87 $contact = $a->contact;
91 $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
95 $tab = notags(trim($_GET['tab']));
97 $tpl = load_view_file('view/profile_tabs.tpl');
99 $o .= replace_macros($tpl,array(
100 '$url' => $a->get_baseurl() . '/' . $a->cmd,
101 '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname'],
102 '$status' => t('Status'),
103 '$profile' => t('Profile'),
104 '$photos' => t('Photos')
108 if($tab === 'profile') {
109 require_once('include/profile_advanced.php');
110 $o .= advanced_profile($a);
111 call_hooks('profile_advanced',$o);
115 $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
116 $commvisitor = (($commpage && $remote_contact == true) ? true : false);
118 $celeb = ((($a->profile['page-flags'] == PAGE_SOAPBOX) || ($a->profile['page-flags'] == PAGE_COMMUNITY)) ? true : false);
120 if(can_write_wall($a,$a->profile['profile_uid'])) {
122 $geotag = ((($is_owner || $commvisitor) && $a->profile['allow_location']) ? load_view_file('view/jot_geotag.tpl') : '');
124 $tpl = load_view_file('view/jot-header.tpl');
126 $a->page['htmlhead'] .= replace_macros($tpl, array(
127 '$baseurl' => $a->get_baseurl(),
128 '$geotag' => $geotag,
129 '$nickname' => $a->profile['nickname'],
130 '$linkurl' => t('Please enter a link URL:'),
131 '$utubeurl' => t('Please enter a YouTube link:'),
132 '$vidurl' => t("Please enter a video\x28.ogg\x29 link/URL:"),
133 '$audurl' => t("Please enter an audio\x28.ogg\x29 link/URL:"),
134 '$whereareu' => t('Where are you right now?'),
135 '$title' => t('Enter a title for this item')
138 require_once('include/acl_selectors.php');
140 $tpl = load_view_file('view/jot.tpl');
142 if(is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))
145 $lockstate = 'unlock';
149 call_hooks('jot_tool', $jotplugins);
151 call_hooks('jot_networks', $jotnets);
153 $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
155 $o .= replace_macros($tpl,array(
156 '$baseurl' => $a->get_baseurl(),
158 '$share' => t('Share'),
159 '$upload' => t('Upload photo'),
160 '$weblink' => t('Insert web link'),
161 '$youtube' => t('Insert YouTube video'),
162 '$video' => t('Insert Vorbis [.ogg] video'),
163 '$audio' => t('Insert Vorbis [.ogg] audio'),
164 '$setloc' => t('Set your location'),
165 '$noloc' => t('Clear browser location'),
166 '$title' => t('Set title'),
167 '$wait' => t('Please wait'),
168 '$permset' => t('Permission settings'),
171 '$defloc' => (($is_owner) ? $a->user['default-location'] : ''),
172 '$return_path' => $a->cmd,
173 '$visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'),
174 '$lockstate' => $lockstate,
175 '$emailcc' => t('CC: email addresses'),
176 '$jotnets' => $jotnets,
177 '$emtitle' => t('Example: bob@example.com, mary@example.com'),
179 '$acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''),
180 '$profile_uid' => $a->profile['profile_uid']
184 // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
185 // because browser prefetching might change it on us. We have to deliver it with the page.
187 if($tab === 'posts') {
188 $o .= '<div id="live-profile"></div>' . "\r\n";
189 $o .= "<script> var profile_uid = " . $a->profile['profile_uid']
190 . "; var netargs = ''; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
194 // Construct permissions
196 // default permissions - anonymous user
198 $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
200 // Profile owner - everything is visible
205 // Oh - while we're here... reset the Unseen messages
207 $r = q("UPDATE `item` SET `unseen` = 0
208 WHERE `type` != 'remote' AND `unseen` = 1 AND `uid` = %d",
209 intval($_SESSION['uid'])
214 // authenticated visitor - here lie dragons
215 // If $remotecontact is true, we know that not only is this a remotely authenticated
216 // person, but that it is *our* contact, which is important in multi-user mode.
218 elseif($remote_contact) {
219 $gs = '<<>>'; // should be impossible to match
221 foreach($groups as $g)
222 $gs .= '|<' . intval($g) . '>';
224 $sql_extra = sprintf(
225 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
226 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
227 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
228 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
230 intval($_SESSION['visitor_id']),
231 intval($_SESSION['visitor_id']),
237 $r = q("SELECT COUNT(*) AS `total`
238 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
239 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
240 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
241 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
243 intval($a->profile['profile_uid'])
248 $a->set_pager_total($r[0]['total']);
249 $a->set_pager_itemspage(40);
252 $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
253 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
254 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
255 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
256 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
258 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
259 intval($a->profile['profile_uid']),
260 intval($a->pager['start']),
261 intval($a->pager['itemspage'])
265 $parents_arr = array();
270 $parents_arr[] = $rr['item_id'];
271 $parents_str = implode(', ', $parents_arr);
273 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
274 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`,
275 `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
276 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
277 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
278 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
279 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
280 AND `item`.`parent` IN ( %s )
282 ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
283 intval($a->profile['profile_uid']),
288 if($is_owner && ! $update)
289 $o .= get_birthdays();
292 require_once('include/conversation.php');
294 $o .= conversation($a,$r,'profile',$update);
300 $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>';