122 $this->cdata = trim($this->cdata);
123 $arrayname = strtolower($this->entity).
'Array';
124 $x = &$this->$arrayname;
129 $query_num_posts =
"SELECT COUNT(pos_pk) cnt 131 WHERE pos_top_fk = ".$ilDB->quote(
132 $this->lastHandledForumId,
'integer');
134 $res_pos = $ilDB->query($query_num_posts);
135 $data_pos = $ilDB->fetchAssoc($res_pos);
136 $num_posts = $data_pos[
'cnt'];
138 $query_num_threads =
"SELECT COUNT(thr_pk) cnt 140 WHERE thr_top_fk = ".$ilDB->quote(
141 $this->lastHandledForumId,
'integer');
143 $res_thr = $ilDB->query($query_num_threads);
144 $data_thr = $ilDB->fetchAssoc($res_thr);
145 $num_threads = $data_thr[
'cnt'];
147 $update_str =
"$this->lastHandledForumId#$this->lastHandledThreadId#$this->lastHandledPostId";
150 SET top_last_post = %s, 153 WHERE top_frm_fk = %s",
154 array(
'text',
'integer',
'integer',
'integer'),
155 array($update_str, $num_posts, $num_threads, $this->forum_obj_id)
160 $x[
'Id'] = $this->cdata;
164 $x[
'ObjId'] = $this->cdata;
168 $x[
'Title'] = $this->cdata;
172 $x[
'Description'] = $this->cdata;
176 $x[
'DefaultView'] = $this->cdata;
180 $x[
'Pseudonyms'] = $this->cdata;
184 $x[
'Statistics'] = $this->cdata;
187 case 'PostingActivation':
188 $x[
'PostingActivation'] = $this->cdata;
191 case 'PresetSubject':
192 $x[
'PresetSubject'] = $this->cdata;
196 $x[
'PresetRe'] = $this->cdata;
199 case 'NotificationType':
200 $x[
'NotificationType'] = $this->cdata;
203 case 'ForceNotification':
204 $x[
'ForceNotification'] = $this->cdata;
207 case 'ToggleNotification':
208 $x[
'ToggleNotification'] = $this->cdata;
212 $x[
'LastPost'] = $this->cdata;
216 $x[
'Moderator'] = $this->cdata;
220 $x[
'CreateDate'] = $this->cdata;
224 $x[
'UpdateDate'] = $this->cdata;
228 $x[
'UpdateUserId'] = $this->cdata;
232 $x[
'UserId'] = $this->cdata;
233 if( $this->entity ==
'forum' && $this->forumArray )
238 $this->forum->createSettings();
241 $this->forumArray[
'UserId'],
'' 244 $oldUsrId = $ilUser->getId();
246 $ilUser->setId($forum_array[
'usr_id']);
248 $this->forum->saveData( array() );
250 $ilUser->setId($oldUsrId);
253 $this->forumArray[
'UpdateUserId'],
'' 258 $_SESSION[
"AccountId"] = $update_forum_array[
'usr_id'];
259 $this->forum->setTitle($this->forumArray[
"Title"]);
260 $this->forum->setDescription($this->forumArray[
"Description"]);
261 $this->forum->update();
267 $this->forum->getId() );
268 $newObjProp->setDefaultView(
269 (
int) $this->forumArray[
'DefaultView'] );
270 $newObjProp->setAnonymisation(
271 (
int) $this->forumArray[
'Pseudonyms'] );
272 $newObjProp->setStatisticsStatus(
273 (
int) $this->forumArray[
'Statistics'] );
274 $newObjProp->setPostActivation(
275 (
int) $this->forumArray[
'PostingActivation'] );
276 $newObjProp->setPresetSubject(
277 (
int) $this->forumArray[
'PresetSubject'] );
278 $newObjProp->setAddReSubject(
279 (
int) $this->forumArray[
'PresetRe'] );
280 $newObjProp->setNotificationType(
281 $this->forumArray[
'NotificationType'] ?
282 $this->forumArray[
'NotificationType'] :
'all_users');
283 $newObjProp->setAdminForceNoti(
284 (
int) $this->forumArray[
'ForceNotification'] );
285 $newObjProp->setUserToggleNoti(
286 (
int) $this->forumArray[
'ToggleNotification'] );
287 $newObjProp->insert();
290 $this->forum_obj_id = $newObjProp->getObjId();
291 $this->mapping[
'frm'][$this->forumArray[
'Id']] = $id;
292 $this->lastHandledForumId = $id;
294 unset($this->forumArray);
300 $update_str =
"$this->lastHandledForumId#$this->lastHandledThreadId#$this->lastHandledPostId";
303 SET thr_last_post = %s 305 array(
'text',
'integer'),
306 array($update_str, $this->lastHandledThreadId)
311 $x[
'Subject'] = $this->cdata;
315 $x[
'Alias'] = $this->cdata;
319 $x[
'Sticky'] = $this->cdata;
323 $x[
'Closed'] = $this->cdata;
325 if($this->entity ==
'thread' && $this->threadArray)
327 require_once
'Modules/Forum/classes/class.ilForumTopic.php';
330 $this->forumThread->setId($this->threadArray[
'Id']);
331 $this->forumThread->setForumId( $this->lastHandledForumId );
332 $this->forumThread->setSubject($this->threadArray[
'Subject']);
333 $this->forumThread->setSticky($this->threadArray[
'Sticky']);
334 $this->forumThread->setClosed($this->threadArray[
'Closed']);
335 $this->forumThread->setCreateDate($this->threadArray[
'CreateDate']);
336 $this->forumThread->setChangeDate($this->threadArray[
'UpdateDate']);
337 $this->forumThread->setImportName($this->threadArray[
'ImportName']);
340 $this->threadArray[
'UserId'], $this->threadArray[
'Alias']
343 $this->forumThread->setUserId($usr_data[
'usr_id']);
344 $this->forumThread->setUserAlias($usr_data[
'usr_alias']);
346 $this->forumThread->insert();
348 $this->mapping[
'thr'][$this->threadArray[
'Id']] = $this->forumThread->getId();
349 $this->lastHandledThreadId = $this->forumThread->getId();
351 unset($this->threadArray);
360 $x[
'Censorship'] = $this->cdata;
363 case 'CensorshipMessage':
364 $x[
'CensorshipMessage'] = $this->cdata;
368 $x[
'Notification'] = $this->cdata;
372 $x[
'ImportName'] = $this->cdata;
376 $x[
'Status'] = $this->cdata;
380 $x[
'Message'] = $this->cdata;
384 $x[
'Lft'] = $this->cdata;
388 $x[
'Rgt'] = $this->cdata;
392 $x[
'Depth'] = $this->cdata;
396 $x[
'ParentId'] = $this->cdata;
398 if($this->entity ==
'post' && $this->postArray)
400 require_once
'Modules/Forum/classes/class.ilForumPost.php';
403 $this->forumPost->setId($this->postArray[
'Id']);
404 $this->forumPost->setCensorship($this->postArray[
'Censorship']);
405 $this->forumPost->setCensorshipComment($this->postArray[
'CensorshipMessage']);
406 $this->forumPost->setNotification($this->postArray[
'Notification']);
407 $this->forumPost->setImportName($this->postArray[
'ImportName']);
408 $this->forumPost->setStatus($this->postArray[
'Status']);
409 $this->forumPost->setMessage($this->postArray[
'Message']);
410 $this->forumPost->setSubject($this->postArray[
'Subject']);
411 $this->forumPost->setLft($this->postArray[
'Lft']);
412 $this->forumPost->setRgt($this->postArray[
'Rgt']);
413 $this->forumPost->setDepth($this->postArray[
'Depth']);
414 $this->forumPost->setParentId($this->postArray[
'ParentId']);
415 $this->forumPost->setThread($this->forumThread);
416 $this->forumPost->setThreadId($this->lastHandledThreadId);
417 $this->forumPost->setForumId($this->lastHandledForumId);
418 $this->forumPost->setCreateDate($this->postArray[
'CreateDate']);
419 $this->forumPost->setChangeDate($this->postArray[
'UpdateDate']);
422 $this->postArray[
'UserId'], $this->postArray[
'Alias']
425 $this->postArray[
'UpdateUserId']
428 $this->forumPost->setUserId($usr_data[
'usr_id']);
429 $this->forumPost->setUserAlias($usr_data[
'usr_alias']);
430 $this->forumPost->setUpdateUserId($update_usr_data[
'usr_id']);
432 $this->forumPost->insert();
434 if($this->mapping[
'pos'][$this->postArray[
'ParentId']])
436 $parentId = $this->mapping[
'pos'][$this->postArray[
'ParentId']];
443 $postTreeNodeId = $ilDB->nextId(
'frm_posts_tree');
444 $ilDB->insert(
'frm_posts_tree', array(
445 'fpt_pk' => array(
'integer', $postTreeNodeId),
446 'thr_fk' => array(
'integer', $this->lastHandledThreadId),
447 'pos_fk' => array(
'integer', $this->forumPost->getId()),
448 'parent_pos' => array(
'integer', $parentId),
449 'lft' => array(
'integer', $this->postArray[
'Lft']),
450 'rgt' => array(
'integer', $this->postArray[
'Rgt']),
451 'depth' => array(
'integer', $this->postArray[
'Depth']),
452 'fpt_date' => array(
'timestamp', date(
'Y-m-d H:i:s'))
455 $this->mapping[
'pos'][$this->postArray[
'Id']] = $this->forumPost->getId();
456 $this->lastHandledPostId = $this->forumPost->getId();
458 $media_objects_found =
false;
459 foreach($this->mediaObjects as $mob_attr)
462 if(file_exists($importfile))
467 $this->forumPost->setMessage(
470 "src=\"" . $mob_attr[
"label"] .
"\"",
471 "src=\"" . preg_replace(
"/(il)_[\d]+_(mob)_([\d]+)/",
"$1_0_$2_$3", $mob_attr[
"label"]) .
"\"" 473 "src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $mob->getId() .
"\"",
474 $this->forumPost->getMessage()
477 $media_objects_found =
true;
481 if($media_objects_found)
483 $this->forumPost->update();
486 unset($this->postArray);
492 $x[
'content'] = $this->cdata;
496 $filedata =
new ilFileDataForum($this->forum->getId(), $this->lastHandledPostId);
498 $importPath = $this->contentArray[
'content'];
500 if( strlen($importPath) )
504 $newFilename = preg_replace(
"/^\d+_\d+(_.*)/ims", $this->forum->getId().
"_".$this->lastHandledPostId.
"$1", basename($importPath));
505 $path = $filedata->getForumPath();
506 $newPath = $path.
'/'.$newFilename;
507 @copy($importPath, $newPath);
getImportDirectory()
Get import directory.
getUserIdAndAlias($imp_usr_id, $imp_usr_alias='')
static getInstance($a_obj_id=0)
This class handles all operations on files for the forum object.