| 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'); |