3 * Name: Default Features
4 * Description: Choose which Additional Features are on by default for new users on the site.
6 * Author: Michael Johnston
9 function defaultfeatures_install() {
10 register_hook('register_account', 'addon/defaultfeatures/defaultfeatures.php', 'defaultfeatures_register');
11 logger("installed defaultfeatures plugin");
14 function defaultfeatures_uninstall() {
15 unregister_hook('register_account', 'addon/defaultfeatures/defaultfeatures.php', 'defaultfeatures_register');
16 logger("uninstalled defaultfeatures plugin");
19 function defaultfeatures_register($a, $newuid) {
21 $features = get_features();
22 foreach($features as $fname => $fdata) {
23 foreach(array_slice($fdata,1) as $f) {
24 set_pconfig($newuid,'feature',$f[0],((intval(get_config('defaultfeatures',$f[0]))) ? "1" : "0"));
29 function defaultfeatures_plugin_admin_post (&$a) {
30 check_form_security_token_redirectOnErr('/admin/plugins/defaultfeatures', 'defaultfeaturessave');
31 foreach($_POST as $k => $v) {
32 if(strpos($k,'feature_') === 0) {
33 set_config('defaultfeatures',substr($k,8),((intval($v)) ? 1 : 0));
36 info( t('Features updated') . EOL);
39 function defaultfeatures_plugin_admin (&$a, &$o) {
40 $t = get_markup_template( "admin.tpl", "addon/defaultfeatures/" );
41 $token = get_form_security_token("defaultfeaturessave");
43 $features = get_features();
44 foreach($features as $fname => $fdata) {
45 $arr[$fname] = array();
46 $arr[$fname][0] = $fdata[0];
47 foreach(array_slice($fdata,1) as $f) {
48 $arr[$fname][1][] = array('feature_' .$f[0],$f[1],((intval(get_config('defaultfeatures',$f[0]))) ? "1" : "0"),$f[2],array(t('Off'),t('On')));
52 //logger("Features: " . print_r($arr,true));
54 $o = replace_macros($t, array(
55 '$submit' => t('Save Settings'),
57 '$form_security_token' => $token