1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php
namespace Zotlabs\Access;
class PermissionLimits {
static public function Std_Limits() {
$perms = Permissions::Perms();
$limits = array();
foreach($perms as $k => $v) {
if(strstr($k,'view'))
$limits[$k] = PERMS_PUBLIC;
else
$limits[$k] = PERMS_SPECIFIC;
}
return $limits;
}
static public function Set($channel_id,$perm,$perm_limit) {
$r = q("select * from perm_limits where channel_id = %d and perm = '%s' limit 1",
intval($channel_id),
dbesc($perm)
);
if($r) {
if($r[0]['perm_limit'] != $perm_limit) {
$x = q("update perm_limits set perm_limit = %d where id = %d",
dbesc($perm_limit),
intval($r[0]['id'])
);
}
}
else {
$r = q("insert into perm_limits ( perm, channel_id, perm_limit )
values ( '%s', %d, %d ) ",
dbesc($perm),
intval($channel_id),
intval($perm_limit)
);
}
}
static public function Get($channel_id,$perm = '') {
if($perm) {
$r = q("select * from perm_limits where channel_id = %d and perm = '%s' limit 1",
intval($channel_id),
dbesc($perm)
);
if($r)
return $r[0];
return false;
}
else {
return q("select * from perm_limits where channel_id = %d",
intval($channel_id)
);
}
}
}
|