]> git.mxchange.org Git - friendica.git/blobdiff - mod/settings.php
Merge remote branch 'upstream/master'
[friendica.git] / mod / settings.php
old mode 100755 (executable)
new mode 100644 (file)
index ce5ceea..2dd9fb9
@@ -15,10 +15,6 @@ function get_theme_config_file($theme){
 }
 
 function settings_init(&$a) {
-       if(local_user()) {
-               profile_load($a,$a->user['nickname']);
-       }
-
        // These lines provide the javascript needed by the acl selector
 
        $a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "';" ;
@@ -47,6 +43,47 @@ function settings_init(&$a) {
 EOT;
 
 
+
+       $tabs = array(
+               array(
+                       'label' => t('Account settings'),
+                       'url'   => $a->get_baseurl(true).'/settings',
+                       'selected'      => (($a->argc == 1)?'active':''),
+               ),      
+               array(
+                       'label' => t('Display settings'),
+                       'url'   => $a->get_baseurl(true).'/settings/display',
+                       'selected'      => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
+               ),      
+               
+               array(
+                       'label' => t('Connector settings'),
+                       'url'   => $a->get_baseurl(true).'/settings/connectors',
+                       'selected'      => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
+               ),
+               array(
+                       'label' => t('Plugin settings'),
+                       'url'   => $a->get_baseurl(true).'/settings/addon',
+                       'selected'      => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
+               ),
+               array(
+                       'label' => t('Connected apps'),
+                       'url' => $a->get_baseurl(true) . '/settings/oauth',
+                       'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
+               ),
+               array(
+                       'label' => t('Export personal data'),
+                       'url' => $a->get_baseurl(true) . '/uexport',
+                       'selected' => ''
+               )
+       );
+       
+       $tabtpl = get_markup_template("generic_links_widget.tpl");
+       $a->page['aside'] = replace_macros($tabtpl, array(
+               '$title' => t('Settings'),
+               '$items' => $tabs,
+       ));
+
 }
 
 
@@ -229,7 +266,7 @@ function settings_post(&$a) {
 
 
                if ($theme == $a->user['theme']){
-                       // call theme_post only if theme has not benn changed
+                       // call theme_post only if theme has not been changed
                        if( ($themeconfigfile = get_theme_config_file($theme)) != null){
                                require_once($themeconfigfile);
                                theme_post($a);
@@ -242,6 +279,7 @@ function settings_post(&$a) {
                                intval(local_user())
                );
        
+               call_hooks('display_settings_post', $_POST);
                goaway($a->get_baseurl(true) . '/settings/display' );
                return; // NOTREACHED
        }
@@ -303,7 +341,8 @@ function settings_post(&$a) {
        $page_flags       = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0);
        $blockwall        = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted!
        $blocktags        = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted!
-
+       $unkmail          = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0);
+       $cntunkmail       = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0);
        $suggestme        = ((x($_POST,'suggestme')) ? intval($_POST['suggestme'])  : 0);  
        $hide_friends     = (($_POST['hide-friends'] == 1) ? 1: 0);
        $hidewall         = (($_POST['hidewall'] == 1) ? 1: 0);
@@ -391,7 +430,7 @@ function settings_post(&$a) {
        set_pconfig(local_user(),'system','suggestme', $suggestme);
 
 
-       $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s',  `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d  WHERE `uid` = %d LIMIT 1",
+       $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s',  `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d  WHERE `uid` = %d LIMIT 1",
                        dbesc($username),
                        dbesc($email),
                        dbesc($openid),
@@ -410,6 +449,8 @@ function settings_post(&$a) {
                        intval($blockwall),
                        intval($hidewall),
                        intval($blocktags),
+                       intval($unkmail),
+                       intval($cntunkmail),
                        intval(local_user())
        );
        if($r)
@@ -475,44 +516,7 @@ function settings_content(&$a) {
                return;
        }
        
-       $tabs = array(
-               array(
-                       'label' => t('Account settings'),
-                       'url'   => $a->get_baseurl(true).'/settings',
-                       'sel'   => (($a->argc == 1)?'active':''),
-               ),      
-               array(
-                       'label' => t('Display settings'),
-                       'url'   => $a->get_baseurl(true).'/settings/display',
-                       'sel'   => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
-               ),      
-               
-               array(
-                       'label' => t('Connector settings'),
-                       'url'   => $a->get_baseurl(true).'/settings/connectors',
-                       'sel'   => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
-               ),
-               array(
-                       'label' => t('Plugin settings'),
-                       'url'   => $a->get_baseurl(true).'/settings/addon',
-                       'sel'   => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
-               ),
-               array(
-                       'label' => t('Connections'),
-                       'url' => $a->get_baseurl(true) . '/settings/oauth',
-                       'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
-               ),
-               array(
-                       'label' => t('Export personal data'),
-                       'url' => $a->get_baseurl(true) . '/uexport',
-                       'sel' => ''
-               )
-       );
-       
-       $tabtpl = get_markup_template("common_tabs.tpl");
-       $tabs = replace_macros($tabtpl, array(
-               '$tabs' => $tabs,
-       ));
+
                
        if(($a->argc > 1) && ($a->argv[1] === 'oauth')) {
                
@@ -520,7 +524,6 @@ function settings_content(&$a) {
                        $tpl = get_markup_template("settings_oauth_edit.tpl");
                        $o .= replace_macros($tpl, array(
                                '$form_security_token' => get_form_security_token("settings_oauth"),
-                               '$tabs'         => $tabs,
                                '$title'        => t('Add application'),
                                '$submit'       => t('Submit'),
                                '$cancel'       => t('Cancel'),
@@ -547,7 +550,6 @@ function settings_content(&$a) {
                        $tpl = get_markup_template("settings_oauth_edit.tpl");
                        $o .= replace_macros($tpl, array(
                                '$form_security_token' => get_form_security_token("settings_oauth"),
-                               '$tabs'         => $tabs,
                                '$title'        => t('Add application'),
                                '$submit'       => t('Update'),
                                '$cancel'       => t('Cancel'),
@@ -590,7 +592,6 @@ function settings_content(&$a) {
                        '$consumerkey' => t('Client key starts with'),
                        '$noname'       => t('No name'),
                        '$remove'       => t('Remove authorization'),
-                       '$tabs'         => $tabs,
                        '$apps'         => $r,
                ));
                return $o;
@@ -610,7 +611,6 @@ function settings_content(&$a) {
                $o .= replace_macros($tpl, array(
                        '$form_security_token' => get_form_security_token("settings_addon"),
                        '$title'        => t('Plugin Settings'),
-                       '$tabs'         => $tabs,
                        '$settings_addons' => $settings_addons
                ));
                return $o;
@@ -654,7 +654,6 @@ function settings_content(&$a) {
                        '$form_security_token' => get_form_security_token("settings_connectors"),
                        
                        '$title'        => t('Connector Settings'),
-                       '$tabs'         => $tabs,
 
                        '$diasp_enabled' => $diasp_enabled,
                        '$ostat_enabled' => $ostat_enabled,
@@ -676,6 +675,8 @@ function settings_content(&$a) {
 
                        '$settings_connectors' => $settings_connectors
                ));
+
+               call_hooks('display_settings', $o);
                return $o;
        }
 
@@ -729,7 +730,6 @@ function settings_content(&$a) {
                
                $tpl = get_markup_template("settings_display.tpl");
                $o = replace_macros($tpl, array(
-                       '$tabs'         => $tabs,
                        '$ptitle'       => t('Display Settings'),
                        '$form_security_token' => get_form_security_token("settings_display"),
                        '$submit'       => t('Submit'),
@@ -760,17 +760,19 @@ function settings_content(&$a) {
        if(count($p))
                $profile = $p[0];
 
-       $username = $a->user['username'];
-       $email    = $a->user['email'];
-       $nickname = $a->user['nickname'];
-       $timezone = $a->user['timezone'];
-       $notify   = $a->user['notify-flags'];
-       $defloc   = $a->user['default-location'];
-       $openid   = $a->user['openid'];
-       $maxreq   = $a->user['maxreq'];
-       $expire   = ((intval($a->user['expire'])) ? $a->user['expire'] : '');
-       $blockwall = $a->user['blockwall'];
-       $blocktags = $a->user['blocktags'];
+       $username   = $a->user['username'];
+       $email      = $a->user['email'];
+       $nickname   = $a->user['nickname'];
+       $timezone   = $a->user['timezone'];
+       $notify     = $a->user['notify-flags'];
+       $defloc     = $a->user['default-location'];
+       $openid     = $a->user['openid'];
+       $maxreq     = $a->user['maxreq'];
+       $expire     = ((intval($a->user['expire'])) ? $a->user['expire'] : '');
+       $blockwall  = $a->user['blockwall'];
+       $blocktags  = $a->user['blocktags'];
+       $unkmail    = $a->user['unkmail'];
+       $cntunkmail = $a->user['cntunkmail'];
 
        $expire_items = get_pconfig(local_user(), 'expire','items');
        $expire_items = (($expire_items===false)? '1' : $expire_items); // default if not set: 1
@@ -870,6 +872,12 @@ function settings_content(&$a) {
        ));
 
 
+       $unkmail = replace_macros($opt_tpl,array(
+                       '$field'        => array('unkmail',  t('Permit unknown people to send you private mail?'), $unkmail, '', array(t('No'),t('Yes'))),
+
+       ));
+
+
        $invisible = (((! $profile['publish']) && (! $profile['net-publish']))
                ? true : false);
 
@@ -906,7 +914,6 @@ function settings_content(&$a) {
        );
 
        $o .= replace_macros($stpl,array(
-               '$tabs'         => $tabs,
                '$ptitle'       => t('Account Settings'),
 
                '$submit'       => t('Submit'),
@@ -946,7 +953,8 @@ function settings_content(&$a) {
                '$profile_in_net_dir' => $profile_in_net_dir,
                '$hide_friends' => $hide_friends,
                '$hide_wall' => $hide_wall,
-               
+               '$unkmail' => $unkmail,         
+               '$cntunkmail'   => array('cntunkmail', t('Maximum private messages per day from unknown people:'), $cntunkmail ,t("\x28to prevent spam abuse\x29")),
                
                
                '$h_not'        => t('Notification Settings'),