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) {
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)) {
$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']));
$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;
$newname = $r[0]['name'];
}
}
-
+
if($prf) {
$with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with);
if(strpos($with,'@') === 0)
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())
);
}
if($is_default) {
+ $location = $locality;
+
+ if ($region != "") {
+ if ($location != "")
+ $location .= ", ";
+
+ $location .= $region;
+ }
+
+ if ($country_name != "") {
+ if ($location != "")
+ $location .= ", ";
+
+ $location .= $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');
$o .= replace_macros($tpl,array(
'$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"),
'$profile_clone_link' => 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone"),
'$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
'$banner' => t('Edit Profile Details'),
'$cr_prof' => t('Create a new profile using these settings'),
'$cl_prof' => t('Clone this profile'),
'$del_prof' => t('Delete this profile'),
+ '$lbl_basic_section' => t('Basic information'),
+ '$lbl_picture_section' => t('Profile picture'),
+ '$lbl_location_section' => t('Location'),
+ '$lbl_preferences_section' => t('Preferences'),
+ '$lbl_status_section' => t('Status information'),
+ '$lbl_about_section' => t('Additional information'),
+ '$lbl_interests_section' => t('Interests'),
+ '$lbl_profile_photo' => t('Upload Profile Photo'),
'$lbl_profname' => t('Profile Name:'),
'$lbl_fullname' => t('Your Full Name:'),
'$lbl_title' => t('Title/Description:'),
'$lbl_gender' => t('Your Gender:'),
- '$lbl_bd' => sprintf( t("Birthday \x28%s\x29:"),datesel_format($f)),
+ '$lbl_bd' => t("Birthday :"),
'$lbl_address' => t('Street Address:'),
'$lbl_city' => t('Locality/City:'),
'$lbl_zip' => t('Postal/Zip Code:'),
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(
+ "SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
+ local_user()
+ );
+ if(count($r)){
+ //Go to the default profile.
+ goaway($a->get_baseurl(true) . '/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'),
'$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']),