AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / docs / include / classes / DiscussionTools / DiscussionToolsImport.class.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 include(TR_INCLUDE_PATH.'classes/DAO/ForumsDAO.class.php');
14 include(TR_INCLUDE_PATH.'classes/DAO/ForumsCoursesDAO.class.php');
15 include(TR_INCLUDE_PATH.'classes/DAO/ContentForumsAssocDAO.class.php');
16
17 /**
18  * A class for DiscussionToolsParser
19  * based on:
20  *  http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imsdt_v1p0_localised.xsd
21  */
22 class DiscussionToolsImport {
23         //global variables
24         var $fid;       //the forum id that is imported 
25
26         //constructor
27         function DiscussionToolsImport(){}
28
29         //import
30         function import($forum_obj, $cid, $course_id){
31                 $title = $forum_obj->getTitle();
32                 $text = $forum_obj->getText();
33
34                 $this->fid = $this->createForum($title, $text, $course_id);
35                 $this->associateForum($cid, $this->fid);
36         }
37
38         
39         /**
40          * create a forum
41          * @param       string  title
42          * @param       string  text/description
43          * @return      added forum's id
44          */
45         function createForum($title, $text, $course_id){
46                 $forumsDAO = new ForumsDAO();
47                 $forums_id = $forumsDAO->Create($title, $text);
48                 
49                 $forumsCoursesDAO = new ForumsCoursesDAO();
50                 $forumsCoursesDAO->Create($forums_id, $course_id);
51                 
52                 return $forums_id;
53         }       
54
55
56         /**
57          * create an association between forum and content
58          * @param       int             content id
59          * @return      
60          */
61         function associateForum($cid, $fid){
62                 $contentForumsAssocDAO = new ContentForumsAssocDAO();
63                 return $contentForumsAssocDAO->Create($cid, $fid);
64         }
65
66         /**
67          * Return the fid that was created by this import
68          * @return      int      forum id.
69          */
70         function getFid(){
71                 return $this->fid;
72         }
73 }
74 ?>