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