| 1 |
<?php |
<?php |
| 2 |
// Install script for bulletin module // |
// Install script for bulletin module // |
| 3 |
// $Revision$ // |
// $Revision$ // |
| 4 |
// -------------------------------------------------------------------------- // |
// -------------------------------------------------------------------------- // |
| 5 |
// XooNIps Xoops modules for Neuroinformatics Platforms // |
// XooNIps Xoops modules for Neuroinformatics Platforms // |
| 6 |
// Copyright (C) 2005 RIKEN, Japan. All rights reserved. // |
// Copyright (C) 2005 RIKEN, Japan. All rights reserved. // |
| 67 |
|
|
| 68 |
function xoops_module_uninstall_xnpbulletin( $xoopsMod ) { |
function xoops_module_uninstall_xnpbulletin( $xoopsMod ) { |
| 69 |
global $xoopsDB; |
global $xoopsDB; |
| 70 |
|
|
| 71 |
|
$item_type_id = -1; |
| 72 |
|
$table = $xoopsDB->prefix('xoonips_item_type'); |
| 73 |
|
$mid = $xoopsMod->getVar('mid'); |
| 74 |
|
$sql = "SELECT item_type_id FROM $table where mid = $mid"; |
| 75 |
|
$result = $xoopsDB->query($sql); |
| 76 |
|
if ( $result ){ |
| 77 |
|
list($item_type_id) = $xoopsDB->fetchRow($result); |
| 78 |
|
}else{ |
| 79 |
|
echo mysql_error(); |
| 80 |
|
echo $sql; |
| 81 |
|
return false; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
// Set "Deleted" status in the item_status table for repository |
| 85 |
|
$table = $xoopsDB->prefix('xoonips_item_basic'); |
| 86 |
|
$sql = "SELECT item_id from ${table} WHERE item_type_id = $item_type_id"; |
| 87 |
|
$result = $xoopsDB->query($sql); |
| 88 |
|
if ( !$result ){ |
| 89 |
|
echo mysql_error(); |
| 90 |
|
echo $sql; |
| 91 |
|
return false; |
| 92 |
|
} |
| 93 |
|
$ids = array( ); |
| 94 |
|
while( list( $item_id ) = $xoopsDB->fetchRow($result) ){ |
| 95 |
|
$ids[] = $item_id; |
| 96 |
|
} |
| 97 |
|
if( count( $ids ) > 0 ){ |
| 98 |
|
$table = $xoopsDB->prefix('xoonips_item_status'); |
| 99 |
|
$sql = "UPDATE ${table} SET deleted_timestamp=UNIX_TIMESTAMP(NOW()), is_deleted=1 WHERE item_id in ( ".implode( ",", $ids ).")"; |
| 100 |
|
if ( $xoopsDB->query($sql) == FALSE ){ |
| 101 |
|
echo mysql_error(); |
| 102 |
|
echo $sql; |
| 103 |
|
return false; |
| 104 |
|
} |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
// remove basic information |
| 108 |
|
$table = $xoopsDB->prefix('xoonips_item_basic'); |
| 109 |
|
$sql = "DELETE FROM $table where item_type_id = $item_type_id"; |
| 110 |
|
if ( $xoopsDB->query($sql) == FALSE ){ |
| 111 |
|
echo mysql_error(); |
| 112 |
|
echo $sql; |
| 113 |
|
return false; |
| 114 |
|
} |
| 115 |
|
|
| 116 |
// unregister itemtype |
// unregister itemtype |
| 117 |
$table = $xoopsDB->prefix('xoonips_item_type'); |
$table = $xoopsDB->prefix('xoonips_item_type'); |
| 118 |
$mid = $xoopsMod->getVar('mid'); |
$mid = $xoopsMod->getVar('mid'); |
| 127 |
// cannot unregister filetype |
// cannot unregister filetype |
| 128 |
return false; |
return false; |
| 129 |
} |
} |
|
$table = $xoopsDB->prefix('xnpbulletin_item_detail_child_author'); |
|
|
$sql = "DROP TABLE $table"; |
|
|
if ( $xoopsDB->query($sql) == FALSE ){ |
|
|
// cannot unregister child_author |
|
|
return false; |
|
|
} |
|
|
$table = $xoopsDB->prefix('xnpbulletin_item_detail_child_keywords'); |
|
|
$sql = "DROP TABLE $table"; |
|
|
if ( $xoopsDB->query($sql) == FALSE ){ |
|
|
// cannot unregister child_keywords |
|
|
return false; |
|
|
} |
|
|
$table = $xoopsDB->prefix('xnpbulletin_item_detail_child_free_keywords'); |
|
|
$sql = "DROP TABLE $table"; |
|
|
if ( $xoopsDB->query($sql) == FALSE ){ |
|
|
// cannot unregister child_free_keywords |
|
|
return false; |
|
|
} |
|
| 130 |
return true; |
return true; |
| 131 |
} |
} |
| 132 |
|
|
| 134 |
|
|
| 135 |
global $xoopsDB; |
global $xoopsDB; |
| 136 |
switch ($oldversion) { //remember that version is multiplied with 100 to get an integer |
switch ($oldversion) { //remember that version is multiplied with 100 to get an integer |
| 137 |
|
case 200: |
| 138 |
|
$table = $xoopsDB->prefix("xnpbulletin_item_detail_child_author"); |
| 139 |
|
$sql = "ALTER TABLE $table ADD author_affiliation_translation varchar(255) NOT NULL"; |
| 140 |
|
$result = $xoopsDB->query($sql); |
| 141 |
|
if( !$result ){ |
| 142 |
|
echo "ERROR: " . $xoopsDB->error(); |
| 143 |
|
return false; |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
case 201: |
| 147 |
default: |
default: |
| 148 |
return true; |
return true; |
| 149 |
} |
} |