aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mod/contacts.php170
-rw-r--r--mod/profiles.php2
-rw-r--r--view/contact_edit.tpl53
-rw-r--r--view/contact_selectors.php35
-rw-r--r--view/contact_template.tpl2
-rw-r--r--view/style.css73
-rw-r--r--wip/todo6
7 files changed, 266 insertions, 75 deletions
diff --git a/mod/contacts.php b/mod/contacts.php
index e1b6c4919..38b49475a 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -6,61 +6,55 @@ 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)
- );
+ if(! count($orig_record)) {
+ notice("Could not access contact record." . EOL);
+ goaway($a->get_baseurl() . '/contacts');
+ return; // NOTREACHED
+ }
- break;
- default:
+ $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;
- break;
+ }
}
+ $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']) ? '<div id="block-message">Currently blocked</div>' : ''),
+ '$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) ? "<p id=\"profile-edit-default-desc\">This is your <strong>public</strong> profile.</p>" : ""),
+ '$default' => (($is_default) ? "<p id=\"profile-edit-default-desc\">This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.</p>" : ""),
'$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 @@
+<h2>Contact Editor</h2>
+
+<div id="contact-edit-banner-name">$name</div>
+
<div id="contact-edit-wrapper" >
- <div class="contact-edit-photo-wrapper" >
+
+ <div id="contact-edit-photo-wrapper" >
<img id="contact-edit-direction-icon" src="$dir_icon" alt="$alt_text" title="$alt_text" />
<div id="contact-edit-photo" >
<a href="$url" title="Visit $name's profile" /><img src="$photo" alt="$name" /></a>
</div>
<div id="contact-edit-photo-end" ></div>
</div>
- <div id="contact-edit-nav-wrapper"
- <div id="contact-edit-name" >$name</div>
-
- <div id="contact-edit-break"></div>
-
-<form action="contacts" method="post" >
-<input type="hidden" name="contact_id" value="$contact_id">
+ <div id="contact-edit-nav-wrapper" >
<div id="contact-edit-links" >
- <a href="contacts/$id/block" id="contact-edit-block-link" ><img src="images/b_block.gif" alt="Block contact" title="Block contact"/></a>
- <a href="contacts/$id/drop" id="contact-edit-drop-link"><img src="images/b_drop.gif" alt="Delete contact" title="Delete contact"/></a>
+ <a href="contacts/$contact_id/block" id="contact-edit-block-link" ><img src="images/b_block.gif" alt="Block/Unblock contact" title="$block_text"/></a>
+ <a href="contacts/$contact_id/drop" id="contact-edit-drop-link"><img src="images/b_drop.gif" alt="Delete contact" title="Delete contact"/></a>
</div>
<div id="contact-edit-nav-end"></div>
</div>
- <div class="contact-dit-end" ></div>
+ <div id="contact-edit-end" ></div>
+
+$blocked
+
+<form action="contacts/$contact_id" method="post" >
+<input type="hidden" name="contact_id" value="$contact_id">
+
+<div class="contact-edit-profile-select-text">
+<h4>Profile Visibility</h4>
+<p>Please choose the profile you would like to display to $name - when he/she connects securely to your profile page.
+</p>
+</div>
$profile_select
+<div id="contact-edit-profile-select-end"></div>
+
+<input class="contact-edit-submit" type="submit" name="submit" value="Submit" />
-$groups
+<div id="contact-edit-rating-wrapper">
+<h4>Online Reputation</h4>
+<p>
+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.
+</p>
+<div id="contact-edit-rating-select-wrapper">
$rating
+</div>
+<div id="contact-edit-rating-explain">
+<p>
+Please take a moment to elaborate on this selection if you feel it could be helpful to others.
+</p>
+<textarea id="contact-edit-rating-text" name="reason" rows="3" cols="64" >$reason</textarea>
+</div>
+</div>
+$groups
-$reason
+<input class="contact-edit-submit" type="submit" name="submit" value="Submit" />
</form>
</div>
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 .= "<select id=\"contact_profile_selector\" name=\"profile_assign\" />";
+ $o .= "<select id=\"contact-profile-selector\" name=\"profile-assign\" />\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 .= "<option value=\"{$rr['profile-name']}\" $selected >{$rr['profile-name']}</option>";
+ $selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
}
}
- $o .= "</select>";
+ $o .= "</select>\r\n";
return $o;
}
+
+function contact_reputation($current) {
+
+ $o = '';
+ $o .= "<select id=\"contact-reputation-selector\" name=\"reputation\" />\r\n";
+
+ $rep = array(
+ 0 => "Unknown | Not categorised",
+ 1 => "Block immediately",
+ 2 => "Shady, spammer, self-marketer",
+ 3 => "Known to me, but no opinion",
+ 4 => "OK, probably harmless",
+ 5 => "Reputable, has my trust"
+ );
+
+ foreach($rep as $k => $v) {
+ $selected = (($k == $current) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
+ }
+ $o .= "</select>\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 @@
</div>
<div class="contact-entry-photo-end" ></div>
</div>
- <div class="contact-entry-nav-wrapper"
+ <div class="contact-entry-nav-wrapper" >
<div class="contact-entry-name" id="contact-entry-name-$id" >$name</div>
<div class="contact-entry-break"></div>
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