예제 #1
0
 private function execute(\Orm\Model $obj)
 {
     // 親記事削除時
     if (empty($this->_conditions['type'])) {
         // delete member_watch_content
         self::delete_member_watch_content($obj, $this->_conditions);
     }
     $notices = \Site_Model::get4relation('\\Notice\\Model_Notice', $this->_conditions, $obj);
     foreach ($notices as $notice) {
         // 親記事削除時
         if (empty($this->_conditions['type'])) {
             $notice->delete();
         } else {
             // delete notice_member_from
             if (self::delete_notice_member_from($notice->id, $obj->member_id)) {
                 $parent_content_member_id = \Site_Model::get_value4table_and_id($notice->foreign_table, $notice->foreign_id, 'member_id');
                 if (!\Notice\Model_NoticeMemberFrom::get_count4notice_id($notice->id, $parent_content_member_id)) {
                     $notice->delete();
                 }
             }
         }
     }
     // 親記事削除時
     if (empty($this->_conditions['type'])) {
         $foreign_table = \Util_Array::get_first_key($this->_conditions['foreign_table']);
         $foreign_id = $obj->id;
         $notices = \Notice\Model_Notice::get4parent_data($foreign_table, $foreign_id);
         foreach ($notices as $notice) {
             $notice->delete();
         }
     } else {
         $type = \Util_Array::get_first_key($this->_conditions['type']);
         // comment 削除時
         if ($type == \Notice\Site_Util::get_notice_type('comment')) {
             $foreign_table = \Util_Array::get_first_key($this->_conditions['foreign_table']) . '_comment';
             $foreign_id = $obj->id;
             $notices = \Notice\Model_Notice::get4foreign_data($foreign_table, $foreign_id);
             foreach ($notices as $notice) {
                 $notice->delete();
             }
         }
     }
 }