4 require_once
'./Modules/Forum/classes/class.ilForumTopic.php';
78 public function __construct($a_id = 0, $a_is_moderator =
false, $preventImplicitRead =
false)
85 if( !$preventImplicitRead )
94 unset($this->objThread);
101 if ($this->forum_id && $this->thread_id)
103 $this->
id = $this->db->nextId(
'frm_posts');
105 $ilDB->insert(
'frm_posts', array(
106 'pos_pk' => array(
'integer', $this->
id),
107 'pos_top_fk' => array(
'integer', $this->forum_id),
108 'pos_thr_fk' => array(
'integer', $this->thread_id),
109 'pos_display_user_id' => array(
'integer', $this->display_user_id),
110 'pos_usr_alias' => array(
'text', $this->user_alias),
111 'pos_subject' => array(
'text', $this->subject),
112 'pos_message' => array(
'clob', $this->message),
113 'pos_date' => array(
'timestamp', $this->createdate),
114 'pos_update' => array(
'timestamp', $this->createdate),
115 'update_user' => array(
'integer', $this->user_id_update),
116 'pos_cens' => array(
'integer', $this->censored),
117 'notify' => array(
'integer', (
int)$this->notification),
118 'import_name' => array(
'text', (
string)$this->import_name),
119 'pos_status' => array(
'integer', (
int)$this->status),
120 'pos_author_id' => array(
'integer', (
int)$this->pos_author_id),
121 'is_author_moderator' => array(
'integer', $this->is_author_moderator)
136 $ilDB->update(
'frm_posts',
138 'pos_top_fk' => array(
'integer', $this->forum_id),
139 'pos_thr_fk' => array(
'integer', $this->thread_id),
140 'pos_subject' => array(
'text', $this->subject),
141 'pos_message' => array(
'clob', $this->message),
142 'pos_update' => array(
'timestamp', $this->changedate),
143 'update_user' => array(
'integer', $this->user_id_update),
144 'pos_cens' => array(
'integer', $this->censored),
145 'pos_cens_com' => array(
'text', $this->censorship_comment),
146 'notify' => array(
'integer', (
int)$this->notification),
147 'pos_status' => array(
'integer', (
int)$this->status)
150 'pos_pk' => array(
'integer', (
int)$this->
id)
154 if($this->objThread->getFirstPostId() ==
$this->id)
156 $this->objThread->setSubject($this->subject);
157 $this->objThread->update();
158 $this->objThread->reload();
170 'pos_pk' => $this->
id,
171 'pos_top_fk' => $this->forum_id,
172 'pos_thr_fk' => $this->thread_id,
173 'pos_display_user_id' => $this->display_user_id,
174 'pos_usr_alias' => $this->user_alias,
175 'title' => $this->fullname,
176 'loginname' => $this->loginname,
177 'pos_message' => $this->message,
178 'pos_subject' => $this->subject,
179 'pos_cens_com' => $this->censorship_comment,
180 'pos_cens' => $this->censored,
181 'pos_date' => $this->createdate,
182 'pos_update' => $this->changedate,
183 'update_user' => $this->user_id_update,
184 'notify' => $this->notification,
185 'import_name' => $this->import_name,
186 'pos_status' => $this->status,
187 'pos_author_id' => $this->pos_author_id,
188 'is_author_moderator' => $this->is_author_moderator
197 'pos_pk' => $this->
id,
198 'child' => $this->
id,
199 'author' => $this->display_user_id,
200 'alias' => $this->user_alias,
201 'title' => $this->fullname,
202 'loginname' => $this->loginname,
204 'message' => $this->message,
205 'subject' => $this->subject,
206 'pos_cens_com' => $this->censorship_comment,
207 'pos_cens' => $this->censored,
208 'date' => $this->createdate,
209 'create_date' => $this->createdate,
210 'update' => $this->changedate,
211 'update_user' => $this->user_id_update,
212 'tree' => $this->thread_id,
213 'parent' => $this->parent_id,
216 'depth' => $this->depth,
217 'id' => $this->tree_id,
218 'notify' => $this->notification,
219 'import_name' => $this->import_name,
220 'pos_status' => $this->status,
221 'pos_author_id' => $this->pos_author_id,
222 'is_author_moderator' => $this->is_author_moderator
232 $res = $this->db->queryf(
' 233 SELECT * FROM frm_posts 234 INNER JOIN frm_posts_tree ON pos_fk = pos_pk 236 array(
'integer'), array($this->
id));
237 $row = $this->db->fetchObject(
$res);
241 $this->
id =
$row->pos_pk;
242 $this->forum_id =
$row->pos_top_fk;
243 $this->thread_id =
$row->pos_thr_fk;
244 $this->display_user_id =
$row->pos_display_user_id;
245 $this->user_alias =
$row->pos_usr_alias;
246 $this->subject =
$row->pos_subject;
247 $this->message =
$row->pos_message;
248 $this->createdate =
$row->pos_date;
249 $this->changedate =
$row->pos_update;
250 $this->user_id_update =
$row->update_user;
251 $this->censored =
$row->pos_cens;
252 $this->censorship_comment =
$row->pos_cens_com;
253 $this->notification =
$row->notify;
254 $this->import_name =
$row->import_name;
255 $this->status =
$row->pos_status;
256 $this->tree_id =
$row->fpt_pk;
257 $this->parent_id =
$row->parent_pos;
258 $this->lft =
$row->lft;
259 $this->rgt =
$row->rgt;
260 $this->depth =
$row->depth;
261 $this->pos_author_id =
$row->pos_author_id;
262 $this->is_author_moderator =
$row->is_author_moderator;
265 $this->objThread =
new ilForumTopic($this->thread_id, $this->is_moderator);
280 $res = $this->db->queryf(
' 281 SELECT * FROM frm_posts_tree 282 INNER JOIN frm_posts ON pos_pk = pos_fk 283 WHERE pos_status = %s 284 AND lft < %s AND rgt > %s 286 array(
'integer',
'integer',
'integer',
'integer'),
287 array(
'0', $this->lft, $this->rgt, $this->thread_id));
289 return $res->numRows();
299 if (
$row[
'pos_display_user_id'] &&
$row[
'pos_pk'])
301 require_once
'Services/User/classes/class.ilObjUser.php';
303 $tmp_user->setFirstname(
$row[
'firstname']);
304 $tmp_user->setLastname(
$row[
'lastname']);
305 $tmp_user->setUTitle(
$row[
'title']);
306 $tmp_user->setLogin(
$row[
'login']);
308 $this->fullname = $tmp_user->getFullname();
309 $this->loginname = $tmp_user->getLogin();
311 $this->fullname = $this->fullname ? $this->fullname : ($this->import_name ? $this->import_name : $lng->txt(
'unknown'));
321 if ($this->
id && $this->display_user_id)
323 require_once(
"Modules/Forum/classes/class.ilObjForumAccess.php");
326 $this->fullname = $tmp_user->getFullname();
327 $this->loginname = $tmp_user->getLogin();
331 $this->fullname = $this->fullname ? $this->fullname : ($this->import_name ? $this->import_name : $lng->txt(
'unknown'));
341 return $this->
read();
346 $this->fullname = $a_fullname;
354 $this->loginname = $a_loginname;
365 $this->db->update(
'frm_posts',
366 array(
'pos_status' => array(
'integer', 1)),
367 array(
'pos_pk' => array(
'integer', $this->
id)));
381 $query =
"SELECT pos_pk FROM frm_posts_tree treea " 382 .
"INNER JOIN frm_posts_tree treeb ON treeb.thr_fk = treea.thr_fk " 383 .
"AND treeb.lft BETWEEN treea.lft AND treea.rgt " 384 .
"INNER JOIN frm_posts ON pos_pk = treeb.pos_fk " 385 .
"WHERE treea.pos_fk = %s";
394 $this->db->update(
'frm_posts',
395 array(
'pos_status' => array(
'integer', 1)),
396 array(
'pos_pk' => array(
'integer',
$row[
'pos_pk'])));
411 $query =
"SELECT pos_pk FROM frm_posts " 412 .
"INNER JOIN frm_posts_tree ON pos_fk = pos_pk " 413 .
"WHERE lft < %s AND rgt > %s AND thr_fk = %s";
416 array(
'integer',
'integer',
'integer'),
417 array($this->lft, $this->rgt, $this->thread_id)
422 $this->db->update(
'frm_posts',
423 array(
'pos_status' => array(
'integer', 1)),
424 array(
'pos_pk' => array(
'integer',
$row[
'pos_pk'])));
437 $query =
"SELECT pos_pk FROM frm_posts_tree treea " 438 .
"INNER JOIN frm_posts_tree treeb ON treeb.thr_fk = treea.thr_fk " 439 .
"AND treeb.lft BETWEEN treea.lft AND treea.rgt " 440 .
"INNER JOIN frm_posts ON pos_pk = treeb.pos_fk " 441 .
"WHERE treea.pos_fk = %s";
450 $this->db->update(
'frm_posts',
451 array(
'pos_status' => array(
'integer', 0)),
452 array(
'pos_pk' => array(
'integer',
$row[
'pos_pk'])));
468 if ($a_user_id && $this->
id)
471 $res = $this->db->queryf(
' 472 SELECT * FROM frm_user_read 475 array(
'integer',
'integer'),
476 array($a_user_id, $this->
id));
478 return $res->numRows() ? true :
false;
486 if ($this->
id && $this->rgt && $this->lft)
488 $res = $this->db->queryf(
' 489 SELECT * FROM frm_posts_tree 490 WHERE lft > %s AND rgt < %s 492 array(
'integer',
'integer',
'integer'),
493 array($this->lft, $this->rgt, $this->thread_id));
495 return $res->numRows() ? true :
false;
503 if ($this->pos_author_id && $a_user_id)
505 if ((
int) $this->pos_author_id == (
int) $a_user_id)
524 $this->forum_id = $a_forum_id;
532 $this->thread_id = $a_thread_id;
540 $this->display_user_id = $a_user_id;
548 $this->user_alias = $a_user_alias;
556 $this->subject = $a_subject;
564 $this->message = $a_message;
572 $this->createdate = $a_createdate;
580 $this->changedate = $a_changedate;
588 $this->user_id_update = $a_user_id_update;
596 $this->censored = $a_censorship;
600 return $this->censored == 1 ? true :
false;
604 $this->censorship_comment = $a_comment;
612 $this->notification = $a_notification;
616 return $this->notification == 1 ? true :
false;
620 $this->import_name = $a_import_name;
628 $this->status = $a_status;
632 return $this->status == 1 ? true :
false;
636 $this->tree_id = $a_tree_id;
644 $this->parent_id = $a_parent_id;
649 $this->post_read = $a_is_read;
679 $this->depth = $a_depth;
687 $this->objThread = $thread;
752 public static function mergePosts($source_thread_id, $target_thread_id)
756 $ilDB->update(
'frm_posts',
757 array(
'pos_thr_fk' => array(
'integer', $target_thread_id)),
758 array(
'pos_thr_fk' => array(
'integer', $source_thread_id)));
static getCachedUserInstance($usr_id)
setThread(ilForumTopic $thread)
setLoginName($a_loginname)
setCreateDate($a_createdate)
setNotification($a_notification)
activatePostAndChildPosts()
getDataAsArrayForExplorer()
buildUserRelatedData($row)
__construct($a_id=0, $a_is_moderator=false, $preventImplicitRead=false)
setUserAlias($a_user_alias)
setImportName($a_import_name)
setIsAuthorModerator($is_author_moderator)
setThreadId($a_thread_id)
setCensorshipComment($a_comment)
setParentId($a_parent_id)
setDisplayUserId($a_user_id)
setCensorship($a_censorship)
deactivatePostAndChildPosts()
setPosAuthorId($pos_author_id)
static mergePosts($source_thread_id, $target_thread_id)
setUpdateUserId($a_user_id_update)
setChangeDate($a_changedate)