141 $this->cdata = trim($this->cdata);
142 $arrayname = strtolower($this->entity) .
'Array';
143 $x = &$this->$arrayname;
147 $query_num_posts =
"SELECT COUNT(pos_pk) cnt 149 WHERE pos_top_fk = " . $this->db->quote(
150 $this->lastHandledForumId,
154 $res_pos = $this->db->query($query_num_posts);
155 $data_pos = $this->db->fetchAssoc($res_pos);
156 $num_posts = $data_pos[
'cnt'];
158 $query_num_threads =
"SELECT COUNT(thr_pk) cnt 160 WHERE thr_top_fk = " . $this->db->quote(
161 $this->lastHandledForumId,
165 $res_thr = $this->db->query($query_num_threads);
166 $data_thr = $this->db->fetchAssoc($res_thr);
167 $num_threads = $data_thr[
'cnt'];
169 $update_str =
"$this->lastHandledForumId#$this->lastHandledThreadId#$this->lastHandledPostId";
170 $this->db->manipulateF(
172 SET top_last_post = %s, 174 top_num_threads = %s, 176 WHERE top_frm_fk = %s",
177 array(
'text',
'integer',
'integer',
'integer',
'integer'),
178 array($update_str, $num_posts, $num_threads, $this->frm_last_mapped_top_usr_id, $this->forum_obj_id)
183 $x[
'Id'] = $this->cdata;
187 $x[
'ObjId'] = $this->cdata;
191 $x[
'Title'] = $this->cdata;
195 $x[
'Description'] = $this->cdata;
199 $x[
'DefaultView'] = $this->cdata;
203 $x[
'Pseudonyms'] = $this->cdata;
207 $x[
'Statistics'] = $this->cdata;
210 case 'ThreadRatings':
211 $x[
'ThreadRatings'] = $this->cdata;
214 case 'PostingActivation':
215 $x[
'PostingActivation'] = $this->cdata;
218 case 'PresetSubject':
219 $x[
'PresetSubject'] = $this->cdata;
223 $x[
'PresetRe'] = $this->cdata;
226 case 'NotificationType':
227 $x[
'NotificationType'] = $this->cdata;
230 case 'ForceNotification':
231 $x[
'ForceNotification'] = $this->cdata;
234 case 'ToggleNotification':
235 $x[
'ToggleNotification'] = $this->cdata;
239 $x[
'LastPost'] = $this->cdata;
243 $x[
'Moderator'] = $this->cdata;
247 $x[
'CreateDate'] = $this->cdata;
251 $x[
'UpdateDate'] = $this->cdata;
255 $x[
'FileUpload'] = $this->cdata;
259 $x[
'UpdateUserId'] = $this->cdata;
263 $x[
'AuthorId'] = $this->cdata;
265 case 'isAuthorModerator':
266 $x[
'isAuthorModerator'] = $this->cdata;
270 $x[
'UserId'] = $this->cdata;
271 if ($this->entity ==
'forum' && $this->forumArray) {
275 $this->forum->createSettings();
278 $this->forumArray[
'UserId'],
282 $this->frm_last_mapped_top_usr_id = $forum_array[
'usr_id'];
285 $this->forumArray[
'UpdateUserId'],
292 $this->forum->setTitle($this->forumArray[
"Title"]);
293 $this->forum->setDescription($this->forumArray[
"Description"]);
294 $this->forum->update($update_forum_array[
'usr_id']);
298 $newObjProp->setDefaultView((
int) $this->forumArray[
'DefaultView']);
299 $newObjProp->setAnonymisation((
int) $this->forumArray[
'Pseudonyms']);
300 $newObjProp->setStatisticsStatus((
int) $this->forumArray[
'Statistics']);
301 $newObjProp->setIsThreadRatingEnabled((
int) $this->forumArray[
'ThreadRatings']);
302 $newObjProp->setPostActivation((
int) $this->forumArray[
'PostingActivation']);
303 $newObjProp->setPresetSubject((
int) $this->forumArray[
'PresetSubject']);
304 $newObjProp->setAddReSubject((
int) $this->forumArray[
'PresetRe']);
305 $newObjProp->setNotificationType($this->forumArray[
'NotificationType'] ? $this->forumArray[
'NotificationType'] :
'all_users');
306 $newObjProp->setAdminForceNoti((
int) $this->forumArray[
'ForceNotification']);
307 $newObjProp->setUserToggleNoti((
int) $this->forumArray[
'ToggleNotification']);
308 $newObjProp->setFileUploadAllowed((
int) $this->forumArray[
'FileUpload']);
309 $newObjProp->setThreadSorting((
int)$this->forumArray[
'Sorting']);
310 $newObjProp->setMarkModeratorPosts((
int)$this->forumArray[
'MarkModeratorPosts']);
311 $newObjProp->update();
314 $this->forum_obj_id = $newObjProp->getObjId();
315 $this->mapping[
'frm'][$this->forumArray[
'Id']] =
$id;
316 $this->lastHandledForumId =
$id;
318 unset($this->forumArray);
324 $update_str =
"$this->lastHandledForumId#$this->lastHandledThreadId#$this->lastHandledPostId";
325 $this->db->manipulateF(
327 SET thr_last_post = %s 329 array(
'text',
'integer'),
330 array($update_str, $this->lastHandledThreadId)
335 $x[
'Subject'] = $this->cdata;
339 $x[
'Alias'] = $this->cdata;
343 $x[
'Sticky'] = $this->cdata;
347 $x[
'Sorting'] = $this->cdata;
350 case 'MarkModeratorPosts':
351 $x[
'MarkModeratorPosts'] = $this->cdata;
355 $x[
'Closed'] = $this->cdata;
357 if ($this->entity ==
'thread' && $this->threadArray) {
359 $this->forumThread->setId($this->threadArray[
'Id']);
360 $this->forumThread->setForumId($this->lastHandledForumId);
361 $this->forumThread->setSubject($this->threadArray[
'Subject']);
362 $this->forumThread->setSticky($this->threadArray[
'Sticky']);
363 $this->forumThread->setClosed($this->threadArray[
'Closed']);
364 $this->forumThread->setCreateDate($this->threadArray[
'CreateDate']);
365 $this->forumThread->setChangeDate($this->threadArray[
'UpdateDate']);
366 $this->forumThread->setImportName($this->threadArray[
'ImportName']);
369 $this->threadArray[
'UserId'],
370 $this->threadArray[
'Alias']
373 $this->forumThread->setDisplayUserId($usr_data[
'usr_id']);
374 $this->forumThread->setUserAlias($usr_data[
'usr_alias']);
377 $this->threadArray[
'AuthorId'] = $this->threadArray[
'UserId'];
381 $this->threadArray[
'AuthorId']
383 $this->forumThread->setThrAuthorId((
int) $author_id_data[
'usr_id']);
385 $this->forumThread->insert();
387 $this->mapping[
'thr'][$this->threadArray[
'Id']] = $this->forumThread->getId();
388 $this->lastHandledThreadId = $this->forumThread->getId();
390 unset($this->threadArray);
399 $x[
'Censorship'] = $this->cdata;
402 case 'CensorshipMessage':
403 $x[
'CensorshipMessage'] = $this->cdata;
407 $x[
'Notification'] = $this->cdata;
411 $x[
'ImportName'] = $this->cdata;
415 $x[
'Status'] = $this->cdata;
419 $x[
'Message'] = $this->cdata;
423 $x[
'Lft'] = $this->cdata;
427 $x[
'Rgt'] = $this->cdata;
431 $x[
'Depth'] = $this->cdata;
435 $x[
'ParentId'] = $this->cdata;
437 if ($this->entity ==
'post' && $this->postArray) {
439 $this->forumPost->setId($this->postArray[
'Id']);
440 $this->forumPost->setCensorship($this->postArray[
'Censorship']);
441 $this->forumPost->setCensorshipComment($this->postArray[
'CensorshipMessage']);
442 $this->forumPost->setNotification($this->postArray[
'Notification']);
443 $this->forumPost->setImportName($this->postArray[
'ImportName']);
444 $this->forumPost->setStatus($this->postArray[
'Status']);
445 $this->forumPost->setMessage($this->postArray[
'Message']);
446 $this->forumPost->setSubject($this->postArray[
'Subject']);
447 $this->forumPost->setLft($this->postArray[
'Lft']);
448 $this->forumPost->setRgt($this->postArray[
'Rgt']);
449 $this->forumPost->setDepth($this->postArray[
'Depth']);
450 $this->forumPost->setParentId($this->postArray[
'ParentId']);
451 $this->forumPost->setThread($this->forumThread);
452 $this->forumPost->setThreadId($this->lastHandledThreadId);
453 $this->forumPost->setForumId($this->lastHandledForumId);
454 $this->forumPost->setCreateDate($this->postArray[
'CreateDate']);
455 $this->forumPost->setChangeDate($this->postArray[
'UpdateDate']);
458 $this->postArray[
'UserId'],
459 $this->postArray[
'Alias']
462 $this->postArray[
'UpdateUserId']
464 $this->forumPost->setDisplayUserId($usr_data[
'usr_id']);
465 $this->forumPost->setUserAlias($usr_data[
'usr_alias']);
466 $this->forumPost->setUpdateUserId($update_usr_data[
'usr_id']);
469 $this->postArray[
'AuthorId'] = $this->postArray[
'UserId'];
472 $this->postArray[
'AuthorId']
474 $this->forumPost->setPosAuthorId((
int) $author_id_data[
'usr_id']);
476 if ($this->postArray[
'isAuthorModerator'] ===
'NULL') {
477 $this->forumPost->setIsAuthorModerator(null);
479 $this->forumPost->setIsAuthorModerator((
int) $this->postArray[
'isAuthorModerator']);
482 $this->forumPost->insert();
484 if ($this->mapping[
'pos'][$this->postArray[
'ParentId']]) {
485 $parentId = $this->mapping[
'pos'][$this->postArray[
'ParentId']];
490 $postTreeNodeId = $this->db->nextId(
'frm_posts_tree');
491 $this->db->insert(
'frm_posts_tree', array(
492 'fpt_pk' => array(
'integer', $postTreeNodeId),
493 'thr_fk' => array(
'integer', $this->lastHandledThreadId),
494 'pos_fk' => array(
'integer', $this->forumPost->getId()),
495 'parent_pos' => array(
'integer', $parentId),
496 'lft' => array(
'integer', $this->postArray[
'Lft']),
497 'rgt' => array(
'integer', $this->postArray[
'Rgt']),
498 'depth' => array(
'integer', $this->postArray[
'Depth']),
499 'fpt_date' => array(
'timestamp', date(
'Y-m-d H:i:s'))
502 $this->mapping[
'pos'][$this->postArray[
'Id']] = $this->forumPost->getId();
503 $this->lastHandledPostId = $this->forumPost->getId();
505 $media_objects_found =
false;
506 foreach ($this->mediaObjects as $mob_attr) {
508 if (file_exists($importfile)) {
512 $this->forumPost->setMessage(
515 "src=\"" . $mob_attr[
"label"] .
"\"",
516 "src=\"" . preg_replace(
"/(il)_[\d]+_(mob)_([\d]+)/",
"$1_0_$2_$3", $mob_attr[
"label"]) .
"\"" 518 "src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $mob->getId() .
"\"",
519 $this->forumPost->getMessage()
522 $media_objects_found =
true;
526 if ($media_objects_found) {
527 $this->forumPost->update();
530 unset($this->postArray);
536 $x[
'content'] = $this->cdata;
540 $filedata =
new ilFileDataForum($this->forum->getId(), $this->lastHandledPostId);
542 $importPath = $this->contentArray[
'content'];
544 if (strlen($importPath)) {
547 $newFilename = preg_replace(
"/^\d+_\d+(_.*)/ims", $this->forum->getId() .
"_" . $this->lastHandledPostId .
"$1", basename($importPath));
548 $path = $filedata->getForumPath();
549 $newPath = $path .
'/' . $newFilename;
550 @copy($importPath, $newPath);
getImportDirectory()
Get import directory.
getUserIdAndAlias($imp_usr_id, $imp_usr_alias='')
if(!array_key_exists('StateId', $_REQUEST)) $id
static getInstance($a_obj_id=0)
This class handles all operations on files for the forum object.