]> git.mxchange.org Git - friendica.git/commitdiff
delete selected items
authorFriendika <info@friendika.com>
Thu, 16 Jun 2011 03:43:39 +0000 (20:43 -0700)
committerFriendika <info@friendika.com>
Thu, 16 Jun 2011 03:43:39 +0000 (20:43 -0700)
include/conversation.php
include/items.php
include/main.js
mod/item.php
mod/photos.php
mod/profile.php
view/jot-header.tpl
view/photo_drop.tpl [new file with mode: 0644]
view/theme/duepuntozero/style.css
view/theme/loozah/style.css
view/wall_item_drop.tpl

index 9ffcbe15798c86d4e4d35c9e2a1eb7b55b7e8ae5..0d3123831e14e53accabdf8e69ecde22a5729330 100644 (file)
@@ -114,6 +114,8 @@ function conversation(&$a, $items, $mode, $update) {
        $noshare_tpl = get_markup_template('like_noshare.tpl');
        $tpl         = get_markup_template('wall_item.tpl');
        $wallwall    = get_markup_template('wallwall_item.tpl');
+       $droptpl     = get_markup_template('wall_item_drop.tpl');
+       $fakedrop    = get_markup_template('wall_fake_drop.tpl');
 
        $alike = array();
        $dlike = array();
@@ -126,7 +128,6 @@ function conversation(&$a, $items, $mode, $update) {
                        // - just loop through the items and format them minimally for display
 
                        $tpl = get_markup_template('search_item.tpl');
-                       $droptpl = get_markup_template('wall_fake_drop.tpl');
 
                        foreach($items as $item) {
 
@@ -171,14 +172,7 @@ function conversation(&$a, $items, $mode, $update) {
                                }
 
                                $drop = '';
-                               $dropping = false;
 
-                               if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
-                                       $dropping = true;
-
-                   $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$delete' => t('Delete')));
-
-                               // 
                                localize_item($item);
 
                                $drop = replace_macros($droptpl,array('$id' => $item['id']));
@@ -390,7 +384,16 @@ function conversation(&$a, $items, $mode, $update) {
                                        ? '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] 
                                                . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>'
                                        : '');
-                       $drop = replace_macros(get_markup_template('wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
+
+
+                       $drop = '';
+                       $dropping = false;
+
+                       if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
+                               $dropping = true;
+
+            $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$delete' => t('Delete')));
+
 
                        $photo = $item['photo'];
                        $thumb = $item['thumb'];
@@ -477,6 +480,7 @@ function conversation(&$a, $items, $mode, $update) {
                                '$comment' => $comment
                        ));
 
+
                        $arr = array('item' => $item, 'output' => $tmp_item);
                        call_hooks('display_item', $arr);
 
@@ -491,6 +495,9 @@ function conversation(&$a, $items, $mode, $update) {
        if($blowhard_count >= 3)
                $o .= '</div>';
 
+       if($dropping)
+               $o .= '<div id="item-delete-selected" class="fakelink" onclick="deleteCheckedItems();"><div id="item-delete-selected-icon" class="icon drophide" title="' . t('Delete Selected Items') . '" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></div><div id="item-delete-selected-desc" >' .  t('Delete Selected Items') . '</div></div><div id="item-delete-selected-end"></div>';
+
        return $o;
 } 
 
index dc177c468c9b21bc8e07ad3a08ea2363f2a70f64..a003b84bb2f61edb56c710d1ff4dce72c25f9360 100644 (file)
@@ -1772,3 +1772,129 @@ function item_expire($uid,$days) {
 
 }
 
+
+function drop_items($items) {
+       $uid = 0;
+
+       if(count($items)) {
+               foreach($items as $item) {
+                       $owner = drop_item($item,false);
+                       if($owner && ! $uid)
+                               $uid = $owner;
+               }
+       }
+
+       // multiple threads may have been deleted, send an expire notification
+
+       if($uid)
+               proc_run('php',"include/notifier.php","expire","$uid");
+}
+
+
+function drop_item($id,$interactive = true) {
+
+       $a = get_app();
+
+       // locate item to be deleted
+
+       $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
+               intval($id)
+       );
+
+       if(! count($r)) {
+               if(! $interactive)
+                       return 0;
+               notice( t('Item not found.') . EOL);
+               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+       }
+
+       $item = $r[0];
+
+       $owner = $item['uid'];
+
+       // check if logged in user is either the author or owner of this item
+
+       if((local_user() == $item['uid']) || (remote_user() == $item['contact-id'])) {
+
+               // delete the item
+
+               $r = q("UPDATE `item` SET `deleted` = 1, `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
+                       dbesc(datetime_convert()),
+                       dbesc(datetime_convert()),
+                       intval($item['id'])
+               );
+
+               // If item is a link to a photo resource, nuke all the associated photos 
+               // (visitors will not have photo resources)
+               // This only applies to photos uploaded from the photos page. Photos inserted into a post do not
+               // generate a resource-id and therefore aren't intimately linked to the item. 
+
+               if(strlen($item['resource-id'])) {
+                       q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ",
+                               dbesc($item['resource-id']),
+                               intval($item['uid'])
+                       );
+                       // ignore the result
+               }
+
+               // If item is a link to an event, nuke the event record.
+
+               if(intval($item['event-id'])) {
+                       q("DELETE FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                               intval($item['event-id']),
+                               intval($item['uid'])
+                       );
+                       // ignore the result
+               }
+
+
+               // If it's the parent of a comment thread, kill all the kids
+
+               if($item['uri'] == $item['parent-uri']) {
+                       $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' 
+                               WHERE `parent-uri` = '%s' AND `uid` = %d ",
+                               dbesc(datetime_convert()),
+                               dbesc(datetime_convert()),
+                               dbesc($item['parent-uri']),
+                               intval($item['uid'])
+                       );
+                       // ignore the result
+               }
+               else {
+                       // ensure that last-child is set in case the comment that had it just got wiped.
+                       q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
+                               dbesc(datetime_convert()),
+                               dbesc($item['parent-uri']),
+                               intval($item['uid'])
+                       );
+                       // who is the last child now? 
+                       $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1",
+                               dbesc($item['parent-uri']),
+                               intval($item['uid'])
+                       );
+                       if(count($r)) {
+                               q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
+                                       intval($r[0]['id'])
+                               );
+                       }       
+               }
+               $drop_id = intval($item['id']);
+                       
+               // send the notification upstream/downstream as the case may be
+
+               if(! $interactive)
+                       return $owner;
+
+               proc_run('php',"include/notifier.php","drop","$drop_id");
+               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+               //NOTREACHED
+       }
+       else {
+               if(! $interactive)
+                       return 0;
+               notice( t('Permission denied.') . EOL);
+               goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+               //NOTREACHED
+       }
+       
+}
\ No newline at end of file
index 34045f57f2b47b5f8e259f51db4a5f343d73ab44..18cb553286dfd7238e9d9ac3179d9679edf3f19f 100644 (file)
                                        $('#pause').html('');
                                }
                        }
