]> git.mxchange.org Git - friendica.git/commitdiff
fixup of some nits with live update and remote comment display on profile page
authorMike Macgirvin <mike@macgirvin.com>
Mon, 26 Jul 2010 05:51:45 +0000 (22:51 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Mon, 26 Jul 2010 05:51:45 +0000 (22:51 -0700)
13 files changed:
images/b_drophide.gif [new file with mode: 0644]
include/items.php
include/notifier.php
mod/item.php
mod/network.php
mod/profile.php
mod/update_profile.php
view/comment_item.tpl
view/head.tpl
view/style.css
view/wall_item.tpl
view/wall_item_drop.tpl [new file with mode: 0644]
view/wallwall_item.tpl

diff --git a/images/b_drophide.gif b/images/b_drophide.gif
new file mode 100644 (file)
index 0000000..3d9746a
Binary files /dev/null and b/images/b_drophide.gif differ
index bcfa7076322afeb1e8fc7307147c9ec31dc34474..2cb894f5add75995d706e9132856c70bef227d61 100644 (file)
@@ -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",
index bd787dbfb887a0bfa9f3dd2aeaf2dd062d825d14..d8e0665834801d23aa89a3ecdfced593cb3248d4 100644 (file)
@@ -15,7 +15,7 @@ require_once("datetime.php");
 
 if($argc < 3)
        exit;
-dbg(3);
+//dbg(3);
        $baseurl = $argv[1];
        $a->set_baseurl($argv[1]);
 
index e0497af7a54e79e240915d6fa1365252d04e706a..c8758726f75e1572c3888c101a89ab6eee447143 100644 (file)
@@ -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;
index 262ecc20bc4964163b39ac56b20257b2adba391a..a91760f7f7ccd4f693814f3b6aa324ef7c606271 100644 (file)
@@ -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
                        ));
                }
index 0cfe2280725b144405c42e35b5363ac04e5cc94b..b0ff85a447a4e25336ed24be89334d96cc45f737 100644 (file)
@@ -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
                        ));
                }
index 367a5568d85636403d0bfe40069b03825178cf71..8ea86eb91ecc7719b4651238f831fdcd3213369b 100644 (file)
@@ -3,7 +3,6 @@
 
 require_once('mod/profile.php');
 
-
 function update_profile_content(&$a) {
 
        header("Content-type: text/html");
index b91be5ab5a172b65ce6a6a105435eb6e5ea3cd88..63737982eb1b3d3488643e4012bff96b16e9eb74 100644 (file)
@@ -2,7 +2,7 @@
 
 <div class="comment-$wwedit-wrapper" id="comment-edit-wrapper-$id" style="display: block;">
        <form class="comment-edit-form" id="comment-edit-form-$id" action="item" method="post" >
-               <input type="hidden" name="type" value="wall-comment" />
+               <input type="hidden" name="type" value="$type" />
                <input type="hidden" name="profile_uid" value="$profile_uid" />
                <input type="hidden" name="parent" value="$parent" />
                <input type="hidden" name="return" value="$return_path" />
index d02f56c72777aaec8d19575745c6786c77c38261..81ce1287f5b85a56d180c889e8136dfbe4d1e2fb 100644 (file)
                $.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?");
+       }
+
 </script>
 
index c6a9a82a6e5427b222a0b7ed12254a70ab865136..e3a2730a15a3688373317b2c2e41f18ef6a921aa 100644 (file)
@@ -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;
 }
index 72ee216d5862698b16109b4c7fa0d2ce5483110e..f27113409bb869a14edb03697885005dad25991a 100644 (file)
@@ -6,8 +6,9 @@
 <div class="wall-item-wrapper" id="wall-item-wrapper-$id" >
 <a href="$profile_url" title="View $name's profile" class="wall-item-name-link"><span class="wall-item-name" id="wall-item-name-$id" >$name</span></a>
 <div class="wall-item-ago"  id="wall-item-ago-$id">$ago</div>
+$drop
 </div>
-<span class="wall-item-body" id="wall-item-body-$id" >$body</span>
+<div class="wall-item-body" id="wall-item-body-$id" >$body</div>
 <div class="wall-item-wrapper-end"></div>
 <div class="wall-item-comment-separator"></div>
 $comment
diff --git a/view/wall_item_drop.tpl b/view/wall_item_drop.tpl
new file mode 100644 (file)
index 0000000..46dfb87
--- /dev/null
@@ -0,0 +1 @@
+<div class="wall-item-delete-wrapper" id="wall-item-delete-wrapper-$id" ><a href="item/drop/$id" onclick="return confirmDelete();" ><img src="images/b_drop.gif" alt="Delete" title="Delete" id="wall-item-delete-icon-$id" class="wall-item-delete-icon"></a></div>
index 94d0da4fc60859c41ae9718dd471e10c026c0d56..f391df16822e9d845395c65f846089f0e114a3ee 100644 (file)
@@ -1,4 +1,4 @@
-<div class="wall-item-$indentoutside-wrapper" id="wall-item-outside-wrapper-$id" >
+<div class="wall-item-outside-wrapper$indent" id="wall-item-outside-wrapper-$id" >
 <div class="wall-item-photo-wrapper" id="wall-item-ownerphoto-wrapper-$id" >
 <a href="$owner_url" title="View $owner_name's profile" class="wall-item-photo-link" id="wall-item-ownerphoto-link-$id">
 <img src="$owner_photo" class="wall-item-photo" id="wall-item-ownerphoto-$id" height="80" width="80" alt="$owner_name" /></a>
 <a href="$profile_url" title="View $name's profile" class="wall-item-name-link"><span class="wall-item-name" id="wall-item-name-$id" >$name</span></a> to <a href="$owner_url" title="View $owner_name's profile" class="wall-item-name-link"><span class="wall-item-name" id="wall-item-ownername-$id">$owner_name</span></a> via Wall-To-Wall:<br />
 <span class="wall-item-body" id="wall-item-body-$id" >$body</span>
 <div class="wall-item-ago"  id="wall-item-ago-$id">$ago</div>
-
+$drop
 </div>
 <div class="wall-item-wrapper-end"></div>
 <div class="wall-item-comment-separator"></div>
 $comment
 </div>
 
-<div class="wall-item-$indentoutside-wrapper-end" ></div>
+<div class="wall-item-outside-wrapper-end$indent" ></div>