4 require_once
'./Modules/Forum/classes/class.ilForumTopic.php';
91 public function __construct($a_id = 0, $a_is_moderator =
false, $preventImplicitRead =
false)
98 if( !$preventImplicitRead )
107 unset($this->objThread);
114 if ($this->forum_id && $this->thread_id)
116 $this->
id = $this->db->nextId(
'frm_posts');
118 $ilDB->insert(
'frm_posts', array(
119 'pos_pk' => array(
'integer', $this->
id),
120 'pos_top_fk' => array(
'integer', $this->forum_id),
121 'pos_thr_fk' => array(
'integer', $this->thread_id),
122 'pos_display_user_id' => array(
'integer', $this->display_user_id),
123 'pos_usr_alias' => array(
'text', $this->user_alias),
124 'pos_subject' => array(
'text', $this->subject),
125 'pos_message' => array(
'clob', $this->message),
126 'pos_date' => array(
'timestamp', $this->createdate),
127 'pos_update' => array(
'timestamp', $this->createdate),
128 'update_user' => array(
'integer', $this->user_id_update),
129 'pos_cens' => array(
'integer', $this->censored),
130 'notify' => array(
'integer', (
int)$this->notification),
131 'import_name' => array(
'text', (
string)$this->import_name),
132 'pos_status' => array(
'integer', (
int)$this->status),
133 'pos_author_id' => array(
'integer', (
int)$this->pos_author_id),
134 'is_author_moderator' => array(
'integer', $this->is_author_moderator),
135 'pos_activation_date' => array(
'timestamp', $this->createdate)
150 $ilDB->update(
'frm_posts',
152 'pos_top_fk' => array(
'integer', $this->forum_id),
153 'pos_thr_fk' => array(
'integer', $this->thread_id),
154 'pos_subject' => array(
'text', $this->subject),
155 'pos_message' => array(
'clob', $this->message),
156 'pos_update' => array(
'timestamp', $this->changedate),
157 'update_user' => array(
'integer', $this->user_id_update),
158 'pos_cens' => array(
'integer', $this->censored),
159 'pos_cens_date' => array(
'timestamp', $this->censored_date),
160 'pos_cens_com' => array(
'text', $this->censorship_comment),
161 'notify' => array(
'integer', (
int)$this->notification),
162 'pos_status' => array(
'integer', (
int)$this->status)
165 'pos_pk' => array(
'integer', (
int)$this->
id)
169 if($this->objThread->getFirstPostId() ==
$this->id)
171 $this->objThread->setSubject($this->subject);
172 $this->objThread->update();
173 $this->objThread->reload();
186 $res = $this->db->queryF(
' 187 SELECT * FROM frm_posts 188 INNER JOIN frm_posts_tree ON pos_fk = pos_pk 190 array(
'integer'), array($this->
id));
191 $row = $this->db->fetchObject(
$res);
195 $this->
id =
$row->pos_pk;
196 $this->forum_id =
$row->pos_top_fk;
197 $this->thread_id =
$row->pos_thr_fk;
198 $this->display_user_id =
$row->pos_display_user_id;
199 $this->user_alias =
$row->pos_usr_alias;
200 $this->subject =
$row->pos_subject;
201 $this->message =
$row->pos_message;
202 $this->createdate =
$row->pos_date;
203 $this->changedate =
$row->pos_update;
204 $this->user_id_update =
$row->update_user;
205 $this->censored =
$row->pos_cens;
206 $this->censored_date =
$row->pos_cens_date;
207 $this->censorship_comment =
$row->pos_cens_com;
208 $this->notification =
$row->notify;
209 $this->import_name =
$row->import_name;
210 $this->status =
$row->pos_status;
211 $this->tree_id =
$row->fpt_pk;
212 $this->parent_id =
$row->parent_pos;
213 $this->lft =
$row->lft;
214 $this->rgt =
$row->rgt;
215 $this->depth =
$row->depth;
216 $this->pos_author_id =
$row->pos_author_id;
217 $this->is_author_moderator =
$row->is_author_moderator;
218 $this->post_activation_date =
$row->pos_activation_date;
221 $this->objThread =
new ilForumTopic($this->thread_id, $this->is_moderator);
236 $res = $this->db->queryF(
' 237 SELECT * FROM frm_posts_tree 238 INNER JOIN frm_posts ON pos_pk = pos_fk 239 WHERE pos_status = %s 240 AND lft < %s AND rgt > %s 242 array(
'integer',
'integer',
'integer',
'integer'),
243 array(
'0', $this->lft, $this->rgt, $this->thread_id));
245 return $res->numRows();
255 if (
$row[
'pos_display_user_id'] &&
$row[
'pos_pk'])
257 require_once
'Services/User/classes/class.ilObjUser.php';
259 $tmp_user->setFirstname(
$row[
'firstname']);
260 $tmp_user->setLastname(
$row[
'lastname']);
261 $tmp_user->setUTitle(
$row[
'title']);
262 $tmp_user->setLogin(
$row[
'login']);
264 $this->fullname = $tmp_user->getFullname();
265 $this->loginname = $tmp_user->getLogin();
267 $this->fullname = $this->fullname ? $this->fullname : ($this->import_name ? $this->import_name : $lng->txt(
'unknown'));
275 if ($this->
id && $this->display_user_id)
277 require_once(
"Modules/Forum/classes/class.ilObjForumAccess.php");
280 $this->fullname = $tmp_user->getFullname();
281 $this->loginname = $tmp_user->getLogin();
285 $this->fullname = $this->fullname ? $this->fullname : ($this->import_name ? $this->import_name : $lng->txt(
'unknown'));
295 return $this->
read();
300 $this->fullname = $a_fullname;
308 $this->loginname = $a_loginname;
319 $this->db->update(
'frm_posts',
320 array(
'pos_status' => array(
'integer', 1),
321 'pos_activation_date' => array(
'timestamp', date(
"Y-m-d H:i:s"))),
322 array(
'pos_pk' => array(
'integer', $this->
id))
337 $query =
"SELECT pos_pk FROM frm_posts_tree treea " 338 .
"INNER JOIN frm_posts_tree treeb ON treeb.thr_fk = treea.thr_fk " 339 .
"AND treeb.lft BETWEEN treea.lft AND treea.rgt " 340 .
"INNER JOIN frm_posts ON pos_pk = treeb.pos_fk " 341 .
"WHERE treea.pos_fk = %s";
348 $now = date(
"Y-m-d H:i:s");
351 $this->db->update(
'frm_posts',
352 array(
'pos_status' => array(
'integer', 1),
353 'pos_activation_date' => array(
'timestamp', $now)),
354 array(
'pos_pk' => array(
'integer',
$row[
'pos_pk']))
370 $query =
"SELECT pos_pk FROM frm_posts " 371 .
"INNER JOIN frm_posts_tree ON pos_fk = pos_pk " 372 .
"WHERE lft < %s AND rgt > %s AND thr_fk = %s";
375 array(
'integer',
'integer',
'integer'),
376 array($this->lft, $this->rgt, $this->thread_id)
379 $now = date(
"Y-m-d H:i:s");
382 $this->db->update(
'frm_posts',
383 array(
'pos_status' => array(
'integer', 1),
384 'pos_activation_date' => array(
'timestamp', $now)),
385 array(
'pos_pk' => array(
'integer',
$row[
'pos_pk']))
402 if ($a_user_id && $this->
id)
405 $res = $this->db->queryF(
' 406 SELECT * FROM frm_user_read 409 array(
'integer',
'integer'),
410 array($a_user_id, $this->
id));
412 return $res->numRows() ? true :
false;
420 if ($this->
id && $this->rgt && $this->lft)
422 $res = $this->db->queryF(
' 423 SELECT * FROM frm_posts_tree 424 WHERE lft > %s AND rgt < %s 426 array(
'integer',
'integer',
'integer'),
427 array($this->lft, $this->rgt, $this->thread_id));
429 return $res->numRows() ? true :
false;
437 if ($this->pos_author_id && $a_user_id)
439 if ((
int) $this->pos_author_id == (
int) $a_user_id)
458 $this->forum_id = $a_forum_id;
466 $this->thread_id = $a_thread_id;
474 $this->display_user_id = $a_user_id;
482 $this->user_alias = $a_user_alias;
490 $this->subject = $a_subject;
498 $this->message = $a_message;
506 $this->createdate = $a_createdate;
514 $this->changedate = $a_changedate;
522 $this->user_id_update = $a_user_id_update;
530 $this->censored = $a_censorship;
534 return $this->censored == 1 ? true :
false;
538 $this->censorship_comment = $a_comment;
546 $this->notification = $a_notification;
550 return $this->notification == 1 ? true :
false;
554 $this->import_name = $a_import_name;
562 $this->status = $a_status;
566 return $this->status == 1 ? true :
false;
570 $this->tree_id = $a_tree_id;
578 $this->parent_id = $a_parent_id;
583 $this->post_read = $a_is_read;
613 $this->depth = $a_depth;
621 $this->objThread = $thread;
726 public static function mergePosts($source_thread_id, $target_thread_id)
730 $ilDB->update(
'frm_posts',
731 array(
'pos_thr_fk' => array(
'integer', $target_thread_id)),
732 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)
setPostActivationDate($post_activation_date)
activatePostAndChildPosts()
buildUserRelatedData($row)
__construct($a_id=0, $a_is_moderator=false, $preventImplicitRead=false)
ilForumPost constructor.
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)
setPosAuthorId($pos_author_id)
static mergePosts($source_thread_id, $target_thread_id)
setUpdateUserId($a_user_id_update)
setChangeDate($a_changedate)
setCensoredDate($censored_date)