]> git.mxchange.org Git - friendica.git/blobdiff - mod/profiles.php
Merge remote-tracking branch 'upstream/develop' into 1603-ostatus-completion
[friendica.git] / mod / profiles.php
index 30b41954553fc5d1b9b288b2e68b6a241bdb84f2..0b8261422f3b5b36b316f44b2e95eb2edac84ebd 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-
+require_once("include/Contact.php");
 
 function profiles_init(&$a) {
 
@@ -16,7 +16,7 @@ function profiles_init(&$a) {
                );
                if(! count($r)) {
                        notice( t('Profile not found.') . EOL);
-                       goaway($a->get_baseurl(true) . '/profiles');
+                       goaway('profiles');
                        return; // NOTREACHED
                }
 
@@ -34,9 +34,9 @@ function profiles_init(&$a) {
                        intval(local_user())
                );
                if($r)
-                       info( t('Profile deleted.') . EOL);
+                       info(t('Profile deleted.').EOL);
 
-               goaway($a->get_baseurl(true) . '/profiles');
+               goaway('profiles');
                return; // NOTREACHED
        }
 
@@ -73,9 +73,9 @@ function profiles_init(&$a) {
 
                info( t('New profile created.') . EOL);
                if(count($r3) == 1)
-                       goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
+                       goaway('profiles/'.$r3[0]['id']);
 
-               goaway($a->get_baseurl(true) . '/profiles');
+               goaway('profiles');
        }
 
        if(($a->argc > 2) && ($a->argv[1] === 'clone')) {
@@ -116,9 +116,9 @@ function profiles_init(&$a) {
                );
                info( t('New profile created.') . EOL);
                if(count($r3) == 1)
-                       goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
+                       goaway('profiles/'.$r3[0]['id']);
 
-               goaway($a->get_baseurl(true) . '/profiles');
+               goaway('profiles');
 
                return; // NOTREACHED
        }
@@ -206,7 +206,7 @@ function profiles_post(&$a) {
                        if($ignore_year)
                                $dob = '0000-' . $dob;
                }
