From 401cf36de3bcce681f95344cc479f0594014b028 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 14 Aug 2010 11:58:54 -0700 Subject: [PATCH] handle deletion of notice --- plugins/NoticeTitle/NoticeTitlePlugin.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/NoticeTitle/NoticeTitlePlugin.php b/plugins/NoticeTitle/NoticeTitlePlugin.php index 18ffed4be2..f7fb1e4d00 100644 --- a/plugins/NoticeTitle/NoticeTitlePlugin.php +++ b/plugins/NoticeTitle/NoticeTitlePlugin.php @@ -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; + } }