aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Settings/Features.php
blob: 3c3205c65f5ddbd4d2ef850872bf0776c1f507c3 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

namespace Zotlabs\Module\Settings;


class Features {

	function post() {
		check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
	
		// Build list of features and check which are set
		// We will not create any settings for features that are above our techlevel

		if(intval($_REQUEST['techlevel']))
			$level = intval($_REQUEST['techlevel']);
		else {
 			$level = get_account_techlevel();
		}

		$features = get_features(true,$level);
		$all_features = array();
		foreach($features as $k => $v) {
			foreach($v as $f) 
				$all_features[] = $f[0];
		}
		foreach($all_features as $k) {
			if(x($_POST,"feature_$k"))
				set_pconfig(local_channel(),'feature',$k, 1);
			else
				set_pconfig(local_channel(),'feature',$k, 0);
		}
		build_sync_packet();
		return;
	}

	function get() {
		
		$arr = [];
		if(intval($_REQUEST['techlevel']))
			$level = intval($_REQUEST['techlevel']);
		else {
 			$level = get_account_techlevel();
		}

		$techlevels = \Zotlabs\Lib\Techlevels::levels();

		$def_techlevel = \App::$account['account_level'];
		$techlock = get_config('system','techlevel_lock');

		$features = get_features(true,$level);

		foreach($features as $fname => $fdata) {
			$arr[$fname] = array();
			$arr[$fname][0] = $fdata[0];
			foreach(array_slice($fdata,1) as $f) {
				$arr[$fname][1][] = array('feature_' .$f[0],$f[1],((intval(feature_enabled(local_channel(),$f[0]))) ? "1" : ''),$f[2],array(t('Off'),t('On')));
			}
		}
			
		$tpl = get_markup_template("settings_features.tpl");
		$o .= replace_macros($tpl, array(
			'$form_security_token' => get_form_security_token("settings_features"),
			'$title'	=> t('Additional Features'),
			'$techlevel' => [ 'techlevel', t('Your technical skill level'), $def_techlevel, t('Used to provide a member experience and additional features consistent with your comfort level'), $techlevels ],
			'$techlock' => $techlock,
			'$features' => $arr,
			'$submit'   => t('Submit'),
		));
	
		return $o;
	}

}