ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
updateADLTree.php
Go to the documentation of this file.
1<?php
2
3// please contact alex.killing (at) gmx.de
4die("Deprecated.");
5
6/*
7 +-----------------------------------------------------------------------------+
8 | ILIAS open source |
9 +-----------------------------------------------------------------------------+
10 | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
11 | |
12 | This program is free software; you can redistribute it and/or |
13 | modify it under the terms of the GNU General Public License |
14 | as published by the Free Software Foundation; either version 2 |
15 | of the License, or (at your option) any later version. |
16 | |
17 | This program is distributed in the hope that it will be useful, |
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | GNU General Public License for more details. |
21 | |
22 | You should have received a copy of the GNU General Public License |
23 | along with this program; if not, write to the Free Software |
24 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 +-----------------------------------------------------------------------------+
26*/
27/*
28 Script to update JSON Data for the activitytree - reads all manifest files in lm_data and updates
29 the filed activitytree in cp_package
30
31 @author Hendrik Holtmann <holtmann@mac.com>
32
33 This software is provided "AS IS," without a warranty of any kind. ALL
34 EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
35 ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
36 OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ADL Co-Lab Hub AND ITS LICENSORS
37 SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
38 USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO
39 EVENT WILL ADL Co-Lab Hub OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
40 PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
41 INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
42 THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
43 SOFTWARE, EVEN IF ADL Co-Lab Hub HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
44 DAMAGES.
45*/
46
47 require_once("adlparser/SeqTreeBuilder.php");
48 require_once("../../../Services/Init/classes/class.ilIniFile.php");
49
50 //find all folders containing data
51 //initIliasIniFile()
52
53 $ini=new ilIniFile("../../../ilias.ini.php");
54 $ini->read();
55
56
57
58 //define constants
59 define("ILIAS_WEB_DIR",$ini->readVariable("clients","path"));
60 define("ILIAS_ABSOLUTE_PATH",$ini->readVariable('server','absolute_path'));
61 define("ILIAS_CLIENT_ID",$ini->readVariable('clients','default'));
62 define("ILIAS_CLIENT_INI",$ini->readVariable('clients','inifile'));
63
64 //build datapath for this ilias installation
66
67 //client ini
69
70 //get db connection data from client_ini
72 $cini->read();
73 define("ILIAS_DB_NAME",$cini->readVariable("db","name"));
74 define("ILIAS_DB_HOST",$cini->readVariable("db","host"));
75 define("ILIAS_DB_USER",$cini->readVariable("db","user"));
76 define("ILIAS_DB_PASS",$cini->readVariable("db","pass"));
77 define("ILIAS_DB_TYPE",$cini->readVariable("db","type"));
78
79 //init db-connection
80
81 $dbh = mysql_connect(ILIAS_DB_HOST, ILIAS_DB_USER, ILIAS_DB_PASS) or die("Unable to connect to MySQL");
82 $sel_db = mysql_select_db(ILIAS_DB_NAME,$dbh);
83
84 //start directory processing - one level only
85
86 $dirs=array();
88 while (false !== ($entry = $d->read())) {
89 if($entry != '.' && $entry != '..' && is_dir($search_path."/".$entry)) {
90 array_push($dirs, $entry);
91 }
92 }
93 $d->close();
94
95 //iterate over array
96
97 for ($i=0;$i<count($dirs);$i++) {
98 //check for imsmanifest
99 $toparse=$search_path."/".$dirs[$i]."/imsmanifest.xml";
100 if (is_file($toparse)) {
101 //check for DB entry
102 //get id
103 $id = $webdir=str_replace("lm_","",$dirs[$i]);
104 $result = mysql_query("SELECT * FROM cp_package WHERE(obj_id=$id)");
105 $row = mysql_fetch_array($result,MYSQL_ASSOC);
106 if (count($row)>0 && strlen($row['jsdata'])>10) {
107 //create new parser
109 $ret=$builder->buildNodeSeqTree($toparse);
110 $global=$ret['global'];
111 $adltree=mysql_escape_string(json_encode($ret['tree']));
112 $result_update = mysql_query("UPDATE cp_package SET activitytree='$adltree',global_to_system='$global' WHERE(obj_id=$id)") or die(mysql_error());
113 echo "Updated activitytree for: ".$dirs[$i]." Global:".$global." \n";
114 }
115 }
116 }
117
118 mysql_close($dbh);
119
120?>
$result
INIFile Parser.
$builder
Definition: parser.php:5
$dirs
const ILIAS_DB_USER
const ILIAS_WEB_DIR
const ILIAS_DB_HOST
const ILIAS_ABSOLUTE_PATH
$ini
$cini
$client_ini
const ILIAS_DB_PASS
$dbh
const ILIAS_CLIENT_ID
$search_path
const ILIAS_CLIENT_INI
const ILIAS_DB_NAME
$sel_db