Develop and Download Open Source Software

Browse CVS Repository

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

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


Revision 1.1 - (hide annotations) (download) (as text)
Wed Jul 5 08:06:49 2006 UTC (17 years, 9 months ago) by ken_ko
Branch point for: MAIN, keio
File MIME type: application/x-httpd-php
Initial revision

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

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