streams/include/contact_widgets.php

206 lines
5.2 KiB
PHP
Raw Normal View History

2013-02-26 01:09:40 +00:00
<?php /** @file */
2013-12-07 05:40:01 +00:00
function follow_widget() {
$a = get_app();
$uid =$a->channel['channel_id'];
$r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d) ",
intval($uid),
intval(ABOOK_FLAG_SELF)
);
if($r)
$total_channels = $r[0]['total'];
$limit = service_class_fetch($uid,'total_channels');
if($limit !== false) {
$abook_usage_message = sprintf( t("You have %1$.0f of %2$.0f allowed connections."), $total_channels, $limit);
}
else {
$abook_usage_message = '';
}
return replace_macros(get_markup_template('follow.tpl'),array(
'$connect' => t('Add New Connection'),
'$desc' => t('Enter the channel address'),
'$hint' => t('Example: bob@example.com, http://example.com/barbara'),
'$follow' => t('Connect'),
'$abook_usage_message' => $abook_usage_message
));
}
function findpeople_widget() {
2012-04-11 03:50:31 +00:00
require_once('include/Contact.php');
$a = get_app();
if(get_config('system','invitation_only')) {
$x = get_pconfig(local_user(),'system','invites_remaining');
if($x || is_site_admin()) {
$a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
. sprintf( tt('%d invitation available','%d invitations available',$x), $x)
. '</div>' . $inv;
}
}
return replace_macros(get_markup_template('peoplefind.tpl'),array(
2012-11-03 09:34:12 +00:00
'$findpeople' => t('Find Channels'),
'$desc' => t('Enter name or interest'),
'$label' => t('Connect/Follow'),
'$hint' => t('Examples: Robert Morgenstein, Fishing'),
'$findthem' => t('Find'),
2012-11-03 09:34:12 +00:00
'$suggest' => t('Channel Suggestions'),
'$similar' => '', // FIXME and uncomment when mod/match working // t('Similar Interests'),
2012-04-11 03:50:31 +00:00
'$random' => t('Random Profile'),
'$inv' => t('Invite Friends')
));
}
2011-11-02 04:27:11 +00:00
function fileas_widget($baseurl,$selected = '') {
$a = get_app();
2012-07-10 05:08:25 +00:00
if(! local_user())
return '';
$terms = array();
2012-07-10 05:08:25 +00:00
$r = q("select distinct(term) from term where uid = %d and type = %d order by term asc",
intval(local_user()),
intval(TERM_FILE)
);
2012-11-03 13:32:27 +00:00
if(! $r)
return;
foreach($r as $rr)
2012-07-10 05:08:25 +00:00
$terms[] = array('name' => $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : ''));
return replace_macros(get_markup_template('fileas_widget.tpl'),array(
2012-03-30 09:42:36 +00:00
'$title' => t('Saved Folders'),
'$desc' => '',
'$sel_all' => (($selected == '') ? 'selected' : ''),
'$all' => t('Everything'),
'$terms' => $terms,
'$base' => $baseurl,
));
}
2012-01-06 04:40:48 +00:00
function categories_widget($baseurl,$selected = '') {
$a = get_app();
2012-11-04 04:52:58 +00:00
if(! feature_enabled($a->profile['profile_uid'],'categories'))
2012-11-03 23:51:29 +00:00
return '';
$terms = array();
$r = q("select distinct(term.term)
from term join item on term.oid = item.id
where item.uid = %d
and term.uid = item.uid
and term.type = %d
and item.author_xchan = '%s'
order by term.term asc",
2012-07-10 05:08:25 +00:00
intval($a->profile['profile_uid']),
intval(TERM_CATEGORY),
2013-09-08 18:53:14 +00:00
dbesc($a->profile['channel_hash'])
2012-07-10 05:08:25 +00:00
);
if($r && count($r)) {
2012-07-10 05:08:25 +00:00
foreach($r as $rr)
$terms[] = array('name' => $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : ''));
return replace_macros(get_markup_template('categories_widget.tpl'),array(
'$title' => t('Categories'),
'$desc' => '',
'$sel_all' => (($selected == '') ? 'selected' : ''),
'$all' => t('Everything'),
'$terms' => $terms,
'$base' => $baseurl,
));
}
return '';
}
2012-05-02 02:16:18 +00:00
function common_friends_visitor_widget($profile_uid) {
$a = get_app();
if(local_user() == $profile_uid)
return;
$observer_hash = get_observer_hash();
2012-09-10 04:17:06 +00:00
if((! $observer_hash) || (! perm_is_allowed($profile_uid,$observer_hash,'view_contacts')))
return;
2012-05-02 02:16:18 +00:00
require_once('include/socgraph.php');
$t = count_common_friends($profile_uid,$observer_hash);
2012-05-02 02:16:18 +00:00
if(! $t)
return;
$r = common_friends($profile_uid,$observer_hash,0,5,true);
2012-05-02 02:16:18 +00:00
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => sprintf( tt("%d connection in common", "%d connections in common", $t), $t),
2012-05-04 08:46:36 +00:00
'$base' => $a->get_baseurl(),
'$uid' => $profile_uid,
'$cid' => $observer,
'$linkmore' => (($t > 5) ? 'true' : ''),
2012-05-04 08:46:36 +00:00
'$more' => t('show more'),
2012-05-02 02:20:41 +00:00
'$items' => $r
2012-05-02 02:16:18 +00:00
));
2013-12-07 05:40:01 +00:00
};
function suggest_widget() {
require_once('include/socgraph.php');
2013-12-07 06:48:06 +00:00
$r = suggestion_query(local_user(),get_observer_hash(),0,20);
2013-12-07 05:40:01 +00:00
if(! $r) {
return;
}
$arr = array();
2013-12-07 06:48:06 +00:00
// Get two random entries from the top 20 returned.
// We'll grab the first one and the one immediately following.
// This will throw some entropy intot he situation so you won't
// be looking at the same two mug shots every time the widget runs
$index = mt_rand(0,count($r) - 2);
for($x = $index; $x <= ($index+1); $x ++) {
$rr = $r[$x];
2013-12-07 05:40:01 +00:00
$connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
$arr[] = array(
'url' => chanlink_url($rr['xchan_url']),
'profile' => $rr['xchan_url'],
2013-12-07 05:40:01 +00:00
'name' => $rr['xchan_name'],
'photo' => $rr['xchan_photo_m'],
'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'],
'conntxt' => t('Connect'),
'connlnk' => $connlnk,
'ignore' => t('Ignore/Hide')
);
}
$o = replace_macros(get_markup_template('suggest_widget.tpl'),array(
'$title' => t('Suggestions'),
'$more' => t('See more...'),
'$entries' => $arr
));
return $o;
}