]> git.mxchange.org Git - friendica.git/blobdiff - include/identity.php
There is now a function to store conversations
[friendica.git] / include / identity.php
index a85b78e717a9e56d8a06da3e129a08e0a2446501..1fea5b25d659880ed1e07cb4c501f53c364b4d62 100644 (file)
@@ -134,7 +134,7 @@ function profile_load(App $a, $nickname, $profile = 0, $profiledata = array()) {
  */
 function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
        if (remote_user() && count($_SESSION['remote'])) {
-                       foreach($_SESSION['remote'] as $visitor) {
+                       foreach ($_SESSION['remote'] as $visitor) {
                                if ($visitor['uid'] == $uid) {
                                        $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
                                                intval($visitor['cid'])
@@ -200,17 +200,22 @@ function profile_sidebar($profile, $block = 0) {
        $o = '';
        $location = false;
        $address = false;
-//             $pdesc = true;
+       // $pdesc = true;
 
-       if ((! is_array($profile)) && (! count($profile)))
+       // This function can also use contact information in $profile
+       $is_contact = x($profile, 'cid');
+
+       if ((! is_array($profile)) && (! count($profile))) {
                return $o;
+       }
 
        $profile['picdate'] = urlencode($profile['picdate']);
 
        if (($profile['network'] != "") AND ($profile['network'] != NETWORK_DFRN)) {
-               $profile['network_name'] = format_network_name($profile['network'],$profile['url']);
-       } else
+               $profile['network_name'] = format_network_name($profile['network'], $profile['url']);
+       } else {
                $profile['network_name'] = "";
+       }
 
        call_hooks('profile_sidebar_enter', $profile);
 
@@ -220,7 +225,7 @@ function profile_sidebar($profile, $block = 0) {
 
        // don't show connect link to authenticated visitors either
        if (remote_user() && count($_SESSION['remote'])) {
-               foreach($_SESSION['remote'] as $visitor) {
+               foreach ($_SESSION['remote'] as $visitor) {
                        if ($visitor['uid'] == $profile['uid']) {
                                $connect = false;
                                break;
@@ -281,7 +286,7 @@ function profile_sidebar($profile, $block = 0) {
        }
 
        // show edit profile to yourself
-       if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
+       if (!$is_contact && $profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
                $profile['edit'] = array(App::get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
                $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
                                local_user());
@@ -310,7 +315,7 @@ function profile_sidebar($profile, $block = 0) {
 
                }
        }
-       if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
+       if (!$is_contact && $profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
                $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
                $profile['menu'] = array(
                        'chg_photo' => t('Change profile photo'),
@@ -390,7 +395,7 @@ function profile_sidebar($profile, $block = 0) {
        }
 
        $p = array();
-       foreach($profile as $k => $v) {
+       foreach ($profile as $k => $v) {
                $k = str_replace('-','_',$k);
                $p[$k] = $v;
        }
@@ -486,7 +491,7 @@ function get_birthdays() {
                }
                $classtoday = $istoday ? ' birthday-today ' : '';
                if ($total) {
-                       foreach($r as &$rr) {
+                       foreach ($r as &$rr) {
                                if (! strlen($rr['name']))
                                        continue;
 
@@ -570,7 +575,7 @@ function get_events() {
 
                $skip = 0;
 
-               foreach($r as &$rr) {
+               foreach ($r as &$rr) {
                        $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
 
                        if (strlen($title) > 35)
@@ -627,9 +632,7 @@ function advanced_profile(App $a) {
 
                if ($a->profile['gender']) $profile['gender'] = array( t('Gender:'),  $a->profile['gender'] );
 
-
-               if (($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
-
+               if (($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) {
                        $year_bd_format = t('j F, Y');
                        $short_bd_format = t('j F');
 
@@ -652,7 +655,7 @@ function advanced_profile(App $a) {
                        $profile['marital']['with'] = $a->profile['with'];
                }
 
-               if (strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') {
+               if (strlen($a->profile['howlong']) && $a->profile['howlong'] >= NULL_DATE) {
                        $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s'));
                }