]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
handle deletion of notice
authorEvan Prodromou <evan@status.net>
Sat, 14 Aug 2010 18:58:54 +0000 (11:58 -0700)
committerEvan Prodromou <evan@status.net>
Sat, 14 Aug 2010 18:58:54 +0000 (11:58 -0700)
plugins/NoticeTitle/NoticeTitlePlugin.php

index 18ffed4be29457ecfe200991998eb885d47eef6f..f7fb1e4d00129aa0883f62c4fe4959f3cbf64d4c 100644 (file)
@@ -137,7 +137,9 @@ class NoticeTitlePlugin extends Plugin
 
     function onStartShowNoticeFormData($form)
     {
-        $form->out->element('style', null, 'label#notice_data-text-label { display: none }');
+        $form->out->element('style',
+                            null,
+                            'label#notice_data-text-label { display: none }');
         $form->out->element('input', array('type' => 'text',
                                            'id' => 'notice_title',
                                            'name' => 'notice_title',
@@ -257,5 +259,24 @@ class NoticeTitlePlugin extends Plugin
 
         return true;
     }
+
+    /**
+     * Remove title when the notice is deleted
+     *
+     * @param Notice $notice Notice being deleted
+     *
+     * @return boolean hook value
+     */
+
+    function onNoticeDeleteRelated($notice)
+    {
+        $nt = Notice_title::staticGet('notice_id', $notice->id);
+
+        if (!empty($nt)) {
+            $nt->delete();
+        }
+
+        return true;
+    }
 }