3 if (!class_exists(
'ProtectorRegistry'))
exit(
'Registry not found');
11 eval(
' function xoops_module_install_'.
$mydirname.
'( $module ) { return protector_oninstall_base( $module , "'.
$mydirname.
'" ) ; } ' ) ;
14 if( ! function_exists(
'protector_oninstall_base' ) ) {
23 if( defined(
'XOOPS_CUBE_LEGACY' ) ) {
24 $root =& XCube_Root::getSingleton();
25 $root->mDelegateManager->add(
'Legacy.Admin.Event.ModuleInstall.' . ucfirst(
$mydirname) .
'.Success' ,
'protector_message_append_oninstall' ) ;
28 if( ! is_array( $ret ) ) $ret = array() ;
35 $sql_file_path = dirname(__FILE__).
'/sql/mysql.sql' ;
37 if( file_exists( $sql_file_path ) ) {
38 $ret[] =
"SQL file found at <b>".htmlspecialchars($sql_file_path).
"</b>.<br /> Creating tables...";
40 if( file_exists( XOOPS_ROOT_PATH.
'/class/database/oldsqlutility.php' ) ) {
41 include_once XOOPS_ROOT_PATH.
'/class/database/oldsqlutility.php' ;
42 $sqlutil =
new OldSqlUtility ;
44 include_once XOOPS_ROOT_PATH.
'/class/database/sqlutility.php' ;
48 $sql_query = trim( file_get_contents( $sql_file_path ) ) ;
49 $sqlutil->splitMySqlFile( $pieces , $sql_query ) ;
50 $created_tables = array() ;
51 foreach( $pieces as $piece ) {
52 $prefixed_query = $sqlutil->prefixQuery( $piece , $prefix_mod ) ;
53 if( ! $prefixed_query ) {
54 $ret[] =
"Invalid SQL <b>".htmlspecialchars($piece).
"</b><br />";
57 if( !
$db->query( $prefixed_query[0] ) ) {
58 $ret[] =
'<b>'.htmlspecialchars(
$db->error() ).
'</b><br />' ;
62 if( ! in_array( $prefixed_query[4] , $created_tables ) ) {
63 $ret[] =
'Table <b>'.htmlspecialchars($prefix_mod.
'_'.$prefixed_query[4]).
'</b> created.<br />';
64 $created_tables[] = $prefixed_query[4];
66 $ret[] =
'Data inserted to table <b>'.htmlspecialchars($prefix_mod.
'_'.$prefixed_query[4]).
'</b>.</br />';
74 $tpl_path = dirname(__FILE__).
'/templates' ;
75 if(
$handler = @opendir( $tpl_path .
'/' ) ) {
77 if( substr(
$file , 0 , 1 ) ==
'.' ) continue ;
78 $file_path = $tpl_path .
'/' .
$file ;
79 if( is_file( $file_path ) && in_array( strrchr(
$file ,
'.' ) , array(
'.html' ,
'.css' ,
'.js' ) ) ) {
80 $mtime = intval( @filemtime( $file_path ) ) ;
81 $tplfile =& $tplfile_handler->create() ;
82 $tplfile->setVar(
'tpl_source' , file_get_contents( $file_path ) ,
true ) ;
83 $tplfile->setVar(
'tpl_refid' ,
$mid ) ;
84 $tplfile->setVar(
'tpl_tplset' ,
'default' ) ;
86 $tplfile->setVar(
'tpl_desc' ,
'' ,
true ) ;
87 $tplfile->setVar(
'tpl_module' ,
$mydirname ) ;
88 $tplfile->setVar(
'tpl_lastmodified' , $mtime ) ;
89 $tplfile->setVar(
'tpl_lastimported' , 0 ) ;
90 $tplfile->setVar(
'tpl_type' ,
'module' ) ;
91 if( ! $tplfile_handler->insert( $tplfile ) ) {
92 $ret[] =
'<span style="color:#ff0000;">ERROR: Could not insert template <b>'.htmlspecialchars(
$mydirname.
'_'.$file).
'</b> to the database.</span><br />';
94 $tplid = $tplfile->getVar(
'tpl_id' ) ;
95 $ret[] =
'Template <b>'.htmlspecialchars(
$mydirname.
'_'.$file).
'</b> added to the database. (ID: <b>'.$tplid.
'</b>)<br />';
97 include_once XOOPS_ROOT_PATH.
'/class/xoopsblock.php' ;
98 include_once XOOPS_ROOT_PATH.
'/class/template.php' ;
100 $ret[] =
'<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars(
$mydirname.
'_'.$file).
'</b>.</span><br />';
102 $ret[] =
'Template <b>'.htmlspecialchars(
$mydirname.
'_'.$file).
'</b> compiled.</span><br />';
109 include_once XOOPS_ROOT_PATH.
'/class/xoopsblock.php' ;
110 include_once XOOPS_ROOT_PATH.
'/class/template.php' ;
116 function protector_message_append_oninstall( &$module_obj , &$log )
118 if( is_array( @
$GLOBALS[
'ret'] ) ) {
119 foreach(
$GLOBALS[
'ret'] as $message ) {
120 $log->add( strip_tags( $message ) ) ;