-                
+
                $name = notags(trim($_POST['name']));
 
                if(! strlen($name)) {
@@ -327,7 +327,7 @@ function profiles_post(&$a) {
 
                $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
 
-
+               set_pconfig(local_user(),'system','detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0));
 
                $changes = array();
                $value = '';
@@ -470,7 +470,8 @@ function profiles_post(&$a) {
 
 
                if($namechanged && $is_default) {
-                       $r = q("UPDATE `contact` SET `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
+                       $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
+                               dbesc($name),
                                dbesc(datetime_convert()),
                                intval(local_user())
                        );
@@ -481,21 +482,7 @@ function profiles_post(&$a) {
                }
 
                if($is_default) {
-                       $location = $locality;
-
-                       if ($region != "") {
-                               if ($location != "")
-                                       $location .= ", ";
-
-                               $location .= $region;
-                       }
-
-                       if ($country_name != "") {
-                               if ($location != "")
-                                       $location .= ", ";
-
-                               $location .= $country_name;
-                       }
+                       $location = formatted_location(array("locality" => $locality, "region" => $region, "country-name" => $country_name));
 
                        $r = q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` = 1 AND `uid` = %d",
                                dbesc($about),
@@ -507,7 +494,7 @@ function profiles_post(&$a) {
 
                        // Update global directory in background
                        $url = $_SESSION['my_url'];
-                       if($url && strlen(get_config('system','directory_submit_url')))
+                       if($url && strlen(get_config('system','directory')))
                                proc_run('php',"include/directory.php","$url");
 
                        require_once('include/profile_update.php');
@@ -539,7 +526,7 @@ function profile_activity($changed, $value) {
                return;
 
        $arr = array();
-       $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user()); 
+       $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
        $arr['uid'] = local_user();
        $arr['contact-id'] = $self[0]['id'];
        $arr['wall'] = 1;
@@ -551,7 +538,7 @@ function profile_activity($changed, $value) {
        $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
        $arr['verb'] = ACTIVITY_UPDATE;
        $arr['object-type'] = ACTIVITY_OBJ_PROFILE;
-                               
+
        $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
 
 
@@ -569,7 +556,7 @@ function profile_activity($changed, $value) {
                $changes .= $ch;
        }
 
-       $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]';      
+       $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]';
 
        if($t == 1 && strlen($value)) {
                $message = sprintf( t('%1$s changed %2$s to &ldquo;%3$s&rdquo;'), $A, $changes, $value);
@@ -577,9 +564,9 @@ function profile_activity($changed, $value) {
        }
        else
                $message =      sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
 
-       $arr['body'] = $message;  
+
+       $arr['body'] = $message;
 
        $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>'
        . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
@@ -595,15 +582,7 @@ function profile_activity($changed, $value) {
 
        $i = item_store($arr);
        if($i) {
-
-               // give it a permanent link
-               //q("update item set plink = '%s' where id = %d",
-               //      dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
-               //      intval($i)
-               //);
-
                proc_run('php',"include/notifier.php","activity","$i");
-
        }
 }
 
@@ -663,8 +642,10 @@ function profiles_content(&$a) {
                        '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
                ));
 
+               $personal_account = !(in_array($a->user["page-flags"],
+                                       array(PAGE_COMMUNITY, PAGE_PRVGROUP)));
 
-
+               $detailled_profile = (get_pconfig(local_user(),'system','detailled_profile') AND $personal_account);
 
                $f = get_config('system','birthday_input_format');
                if(! $f)
@@ -673,6 +654,17 @@ function profiles_content(&$a) {
                $is_default = (($r[0]['is-default']) ? 1 : 0);
                $tpl = get_markup_template("profile_edit.tpl");
                $o .= replace_macros($tpl,array(
+                       '$personal_account' => $personal_account,
+                       '$detailled_profile' => $detailled_profile,
+
+                       '$details' => array(
+                                'detailled_profile', //Name
+                                t('Show more profile fields:'), //Label
+                                $detailled_profile, //Value
+                                '', //Help string
+                                array(t('No'),t('Yes')) //Off - On strings
+                        ),
+
                        '$multi_profiles' => feature_enabled(local_user(),'multi_profiles'),
                        '$form_security_token' => get_form_security_token("profile_edit"),
                        '$form_security_token_photo' => get_form_security_token("profile_photo"),
@@ -774,10 +766,10 @@ function profiles_content(&$a) {
 
                return $o;
        }
-       
+
        //Profiles list.
        else {
-               
+
                //If we don't support multi profiles, don't display this list.
                if(!feature_enabled(local_user(),'multi_profiles')){
                        $r = q(
@@ -786,14 +778,14 @@ function profiles_content(&$a) {
                        );
                        if(count($r)){
                                //Go to the default profile.
-                               goaway($a->get_baseurl(true) . '/profiles/'.$r[0]['id']);
+                               goaway('profiles/'.$r[0]['id']);
                        }
                }
-               
+
                $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
                        local_user());
                if(count($r)) {
-                       
+
                        $tpl_header = get_markup_template('profile_listing_header.tpl');
                        $o .= replace_macros($tpl_header,array(
                                '$header' => t('Edit/Manage Profiles'),
@@ -801,18 +793,18 @@ function profiles_content(&$a) {
                                '$cr_new' => t('Create New Profile'),
                                '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new")
                        ));
-                       
-                       
+
+
                        $tpl = get_markup_template('profile_entry.tpl');
-                       
+
                        foreach($r as $rr) {
                                $o .= replace_macros($tpl, array(
-                                       '$photo' => $a->get_cached_avatar_image($rr['thumb']),
+                                       '$photo' => $a->remove_baseurl($rr['thumb']),
                                        '$id' => $rr['id'],
                                        '$alt' => t('Profile Image'),
                                        '$profile_name' => $rr['profile-name'],
-                                       '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>' 
-                                               : '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>')
+                                       '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>'
+                                               : '<a href="'.'profperm/'.$rr['id'].'" />' . t('Edit visibility') . '</a>')
                                ));
                        }
                }