X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Fprofiles.php;h=39382fbdd5b6c14b671289b60680151c51531776;hb=49d52faab5900dfe0ec66d8eec7a51473e7c1344;hp=e57a0fa8414fbc02f846afdeb4bdb213b0fb9016;hpb=a3895c8deeee52a2a51bc9245ceb5bedda3be98b;p=friendica.git
diff --git a/mod/profiles.php b/mod/profiles.php
index e57a0fa841..39382fbdd5 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -1,5 +1,5 @@
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
}
@@ -138,6 +138,25 @@ function profiles_init(&$a) {
profile_load($a,$a->user['nickname'],$r[0]['id']);
}
+
+
+}
+
+function profile_clean_keywords($keywords) {
+ $keywords = str_replace(","," ",$keywords);
+ $keywords = explode(" ", $keywords);
+
+ $cleaned = array();
+ foreach ($keywords as $keyword) {
+ $keyword = trim(strtolower($keyword));
+ $keyword = trim($keyword, "#");
+ if ($keyword != "")
+ $cleaned[] = $keyword;
+ }
+
+ $keywords = implode(", ", $cleaned);
+
+ return $keywords;
}
function profiles_post(&$a) {
@@ -167,31 +186,27 @@ function profiles_post(&$a) {
$profile_name = notags(trim($_POST['profile_name']));
if(! strlen($profile_name)) {
- notify( t('Profile Name is required.') . EOL);
+ notice( t('Profile Name is required.') . EOL);
return;
}
- $year = intval($_POST['year']);
- if($year < 1900 || $year > 2100 || $year < 0)
- $year = 0;
- $month = intval($_POST['month']);
- if(($month > 12) || ($month < 0))
- $month = 0;
- $mtab = array(0,31,29,31,30,31,30,31,31,30,31,30,31);
- $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);
-
-
+ $dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
+
+ $y = substr($dob,0,4);
+ if((! ctype_digit($y)) || ($y < 1900))
+ $ignore_year = true;
+ else
+ $ignore_year = false;
+ if($dob != '0000-00-00') {
+ if(strpos($dob,'0000-') === 0) {
+ $ignore_year = true;
+ $dob = substr($dob,5);
+ }
+ $dob = datetime_convert('UTC','UTC',(($ignore_year) ? '1900-' . $dob : $dob),(($ignore_year) ? 'm-d' : 'Y-m-d'));
+ if($ignore_year)
+ $dob = '0000-' . $dob;
+ }
+
$name = notags(trim($_POST['name']));
if(! strlen($name)) {
@@ -210,8 +225,8 @@ function profiles_post(&$a) {
$region = notags(trim($_POST['region']));
$postal_code = notags(trim($_POST['postal_code']));
$country_name = notags(trim($_POST['country_name']));
- $pub_keywords = notags(trim($_POST['pub_keywords']));
- $prv_keywords = notags(trim($_POST['prv_keywords']));
+ $pub_keywords = profile_clean_keywords(notags(trim($_POST['pub_keywords'])));
+ $prv_keywords = profile_clean_keywords(notags(trim($_POST['prv_keywords'])));
$marital = notags(trim($_POST['marital']));
$howlong = notags(trim($_POST['howlong']));
@@ -221,7 +236,7 @@ function profiles_post(&$a) {
$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;
@@ -275,7 +290,7 @@ function profiles_post(&$a) {
$newname = $r[0]['name'];
}
}
-
+
if($prf) {
$with = str_replace($lookup,'' . $newname . '', $with);
if(strpos($with,'@') === 0)
@@ -312,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 = '';
@@ -455,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())
);
@@ -466,9 +482,19 @@ function profiles_post(&$a) {
}
if($is_default) {
+ $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),
+ dbesc($location),
+ dbesc($pub_keywords),
+ dbesc($gender),
+ intval(local_user())
+ );
+
// 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');
@@ -500,7 +526,9 @@ function profile_activity($changed, $value) {
return;
$arr = array();
- $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
+
+ $arr['guid'] = get_guid(32);
+ $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;
@@ -512,7 +540,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]';
@@ -530,7 +558,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 “%3$s”'), $A, $changes, $value);
@@ -538,9 +566,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'] = '