Develop and Download Open Source Software

Browse CVS Repository

Annotation of /xoonips-library/xoonips-library/install_funcs.php

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


Revision 1.1.1.1 - (hide annotations) (download) (as text) (vendor branch)
Wed Oct 25 05:43:46 2006 UTC (17 years, 5 months ago) by ken_ko
Branch: current, MAIN
CVS Tags: s051025, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: application/x-httpd-php
first check in xnparticle module(xoops module,xoonips library module).

1 ken_ko 1.1 <?php
2     // XooNIps article item type module
3     // $Revision: 1.00 $
4     // --------------------------------------------------------------------------
5     // XooNIps Library Module Xoops modules for XooNIps Platforms
6     // Copyright (C) 2006 Keio University and RIKEN, Japan. All rights reserved.
7     // http://sourceforge.jp/projects/xoonips-library/
8     // --------------------------------------------------------------------------
9     // This program is free software; you can redistribute it and/or
10     // modify it under the terms of the GNU General Public License
11     // as published by the Free Software Foundation; either version 2
12     // of the License, or (at your option) any later version.
13     //
14     // This program is distributed in the hope that it will be useful,
15     // but WITHOUT ANY WARRANTY; without even the implied warranty of
16     // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     // GNU General Public License for more details.
18     //
19     // You should have received a copy of the GNU General Public License
20     // along with this program; if not, write to the Free Software
21     // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22     // --------------------------------------------------------------------------
23    
24     function xoops_module_install_xnparticle( $xoopsMod ) {
25     global $xoopsDB;
26    
27     // register itemtype
28     $table = $xoopsDB->prefix('xoonips_item_type');
29     $mid = $xoopsMod->getVar('mid');
30     $sql = "INSERT INTO $table ( name, display_name, mid, viewphp ) VALUES ( 'xnparticle', 'Article', $mid, 'xnparticle/include/view.php' )";
31     if ( $xoopsDB->query($sql) == FALSE ){
32     // cannot register itemtype
33     return false;
34     }
35    
36     // register filetype
37     $table = $xoopsDB->prefix('xoonips_file_type');
38     $mid = $xoopsMod->getVar('mid');
39     $sql = "INSERT INTO $table ( name, display_name, mid ) VALUES ( 'article_attachment', 'Article attachment', $mid )";
40     if ( $xoopsDB->query($sql) == FALSE ){
41     // cannot register itemtype
42     return false;
43     }
44    
45     // Delete 'Module Access Rights' from all groups
46     // This allows to remove redundant module name in Main Menu
47     $member_handler =& xoops_gethandler('member');
48     $gperm_handler =& xoops_gethandler('groupperm');
49     $groups =& $member_handler->getGroupList();
50     foreach ($groups as $groupid2 => $groupname) {
51     if ($gperm_handler->checkRight('module_read', $mid, $groupid2)) {
52     $criteria = new CriteriaCompo();
53     $criteria->add( new Criteria( 'gperm_groupid', $groupid2 ) );
54     $criteria->add( new Criteria( 'gperm_itemid', $mid ) );
55     $criteria->add( new Criteria( 'gperm_name', 'module_read' ) );
56    
57     $objects = $gperm_handler->getObjects($criteria);
58     if ( count( $objects ) == 1 ){
59     $gperm_handler->delete( $objects[0] );
60     }
61     }
62     }
63    
64     //$item_type_id = $xoopsDB->getInsertId();
65     return true;
66     }
67    
68     function xoops_module_uninstall_xnparticle( $xoopsMod ) {
69     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
117     $table = $xoopsDB->prefix('xoonips_item_type');
118     $mid = $xoopsMod->getVar('mid');
119     $sql = "DELETE FROM $table where mid = $mid";
120     if ( $xoopsDB->query($sql) == FALSE ){
121     // cannot unregister itemtype
122     return false;
123     }
124     $table = $xoopsDB->prefix('xoonips_file_type');
125     $sql = "DELETE FROM $table where mid = $mid";
126     if ( $xoopsDB->query($sql) == FALSE ){
127     // cannot unregister filetype
128     return false;
129     }
130    
131     // drop detail_child_tables
132     $table = $xoopsDB->prefix('xnparticle_item_detail_child_author');
133     $sql = "DROP TABLE $table";
134     if ( $xoopsDB->query($sql) == FALSE ){
135     // cannot unregister child_author
136     return false;
137     }
138    
139     $table = $xoopsDB->prefix('xnparticle_item_detail_child_keywords');
140     $sql = "DROP TABLE $table";
141     if ( $xoopsDB->query($sql) == FALSE ){
142     // cannot unregister child_keywords
143     return false;
144     }
145    
146     $table = $xoopsDB->prefix('xnparticle_item_detail_child_sub_title');
147     $sql = "DROP TABLE $table";
148     if ( $xoopsDB->query($sql) == FALSE ){
149     // cannot unregister child_sub_title
150     return false;
151     }
152    
153     $table = $xoopsDB->prefix('xnparticle_item_detail_child_ndc_classifications');
154     $sql = "DROP TABLE $table";
155     if ( $xoopsDB->query($sql) == FALSE ){
156     // cannot unregister child_ndc_classification
157     return false;
158     }
159    
160     $table = $xoopsDB->prefix('xnparticle_item_detail_child_physical_descriptions');
161     $sql = "DROP TABLE $table";
162     if ( $xoopsDB->query($sql) == FALSE ){
163     // cannot unregister child_physical_description
164     return false;
165     }
166    
167     $table = $xoopsDB->prefix('xnparticle_item_detail_child_langs');
168     $sql = "DROP TABLE $table";
169     if ( $xoopsDB->query($sql) == FALSE ){
170     // cannot unregister child_lang
171     return false;
172     }
173    
174     $table = $xoopsDB->prefix('xnparticle_item_detail_child_id_issns');
175     $sql = "DROP TABLE $table";
176     if ( $xoopsDB->query($sql) == FALSE ){
177     // cannot unregister child_id_issn
178     return false;
179     }
180    
181     $table = $xoopsDB->prefix('xnparticle_item_detail_child_id_isbns');
182     $sql = "DROP TABLE $table";
183     if ( $xoopsDB->query($sql) == FALSE ){
184     // cannot unregister child_id_isbn
185     return false;
186     }
187    
188     $table = $xoopsDB->prefix('xnparticle_item_detail_child_id_dois');
189     $sql = "DROP TABLE $table";
190     if ( $xoopsDB->query($sql) == FALSE ){
191     // cannot unregister child_id_doi
192     return false;
193     }
194    
195     $table = $xoopsDB->prefix('xnparticle_item_detail_child_id_uris');
196     $sql = "DROP TABLE $table";
197     if ( $xoopsDB->query($sql) == FALSE ){
198     // cannot unregister child_id_uri
199     return false;
200     }
201    
202     $table = $xoopsDB->prefix('xnparticle_item_detail_child_id_locals');
203     $sql = "DROP TABLE $table";
204     if ( $xoopsDB->query($sql) == FALSE ){
205     // cannot unregister child_id_local
206     return false;
207     }
208    
209     $table = $xoopsDB->prefix('xnparticle_item_detail_child_uris');
210     $sql = "DROP TABLE $table";
211     if ( $xoopsDB->query($sql) == FALSE ){
212     // cannot unregister child_uri
213     return false;
214     }
215    
216     return true;
217     }
218    
219     function xoops_module_update_xnparticle ( $xoopsMod, $oldversion) {
220    
221     global $xoopsDB;
222     switch ($oldversion) { //remember that version is multiplied with 100 to get an integer
223     case 200:
224     $table = $xoopsDB->prefix("xnparticle_item_detail_child_author");
225     $sql = "ALTER TABLE $table ADD author_affiliation_translation varchar(255) NOT NULL";
226     $result = $xoopsDB->query($sql);
227     if( !$result ){
228     echo "ERROR: " . $xoopsDB->error();
229     return false;
230     }
231    
232     default:
233     return true;
234     }
235     return true;
236     }
237     ?>

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