]> git.mxchange.org Git - friendica.git/blob - mod/nogroup.php
The central item fetch does work now and the API now uses these functions
[friendica.git] / mod / nogroup.php
1 <?php
2 /**
3  * @file mod/nogroup.php
4  */
5 use Friendica\App;
6 use Friendica\Content\ContactSelector;
7 use Friendica\Core\L10n;
8 use Friendica\Database\DBM;
9 use Friendica\Model\Contact;
10 use Friendica\Model\Group;
11
12 function nogroup_init(App $a)
13 {
14         if (! local_user()) {
15                 return;
16         }
17
18         if (! x($a->page, 'aside')) {
19                 $a->page['aside'] = '';
20         }
21
22         $a->page['aside'] .= Group::sidebarWidget('contacts', 'group', 'extended');
23 }
24
25 function nogroup_content(App $a)
26 {
27         if (! local_user()) {
28                 notice(L10n::t('Permission denied.') . EOL);
29                 return '';
30         }
31
32         $r = Contact::getUngroupedList(local_user());
33         if (DBM::is_result($r)) {
34                 $a->set_pager_total($r[0]['total']);
35         }
36         $r = Contact::getUngroupedList(local_user(), $a->pager['start'], $a->pager['itemspage']);
37         if (DBM::is_result($r)) {
38                 foreach ($r as $rr) {
39                         $contact_details = Contact::getDetailsByURL($rr['url'], local_user(), $rr);
40
41                         $contacts[] = [
42                                 'img_hover' => L10n::t('Visit %s\'s profile [%s]', $contact_details['name'], $rr['url']),
43                                 'edit_hover' => L10n::t('Edit contact'),
44                                 'photo_menu' => Contact::photoMenu($rr),
45                                 'id' => $rr['id'],
46                                 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
47                                 'name' => $contact_details['name'],
48                                 'username' => $contact_details['name'],
49                                 'details'       => $contact_details['location'],
50                                 'tags'          => $contact_details['keywords'],
51                                 'about'         => $contact_details['about'],
52                                 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
53                                 'url' => $rr['url'],
54                                 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
55                         ];
56                 }
57         }
58
59         $tpl = get_markup_template("nogroup-template.tpl");
60         $o = replace_macros(
61                 $tpl,
62                 [
63                 '$header' => L10n::t('Contacts who are not members of a group'),
64                 '$contacts' => $contacts,
65                 '$paginate' => paginate($a)]
66         );
67
68         return $o;
69 }