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 return $this->$property; 21 } 22 return parent::__get($property); 23 } 24 25 public function __construct($model, $defaults=array()) { 26 parent::__construct($model, $defaults); 27 28 $this->validator->set_rules(array( 29 'content' => array(array('length', 10000), 'NOT NULL') 30 )); 31 32 //new object 33 if ($this->id === NULL) { 34 35 $this->author = $this->model->user_nick; 36 $this->create_date = date('c'); 37 $this->last_modification_date = $this->create_date; 38 39 40 if (!isset($defaults['task'])) { 41 throw new \Exception('$defaults[task] not set'); 42 } 43 $this->task = $defaults['task']; 44 $this->task_id = $this->task->id; 45 } else { 46 if ($this->task_id != '') { 47 if (isset($defaults['task']) && $this->task_id == $defaults['task']->id) { 48 $this->task = $defaults['task']; 49 } elseif ($this->task_id != null) { 50 $this->task = $this->model->taskFactory->get_one($this->task_id); 51 } 52 } 53 } 54 55 } 56 public function set_data($post) { 57 parent::set_data($post); 58 $this->content_html = p_render('xhtml',p_get_instructions($this->content), $ignore); 59 } 60 61 public function mail_notify_add() { 62 $rep = array( 63 'content' => $this->content, 64 'content_html' => $this->content_html, 65 'who' => $this->author, 66 'when' => $this->create_date 67 ); 68 69 $rep['action'] = $this->model->action->getLang('mail_comment_added'); 70 $rep['action_color'] = 'transparent'; 71 $rep['action_border_color'] = '#E5E5E5'; 72 73 //$this->thread->mail_notify($rep); 74 } 75} 76