/[drupal]/contributions/modules/usernode/usernode.install
ViewVC logotype

Contents of /contributions/modules/usernode/usernode.install

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


Revision 1.8 - (show annotations) (download) (as text)
Fri Oct 12 14:26:59 2007 UTC (2 years, 1 month ago) by fago
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +2 -1 lines
File MIME type: text/x-php
#182393 fixed uninstallation procedure
1 <?php
2 // $Id: usernode.install,v 1.7 2007/09/11 13:27:58 fago Exp $
3
4 if (!defined('USERNODE_CONTENT_TYPE')) {
5 //if the module isn't included yet, we need to make this define so that things are working...
6 define('USERNODE_CONTENT_TYPE', "usernode");
7 }
8
9 function usernode_install() {
10 switch ($GLOBALS['db_type']) {
11 case 'mysqli':
12 case 'mysql':
13 db_query("CREATE TABLE if not exists {usernode} (
14 nid int(10) unsigned NOT NULL,
15 uid int(10) unsigned NOT NULL,
16 PRIMARY KEY(uid,nid)
17 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
18 break;
19 case 'pgsql':
20 db_query("CREATE TABLE {usernode} (
21 nid int_unsigned NOT NULL,
22 uid int_unsigned NOT NULL,
23 PRIMARY KEY(uid,nid)
24 )");
25 break;
26 default:
27 break;
28 }
29
30 // Prevent the promotion of new usernode objects to the front page by default,
31 // by only placing 'status' (the 'Published' option) into the node options.
32 variable_set('node_options_'. USERNODE_CONTENT_TYPE, array('status'));
33 }
34
35 function usernode_uninstall() {
36 include_once(drupal_get_path('module', 'usernode') .'/usernode.module');
37 // We can't call node_type_delete() because usernode_delete() forbids that,
38 // so let's find and delete the usernodes manually
39 $result = db_query("SELECT u.* FROM {users} u ".
40 "JOIN {node} n ON u.uid = n.uid ".
41 "WHERE n.type = '". USERNODE_CONTENT_TYPE ."'");
42
43 while ($user = db_fetch_object($result)) {
44 usernode_delete_node($user);
45 }
46
47 db_query("DROP TABLE {usernode}");
48 db_query("DELETE FROM {node_type} WHERE type = '". USERNODE_CONTENT_TYPE ."'");
49 variable_del('node_options_'. USERNODE_CONTENT_TYPE);
50 }
51
52 /*
53 * Set the nodefamily maximum population, so that nodefamily knows that usernodes are lonely nodes
54 */
55 function usernode_update_1() {
56 if (module_exists('nodefamily')) {
57 nodefamily_content_type_set_max(USERNODE_CONTENT_TYPE, 1);
58 }
59 return array();
60 }
61
62 function usernode_update_2() {
63 //when the define was missing during installation, a wrong variable has been created
64 //this update removes it
65 variable_del('node_options_USERNODE_CONTENT_TYPE');
66 return array();
67 }

  ViewVC Help
Powered by ViewVC 1.1.2