-//                     // F8 - show/hide language selector
-//                     if(event.keyCode == '119') {
-//                             if(langSelect) {
-//                                     langSelect = false;
-//                                     $('#language-selector').hide();
-//                             }
-//                             else {
-//                                     langSelect = true;
-//                                     $('#language-selector').show();
-//                             }
-//                     }               
-//
-// this is shift-home on FF, but $ on IE, disabling until I figure out why the diff.
-// update: incompatible usage of onKeyDown vs onKeyPress
-//                     if(event.keyCode == '36' && event.shiftKey == true) {
-//                             if(homebase !== undefined) {
-//                                     event.preventDefault();
-//                                     document.location = homebase;
-//                             }
-//                     }
                });                                     
        });
 
index 776c0dcc2d501dbe1eaeff58fe059fe7783c96a1..3edbae696e7f686be694e1fb714ce8e2e8c25b3b 100644 (file)
@@ -22,6 +22,13 @@ function item_post(&$a) {
 
        $uid = local_user();
 
+       if(x($_POST,'dropitems')) {
+               require_once('include/items.php');
+               $arr_drop = explode(',',$_POST['dropitems']);
+               drop_items($arr_drop);
+               killme();
+       }
+
        call_hooks('post_local_start', $_POST);
 
        $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
@@ -735,102 +742,8 @@ function item_content(&$a) {
 
        require_once('include/security.php');
 
-       $uid = local_user();
-
        if(($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
-
-               // locate item to be deleted
-
-               $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
-                       intval($a->argv[2])
-               );
-
-               if(! count($r)) {
-                       notice( t('Item not found.') . EOL);
-                       goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
-               }
-               $item = $r[0];
-
-               // check if logged in user is either the author or owner of this item
-
-               if(($_SESSION['visitor_id'] == $item['contact-id']) || ($_SESSION['uid'] == $item['uid'])) {
-
-                       // delete the item
-
-                       $r = q("UPDATE `item` SET `deleted` = 1, `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
-                               dbesc(datetime_convert()),
-                               dbesc(datetime_convert()),
-                               intval($item['id'])
-                       );
-
-                       // If item is a link to a photo resource, nuke all the associated photos 
-                       // (visitors will not have photo resources)
-                       // This only applies to photos uploaded from the photos page. Photos inserted into a post do not
-                       // generate a resource-id and therefore aren't intimately linked to the item. 
-
-                       if(strlen($item['resource-id'])) {
-                               q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ",
-                                       dbesc($item['resource-id']),
-                                       intval($item['uid'])
-                               );
-                               // ignore the result
-                       }
-
-                       // If item is a link to an event, nuke the event record.
-
-                       if(intval($item['event-id'])) {
-                               q("DELETE FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                                       intval($item['event-id']),
-                                       intval($item['uid'])
-                               );
-                               // ignore the result
-                       }
-
-
-                       // If it's the parent of a comment thread, kill all the kids
-
-                       if($item['uri'] == $item['parent-uri']) {
-                               $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' 
-                                       WHERE `parent-uri` = '%s' AND `uid` = %d ",
-                                       dbesc(datetime_convert()),
-                                       dbesc(datetime_convert()),
-                                       dbesc($item['parent-uri']),
-                                       intval($item['uid'])
-                               );
-                               // ignore the result
-                       }
-                       else {
-                               // ensure that last-child is set in case the comment that had it just got wiped.
-                               q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
-                                       dbesc(datetime_convert()),
-                                       dbesc($item['parent-uri']),
-                                       intval($item['uid'])
-                               );
-                               // who is the last child now? 
-                               $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1",
-                                       dbesc($item['parent-uri']),
-                                       intval($item['uid'])
-                               );
-                               if(count($r)) {
-                                       q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
-                                               intval($r[0]['id'])
-                                       );
-                               }       
-                       }
-                       $drop_id = intval($item['id']);
-                       
-                       // send the notification upstream/downstream as the case may be
-
-                       proc_run('php',"include/notifier.php","drop","$drop_id");
-// We seem to lose the return url occasionally. Have not been able to reliably duplicate
-//                     logger('drop_return_url: ' . $_SESSION['return_url']);
-                       goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
-                       //NOTREACHED
-               }
-               else {
-                       notice( t('Permission denied.') . EOL);
-                       goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
-                       //NOTREACHED
-               }
+               require_once('include/items.php');
+               drop_item($a->argv[2]);
        }
 }
