]> git.mxchange.org Git - friendica.git/blob - addon/pages/pages.php
New plugin that shows community pages in the sidebar
[friendica.git] / addon / pages / pages.php
1 <?php
2 /**
3  * Name: Pages
4  * Description: Shows lists of community pages
5  * Version: 1.0
6  * Author: Michael Vogel <ike@piratenpartei.de>
7  *
8  */
9
10 function pages_install() {
11         register_hook('page_end', 'addon/pages/pages.php', 'pages_page_end');
12 }
13
14 function pages_uninstall() {
15         unregister_hook('page_end', 'addon/pages/pages.php', 'pages_page_end');
16 }
17
18 function pages_page_end($a,&$b) {
19         if (($a->module != "network") OR ($a->user['uid'] == 0))
20                 return;
21
22         $pages = '<div id="pages-sidebar" class="widget"><h3>'.t("Community").'</h3><ul>';
23         $contacts = q("SELECT `contact`.`id`, `contact`.`url`, `contact`.`Name` FROM `contact`, `user` 
24                         WHERE `network`= 'dfrn' AND `duplex` 
25                         AND `contact`.`nick`=`user`.`nickname`
26                         AND `user`.`page-flags`= %d
27                         AND `contact`.`uid` = %d",
28                         intval(PAGE_COMMUNITY),
29                         intval($a->user['uid']));
30         foreach($contacts as $contact) {
31                 $pages .= '<li class="tool"><a href="'.$contact["url"].'">'.$contact["Name"]."</a></li>";
32         }
33         $pages .= "</ul>";
34         if (sizeof($contacts) > 0)
35                 $a->page['aside'] = $pages.$a->page['aside'];
36
37 }
38
39 ?>