remove old readme
[atutor.git] / mods / _core / imscc / classes / DiscussionToolsImport.class.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2009                                                                              */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id$
14
15 include(AT_INCLUDE_PATH.'../mods/_standard/forums/lib/forums.inc.php');
16 /**
17  * A class for DiscussionToolsParser
18  * based on:
19  *  http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imsdt_v1p0_localised.xsd
20  */
21 class DiscussionToolsImport {
22         //global variables
23         var $fid;       //the forum id that is imported 
24
25         //constructor
26         function DiscussionToolsImport(){}
27
28         //import
29         function import($forum_obj){
30                 $title = $forum_obj->getTitle();
31                 $text = $forum_obj->getText();
32
33                 $this->fid = $this->createForum($title, $text);
34                 $this->associateForum($cid, $this->fid);
35         }
36
37         
38         /**
39          * create a forum
40          * @param       string  title
41          * @param       string  text/description
42          * @return      added forum's id
43          */
44         function createForum($title, $text){
45                 global $db;
46                 //create POST array
47                 $temp['title'] = $title;
48                 $temp['body'] = $text;
49                 $temp['edit'] = 0;      //default 0 minutes 
50
51                 add_forum($temp);       //check forums.inc.php
52
53                 $sql = 'SELECT MAX(forum_id) FROM '.TABLE_PREFIX.'forums';
54                 $result = mysql_query($sql, $db);
55                 $row = mysql_fetch_row($result);
56                 return $row[0];
57         }       
58
59
60         /**
61          * create an association between forum and content
62          * @param       int             content id
63          * @return      
64          */
65         function associateForum($cid, $fid){
66                 global $db;
67                 $sql = 'INSERT INTO '.TABLE_PREFIX."content_forums_assoc (content_id, forum_id) VALUES ($cid, $fid)";
68                 mysql_query($sql, $db);
69         }
70
71         /**
72          * Return the fid that was created by this import
73          * @return      int      forum id.
74          */
75         function getFid(){
76                 return $this->fid;
77         }
78 }
79 ?>