• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/Scorm2004/classes/updateADLTree.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004         +-----------------------------------------------------------------------------+
00005         | ILIAS open source                                                           |
00006         +-----------------------------------------------------------------------------+
00007         | Copyright (c) 1998-2007 ILIAS open source, University of Cologne            |
00008         |                                                                             |
00009         | This program is free software; you can redistribute it and/or               |
00010         | modify it under the terms of the GNU General Public License                 |
00011         | as published by the Free Software Foundation; either version 2              |
00012         | of the License, or (at your option) any later version.                      |
00013         |                                                                             |
00014         | This program is distributed in the hope that it will be useful,             |
00015         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017         | GNU General Public License for more details.                                |
00018         |                                                                             |
00019         | You should have received a copy of the GNU General Public License           |
00020         | along with this program; if not, write to the Free Software                 |
00021         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00022         +-----------------------------------------------------------------------------+
00023 */
00024 /*
00025         Script to update JSON Data for the activitytree - reads all manifest files in lm_data and updates 
00026         the filed activitytree in cp_package
00027         
00028         @author Hendrik Holtmann <holtmann@mac.com>
00029         
00030         This software is provided "AS IS," without a warranty of any kind.  ALL 
00031         EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING 
00032         ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
00033         OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.  ADL Co-Lab Hub AND ITS LICENSORS 
00034         SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF 
00035         USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES.  IN NO 
00036         EVENT WILL ADL Co-Lab Hub OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, 
00037         PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, 
00038         INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE 
00039         THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE 
00040         SOFTWARE, EVEN IF ADL Co-Lab Hub HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 
00041         DAMAGES.
00042 */
00043 
00044         require_once("adlparser/SeqTreeBuilder.php");
00045         require_once("../../../classes/class.ilIniFile.php");
00046         
00047         //find all folders containing data
00048         //initIliasIniFile()
00049         
00050         $ini=new ilIniFile("../../../ilias.ini.php");
00051         $ini->read();
00052         
00053         //define constants
00054     define("ILIAS_WEB_DIR",$ini->readVariable("clients","path"));
00055     define("ILIAS_ABSOLUTE_PATH",$ini->readVariable('server','absolute_path'));
00056         define("ILIAS_CLIENT_ID",$ini->readVariable('clients','default'));
00057         define("ILIAS_CLIENT_INI",$ini->readVariable('clients','inifile'));
00058         
00059         //build datapath for this ilias installation
00060         $search_path=ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".ILIAS_CLIENT_ID."/lm_data";
00061         
00062         //client ini
00063         $client_ini=ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".ILIAS_CLIENT_ID."/".ILIAS_CLIENT_INI;
00064 
00065         //get db connection data from client_ini
00066         $cini=new ilIniFile($client_ini);
00067         $cini->read();
00068         define("ILIAS_DB_NAME",$cini->readVariable("db","name"));
00069         define("ILIAS_DB_HOST",$cini->readVariable("db","host"));       
00070         define("ILIAS_DB_USER",$cini->readVariable("db","user"));
00071         define("ILIAS_DB_PASS",$cini->readVariable("db","pass"));
00072         define("ILIAS_DB_TYPE",$cini->readVariable("db","type"));
00073         
00074         //init db-connection
00075 
00076         $dbh = mysql_connect(ILIAS_DB_HOST, ILIAS_DB_USER, ILIAS_DB_PASS)  or die("Unable to connect to MySQL");
00077         $sel_db = mysql_select_db(ILIAS_DB_NAME,$dbh);
00078         
00079         //start directory processing - one level only
00080         
00081         $dirs=array();
00082         $d = dir($search_path);
00083     while (false !== ($entry = $d->read())) {
00084         if($entry != '.' && $entry != '..' && is_dir($search_path."/".$entry)) {
00085                         array_push($dirs, $entry);
00086                 }
00087     }
00088     $d->close();
00089         
00090         //iterate over array
00091         
00092         for ($i=0;$i<count($dirs);$i++) {
00093                 //check for imsmanifest
00094                 $toparse=$search_path."/".$dirs[$i]."/imsmanifest.xml";
00095                 if (is_file($toparse)) {
00096                         //check for DB entry
00097                         //get id
00098                         $id = $webdir=str_replace("lm_","",$dirs[$i]);  
00099                         $result = mysql_query("SELECT * FROM cp_package WHERE(obj_id=$id)");
00100                         $row = mysql_fetch_array($result,MYSQL_ASSOC);
00101                         if (count($row)>0 && strlen($row['jsdata'])>10) {
00102                                 //create new parser
00103                                 $builder=new SeqTreeBuilder();
00104                                 $ret=$builder->buildNodeSeqTree($toparse);
00105                                 $global=$ret['global'];
00106                                 $adltree=mysql_escape_string(json_encode($ret['tree']));
00107                                 $result_update = mysql_query("UPDATE cp_package SET activitytree='$adltree',global_to_system='$global' WHERE(obj_id=$id)") or die(mysql_error());
00108                                 echo "Updated activitytree for: ".$dirs[$i]." Global:".$global." \n";
00109                         }
00110                 }
00111         }
00112 
00113         mysql_close($dbh);
00114 
00115 ?>

Generated on Fri Dec 13 2013 17:56:52 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1