aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Access/PermissionLimits.php
blob: 8caeedb9150b0eb5f987c32261903ba7183fdc7c (plain) (blame)
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
<?php

namespace Zotlabs\Access;

use \Zotlabs\Lib as ZLib;

class PermissionLimits {

	static public function Std_Limits() {
		$perms = Permissions::Perms();
		$limits = array();
		foreach($perms as $k => $v) {
			if(strstr($k,'view') || $k === 'post_comments')
				$limits[$k] = PERMS_PUBLIC;
			else
				$limits[$k] = PERMS_SPECIFIC;
		}
		return $limits;
	}

	static public function Set($channel_id,$perm,$perm_limit) {
		ZLib\PConfig::Set($channel_id,'perm_limits',$perm,$perm_limit);
	}

	static public function Get($channel_id,$perm = '') {
		if($perm) {
			return Zlib\PConfig::Get($channel_id,'perm_limits',$perm);
		}
		else {
			Zlib\PConfig::Load($channel_id);
			if(array_key_exists($channel_id,\App::$config) && array_key_exists('perm_limits',\App::$config[$channel_id]))
				return \App::$config[$channel_id]['perm_limits'];
			return false;
		}
	}	
}