]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Update notice deletion
authorEvan Prodromou <evan@controlyourself.ca>
Sat, 24 Jan 2009 18:38:40 +0000 (19:38 +0100)
committerEvan Prodromou <evan@controlyourself.ca>
Sat, 24 Jan 2009 18:38:40 +0000 (19:38 +0100)
Changed the errors in notice deletion so it now works. Also,
consistently delete records from related tables that refer
to the notice.

actions/deletenotice.php
classes/Notice.php
lib/util.php

index d8bc5d0e0c9206816b3698f87d217bdb3e09f5dc..d4b8e50e5e4cd5e397cec27f1279e35d9937ef8e 100644 (file)
@@ -111,15 +111,8 @@ class DeletenoticeAction extends DeleteAction
         $this->elementStart('p');
         $this->element('span', array('id' => 'confirmation_text'),
                        _('Are you sure you want to delete this notice?'));
-
-        $this->element('input', array('id' => 'submit_no',
-                                      'name' => 'submit',
-                                      'type' => 'submit',
-                                      'value' => _('No')));
-        $this->element('input', array('id' => 'submit_yes',
-                                      'name' => 'submit',
-                                      'type' => 'submit',
-                                      'value' => _('Yes')));
+        $this->submit('yes', _('Yes'));
+        $this->submit('no', _('No'));
         $this->elementEnd('p');
         $this->elementEnd('form');
     }
@@ -135,31 +128,18 @@ class DeletenoticeAction extends DeleteAction
             return;
         }
 
-        $url       = common_get_returnto();
-        $confirmed = $this->trimmed('submit');
-
-        if ($confirmed == _('Yes')) {
-
-            $replies = new Reply;
-            $replies->get('notice_id', $this->notice->id);
-
-            common_dequeue_notice($this->notice);
-
-            if (common_config('memcached', 'enabled')) {
-                $notice->blowSubsCache();
-            }
-
-            $replies->delete();
+        if ($this->arg('yes')) {
             $this->notice->delete();
+        }
 
-        } else {
+        $url = common_get_returnto();
 
-            if ($url) {
-                common_set_returnto(null);
-            } else {
-                $url = common_local_url('public');
-            }
+        if ($url) {
+            common_set_returnto(null);
+        } else {
+            $url = common_local_url('public');
         }
+
         common_redirect($url);
     }
 }
index 4a06c925857637474fe048fceef2a30fd2dc1e8d..c597137feed8b61b494e514a82d2cb3fc92d21ec 100644 (file)
@@ -63,8 +63,24 @@ class Notice extends Memcached_DataObject
     {
         $this->blowCaches(true);
         $this->blowFavesCache(true);
-        $this->blowInboxes();
-        return parent::delete();
+        $this->blowSubsCache(true);
+
+        $this->query('BEGIN');
+        $related = array('Reply',
+                         'Fave',
+                         'Notice_tag',
+                         'Group_inbox',
+                         'Queue_item');
+        if (common_config('inboxes', 'enabled')) {
+            $related[] = 'Notice_inbox';
+        }
+        foreach ($related as $cls) {
+            $inst = new $cls();
+            $inst->notice_id = $this->id;
+            $inst->delete();
+        }
+        $result = parent::delete();
+        $this->query('COMMIT');
     }
 
     function saveTags()
@@ -568,22 +584,6 @@ class Notice extends Memcached_DataObject
         return;
     }
 
-    # Delete from inboxes if we're deleted.
-
-    function blowInboxes()
-    {
-
-        $enabled = common_config('inboxes', 'enabled');
-
-        if ($enabled === true || $enabled === 'transitional') {
-            $inbox = new Notice_inbox();
-            $inbox->notice_id = $this->id;
-            $inbox->delete();
-        }
-
-        return;
-    }
-
     function saveGroups()
     {
         $enabled = common_config('inboxes', 'enabled');
index b5b194519e37598b260cfba818673069c0bf0e74..a80c62287d3f4d1ee7e13ba622048b2a3f04d74e 100644 (file)
@@ -1140,23 +1140,6 @@ function common_enqueue_notice($notice)
     return $result;
 }
 
-function common_dequeue_notice($notice)
-{
-    $qi = Queue_item::staticGet($notice->id);
-    if ($qi) {
-        $result = $qi->delete();
-        if (!$result) {
-            $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
-            common_log(LOG_ERR, 'DB error deleting queue item: ' . $last_error->message);
-            return false;
-        }
-        common_log(LOG_DEBUG, 'complete dequeueing notice ID = ' . $notice->id);
-        return $result;
-    } else {
-        return false;
-    }
-}
-
 function common_real_broadcast($notice, $remote=false)
 {
     $success = true;