1<?php 2 3namespace dokuwiki\plugin\bez\mdl; 4 5class Task_comment extends Entity { 6 7 //real 8 protected $id, $task_id, $author, $create_date, $last_modification_date, $content, $content_html; 9 10 /** @var Task */ 11 protected $task; 12 13 public static function get_columns() { 14 return array('id', 'task_id', 'author', 15 'create_date', 'last_modification_date', 'content', 'content_html'); 16 } 17 18 public function __get($property) { 19 if ($property == 'task') { 20 if ($this->task_id == null) { 21 return null; 22 } 23 if ($this->task == null) { 24 $this->task = $this->model->taskFactory->get_one($this->task_id); 25 } 26 return $this->task; 27 } 28 return parent::__get($property); 29 } 30 31 public function __construct($model, $defaults=array()) { 32 parent::__construct($model, $defaults); 33 34 $this->validator->set_rules(array( 35 'content' => array(array('length', 10000), 'NOT NULL') 36 )); 37 38 //new object 39 if ($this->id === NULL) { 40 41 $this->author = $this->model->user_nick; 42 $this->create_date = date('c'); 43 $this->last_modification_date = $this->create_date; 44 45 46 if (!isset($defaults['task'])) { 47 throw new \Exception('$defaults[task] not set'); 48 } 49 $this->task = $defaults['task']; 50 $this->task_id = $this->task->id; 51 } else { 52 if (isset($defaults['task']) && $this->task_id == $defaults['task']->id) { 53 $this->task = $defaults['task']; 54 } 55 } 56 57 } 58 public function set_data($post) { 59 parent::set_data($post); 60 $this->content_html = p_render('xhtml',p_get_instructions($this->content), $ignore); 61 } 62 63 public function mail_notify_add() { 64 $rep = array( 65 'content' => $this->content, 66 'content_html' => $this->content_html, 67 'who' => $this->author, 68 'when' => $this->create_date 69 ); 70 71 $rep['action'] = $this->model->action->getLang('mail_comment_added'); 72 $rep['action_color'] = 'transparent'; 73 $rep['action_border_color'] = '#E5E5E5'; 74 75 //$this->thread->mail_notify($rep); 76 } 77} 78