function delete(&$obj, $force = false)
 {
     // remove children (answer)
     $handler =& plzXoo::getHandler('answer');
     $answers =& $handler->getObjects(new Criteria('qid', $obj->getVar('qid')));
     foreach ($answers as $answer) {
         $handler->delete($answer);
     }
     // get parent (category)
     $handler =& plzXoo::getHandler('category');
     $category =& $handler->get($obj->getVar('cid'));
     // delete notifications
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname('plzXoo');
     $module_id = $module->getVar('mid');
     $notification_handler =& xoops_gethandler('notification');
     $notification_handler->unsubscribeByItem($module_id, 'question', $obj->getVar('qid'));
     $ret = parent::delete($obj, $force);
     // update parent (category)
     $category->updateSize();
     // $category->setVar('modified_date',time());
     $handler->insert($category);
     return $ret;
 }
 function delete(&$obj, $force = false)
 {
     // get parent (question)
     $qHandler =& plzXoo::getHandler('question');
     $question =& $qHandler->get($obj->getVar('qid'));
     // notification delete
     $ret = parent::delete($obj, $force);
     // update parent (question)
     $question->updateSize();
     $question->setVar('modified_date', time());
     $qHandler->insert($question);
     return $ret;
 }
 function delete(&$obj, $force = false)
 {
     // handlers
     $module_handler =& xoops_gethandler('module');
     $notification_handler =& xoops_gethandler('notification');
     $question_handler =& plzXoo::getHandler('question');
     $answer_handler =& plzXoo::getHandler('answer');
     // get this module
     $module =& $module_handler->getByDirname('plzXoo');
     $module_id = $module->getVar('mid');
     // ----------------------------------------------
     // 子カテゴリーがあったらエラー
     // ----------------------------------------------
     $cid = $obj->getVar('cid');
     $child_handler =& plzXoo::getHandler('category');
     $children =& $child_handler->getObjects(new Criteria('pid', $cid));
     if (!empty($children)) {
         return false;
     }
     // ----------------------------------------------
     // ぶら下がっている質問・回答をすべて削除
     // ----------------------------------------------
     $questions =& $question_handler->getObjects(new Criteria('cid', $cid));
     foreach ($questions as $question) {
         $qid = $question->getVar('qid');
         $answers =& $answer_handler->getObjects(new Criteria('qid', $qid));
         foreach ($answers as $answer) {
             $answer_handler->delete($answer);
         }
         $question_handler->delete($question);
     }
     // delete notifications about this category
     $notification_handler->unsubscribeByItem($module_id, 'category', $obj->getVar('cid'));
     return parent::delete($obj, $force);
 }