]> git.mxchange.org Git - friendica.git/blobdiff - mod/settings.php
small fix
[friendica.git] / mod / settings.php
index 9a9fde5c6b4eee911fbcaed5430962e41bc0dd16..85029b3d729fd2d16391b4b62741cece0c881daf 100644 (file)
@@ -15,15 +15,18 @@ function settings_post(&$a) {
                return;
        }
 
-       call_hooks('settings_post', $_POST);
-
-       if(($a->argc > 1) && ($a->argv[1] == 'addon'))
-               return;
-
        if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
+
+       if(($a->argc > 1) && ($a->argv[1] == 'addon')) {
+               call_hooks('plugin_settings_post', $_POST);
+               return;
+       }
+
+       call_hooks('settings_post', $_POST);
+
        if((x($_POST,'npassword')) || (x($_POST,'confirm'))) {
 
                $newpass = $_POST['npassword'];
@@ -60,6 +63,7 @@ function settings_post(&$a) {
        $defloc           = ((x($_POST,'defloc'))     ? notags(trim($_POST['defloc']))       : '');
        $openid           = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url']))   : '');
        $maxreq           = ((x($_POST,'maxreq'))     ? intval($_POST['maxreq'])             : 0);
+       $expire           = ((x($_POST,'expire'))     ? intval($_POST['expire'])             : 0);
 
        $allow_location   = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
        $publish          = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
@@ -84,11 +88,14 @@ function settings_post(&$a) {
 
        $err = '';
 
+       $name_change = false;
+
        if($username != $a->user['username']) {
-               if(strlen($username) > 40)
-                       $err .= t(' Please use a shorter name.');
-               if(strlen($username) < 3)
-                       $err .= t(' Name too short.');
+               $name_change = true;
+               if(strlen($username) > 40)
+                       $err .= t(' Please use a shorter name.');
+               if(strlen($username) < 3)
+                       $err .= t(' Name too short.');
        }
 
        if($email != $a->user['email']) {
@@ -133,7 +140,7 @@ function settings_post(&$a) {
                        $openidserver = '';
        }
 
-       $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, `theme` = '%s', `maxreq` = %d, `openidserver` = '%s'  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, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s'  WHERE `uid` = %d LIMIT 1",
                        dbesc($username),
                        dbesc($email),
                        dbesc($openid),
@@ -148,6 +155,7 @@ function settings_post(&$a) {
                        intval($allow_location),
                        dbesc($theme),
                        intval($maxreq),
+                       intval($expire),
                        dbesc($openidserver),
                        intval(local_user())
        );
@@ -162,13 +170,20 @@ function settings_post(&$a) {
                intval(local_user())
        );
 
+
+       if($name_change) {
+               q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1",
+                       dbesc($username),
+                       dbesc(datetime_convert()),
+                       intval(local_user())
+               );
+       }               
+
        if($old_visibility != $net_publish) {
                // Update global directory in background
-               $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
                $url = $_SESSION['my_url'];
                if($url && strlen(get_config('system','directory_submit_url')))
-                       proc_close(proc_open("\"$php_path\" \"include/directory.php\" \"$url\" &",
-                               array(),$foo));
+                       proc_run('php',"include/directory.php","$url");
        }
 
        $_SESSION['theme'] = $theme;
@@ -225,6 +240,7 @@ function settings_content(&$a) {
        $defloc   = $a->user['default-location'];
        $openid   = $a->user['openid'];
        $maxreq   = $a->user['maxreq'];
+       $expire   = ((intval($a->user['expire'])) ? $a->user['expire'] : '');
 
        if(! strlen($a->user['timezone']))
                $timezone = date_default_timezone_get();
@@ -345,6 +361,7 @@ function settings_content(&$a) {
                '$sel_notify4' => (($notify & NOTIFY_COMMENT) ? ' checked="checked" ' : ''),
                '$sel_notify5' => (($notify & NOTIFY_MAIL)    ? ' checked="checked" ' : ''),
                '$maxreq' => $maxreq,
+               '$expire' => $expire,
                '$theme' => $theme_selector,
                '$pagetype' => $pagetype
        ));