diff --git a/mod/contacts.php b/mod/contacts.php index e1b6c4919..38b49475a 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -6,62 +6,56 @@ function edit_contact(&$a,$contact_id) { function contacts_post(&$a) { - if(($a->argc != 3) || (! local_user())) + if(! local_user()) return; $contact_id = intval($a->argv[1]); if(! $contact_id) return; - - $cmd = $a->argv[2]; - - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", +dbg(2); +print_r($_POST); + $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval($_SESSION['uid']) ); - if(! count($r)) - return; - $photo = str_replace('-4.jpg', '' , $r[0]['photo']); - $photos = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d", - dbesc($photo), - intval($_SESSION['uid']) - ); - - - switch($cmd) { - case 'edit': - edit_contact($a,$contact_id); - break; - case 'block': - $r = q("UPDATE `contact` SET `blocked` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval($_SESSION['uid']) - ); - if($r) - $_SESSION['sysmsg'] .= "Contact has been blocked." . EOL; - break; - case 'drop': - $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval($_SESSION['uid'])); - if(count($photos)) { - foreach($photos as $p) { - q("DELETE FROM `photos` WHERE `id` = %d LIMIT 1", - $p['id']); - } - } - if($intval($contact_id)) - q("DELETE FROM `item` WHERE `contact-id` = %d LIMIT 1", - intval($contact_id) - ); - - break; - default: - return; - break; + if(! count($orig_record)) { + notice("Could not access contact record." . EOL); + goaway($a->get_baseurl() . '/contacts'); + return; // NOTREACHED } + $profile_id = intval($_POST['profile-assign']); + if($profile_id) { + $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($profile_id), + intval($_SESSION['uid']) + ); + if(! count($r)) { + notice("Cannot locate selected profile." . EOL); + return; + } + } + $rating = intval($_POST['reputation']); + if($rating > 5 || $rating < 0) + $rating = 0; + + $reason = notags(trim($_POST['reason'])); + + $r = q("UPDATE `contact` SET `profile-id` = %d, `rating` = %d, `reason` = '%s' + WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($profile_id), + intval($rating), + dbesc($reason), + intval($contact_id), + intval($_SESSION['uid']) + ); + if($r) + notice("Contact updated." . EOL); + else + notice("Failed to update contact record." . EOL); + return; + } @@ -75,6 +69,7 @@ function contacts_post(&$a) { function contacts_content(&$a) { + if(! local_user()) { $_SESSION['sysmsg'] .= "Permission denied." . EOL; return; @@ -82,6 +77,67 @@ function contacts_content(&$a) { + if($a->argc == 3) { + + $contact_id = intval($a->argv[1]); + if(! $contact_id) + return; + + $cmd = $a->argv[2]; + + $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($contact_id), + intval($_SESSION['uid']) + ); + + if(! count($orig_record)) { + notice("Could not access contact record." . EOL); + goaway($a->get_baseurl() . '/contacts'); + return; // NOTREACHED + } + + + $photo = str_replace('-4.jpg', '' , $r[0]['photo']); + $photos = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d", + dbesc($photo), + intval($_SESSION['uid']) + ); + + if($cmd == 'block') { + $blocked = (($orig_record[0]['blocked']) ? 0 : 1); + $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($blocked), + intval($contact_id), + intval($_SESSION['uid']) + ); + if($r) { + $msg = "Contact has been " . (($blocked) ? '' : 'un') . "blocked." . EOL ; + notice($msg); + } + goaway($a->get_baseurl() ."/contacts/$contact_id"); + return; // NOTREACHED + } + + if($cmd == 'drop') { + $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($contact_id), + intval($_SESSION['uid'])); + if(count($photos)) { + foreach($photos as $p) { + q("DELETE FROM `photos` WHERE `id` = %d LIMIT 1", + $p['id']); + } + } + if($intval($contact_id)) + q("DELETE FROM `item` WHERE `contact-id` = %d LIMIT 1", + intval($contact_id) + ); + + notice("Contact has been removed." . EOL ); + goaway($a->get_baseurl() . '/contacts'); + return; // NOTREACHED + } + } if(($a->argc == 2) && intval($a->argv[1])) { @@ -99,13 +155,33 @@ function contacts_content(&$a) { $tpl = file_get_contents("view/contact_edit.tpl"); + $direction = ''; + if(strlen($r[0]['issued-id'])) { + if(strlen($r[0]['dfrn-id'])) { + $direction = DIRECTION_BOTH; + $dir_icon = 'images/lrarrow.gif'; + $alt_text = 'Mutual Friendship'; + } + else { + $direction = DIRECTION_IN; + $dir_icon = 'images/larrow.gif'; + $alt_text = 'is a fan of yours'; + } + } + else { + $direction = DIRECTION_OUT; + $dir_icon = 'images/rarrow.gif'; + $alt_text = 'you are a fan of'; + } + $o .= replace_macros($tpl,array( '$profile_select' => contact_profile_assign($r[0]['profile-id']), '$contact_id' => $r[0]['id'], - '$blocked' => $r[0]['blocked'], - '$rating' => $r[0]['rating'], + '$block_text' => (($r[0]['blocked']) ? 'Unblock this contact' : 'Block this contact' ), + '$blocked' => (($r[0]['blocked']) ? '
Currently blocked
' : ''), + '$rating' => contact_reputation($r[0]['rating']), '$reason' => $r[0]['reason'], - // '$groups' => group_selector(), + '$groups' => '', // group_selector(), '$photo' => $r[0]['photo'], '$name' => $r[0]['name'], '$dir_icon' => $dir_icon, @@ -184,6 +260,4 @@ function contacts_content(&$a) { } } return $o; - - } \ No newline at end of file diff --git a/mod/profiles.php b/mod/profiles.php index 26776ff60..3f5980ba6 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -292,7 +292,7 @@ function profiles_content(&$a) { '$baseurl' => $a->get_baseurl(), '$profile_id' => $r[0]['id'], '$profile_name' => $r[0]['profile-name'], - '$default' => (($is_default) ? "

This is your public profile.

" : ""), + '$default' => (($is_default) ? "

This is your public profile.
It may be visible to anybody using the internet.

" : ""), '$name' => $r[0]['name'], '$dob' => dob($r[0]['dob']), '$hide_birth' => (($r[0]['dob_hide']) ? " checked=\"checked\" " : ""), diff --git a/view/contact_edit.tpl b/view/contact_edit.tpl index a786e47b7..91ae30ec1 100644 --- a/view/contact_edit.tpl +++ b/view/contact_edit.tpl @@ -1,34 +1,61 @@ +

Contact Editor

+ +
$name
+
-
+ +
$alt_text
$name
-
$name
- -
- -
- +
-
-$profile_select +
+$blocked + + + + +
+

Profile Visibility

+

Please choose the profile you would like to display to $name - when he/she connects securely to your profile page. +

+
+$profile_select +
+ + + + +
+

Online Reputation

+

+Occasionally your friends may wish to inquire about this person's online legitimacy. You may help them choose whether or not to interact with this person by providing a 'reputation' to guide them. +

+
+$rating +
+
+

+Please take a moment to elaborate on this selection if you feel it could be helpful to others. +

+ +
+
$groups -$rating - -$reason +
diff --git a/view/contact_selectors.php b/view/contact_selectors.php index a7d3d0f5b..a6cafe4ee 100644 --- a/view/contact_selectors.php +++ b/view/contact_selectors.php @@ -4,18 +4,43 @@ function contact_profile_assign($current) { $o = ''; - $o .= "\r\n"; - $r = q("SELECT `profile-name` FROM `profile` WHERE `uid` = %d", + $r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d", intval($_SESSION['uid'])); if(count($r)) { foreach($r as $rr) { - $selected = (($rr['profile-name'] == $current) ? " selected=\"selected\" " : ""); - $o .= ""; + $selected = (($rr['id'] == $current) ? " selected=\"selected\" " : ""); + $o .= "\r\n"; } } - $o .= ""; + $o .= "\r\n"; return $o; } + +function contact_reputation($current) { + + $o = ''; + $o .= "\r\n"; + return $o; +} + + + diff --git a/view/contact_template.tpl b/view/contact_template.tpl index 7481bdc70..f2bcdc2d5 100644 --- a/view/contact_template.tpl +++ b/view/contact_template.tpl @@ -7,7 +7,7 @@
-
$name
diff --git a/view/style.css b/view/style.css index 7b1a1beb5..169a89589 100644 --- a/view/style.css +++ b/view/style.css @@ -369,6 +369,7 @@ input#dfrn-url { .contact-entry-direction-icon { margin-top: 24px; float: left; + margin-right: 2px; } .contact-entry-photo img { border: none; @@ -650,4 +651,74 @@ input#dfrn-url { margin-right: 20px; padding: 10px; border: 1px solid #CCCCCC; -} \ No newline at end of file +} + +#contact-edit-wrapper { + margin-top: 50px; +} + +#contact-edit-banner-name { + font-size: 1.4em; + font-weight: bold; + margin-left: 30px; +} + + +#contact-edit-links img { + margin-left: 20px; + border: none; +} + +#contact-edit-direction-icon { + float: left; + margin-top: 70px; + margin-right: 2px; +} + +#contact-edit-photo { + float: left; +} + +#contact-edit-photo-end { + clear: both; +} + +#contact-edit-photo-wrapper { + float: left; +} + +#contact-edit-nav-wrapper { + float: left; +} + +#contact-edit-end { + clear: both; +} + +#contact-profile-selector { + width: 175px; + margin-left: 175px; +} + +#contact-reputation-selector { + margin-left: 175px; +} + +#contact-edit-rating-text { + margin-left: 175px; +} + +.contact-edit-submit { + margin-top: 20px; + margin-left: 50px; +} + +#block-message { + margin-top: 20px; + width: 180px; + color: #FF0000; + font-size: 1.1em; + border: 1px solid #FF8888; + background-color: #FFEEEE; + padding: 10px; +} diff --git a/wip/todo b/wip/todo index cf99ca750..7acb60dce 100644 --- a/wip/todo +++ b/wip/todo @@ -8,13 +8,7 @@ profile photo to self contact page? - resolve profile photo inconsistency contact editor - - profile selector - block block photo - remove - reputation - profile "you name it" field