]> git.mxchange.org Git - friendica.git/blobdiff - mod/profiles.php
better handling of dead contacts
[friendica.git] / mod / profiles.php
index 7a33a03e44852a84b3a8c7419e2c192a153a9085..6a8ce9e1eda2d93441d91de22ab4334c50b08e8a 100644 (file)
@@ -62,9 +62,15 @@ function profiles_post(&$a) {
                $pub_keywords = notags(trim($_POST['pub_keywords']));
                $prv_keywords = notags(trim($_POST['prv_keywords']));
                $marital = notags(trim($_POST['marital']));
+               $howlong = notags(trim($_POST['howlong']));
 
                $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
 
+               if(! strlen($howlong))
+                       $howlong = '0000-00-00 00:00:00';
+               else
+                       $howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong);
                // linkify the relationship target if applicable
 
                $withchanged = false;
@@ -120,6 +126,7 @@ function profiles_post(&$a) {
 
                $sexual = notags(trim($_POST['sexual']));
                $homepage = notags(trim($_POST['homepage']));
+               $hometown = notags(trim($_POST['hometown']));
                $politic = notags(trim($_POST['politic']));
                $religion = notags(trim($_POST['religion']));
 
@@ -139,21 +146,58 @@ function profiles_post(&$a) {
 
 
                $changes = array();
+               $value = '';
                if($is_default) {
-                       if($marital != $orig[0]['marital']) $changes[] = '♥ ' . t('Marital Status');
-                       if($withchanged) $changes[] = '♥ ' . t('Romantic Partner');                      
-                       if($work != $orig[0]['work']) $changes[] = t('Work/Employment');
-                       if($religion != $orig[0]['religion']) $changes[] = t('Religion');
-                       if($politic != $orig[0]['politic']) $changes[] = t('Political Views');
-                       if($gender != $orig[0]['gender']) $changes[] = t('Gender');
-                       if($sexual != $orig[0]['sexual']) $changes[] = t('Sexual Preference');
-                       if($homepage != $orig[0]['homepage']) $changes[] = t('Homepage');
-                       if($interest != $orig[0]['interest']) $changes[] = t('Interests');
-                       if($address != $orig[0]['address'] || $locality != $orig[0]['locality'] || $region != $orig[0]['region']
-                               || $country_name != $orig[0]['country_name'])
-                               $changes[] = t('Location');
-
-                       profile_activity($changes);
+                       if($marital != $orig[0]['marital']) {
+                               $changes[] = '[color=#ff0000]♥[/color] ' . t('Marital Status');
+                               $value = $marital;
+                       }
+                       if($withchanged) {
+                               $changes[] = '[color=#ff0000]♥[/color] ' . t('Romantic Partner');
+                               $value = strip_tags($with);
+                       }                                                       
+                       if($work != $orig[0]['work']) {
+                               $changes[] = t('Work/Employment');
+                       }
+                       if($religion != $orig[0]['religion']) {
+                               $changes[] = t('Religion');
+                               $value = $religion;
+                       }
+                       if($politic != $orig[0]['politic']) {
+                               $changes[] = t('Political Views');
+                               $value = $politic;
+                       }
+                       if($gender != $orig[0]['gender']) {
+                               $changes[] = t('Gender');
+                               $value = $gender;
+                       }
+                       if($sexual != $orig[0]['sexual']) {
+                               $changes[] = t('Sexual Preference');
+                               $value = $sexual;
+                       }
+                       if($homepage != $orig[0]['homepage']) {
+                               $changes[] = t('Homepage');
+                               $value = $homepage;
+                       }
+                       if($interest != $orig[0]['interest']) {
+                               $changes[] = t('Interests');
+                               $value = $interest;
+                       }
+                       if($address != $orig[0]['address']) {
+                               $changes[] = t('Address');
+                               // New address not sent in notifications, potential privacy issues
+                               // in case this leaks to unintended recipients. Yes, it's in the public
+                               // profile but that doesn't mean we have to broadcast it to everybody.
+                       }
+                       if($locality != $orig[0]['locality'] || $region != $orig[0]['region']
+                               || $country_name != $orig[0]['country-name']) {
+                               $changes[] = t('Location');
+                               $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
+                               $comma2 = (($region && $country_name) ? ', ' : '');
+                               $value = $locality . $comma1 . $region . $comma2 . $country_name;
+                       }
+
+                       profile_activity($changes,$value);
 
                }                       
                        
@@ -170,8 +214,10 @@ function profiles_post(&$a) {
                        `country-name` = '%s',
                        `marital` = '%s',
                        `with` = '%s',
+                       `howlong` = '%s',
                        `sexual` = '%s',
                        `homepage` = '%s',
+                       `hometown` = '%s',
                        `politic` = '%s',
                        `religion` = '%s',
                        `pub_keywords` = '%s',
@@ -200,8 +246,10 @@ function profiles_post(&$a) {
                        dbesc($country_name),
                        dbesc($marital),
                        dbesc($with),
+                       dbesc($howlong),
                        dbesc($sexual),
                        dbesc($homepage),
+                       dbesc($hometown),
                        dbesc($politic),
                        dbesc($religion),
                        dbesc($pub_keywords),
@@ -245,7 +293,7 @@ function profiles_post(&$a) {
 }
 
 
-function profile_activity($changed) {
+function profile_activity($changed, $value) {
        $a = get_app();
 
        if(! local_user() || ! is_array($changed) || ! count($changed))
@@ -289,7 +337,7 @@ function profile_activity($changed) {
        foreach($changed as $ch) {
                if(strlen($changes)) {
                        if ($z == ($t - 1))
-                               $changes .= ' and ';
+                               $changes .= t(' and ');
                        else
                                $changes .= ', ';
                }
@@ -299,7 +347,15 @@ function profile_activity($changed) {
 
        $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]';      
 
-       $arr['body'] =  sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
+       if($t == 1 && strlen($value)) {
+               $message = sprintf( t('%1$s changed %2$s to “%3$s”'), $A, $changes, $value);
+               $message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof);
+       }
+       else
+               $message =      sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
+
+       $arr['body'] = $message;  
 
        $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>'
        . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
@@ -513,8 +569,10 @@ function profiles_content(&$a) {
                        '$lbl_marital' => t('<span class="heart">&hearts;</span> Marital Status:'),
                        '$lbl_with' => t("Who: \x28if applicable\x29"),
                        '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'),
+                       '$lbl_howlong' => t('Since [date]:'),
                        '$lbl_sexual' => t('Sexual Preference:'),
                        '$lbl_homepage' => t('Homepage URL:'),
+                       '$lbl_hometown' => t('Hometown:'),
                        '$lbl_politic' => t('Political Views:'),
                        '$lbl_religion' => t('Religious Views:'),
                        '$lbl_pubkey' => t('Public Keywords:'),
@@ -550,9 +608,11 @@ function profiles_content(&$a) {
                        '$gender' => gender_selector($r[0]['gender']),
                        '$marital' => marital_selector($r[0]['marital']),
                        '$with' => strip_tags($r[0]['with']),
+                       '$howlong' => ($r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong'])),
                        '$sexual' => sexpref_selector($r[0]['sexual']),
                        '$about' => $r[0]['about'],
                        '$homepage' => $r[0]['homepage'],
+                       '$hometown' => $r[0]['hometown'],
                        '$politic' => $r[0]['politic'],
                        '$religion' => $r[0]['religion'],
                        '$pub_keywords' => $r[0]['pub_keywords'],