1<?php 2 3namespace dokuwiki\plugin\bez\mdl; 4 5class Thread_commentFactory extends Factory { 6 7 protected function select_query() { 8 return "SELECT thread_comment.*, thread.coordinator 9 FROM thread_comment JOIN thread ON thread_comment.thread_id=thread.id"; 10 } 11 12 public function get_from_thread(Thread $thread) { 13 return $this->get_all(array('thread_id' => $thread->id), $orderby='', $desc=true, array('thread' => $thread)); 14 } 15 16 /** 17 * @param Thread_comment $thread_comment 18 * @param $data 19 * @throws \Exception 20 */ 21 public function initial_save(Entity $thread_comment, $data) { 22 parent::initial_save($thread_comment, $data); 23 24 $thread_comment->set_data($data); 25 try { 26 $this->beginTransaction(); 27 $this->save($thread_comment); 28 29 $thread_comment->thread->set_participant_flags($thread_comment->author, array('subscribent', 'commentator')); 30 $thread_comment->thread->update_last_activity(); 31 32 $this->commitTransaction(); 33 } catch(Exception $exception) { 34 $this->rollbackTransaction(); 35 } 36 37 $thread_comment->mail_notify_add(); 38 } 39 40 public function update_save(Entity $thread_comment, $data) { 41 parent::update_save($thread_comment, $data); 42 43 $thread_comment->set_data($data); 44 try { 45 $this->beginTransaction(); 46 $this->save($thread_comment); 47 48 $thread_comment->thread->update_last_activity(); 49 50 $this->commitTransaction(); 51 } catch(Exception $exception) { 52 $this->rollbackTransaction(); 53 } 54 } 55 56 public function delete(Entity $obj) { 57 try { 58 $this->beginTransaction(); 59 60 parent::delete($obj); 61 $obj->thread->update_last_activity(); 62 63 $this->commitTransaction(); 64 } catch(Exception $exception) { 65 $this->rollbackTransaction(); 66 } 67 } 68}