aboutsummaryrefslogtreecommitdiffstats
path: root/mod/connections.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/connections.php')
-rw-r--r--mod/connections.php74
1 files changed, 49 insertions, 25 deletions
diff --git a/mod/connections.php b/mod/connections.php
index 1875ed908..70e28913a 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -81,7 +81,7 @@ function connections_post(&$a) {
}
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d
- where abook_id = %d AND abook_channel = %d LIMIT 1",
+ where abook_id = %d AND abook_channel = %d",
dbesc($profile_id),
intval($abook_my_perms),
intval($closeness),
@@ -213,7 +213,7 @@ function connections_content(&$a) {
nav_set_selected('intros');
break;
case 'ifpending':
- $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) and not ((abook_flags & %d) or (xchan_flags & %d))",
+ $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or (xchan_flags & %d)>0)",
intval(local_user()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
@@ -250,13 +250,13 @@ function connections_content(&$a) {
}
- $sql_extra = (($search_flags) ? " and ( abook_flags & " . $search_flags . " ) " : "");
+ $sql_extra = (($search_flags) ? " and ( abook_flags & " . $search_flags . " )>0 " : "");
if(argv(1) === 'pending')
- $sql_extra .= " and not ( abook_flags & " . ABOOK_FLAG_IGNORED . " ) ";
+ $sql_extra .= " and not ( abook_flags & " . ABOOK_FLAG_IGNORED . " )>0 ";
}
else {
- $sql_extra = " and not ( abook_flags & " . ABOOK_FLAG_BLOCKED . " ) ";
+ $sql_extra = " and not ( abook_flags & " . ABOOK_FLAG_BLOCKED . " )>0 ";
$unblocked = true;
}
@@ -337,9 +337,12 @@ function connections_content(&$a) {
}
$sql_extra .= (($searching) ? protect_sprintf(" AND xchan_name like '%$search_txt%' ") : "");
+ if($_REQUEST['gid']) {
+ $sql_extra .= " and xchan_hash in ( select xchan from group_member where gid = " . intval($_REQUEST['gid']) . " and uid = " . intval(local_user()) . " ) ";
+ }
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
- where abook_channel = %d and not (abook_flags & %d) and not (xchan_flags & %d ) $sql_extra $sql_extra2 ",
+ where abook_channel = %d and not (abook_flags & %d)>0 and not (xchan_flags & %d )>0 $sql_extra $sql_extra2 ",
intval(local_user()),
intval(ABOOK_FLAG_SELF),
intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
@@ -350,12 +353,12 @@ function connections_content(&$a) {
}
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
- WHERE abook_channel = %d and not (abook_flags & %d) and not ( xchan_flags & %d) $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d , %d ",
+ WHERE abook_channel = %d and not (abook_flags & %d)>0 and not ( xchan_flags & %d)>0 $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d OFFSET %d ",
intval(local_user()),
intval(ABOOK_FLAG_SELF),
intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN),
- intval($a->pager['start']),
- intval($a->pager['itemspage'])
+ intval($a->pager['itemspage']),
+ intval($a->pager['start'])
);
$contacts = array();
@@ -366,7 +369,7 @@ function connections_content(&$a) {
if($rr['xchan_url']) {
$contacts[] = array(
'img_hover' => sprintf( t('%1$s [%2$s]'),$rr['xchan_name'],$rr['xchan_url']),
- 'edit_hover' => t('Edit contact'),
+ 'edit_hover' => t('Edit connection'),
'id' => $rr['abook_id'],
'alt_text' => $alt_text,
'dir_icon' => $dir_icon,
@@ -375,6 +378,7 @@ function connections_content(&$a) {
'username' => $rr['xchan_name'],
'classes' => (($rr['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'archived' : ''),
'link' => z_root() . '/connedit/' . $rr['abook_id'],
+ 'edit' => t('Edit'),
'url' => chanlink_url($rr['xchan_url']),
'network' => network_to_name($rr['network']),
);
@@ -382,20 +386,40 @@ function connections_content(&$a) {
}
}
- $o .= replace_macros(get_markup_template('connections.tpl'),array(
- '$header' => t('Connections') . (($head) ? ' - ' . $head : ''),
- '$tabs' => $t,
- '$total' => $total,
- '$search' => $search_hdr,
- '$desc' => t('Search your connections'),
- '$finding' => (($searching) ? t('Finding: ') . "'" . $search . "'" : ""),
- '$submit' => t('Find'),
- '$edit' => t('Edit'),
- '$cmd' => $a->cmd,
- '$contacts' => $contacts,
- '$paginate' => paginate($a),
-
- ));
-
+
+ if($_REQUEST['aj']) {
+ if($contacts) {
+ $o = replace_macros(get_markup_template('contactsajax.tpl'),array(
+ '$contacts' => $contacts,
+ '$edit' => t('Edit'),
+ ));
+ }
+ else {
+ $o = '<div id="content-complete"></div>';
+ }
+ echo $o;
+ killme();
+ }
+ else {
+ $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
+ $o .= replace_macros(get_markup_template('connections.tpl'),array(
+ '$header' => t('Connections') . (($head) ? ' - ' . $head : ''),
+ '$tabs' => $t,
+ '$total' => $total,
+ '$search' => $search_hdr,
+ '$desc' => t('Search your connections'),
+ '$finding' => (($searching) ? t('Finding: ') . "'" . $search . "'" : ""),
+ '$submit' => t('Find'),
+ '$edit' => t('Edit'),
+ '$cmd' => $a->cmd,
+ '$contacts' => $contacts,
+ '$paginate' => paginate($a),
+
+ ));
+ }
+
+ if(! $contacts)
+ $o .= '<div id="content-complete"></div>';
+
return $o;
}