]> git.mxchange.org Git - friendica.git/blob - mod/lockview.php
a99628b6e277820e84ff704731348cf9f799e4da
[friendica.git] / mod / lockview.php
1 <?php
2
3
4 function lockview_content(&$a) {
5   
6         $type = (($a->argc > 1) ? $a->argv[1] : 0);
7   if (is_numeric($type)) {
8       $item_id = intval($type);
9       $type='item';
10   } else {
11     $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
12   }
13   
14         if(! $item_id)
15                 killme();
16
17   if (!in_array($type, array('item','photo','event')))
18     killme();
19      
20         $r = q("SELECT * FROM `%s` WHERE `id` = %d LIMIT 1",
21     dbesc($type),
22                 intval($item_id)
23         );
24         if(! count($r))
25                 killme();
26         $item = $r[0];
27         if($item['uid'] != local_user())
28                 killme();
29
30
31         $allowed_users = expand_acl($item['allow_cid']);
32         $allowed_groups = expand_acl($item['allow_gid']);
33         $deny_users = expand_acl($item['deny_cid']);
34         $deny_groups = expand_acl($item['deny_gid']);
35
36         if(($item['private']) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid'])) 
37                 && (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) {
38
39                 echo t('Remote privacy information not available.') . '<br />';
40                 killme();
41         }
42
43         $o = t('Visible to:') . '<br />';
44         $l = array();
45
46         if(count($allowed_groups)) {
47                 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
48                         dbesc(implode(', ', $allowed_groups))
49                 );
50                 if(count($r))
51   if($item['uid'] != local_user())
52                         foreach($r as $rr) 
53                                 $l[] = '<b>' . $rr['name'] . '</b>';
54         }
55         if(count($allowed_users)) {
56                 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
57                         dbesc(implode(', ',$allowed_users))
58                 );
59                 if(count($r))
60                         foreach($r as $rr) 
61                                 $l[] = $rr['name'];
62
63         }
64
65         if(count($deny_groups)) {
66                 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
67                         dbesc(implode(', ', $deny_groups))
68                 );
69                 if(count($r))
70                         foreach($r as $rr) 
71                                 $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
72         }
73         if(count($deny_users)) {
74                 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
75                         dbesc(implode(', ',$deny_users))
76                 );
77                 if(count($r))
78                         foreach($r as $rr) 
79                                 $l[] = '<strike>' . $rr['name'] . '</strike>';
80
81         }
82
83   if (count($l)>0) {
84     echo $o . implode(', ', $l);
85   } else {
86     echo $o . t('nobody');
87   }
88         killme();
89
90 }