From 9f81c3345b40d635a34f0448dd625b17f20508c3 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 25 Jul 2010 22:51:45 -0700 Subject: [PATCH] fixup of some nits with live update and remote comment display on profile page --- images/b_drophide.gif | Bin 0 -> 111 bytes include/items.php | 2 +- include/notifier.php | 2 +- mod/item.php | 8 +++++++- mod/network.php | 6 ++++++ mod/profile.php | 36 +++++++++++++++++++++++++++++++----- mod/update_profile.php | 1 - view/comment_item.tpl | 2 +- view/head.tpl | 14 +++++++++++++- view/style.css | 11 +++++++++++ view/wall_item.tpl | 3 ++- view/wall_item_drop.tpl | 1 + view/wallwall_item.tpl | 6 +++--- 13 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 images/b_drophide.gif create mode 100644 view/wall_item_drop.tpl diff --git a/images/b_drophide.gif b/images/b_drophide.gif new file mode 100644 index 0000000000000000000000000000000000000000..3d9746a18247594d66de4489b4ae70d2d4121a5b GIT binary patch literal 111 zcmZ?wbhEHb6krfwIKHX*wXgyz#hM;Ec*ek6tl8`KeWCtiRPrBvjd?*_->g#FH@R M`&lPbR2Uen0kVoIfB*mh literal 0 HcmV?d00001 diff --git a/include/items.php b/include/items.php index bcfa707632..2cb894f5ad 100644 --- a/include/items.php +++ b/include/items.php @@ -63,7 +63,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND NOT `item`.`type` IN ( 'remote', 'net-comment') AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`edited` > '%s' $sql_extra ORDER BY `parent` ASC, `created` ASC LIMIT 0, 300", diff --git a/include/notifier.php b/include/notifier.php index bd787dbfb8..d8e0665834 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -15,7 +15,7 @@ require_once("datetime.php"); if($argc < 3) exit; -dbg(3); +//dbg(3); $baseurl = $argv[1]; $a->set_baseurl($argv[1]); diff --git a/mod/item.php b/mod/item.php index e0497af7a5..c8758726f7 100644 --- a/mod/item.php +++ b/mod/item.php @@ -91,10 +91,16 @@ function item_post(&$a) { if(count($r)) $contact_record = $r[0]; + $post_type == notags(trim($_POST['type'])); + + if($post_type == 'net-comment') { + if($parent_item !== null && $parent_item['type'] != 'remote') + $post_type = 'wall-comment'; + } $notify_type = (($parent) ? 'comment-new' : 'wall-new' ); - if(($_POST['type'] == 'wall') || ($_POST['type'] == 'wall-comment')) { + if(($_POST['type'] == 'wall') || ($_POST['type'] == 'wall-comment') || ($_POST['type'] == 'net-comment')) { do { $dups = false; diff --git a/mod/network.php b/mod/network.php index 262ecc20bc..a91760f7f7 100644 --- a/mod/network.php +++ b/mod/network.php @@ -166,6 +166,7 @@ function network_content(&$a, $update = false) { if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( '$return_path' => $_SESSION['return_url'], + '$type' => 'net-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $_SESSION['uid'], @@ -173,6 +174,10 @@ function network_content(&$a, $update = false) { )); } + + $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id'])); + + if(($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] )) $profile_url = $redirect_url; @@ -209,6 +214,7 @@ function network_content(&$a, $update = false) { '$owner_url' => $owner_url, '$owner_photo' => $owner_photo, '$owner_name' => $owner_name, + '$drop' => $drop, '$comment' => $comment )); } diff --git a/mod/profile.php b/mod/profile.php index 0cfe228072..b0ff85a447 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -79,6 +79,7 @@ function profile_content(&$a, $update = false) { + if(remote_user()) { $contact_id = $_SESSION['visitor_id']; $groups = init_groups_visitor($contact_id); @@ -88,9 +89,23 @@ function profile_content(&$a, $update = false) { } if($update) { - if(! local_user()) - return ''; - $a->profile['uid'] = $_SESSION['uid']; + // Ensure we've got a profile owner if updating. + if(remote_user()) { + $r = q("SELECT `uid` FROM `contact` WHERE `id` = %d LIMIT 1", + intval($_SESSION['visitor_id']) + ); + if(count($r)) + $a->profile['uid'] = $r[0]['uid']; + else + killme(); + } + elseif(local_user()) { + $a->profile['uid'] = $_SESSION['uid']; + } + else { + killme(); + return; // NOTREACHED + } } else { @@ -174,7 +189,7 @@ function profile_content(&$a, $update = false) { $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND NOT `item`.`type` IN ( 'remote', 'net-comment') AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ", intval($a->profile['uid']) @@ -190,7 +205,7 @@ function profile_content(&$a, $update = false) { `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND NOT `item`.`type` IN ( 'remote', 'net-comment') AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", intval($a->profile['uid']), @@ -217,10 +232,12 @@ function profile_content(&$a, $update = false) { else $return_url = $_SESSION['return_url'] = $a->cmd; + if(can_write_wall($a,$a->profile['uid'])) { if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( '$return_path' => $_SESSION['return_url'], + '$type' => 'wall-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $a->profile['uid'], @@ -252,6 +269,14 @@ function profile_content(&$a, $update = false) { $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']); $profile_link = $profile_url; + $drop = ''; + + if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == $_SESSION['uid'])) + $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id'])); + + + + $o .= replace_macros($template,array( '$id' => $item['item_id'], '$profile_url' => $profile_link, @@ -260,6 +285,7 @@ function profile_content(&$a, $update = false) { '$body' => bbcode($item['body']), '$ago' => relative_date($item['created']), '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''), + '$drop' => $drop, '$comment' => $comment )); } diff --git a/mod/update_profile.php b/mod/update_profile.php index 367a5568d8..8ea86eb91e 100644 --- a/mod/update_profile.php +++ b/mod/update_profile.php @@ -3,7 +3,6 @@ require_once('mod/profile.php'); - function update_profile_content(&$a) { header("Content-type: text/html"); diff --git a/view/comment_item.tpl b/view/comment_item.tpl index b91be5ab5a..63737982eb 100644 --- a/view/comment_item.tpl +++ b/view/comment_item.tpl @@ -2,7 +2,7 @@
- + diff --git a/view/head.tpl b/view/head.tpl index d02f56c727..81ce1287f5 100644 --- a/view/head.tpl +++ b/view/head.tpl @@ -19,6 +19,14 @@ $.ajaxSetup({cache: false}); msie = $.browser.msie ; NavUpdate(); + +// $('.wall-item-delete-icon').hover(function() { +// $(this).attr("src",$(this).attr("src").replace('hide','')); +// },function() { +// $(this).attr("src",$(this).attr("src").replace('','hide')); +// }); + + }); function NavUpdate() { @@ -57,7 +65,7 @@ $.get('update_' + src + '?msie=' + ((msie) ? 1 : 0),function(data) { $('.wall-item-outside-wrapper',data).each(function() { var ident = $(this).attr('id'); - if($('#' + ident).length == 0) { + if($('#' + ident).length == 0) { $('#' + prev).after($(this)); } else { $('#' + ident).replaceWith($(this)); } @@ -67,5 +75,9 @@ } + function confirmDelete() { + return confirm("Delete this item?"); + } + diff --git a/view/style.css b/view/style.css index c6a9a82a6e..e3a2730a15 100644 --- a/view/style.css +++ b/view/style.css @@ -482,6 +482,17 @@ input#dfrn-url { font-size: 0.8em; } +.wall-item-delete-wrapper { + float: left; + margin-top: 10px; + margin-left: 50px; +} + +.wall-item-delete-icon { + border: none; +} + + .wall-item-wrapper-end { clear: both; } diff --git a/view/wall_item.tpl b/view/wall_item.tpl index 72ee216d58..f27113409b 100644 --- a/view/wall_item.tpl +++ b/view/wall_item.tpl @@ -6,8 +6,9 @@
$name
$ago
+$drop
-$body +
$body
$comment diff --git a/view/wall_item_drop.tpl b/view/wall_item_drop.tpl new file mode 100644 index 0000000000..46dfb870de --- /dev/null +++ b/view/wall_item_drop.tpl @@ -0,0 +1 @@ +
Delete
diff --git a/view/wallwall_item.tpl b/view/wallwall_item.tpl index 94d0da4fc6..f391df1682 100644 --- a/view/wallwall_item.tpl +++ b/view/wallwall_item.tpl @@ -1,4 +1,4 @@ -
+
$owner_name @@ -12,12 +12,12 @@ $name to $owner_name via Wall-To-Wall:
$body
$ago
- +$drop
$comment
-
+