Develop and Download Open Source Software

Browse CVS Repository

Contents of /xoonips-library/xnprarebook/install_funcs.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.1.1 - (show annotations) (download) (as text) (vendor branch)
Tue Jul 4 10:04:25 2006 UTC (17 years, 9 months ago) by ken_ko
Branch: MAIN, keio
CVS Tags: v1, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: application/x-httpd-php
貴重書アイテムタイプ:xnprarebookの初期登録です。

1 <?php
2 // Install script for rarebook module //
3 // $Revision: $ //
4 // -------------------------------------------------------------------------- //
5 // XNPRAREBOOK is a XooNIps item type module. //
6 // It's being developed for Library mainly. //
7 // Copyright (C) 2006 RIKEN & KEIO University, Japan. All rights reserved. //
8 // http://sourceforge.jp/projects/xoonips-library/ //
9 // -------------------------------------------------------------------------- //
10 // This program is free software; you can redistribute it and/or //
11 // modify it under the terms of the GNU General Public License //
12 // as published by the Free Software Foundation; either version 2 //
13 // of the License, or (at your option) any later version. //
14 // //
15 // This program is distributed in the hope that it will be useful, //
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
18 // GNU General Public License for more details. //
19 // //
20 // You should have received a copy of the GNU General Public License //
21 // along with this program; if not, write to the Free Software //
22 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //
23 // -------------------------------------------------------------------------- //
24
25 function xoops_module_install_xnprarebook( $xoopsMod ) {
26 global $xoopsDB;
27
28 // register itemtype
29 $table = $xoopsDB->prefix('xoonips_item_type');
30 $mid = $xoopsMod->getVar('mid');
31 $sql = "INSERT INTO $table ( name, display_name, mid, viewphp ) VALUES ( 'xnprarebook', 'Rarebook', $mid, 'xnprarebook/include/view.php' )";
32 if ( $xoopsDB->query($sql) == FALSE ){
33 // cannot register itemtype
34 return false;
35 }
36
37 // register filetype
38 $table = $xoopsDB->prefix('xoonips_file_type');
39 $mid = $xoopsMod->getVar('mid');
40 $sql = "INSERT INTO $table ( name, display_name, mid ) VALUES ( 'rarebook_attachment', 'Rarebook attachment', $mid )";
41 if ( $xoopsDB->query($sql) == FALSE ){
42 // cannot register itemtype
43 return false;
44 }
45
46 // Delete 'Module Access Rights' from all groups
47 // This allows to remove redundant module name in Main Menu
48 $member_handler =& xoops_gethandler('member');
49 $gperm_handler =& xoops_gethandler('groupperm');
50 $groups =& $member_handler->getGroupList();
51 foreach ($groups as $groupid2 => $groupname) {
52 if ($gperm_handler->checkRight('module_read', $mid, $groupid2)) {
53 $criteria = new CriteriaCompo();
54 $criteria->add( new Criteria( 'gperm_groupid', $groupid2 ) );
55 $criteria->add( new Criteria( 'gperm_itemid', $mid ) );
56 $criteria->add( new Criteria( 'gperm_name', 'module_read' ) );
57
58 $objects = $gperm_handler->getObjects($criteria);
59 if ( count( $objects ) == 1 ){
60 $gperm_handler->delete( $objects[0] );
61 }
62 }
63 }
64
65 //$item_type_id = $xoopsDB->getInsertId();
66 return true;
67 }
68
69 function xoops_module_uninstall_xnprarebook( $xoopsMod ) {
70 global $xoopsDB;
71
72 $item_type_id = -1;
73 $table = $xoopsDB->prefix('xoonips_item_type');
74 $mid = $xoopsMod->getVar('mid');
75 $sql = "SELECT item_type_id FROM $table where mid = $mid";
76 $result = $xoopsDB->query($sql);
77 if ( $result ){
78 list($item_type_id) = $xoopsDB->fetchRow($result);
79 }else{
80 echo mysql_error();
81 echo $sql;
82 return false;
83 }
84
85 // Set "Deleted" status in the item_status table for repository
86 $table = $xoopsDB->prefix('xoonips_item_basic');
87 $sql = "SELECT item_id from ${table} WHERE item_type_id = $item_type_id";
88 $result = $xoopsDB->query($sql);
89 if ( !$result ){
90 echo mysql_error();
91 echo $sql;
92 return false;
93 }
94 $ids = array( );
95 while( list( $item_id ) = $xoopsDB->fetchRow($result) ){
96 $ids[] = $item_id;
97 }
98 if( count( $ids ) > 0 ){
99 $table = $xoopsDB->prefix('xoonips_item_status');
100 $sql = "UPDATE ${table} SET deleted_timestamp=UNIX_TIMESTAMP(NOW()), is_deleted=1 WHERE item_id in ( ".implode( ",", $ids ).")";
101 if ( $xoopsDB->query($sql) == FALSE ){
102 echo mysql_error();
103 echo $sql;
104 return false;
105 }
106 }
107
108 // remove basic information
109 $table = $xoopsDB->prefix('xoonips_item_basic');
110 $sql = "DELETE FROM $table where item_type_id = $item_type_id";
111 if ( $xoopsDB->query($sql) == FALSE ){
112 echo mysql_error();
113 echo $sql;
114 return false;
115 }
116
117 // unregister itemtype
118 $table = $xoopsDB->prefix('xoonips_item_type');
119 $mid = $xoopsMod->getVar('mid');
120 $sql = "DELETE FROM $table where mid = $mid";
121 if ( $xoopsDB->query($sql) == FALSE ){
122 // cannot unregister itemtype
123 return false;
124 }
125 $table = $xoopsDB->prefix('xoonips_file_type');
126 $sql = "DELETE FROM $table where mid = $mid";
127 if ( $xoopsDB->query($sql) == FALSE ){
128 // cannot unregister filetype
129 return false;
130 }
131 $table = $xoopsDB->prefix('xnprarebook_item_detail_child_author');
132 $sql = "DROP TABLE $table";
133 if ( $xoopsDB->query($sql) == FALSE ){
134 // cannot unregister child_author
135 return false;
136 }
137 $table = $xoopsDB->prefix('xnprarebook_item_detail_child_keywords');
138 $sql = "DROP TABLE $table";
139 if ( $xoopsDB->query($sql) == FALSE ){
140 // cannot unregister child_keywords
141 return false;
142 }
143 $table = $xoopsDB->prefix('xnprarebook_item_detail_child_free_keywords');
144 $sql = "DROP TABLE $table";
145 if ( $xoopsDB->query($sql) == FALSE ){
146 // cannot unregister child_free_keywords
147 return false;
148 }
149 return true;
150 }
151
152 function xoops_module_update_xnprarebook ( $xoopsMod, $oldversion) {
153
154 global $xoopsDB;
155 switch ($oldversion) { //remember that version is multiplied with 100 to get an integer
156 case 200:
157 $table = $xoopsDB->prefix("xnprarebook_item_detail_child_author");
158 $sql = "ALTER TABLE $table ADD author_affiliation_translation varchar(255) NOT NULL";
159 $result = $xoopsDB->query($sql);
160 if( !$result ){
161 echo "ERROR: " . $xoopsDB->error();
162 return false;
163 }
164
165 case 201:
166 default:
167 return true;
168 }
169 return true;
170 }
171 ?>

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26