4 require_once
'./Modules/Forum/classes/class.ilForumTopic.php';
66 public function __construct($a_id = 0, $a_is_moderator =
false, $preventImplicitRead =
false)
70 $this->is_moderator = $a_is_moderator;
74 if( !$preventImplicitRead )
83 unset($this->objThread);
90 if ($this->forum_id && $this->thread_id)
92 $this->
id = $this->db->nextId(
'frm_posts');
94 $ilDB->insert(
'frm_posts', array(
95 'pos_pk' => array(
'integer', $this->
id),
96 'pos_top_fk' => array(
'integer', $this->forum_id),
97 'pos_thr_fk' => array(
'integer', $this->thread_id),
98 'pos_usr_id' => array(
'integer', $this->user_id),
99 'pos_usr_alias' => array(
'text', $this->user_alias),
100 'pos_subject' => array(
'text', $this->subject),
101 'pos_message' => array(
'clob', $this->message),
102 'pos_date' => array(
'timestamp', $this->createdate),
103 'pos_update' => array(
'timestamp', null),
104 'update_user' => array(
'integer', $this->user_id_update),
105 'pos_cens' => array(
'integer', $this->censored),
106 'notify' => array(
'integer', (
int)$this->notification),
107 'import_name' => array(
'text', (
string)$this->import_name),
108 'pos_status' => array(
'integer', (
int)$this->status)
123 $ilDB->update(
'frm_posts',
125 'pos_top_fk' => array(
'integer', $this->forum_id),
126 'pos_thr_fk' => array(
'integer', $this->thread_id),
127 'pos_subject' => array(
'text', $this->subject),
128 'pos_message' => array(
'clob', $this->message),
129 'pos_update' => array(
'timestamp', $this->changedate),
130 'update_user' => array(
'integer', $this->user_id_update),
131 'pos_cens' => array(
'integer', $this->censored),
132 'pos_cens_com' => array(
'text', $this->censorship_comment),
133 'notify' => array(
'integer', (
int)$this->notification),
134 'pos_status' => array(
'integer', (
int)$this->status)
137 'pos_pk' => array(
'integer', (
int)$this->
id)
141 if($this->objThread->getFirstPostId() ==
$this->id)
143 $this->objThread->setSubject($this->subject);
144 $this->objThread->update();
145 $this->objThread->reload();
157 'pos_pk' => $this->
id,
158 'pos_top_fk' => $this->forum_id,
159 'pos_thr_fk' => $this->thread_id,
160 'pos_usr_id' => $this->user_id,
161 'pos_usr_alias' => $this->user_alias,
162 'title' => $this->fullname,
163 'loginname' => $this->loginname,
164 'pos_message' => $this->message,
165 'pos_subject' => $this->subject,
166 'pos_cens_com' => $this->censorship_comment,
167 'pos_cens' => $this->censored,
168 'pos_date' => $this->createdate,
169 'pos_update' => $this->changedate,
170 'update_user' => $this->user_id_update,
171 'notify' => $this->notification,
172 'import_name' => $this->import_name,
173 'pos_status' => $this->status
182 'pos_pk' => $this->
id,
183 'child' => $this->
id,
184 'author' => $this->user_id,
185 'alias' => $this->user_alias,
186 'title' => $this->fullname,
187 'loginname' => $this->loginname,
189 'message' => $this->message,
190 'subject' => $this->subject,
191 'pos_cens_com' => $this->censorship_comment,
192 'pos_cens' => $this->censored,
193 'date' => $this->createdate,
194 'create_date' => $this->createdate,
195 'update' => $this->changedate,
196 'update_user' => $this->user_id_update,
197 'tree' => $this->thread_id,
198 'parent' => $this->parent_id,
201 'depth' => $this->depth,
202 'id' => $this->tree_id,
203 'notify' => $this->notification,
204 'import_name' => $this->import_name,
205 'pos_status' => $this->status
215 $res = $this->db->queryf(
'
216 SELECT * FROM frm_posts
217 INNER JOIN frm_posts_tree ON pos_fk = pos_pk
219 array(
'integer'), array($this->
id));
224 $this->
id =
$row->pos_pk;
225 $this->forum_id =
$row->pos_top_fk;
226 $this->thread_id =
$row->pos_thr_fk;
227 $this->user_id =
$row->pos_usr_id;
228 $this->user_alias =
$row->pos_usr_alias;
229 $this->subject =
$row->pos_subject;
230 $this->message =
$row->pos_message;
231 $this->createdate =
$row->pos_date;
232 $this->changedate =
$row->pos_update;
233 $this->user_id_update =
$row->update_user;
234 $this->censored =
$row->pos_cens;
235 $this->censorship_comment =
$row->pos_cens_com;
236 $this->notification =
$row->notify;
237 $this->import_name =
$row->import_name ;
238 $this->status =
$row->pos_status;
239 $this->tree_id =
$row->fpt_pk;
240 $this->parent_id =
$row->parent_pos;
241 $this->lft =
$row->lft;
242 $this->rgt =
$row->rgt;
243 $this->depth =
$row->depth;
247 $this->objThread =
new ilForumTopic($this->thread_id, $this->is_moderator);
262 $res = $this->db->queryf(
'
263 SELECT * FROM frm_posts_tree
264 INNER JOIN frm_posts ON pos_pk = pos_fk
265 WHERE pos_status = %s
266 AND lft < %s AND rgt > %s
268 array(
'integer',
'integer',
'integer',
'integer'),
269 array(
'0', $this->lft, $this->rgt, $this->thread_id));
271 return $res->numRows();
281 if (
$row[
'pos_usr_id'] &&
$row[
'pos_pk'])
283 require_once
'Services/User/classes/class.ilObjUser.php';
285 $tmp_user->setFirstname(
$row[
'firstname']);
286 $tmp_user->setLastname(
$row[
'lastname']);
287 $tmp_user->setUTitle(
$row[
'title']);
288 $tmp_user->setLogin(
$row[
'login']);
290 $this->fullname = $tmp_user->getFullname();
291 $this->loginname = $tmp_user->getLogin();
293 $this->fullname = $this->fullname ? $this->fullname : ($this->import_name ? $this->import_name : $lng->txt(
'unknown'));
303 if ($this->
id && $this->user_id)
305 require_once(
"Modules/Forum/classes/class.ilObjForumAccess.php");
308 $this->fullname = $tmp_user->getFullname();
309 $this->loginname = $tmp_user->getLogin();
313 $this->fullname = $this->fullname ? $this->fullname : ($this->import_name ? $this->import_name : $lng->txt(
'unknown'));
323 return $this->
read();
328 $this->fullname = $a_fullname;
336 $this->loginname = $a_loginname;
347 $this->db->update(
'frm_posts',
348 array(
'pos_status' => array(
'integer', 1)),
349 array(
'pos_pk' => array(
'integer', $this->
id)));
363 $query =
"SELECT pos_pk FROM frm_posts_tree treea "
364 .
"INNER JOIN frm_posts_tree treeb ON treeb.thr_fk = treea.thr_fk "
365 .
"AND treeb.lft BETWEEN treea.lft AND treea.rgt "
366 .
"INNER JOIN frm_posts ON pos_pk = treeb.pos_fk "
367 .
"WHERE treea.pos_fk = %s";
376 $this->db->update(
'frm_posts',
377 array(
'pos_status' => array(
'integer', 1)),
378 array(
'pos_pk' => array(
'integer',
$row[
'pos_pk'])));
393 $query =
"SELECT pos_pk FROM frm_posts "
394 .
"INNER JOIN frm_posts_tree ON pos_fk = pos_pk "
395 .
"WHERE lft < %s AND rgt > %s AND thr_fk = %s";
398 array(
'integer',
'integer',
'integer'),
399 array($this->lft, $this->rgt, $this->thread_id)
404 $this->db->update(
'frm_posts',
405 array(
'pos_status' => array(
'integer', 1)),
406 array(
'pos_pk' => array(
'integer',
$row[
'pos_pk'])));
419 $query =
"SELECT pos_pk FROM frm_posts_tree treea "
420 .
"INNER JOIN frm_posts_tree treeb ON treeb.thr_fk = treea.thr_fk "
421 .
"AND treeb.lft BETWEEN treea.lft AND treea.rgt "
422 .
"INNER JOIN frm_posts ON pos_pk = treeb.pos_fk "
423 .
"WHERE treea.pos_fk = %s";
432 $this->db->update(
'frm_posts',
433 array(
'pos_status' => array(
'integer', 0)),
434 array(
'pos_pk' => array(
'integer',
$row[
'pos_pk'])));
450 if ($a_user_id && $this->
id)
453 $res = $this->db->queryf(
'
454 SELECT * FROM frm_user_read
457 array(
'integer',
'integer'),
458 array($a_user_id, $this->
id));
460 return $res->numRows() ?
true :
false;
468 if ($this->
id && $this->rgt && $this->lft)
470 $res = $this->db->queryf(
'
471 SELECT * FROM frm_posts_tree
472 WHERE lft > %s AND rgt < %s
474 array(
'integer',
'integer',
'integer'),
475 array($this->lft, $this->rgt, $this->thread_id));
477 return $res->numRows() ?
true :
false;
485 if ($this->user_id && $a_user_id)
487 if ((
int) $this->user_id == (
int) $a_user_id)
506 $this->forum_id = $a_forum_id;
514 $this->thread_id = $a_thread_id;
522 $this->user_id = $a_user_id;
530 $this->user_alias = $a_user_alias;
538 $this->subject = $a_subject;
546 $this->message = $a_message;
554 $this->createdate = $a_createdate;
562 $this->changedate = $a_changedate;
570 $this->user_id_update = $a_user_id_update;
578 $this->censored = $a_censorship;
582 return $this->censored == 1 ?
true :
false;
586 $this->censorship_comment = $a_comment;
594 $this->notification = $a_notification;
598 return $this->notification == 1 ?
true :
false;
602 $this->import_name = $a_import_name;
610 $this->status = $a_status;
614 return $this->status == 1 ?
true :
false;
618 $this->tree_id = $a_tree_id;
626 $this->parent_id = $a_parent_id;
631 $this->post_read = $a_is_read;
661 $this->depth = $a_depth;
669 $this->objThread = $thread;