]> git.mxchange.org Git - friendica.git/blobdiff - mod/profiles.php
.
[friendica.git] / mod / profiles.php
index a8b40c8a538286d1bb695b330a0626d71b5a9869..eaa603a282bf537fbdebe9719969199078b98df4 100644 (file)
@@ -42,16 +42,28 @@ function profiles_post(&$a) {
                $day = intval($_POST['day']);
                        if(($day > $mtab[$month]) || ($day < 0))
                                $day = 0;
+
+               // It's OK to have an empty (0) year, but if you supplied a year you have to have a non-zero month and day
+               if($year && ! $month)
+                       $month = 1;
+               if($year && ! $day)
+                       $day = 1;
+
                $dob = '0000-00-00';
                $dob = sprintf('%04d-%02d-%02d',$year,$month,$day);
 
                        
                $name = notags(trim($_POST['name']));
 
+               if(! strlen($name)) {
+                       $name = '[No Name]';
+               }
+
                if($orig[0]['name'] != $name)
                        $namechanged = true;
 
 
+
                $pdesc = notags(trim($_POST['pdesc']));
                $gender = notags(trim($_POST['gender']));
                $address = notags(trim($_POST['address']));
@@ -96,7 +108,7 @@ function profiles_post(&$a) {
                                }
                                else {
                                        $newname = $lookup;
-                                       if(strstr($lookup,' ')) {
+/*                                     if(strstr($lookup,' ')) {
                                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                        dbesc($newname),
                                                        intval(local_user())
@@ -107,6 +119,17 @@ function profiles_post(&$a) {
                                                        dbesc($lookup),
                                                        intval(local_user())
                                                );
+                                       }*/
+                                       
+                                       $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
+                                               dbesc($newname),
+                                               intval(local_user())
+                                       );
+                                       if(! $r) {
+                                               $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
+                                                       dbesc($lookup),
+                                                       intval(local_user())
+                                               );
                                        }
                                        if(count($r)) {
                                                $prf = $r[0]['url'];
@@ -130,6 +153,9 @@ function profiles_post(&$a) {
                $politic = notags(trim($_POST['politic']));
                $religion = notags(trim($_POST['religion']));
 
+               $likes = fix_mce_lf(escape_tags(trim($_POST['likes'])));
+               $dislikes = fix_mce_lf(escape_tags(trim($_POST['dislikes'])));
+
                $about = fix_mce_lf(escape_tags(trim($_POST['about'])));
                $interest = fix_mce_lf(escape_tags(trim($_POST['interest'])));
                $contact = fix_mce_lf(escape_tags(trim($_POST['contact'])));
@@ -155,7 +181,15 @@ function profiles_post(&$a) {
                        if($withchanged) {
                                $changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Romantic Partner');
                                $value = strip_tags($with);
-                       }                                                       
+                       }
+                       if($likes != $orig[0]['likes']) {
+                               $changes[] = t('Likes');
+                               $value = $likes;
+                       }
+                       if($dislikes != $orig[0]['dislikes']) {
+                               $changes[] = t('Dislikes');
+                               $value = $dislikes;
+                       }
                        if($work != $orig[0]['work']) {
                                $changes[] = t('Work/Employment');
                        }
@@ -222,6 +256,8 @@ function profiles_post(&$a) {
                        `religion` = '%s',
                        `pub_keywords` = '%s',
                        `prv_keywords` = '%s',
+                       `likes` = '%s',
+                       `dislikes` = '%s',
                        `about` = '%s',
                        `interest` = '%s',
                        `contact` = '%s',
@@ -254,6 +290,8 @@ function profiles_post(&$a) {
                        dbesc($religion),
                        dbesc($pub_keywords),
                        dbesc($prv_keywords),
+                       dbesc($likes),
+                       dbesc($dislikes),
                        dbesc($about),
                        dbesc($interest),
                        dbesc($contact),
@@ -370,9 +408,17 @@ function profile_activity($changed, $value) {
        $arr['deny_gid']  = $a->user['deny_gid'];
 
        $i = item_store($arr);
-       if($i)
+       if($i) {
+
+               // give it a permanent link
+               q("update item set plink = '%s' where id = %d limit 1",
+                       dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
+                       intval($i)
+               );
+
                proc_run('php',"include/notifier.php","activity","$i");
 
+       }
 }
 
 
@@ -515,14 +561,21 @@ function profiles_content(&$a) {
                require_once('include/profile_selectors.php');
 
 
-               $editselect = 'textareas';
-               if(intval(get_pconfig(local_user(),'system','plaintext')))
-                       $editselect = 'none';
+/*             $editselect = 'textareas';
+               if( intval(get_pconfig(local_user(),'system','plaintext')) || !feature_enabled(local_user(),'richtext') )
+                       $editselect = 'none';*/
+               $editselect = 'none';
+               if( feature_enabled(local_user(),'richtext') )
+                       $editselect = 'textareas';
 
                $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
                        '$baseurl' => $a->get_baseurl(true),
                        '$editselect' => $editselect,
                ));
+               $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array(
+                       '$baseurl' => $a->get_baseurl(true),
+                       '$editselect' => $editselect,
+               ));
 
 
                $opt_tpl = get_markup_template("profile-hide-friends.tpl");
@@ -534,9 +587,6 @@ function profiles_content(&$a) {
                        '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
                ));
 
-               $a->page['htmlhead'] .= "<script type=\"text/javascript\" src=\"js/country.js\" ></script>";
-
-
 
 
 
@@ -552,6 +602,7 @@ function profiles_content(&$a) {
                        '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
                        '$banner' => t('Edit Profile Details'),
                        '$submit' => t('Submit'),
+                       '$profpic' => t('Change Profile Photo'),
                        '$viewprof' => t('View this profile'),
                        '$cr_prof' => t('Create a new profile using these settings'),
                        '$cl_prof' => t('Clone this profile'),
@@ -577,6 +628,8 @@ function profiles_content(&$a) {
                        '$lbl_religion' => t('Religious Views:'),
                        '$lbl_pubkey' => t('Public Keywords:'),
                        '$lbl_prvkey' => t('Private Keywords:'),
+                       '$lbl_likes' => t('Likes:'),
+                       '$lbl_dislikes' => t('Dislikes:'),
                        '$lbl_ex2' => t('Example: fishing photography software'),
                        '$lbl_pubdsc' => t("\x28Used for suggesting potential friends, can be seen by others\x29"),
                        '$lbl_prvdsc' => t("\x28Used for searching profiles, never shown to others\x29"),
@@ -617,6 +670,8 @@ function profiles_content(&$a) {
                        '$religion' => $r[0]['religion'],
                        '$pub_keywords' => $r[0]['pub_keywords'],
                        '$prv_keywords' => $r[0]['prv_keywords'],
+                       '$likes' => $r[0]['likes'],
+                       '$dislikes' => $r[0]['dislikes'],
                        '$music' => $r[0]['music'],
                        '$book' => $r[0]['book'],
                        '$tv' => $r[0]['tv'],
@@ -635,7 +690,7 @@ function profiles_content(&$a) {
        }
        else {
 
-               $r = q("SELECT `profile`.*, `contact`.`avatar-date` AS picdate FROM `profile` LEFT JOIN `contact` on `contact`.`uid` = `profile`.`uid` WHERE `profile`.`uid` = %d",
+               $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
                        local_user());
                if(count($r)) {
 
@@ -652,7 +707,7 @@ function profiles_content(&$a) {
 
                        foreach($r as $rr) {
                                $o .= replace_macros($tpl, array(
-                                       '$photo' => $rr['thumb'] . '?rev=' . urlencode($rr['picdate']),
+                                       '$photo' => $a->get_cached_avatar_image($rr['thumb']),
                                        '$id' => $rr['id'],
                                        '$alt' => t('Profile Image'),
                                        '$profile_name' => $rr['profile-name'],