index 71780036435045c58a3984b6ecd63f5eb64e48f5..e52f67008ff33457855b59910a2a528f5458139f 100644 (file)
@@ -1274,7 +1274,7 @@ function photos_content(&$a) {
                                        $drop = '';
 
                                        if(($item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
-                                               $drop = replace_macros(get_markup_template('wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
+                                               $drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
 
 
                                        $comments .= replace_macros($template,array(
index aeb21f077c38ab2b0397a4e777a11b62fcaccdd4..587ac6288e7b1cfa60b7a5dded955091bddf6a95 100644 (file)
@@ -261,11 +261,8 @@ function profile_content(&$a, $update = 0) {
        if($is_owner && ! $update)
                $o .= get_birthdays();
 
-
-
        $o .= conversation($a,$r,'profile',$update);
 
-
        if(! $update) {
                
                $o .= paginate($a);
index 77e5bc4bcd0fca73eddc65f7315465c11bc0922b..382a52644696bc25fb43f7d9a86cac495cdf1f6c 100644 (file)
@@ -109,6 +109,22 @@ tinyMCE.init({
 
        });
 
+       function deleteCheckedItems() {
+               var checkedstr = '';
+
+               $('.item-select').each( function() {
+                       if($(this).is(':checked')) {
+                               if(checkedstr.length != 0)
+                                       checkedstr = checkedstr + ',' + $(this).val();
+                               else
+                                       checkedstr = $(this).val();
+                       }       
+               });
+               $.post('item', { dropitems: checkedstr });
+               window.location.reload();
+
+       }
+
        function jotGetLink() {
                reply = prompt("$linkurl");
                if(reply && reply.length) {
diff --git a/view/photo_drop.tpl b/view/photo_drop.tpl
new file mode 100644 (file)
index 0000000..b4ea62b
--- /dev/null
@@ -0,0 +1,4 @@
+<div class="wall-item-delete-wrapper" id="wall-item-delete-wrapper-$id" >
+       <a href="item/drop/$id" onclick="return confirmDelete();" class="icon drophide" title="$delete" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a>
+</div>
+<div class="wall-item-delete-end"></div>
index 155641463236d6f05a8d35c0e48fb867506d5308..3bf78346f1d30454acee138873116d6d97b2bd8c 100644 (file)
@@ -2489,8 +2489,32 @@ a.mail-list-link {
        margin-top: 10px;
 }
 
+.item-select {
+       opacity: 0.3;
+       filter:alpha(opacity=30);
+       float: right;
+       margin-right: 10px;
+
+}
+.item-select:hover {
+       opacity: 1;
+       filter:alpha(opacity=100);
+}
 
+#item-delete-selected {
+       margin-top: 30px;
+}
 
+#item-delete-selected-end {
+       clear: both;
+}
+#item-delete-selected-icon, #item-delete-selected-desc {
+       float: left;
+       margin-right: 5px;
+}
+#item-delete-selected-desc:hover {
+       text-decoration: underline;
+}
 
 #lang-select-icon {
        cursor: pointer;
index d70968a8471911a744ad856ec3980864b8fcbf0d..c07ef045a43b60a08d7ed4d1ba24035329eff271 100644 (file)
@@ -2518,6 +2518,33 @@ a.mail-list-link {
 }
 
 
+.item-select {
+       opacity: 0.3;
+       filter:alpha(opacity=30);
+       float: right;
+       margin-right: 10px;
+
+}
+.item-select:hover {
+       opacity: 1;
+       filter:alpha(opacity=100);
+}
+
+#item-delete-selected {
+       margin-top: 30px;
+}
+
+#item-delete-selected-end {
+       clear: both;
+}
+#item-delete-selected-icon, #item-delete-selected-desc {
+       float: left;
+       margin-right: 5px;
+}
+#item-delete-selected-desc:hover {
+       text-decoration: underline;
+}
+
 #lang-select-icon {
        cursor: pointer;
        position: absolute;
index b4ea62b45135285f760245e282d651ad2d3664f9..b10c2109352ae8dacf1fd2f461be858b6135502a 100644 (file)
@@ -1,4 +1,6 @@
 <div class="wall-item-delete-wrapper" id="wall-item-delete-wrapper-$id" >
+       
        <a href="item/drop/$id" onclick="return confirmDelete();" class="icon drophide" title="$delete" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a>
 </div>
+<input type="checkbox" class="item-select" name="itemselected[]" value="$id" />
 <div class="wall-item-delete-end"></div>