From d11c1c63c02e88b3c73336741a2240ccc18d3b02 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 8 Aug 2010 21:03:08 -0700 Subject: lots of fixes - most recent photo updates for contacts --- mod/profiles.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'mod/profiles.php') diff --git a/mod/profiles.php b/mod/profiles.php index db4426474..bfdff5f6b 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -7,16 +7,19 @@ function profiles_post(&$a) { notice( "Permission denied." . EOL); return; } + + $namechanged = false; + if(($a->argc > 1) && ($a->argv[1] != "new") && intval($a->argv[1])) { - $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[1]), intval($_SESSION['uid']) ); - if(! count($r)) { + if(! count($orig)) { $_SESSION['sysmsg'] .= "Profile not found." . EOL; return; } - $is_default = (($r[0]['is-default']) ? 1 : 0); + $is_default = (($orig[0]['is-default']) ? 1 : 0); $profile_name = notags(trim($_POST['profile_name'])); if(! strlen($profile_name)) { @@ -39,6 +42,10 @@ function profiles_post(&$a) { $name = notags(trim($_POST['name'])); + + if($orig[0]['name'] != $name) + $namechanged = true; + $gender = notags(trim($_POST['gender'])); $address = notags(trim($_POST['address'])); $locality = notags(trim($_POST['locality'])); @@ -132,7 +139,12 @@ function profiles_post(&$a) { ); } - + if($namechanged && $is_default) { + $r = q("UPDATE `contact` SET `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1", + dbesc(datetime_convert()), + intval($_SESSION['uid']) + ); + } } -- cgit v1.2.3