Develop and Download Open Source Software

Browse CVS Repository

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

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


Revision 1.3 - (hide annotations) (download) (as text)
Wed Apr 12 04:46:14 2006 UTC (18 years ago) by yamaji
Branch: MAIN
Changes since 1.2: +48 -3 lines
File MIME type: application/x-httpd-php
In order to correspond with the merging works of original XooNIps current version.

1 yamaji 1.1 <?php
2 yamaji 1.3 // Install script for bulletin module //
3     // $Revision: 1.2 $ //
4 yamaji 1.1 // -------------------------------------------------------------------------- //
5     // XooNIps Xoops modules for Neuroinformatics Platforms //
6     // Copyright (C) 2005 RIKEN, Japan. All rights reserved. //
7     // http://sourceforge.jp/projects/xoonips/ //
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_xnpbulletin( $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 ( 'xnpbulletin', 'Bulletin', $mid, 'xnpbulletin/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 ( 'bulletin_attachment', 'Bulletin 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_xnpbulletin( $xoopsMod ) {
69     global $xoopsDB;
70 yamaji 1.3
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 yamaji 1.1 // 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     $table = $xoopsDB->prefix('xnpbulletin_item_detail_child_author');
131     $sql = "DROP TABLE $table";
132     if ( $xoopsDB->query($sql) == FALSE ){
133     // cannot unregister child_author
134     return false;
135     }
136     $table = $xoopsDB->prefix('xnpbulletin_item_detail_child_keywords');
137     $sql = "DROP TABLE $table";
138     if ( $xoopsDB->query($sql) == FALSE ){
139     // cannot unregister child_keywords
140     return false;
141     }
142     $table = $xoopsDB->prefix('xnpbulletin_item_detail_child_free_keywords');
143     $sql = "DROP TABLE $table";
144     if ( $xoopsDB->query($sql) == FALSE ){
145     // cannot unregister child_free_keywords
146     return false;
147     }
148     return true;
149     }
150    
151     function xoops_module_update_xnpbulletin ( $xoopsMod, $oldversion) {
152    
153     global $xoopsDB;
154     switch ($oldversion) { //remember that version is multiplied with 100 to get an integer
155     default:
156     return true;
157     }
158     return true;
159     }
160     ?>

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