diff options
-rw-r--r-- | include/Contact.php | 22 | ||||
-rw-r--r-- | include/group.php | 1 | ||||
-rw-r--r-- | mod/nogroup.php | 65 | ||||
-rw-r--r-- | view/group_side.tpl | 5 | ||||
-rw-r--r-- | view/nogroup-template.tpl | 12 |
5 files changed, 101 insertions, 4 deletions
diff --git a/include/Contact.php b/include/Contact.php index 8d893cf70..657977801 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -176,12 +176,26 @@ function random_profile() { } -function contacts_not_grouped($uid) { - $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ", +function contacts_not_grouped($uid,$start = 0,$count = 0) { +dbg(1); + if(! $count) { + $r = q("select count(*) as total from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ", + intval($uid), + intval($uid) + ); +dbg(0); + return $r; + + + } +dbg(1); + $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) limit %d, %d", + intval($uid), intval($uid), - intval($uid) + intval($start), + intval($count) ); - +dbg(0); return $r; } diff --git a/include/group.php b/include/group.php index 4a35912e5..edb547de6 100644 --- a/include/group.php +++ b/include/group.php @@ -212,6 +212,7 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0 '$title' => t('Groups'), '$edittext' => t('Edit group'), '$createtext' => t('Create a new group'), + '$ungrouped' => (($every === 'contacts') ? t('Contacts not in any group') : ''), '$groups' => $groups, '$add' => t('add'), )); diff --git a/mod/nogroup.php b/mod/nogroup.php new file mode 100644 index 000000000..bd1ec82ed --- /dev/null +++ b/mod/nogroup.php @@ -0,0 +1,65 @@ +<?php + +require_once('include/Contact.php'); +require_once('include/socgraph.php'); +require_once('include/contact_selectors.php'); + +function nogroup_init(&$a) { + + if(! local_user()) + return; + + require_once('include/group.php'); + require_once('include/contact_widgets.php'); + + if(! x($a->page,'aside')) + $a->page['aside'] = ''; + + $a->page['aside'] .= group_side('contacts','group',false,0,$contact_id); +} + + +function nogroup_content(&$a) { + + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return ''; + } + + require_once('include/Contact.php'); + $r = contacts_not_grouped(local_user()); + if(count($r)) { + $a->set_pager_total($r[0]['total']); + } + $r = contacts_not_grouped(local_user(),$a->pager['start'],$a->pager['itemspage']); + if(count($r)) { + foreach($r as $rr) { + + + $contacts[] = array( + 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']), + 'edit_hover' => t('Edit contact'), + 'photo_menu' => contact_photo_menu($rr), + 'id' => $rr['id'], + 'alt_text' => $alt_text, + 'dir_icon' => $dir_icon, + 'thumb' => $rr['thumb'], + 'name' => $rr['name'], + 'username' => $rr['name'], + 'sparkle' => $sparkle, + 'itemurl' => $rr['url'], + 'url' => $url, + 'network' => network_to_name($rr['network']), + ); + } + } + $tpl = get_markup_template("nogroup-template.tpl"); + $o .= replace_macros($tpl,array( + '$header' => t('Contacts who are not members of a group'), + '$contacts' => $contacts, + '$paginate' => paginate($a), + )); + + return $o; + +} diff --git a/view/group_side.tpl b/view/group_side.tpl index 0353b1d2c..ebb194d9c 100644 --- a/view/group_side.tpl +++ b/view/group_side.tpl @@ -23,6 +23,11 @@ <div id="sidebar-new-group"> <a href="group/new">$createtext</a> </div> + {{ if $ungrouped }} + <div id="sidebar-ungrouped"> + <a href="nogroup">$ungrouped</a> + </div> + {{ endif }} </div> diff --git a/view/nogroup-template.tpl b/view/nogroup-template.tpl new file mode 100644 index 000000000..dd00ed097 --- /dev/null +++ b/view/nogroup-template.tpl @@ -0,0 +1,12 @@ +<h1>$header</h1> + +{{ for $contacts as $contact }} + {{ inc contact_template.tpl }}{{ endinc }} +{{ endfor }} +<div id="contact-edit-end"></div> + +$paginate + + + + |