streams/mod/common.php

74 lines
1.3 KiB
PHP
Raw Normal View History

2011-11-02 02:16:33 +00:00
<?php
require_once('include/socgraph.php');
2013-02-13 23:39:48 +00:00
function common_init(&$a) {
2011-11-02 02:16:33 +00:00
if(argc() > 1 && intval(argv(1)))
$channel_id = intval(argv(1));
2012-05-04 08:46:36 +00:00
else {
notice( t('No channel.') . EOL );
2013-02-13 23:39:48 +00:00
$a->error = 404;
2011-11-02 02:16:33 +00:00
return;
2013-02-13 23:39:48 +00:00
}
$x = q("select channel_address from channel where channel_id = %d limit 1",
intval($channel_id)
};
2011-11-02 02:16:33 +00:00
if($x)
profile_load($a,$x[0]['channel_address'],0);
2012-05-04 08:46:36 +00:00
2013-02-13 23:39:48 +00:00
}
2012-05-04 08:46:36 +00:00
2013-02-13 23:39:48 +00:00
function common_aside(&$a) {
if(! $a->profile['profile_uid'])
return;
2012-05-04 08:46:36 +00:00
2013-02-13 23:39:48 +00:00
profile_create_sidebar($a);
}
2012-05-04 08:46:36 +00:00
2013-02-13 23:39:48 +00:00
function common_content(&$a) {
2012-05-04 08:46:36 +00:00
2013-02-13 23:39:48 +00:00
$o = '';
if(! $a->profile['profile_uid'])
return;
2012-05-04 08:46:36 +00:00
2013-02-13 23:39:48 +00:00
$observer_hash = get_observer_hash();
2012-05-04 08:46:36 +00:00
2011-11-02 02:16:33 +00:00
2013-02-13 23:39:48 +00:00
if(! perm_is_allowed($a->profile['profile_uid'],$observer_hash,'view_contacts')) {
notice( t('Permission denied.') . EOL);
return;
}
$o .= '<h2>' . t('Common connections') . '</h2>';
2011-11-02 02:16:33 +00:00
2013-02-13 23:39:48 +00:00
$t = count_common_friends($a->profile['profile_uid'],$observer_hash);
if(! $t)
notice( t('No connections in common.') . EOL);
2011-11-02 02:16:33 +00:00
return $o;
}
2013-02-13 23:39:48 +00:00
$r = common_friends($a->profile['profile_uid'],$observer_hash);
if($r) {
2011-11-02 02:16:33 +00:00
$tpl = get_markup_template('common_friends.tpl');
foreach($r as $rr) {
2013-02-13 23:39:48 +00:00
$o .= replace_macros($tpl,array(
2011-11-02 02:16:33 +00:00
'$url' => $rr['url'],
'$name' => $rr['name'],
'$photo' => $rr['photo'],
'$tags' => ''
));
}
$o .= cleardiv();
return $o;
}