]> git.mxchange.org Git - friendica.git/blobdiff - mod/profiles.php
comment open/close anomolies in non-English languages
[friendica.git] / mod / profiles.php
index 1c75dc0eb140956eaca0ab2af10d26cf9c74143f..434f58adf990d487c6fae8013f6a87025afcaaac 100644 (file)
@@ -10,6 +10,8 @@ function profiles_post(&$a) {
 
        $namechanged = false;
 
+       call_hooks('profile_post', $_POST);
+
        if(($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
                $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                        intval($a->argv[1]),
@@ -46,13 +48,15 @@ function profiles_post(&$a) {
                if($orig[0]['name'] != $name)
                        $namechanged = true;
 
+               $pdesc = notags(trim($_POST['pdesc']));
                $gender = notags(trim($_POST['gender']));
                $address = notags(trim($_POST['address']));
                $locality = notags(trim($_POST['locality']));
                $region = notags(trim($_POST['region']));
                $postal_code = notags(trim($_POST['postal_code']));
                $country_name = notags(trim($_POST['country_name']));
-               $keywords = notags(trim($_POST['keywords']));
+               $pub_keywords = notags(trim($_POST['pub_keywords']));
+               $prv_keywords = notags(trim($_POST['prv_keywords']));
                $marital = notags(trim($_POST['marital']));
                if($marital != $orig[0]['marital'])
                        $maritalchanged = true;
@@ -65,7 +69,10 @@ function profiles_post(&$a) {
                        if($with != strip_tags($orig[0]['with'])) {
                                $prf = '';
                                $lookup = $with;
-                               if((strpos($lookup,'@')) || (strpos($lookup,'http://'))) {
+                               if(strpos($lookup,'@') === 0)
+                                       $lookup = substr($lookup,1);
+                               $lookup = str_replace('_',' ', $lookup);
+                               if(strpos($lookup,'@') || (strpos($lookup,'http://'))) {
                                        $newname = $lookup;
                                        $links = @lrdd($lookup);
                                        if(count($links)) {
@@ -98,6 +105,8 @@ function profiles_post(&$a) {
        
                                if($prf) {
                                        $with = str_replace($lookup,'<a href="' . $prf . '">' . $newname        . '</a>', $with);
+                                       if(strpos($with,'@') === 0)
+                                               $with = substr($with,1);
                                }
                        }
                        else
@@ -125,6 +134,7 @@ function profiles_post(&$a) {
                $r = q("UPDATE `profile` 
                        SET `profile-name` = '%s',
                        `name` = '%s',
+                       `pdesc` = '%s',
                        `gender` = '%s',
                        `dob` = '%s',
                        `address` = '%s',
@@ -138,7 +148,8 @@ function profiles_post(&$a) {
                        `homepage` = '%s',
                        `politic` = '%s',
                        `religion` = '%s',
-                       `keywords` = '%s',
+                       `pub_keywords` = '%s',
+                       `prv_keywords` = '%s',
                        `about` = '%s',
                        `interest` = '%s',
                        `contact` = '%s',
@@ -153,6 +164,7 @@ function profiles_post(&$a) {
                        WHERE `id` = %d AND `uid` = %d LIMIT 1",
                        dbesc($profile_name),
                        dbesc($name),
+                       dbesc($pdesc),
                        dbesc($gender),
                        dbesc($dob),
                        dbesc($address),
@@ -166,7 +178,8 @@ function profiles_post(&$a) {
                        dbesc($homepage),
                        dbesc($politic),
                        dbesc($religion),
-                       dbesc($keywords),
+                       dbesc($pub_keywords),
+                       dbesc($prv_keywords),
                        dbesc($about),
                        dbesc($interest),
                        dbesc($contact),
@@ -195,11 +208,9 @@ function profiles_post(&$a) {
 
                if($is_default) {
                        // 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");
                }
        }
 }
@@ -208,6 +219,7 @@ function profiles_post(&$a) {
 
 
 function profiles_content(&$a) {
+
        $o = '';
        $o .= '<script> $(document).ready(function() { $(\'#nav-profiles-link\').addClass(\'nav-selected\'); });</script>';
 
@@ -217,7 +229,7 @@ function profiles_content(&$a) {
        }
 
        if(($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
-               $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 AND `self` = 0 LIMIT 1",
+               $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
                        intval($a->argv[2]),
                        intval(local_user())
                );
@@ -234,8 +246,9 @@ function profiles_content(&$a) {
                        intval($a->argv[2]),
                        intval(local_user())
                );
-               $r = q("DELETE FROM `profile` WHERE `id` = %d LIMIT 1",
-                       intval($a->argv[2])
+               $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                       intval($a->argv[2]),
+                       intval(local_user())
                );
                if($r)
                        notice( t('Profile deleted.') . EOL);
@@ -356,6 +369,7 @@ function profiles_content(&$a) {
                        '$profile_name' => $r[0]['profile-name'],
                        '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""),
                        '$name' => $r[0]['name'],
+                       '$pdesc' => $r[0]['pdesc'],
                        '$dob' => dob($r[0]['dob']),
                        '$hide_friends' => $hide_friends,
                        '$address' => $r[0]['address'],
@@ -372,7 +386,8 @@ function profiles_content(&$a) {
                        '$homepage' => $r[0]['homepage'],
                        '$politic' => $r[0]['politic'],
                        '$religion' => $r[0]['religion'],
-                       '$keywords' => $r[0]['keywords'],
+                       '$pub_keywords' => $r[0]['pub_keywords'],
+                       '$prv_keywords' => $r[0]['prv_keywords'],
                        '$music' => $r[0]['music'],
                        '$book' => $r[0]['book'],
                        '$tv' => $r[0]['tv'],
@@ -384,6 +399,9 @@ function profiles_content(&$a) {
                        '$contact' => $r[0]['contact']
                ));
 
+               $arr = array('profile' => $r[0], 'entry' => $o);
+               call_hooks('profile_edit', $arr);
+
                return $o;
        }
        else {
@@ -401,6 +419,7 @@ function profiles_content(&$a) {
                                $o .= replace_macros($template, array(
                                        '$photo' => $rr['thumb'],
                                        '$id' => $rr['id'],
+                                       '$alt' => t('Profile Image'),
                                        '$profile_name' => $rr['profile-name']
                                ));
                        }