2016-09-07 03:10:56 +00:00
< ? php
namespace Zotlabs\Module\Settings ;
class Features {
function post () {
check_form_security_token_redirectOnErr ( '/settings/features' , 'settings_features' );
2018-04-09 05:02:48 +00:00
$features = get_features ( false );
2016-09-07 03:10:56 +00:00
2018-04-09 05:02:48 +00:00
foreach ( $features as $fname => $fdata ) {
foreach ( array_slice ( $fdata , 1 ) as $f ) {
$k = $f [ 0 ];
if ( array_key_exists ( " feature_ $k " , $_POST ))
set_pconfig ( local_channel (), 'feature' , $k , ( string ) $_POST [ " feature_ $k " ]);
else
set_pconfig ( local_channel (), 'feature' , $k , '' );
}
2016-09-07 03:10:56 +00:00
}
build_sync_packet ();
return ;
}
function get () {
2018-04-09 03:05:30 +00:00
$arr = [];
2018-04-09 05:02:48 +00:00
$harr = [];
2018-04-09 03:05:30 +00:00
if ( intval ( $_REQUEST [ 'techlevel' ]))
$level = intval ( $_REQUEST [ 'techlevel' ]);
else {
$level = get_account_techlevel ();
}
2018-04-09 05:09:08 +00:00
if ( ! intval ( $level )) {
notice ( t ( 'Permission denied.' ) . EOL );
return ;
}
2018-04-09 03:05:30 +00:00
$techlevels = \Zotlabs\Lib\Techlevels :: levels ();
2018-04-09 05:09:08 +00:00
// This page isn't accessible at techlevel 0
2018-04-09 05:02:48 +00:00
2018-04-09 05:09:08 +00:00
unset ( $techlevels [ 0 ]);
2018-04-09 05:02:48 +00:00
$def_techlevel = (( $level > 0 ) ? $level : 1 );
2018-04-09 03:05:30 +00:00
$techlock = get_config ( 'system' , 'techlevel_lock' );
2018-04-09 05:02:48 +00:00
$all_features_raw = get_features ( false );
foreach ( $all_features_raw as $fname => $fdata ) {
foreach ( array_slice ( $fdata , 1 ) as $f ) {
$harr [ $f [ 0 ]] = (( intval ( feature_enabled ( local_channel (), $f [ 0 ]))) ? " 1 " : '' );
}
}
2018-04-09 03:05:30 +00:00
$features = get_features ( true , $level );
2016-09-07 03:10:56 +00:00
foreach ( $features as $fname => $fdata ) {
$arr [ $fname ] = array ();
$arr [ $fname ][ 0 ] = $fdata [ 0 ];
foreach ( array_slice ( $fdata , 1 ) as $f ) {
2018-04-09 05:02:48 +00:00
$arr [ $fname ][ 1 ][] = array ( 'feature_' . $f [ 0 ], $f [ 1 ],(( intval ( feature_enabled ( local_channel (), $f [ 0 ]))) ? " 1 " : '' ), $f [ 2 ], array ( t ( 'Off' ), t ( 'On' )));
unset ( $harr [ $f [ 0 ]]);
2016-09-07 03:10:56 +00:00
}
}
$tpl = get_markup_template ( " settings_features.tpl " );
$o .= replace_macros ( $tpl , array (
'$form_security_token' => get_form_security_token ( " settings_features " ),
2018-04-09 05:02:48 +00:00
'$title' => t ( 'Additional Features' ),
2018-04-09 03:05:30 +00:00
'$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 ],
2018-04-09 05:02:48 +00:00
'$techlock' => $techlock ,
'$features' => $arr ,
'$hiddens' => $harr ,
'$baseurl' => z_root (),
'$submit' => t ( 'Submit' ),
2016-09-07 03:10:56 +00:00
));
return $o ;
}
2016-10-04 19:11:11 +00:00
}