streams/include/contact_widgets.php

234 lines
6.4 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 findpeople_widget() {
if(get_config('system','invitation_only')) {
2015-01-29 04:56:04 +00:00
$x = get_pconfig(local_channel(),'system','invites_remaining');
if($x || is_site_admin()) {
2016-03-31 23:06:03 +00:00
App::$page['aside'] .= '<div class="side-link" id="side-invite-remain">'
. sprintf( tt('%d invitation available','%d invitations available',$x), $x)
. '</div>' . $inv;
}
}
2014-03-09 01:39:20 +00:00
$advanced_search = ((local_channel() && feature_enabled(local_channel(),'advanced_dirsearch')) ? t('Advanced') : false);
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'),
2014-03-09 01:39:20 +00:00
'$advanced_search' => $advanced_search,
'$advanced_hint' => "\r\n" . t('Advanced example: name=fred and country=iceland'),
2015-01-29 04:56:04 +00:00
'$loggedin' => local_channel()
));
}
2011-11-02 04:27:11 +00:00
function fileas_widget($baseurl,$selected = '') {
2012-07-10 05:08:25 +00:00
2015-01-29 04:56:04 +00:00
if(! local_channel())
return '';
$terms = array();
2016-06-01 04:45:33 +00:00
$r = q("select distinct(term) from term where uid = %d and ttype = %d order by term asc",
2015-01-29 04:56:04 +00:00
intval(local_channel()),
2012-07-10 05:08:25 +00:00
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 = '') {
2016-03-31 23:06:03 +00:00
if(! feature_enabled(App::$profile['profile_uid'],'categories'))
2012-11-03 23:51:29 +00:00
return '';
2017-10-23 19:35:46 +00:00
require_once('include/security.php');
$sql_extra = item_permissions_sql(App::$profile['profile_uid']);
$item_normal = item_normal();
$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
2016-06-01 04:45:33 +00:00
and term.ttype = %d
and term.otype = %d
and item.owner_xchan = '%s'
and item.item_wall = 1
$item_normal
2017-10-23 19:35:46 +00:00
$sql_extra
order by term.term asc",
2016-03-31 23:06:03 +00:00
intval(App::$profile['profile_uid']),
intval(TERM_CATEGORY),
intval(TERM_OBJ_POST),
2016-03-31 23:06:03 +00:00
dbesc(App::$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 '';
}
2017-08-23 07:01:02 +00:00
function cardcategories_widget($baseurl,$selected = '') {
if(! feature_enabled(App::$profile['profile_uid'],'categories'))
return '';
2017-10-23 19:35:46 +00:00
$sql_extra = item_permissions_sql(App::$profile['profile_uid']);
2017-08-23 07:01:02 +00:00
$item_normal = "and item.item_hidden = 0 and item.item_type = 6 and item.item_deleted = 0
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
$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.ttype = %d
and term.otype = %d
and item.owner_xchan = '%s'
$item_normal
2017-10-23 19:35:46 +00:00
$sql_extra
2017-08-23 07:01:02 +00:00
order by term.term asc",
intval(App::$profile['profile_uid']),
intval(TERM_CATEGORY),
intval(TERM_OBJ_POST),
dbesc(App::$profile['channel_hash'])
);
if($r && count($r)) {
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 '';
}
2017-11-22 23:39:06 +00:00
function articlecategories_widget($baseurl,$selected = '') {
if(! feature_enabled(App::$profile['profile_uid'],'categories'))
return '';
$sql_extra = item_permissions_sql(App::$profile['profile_uid']);
$item_normal = "and item.item_hidden = 0 and item.item_type = 7 and item.item_deleted = 0
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
$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.ttype = %d
and term.otype = %d
and item.owner_xchan = '%s'
$item_normal
$sql_extra
order by term.term asc",
intval(App::$profile['profile_uid']),
intval(TERM_CATEGORY),
intval(TERM_OBJ_POST),
dbesc(App::$profile['channel_hash'])
);
if($r && count($r)) {
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 '';
}
2017-08-23 07:01:02 +00:00
function common_friends_visitor_widget($profile_uid,$cnt = 25) {
2012-05-02 02:16:18 +00:00
2015-01-29 04:56:04 +00:00
if(local_channel() == $profile_uid)
2012-05-02 02:16:18 +00:00
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);
2017-09-20 00:35:57 +00:00
2012-05-02 02:16:18 +00:00
if(! $t)
return;
2017-09-20 00:35:57 +00:00
$r = common_friends($profile_uid,$observer_hash,0,$cnt,true);
2012-05-02 02:16:18 +00:00
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => t('Common Connections'),
2017-09-20 00:35:57 +00:00
'$base' => z_root(),
'$uid' => $profile_uid,
'$cid' => $observer,
'$linkmore' => (($t > $cnt) ? 'true' : ''),
'$more' => sprintf( t('View all %d common connections'), $t),
2017-09-20 00:35:57 +00:00
'$items' => $r
2012-05-02 02:16:18 +00:00
));
2013-12-07 05:40:01 +00:00
};