source: extensions/NBC_News/trunk/maintain.inc.php @ 15824

Last change on this file since 15824 was 5179, checked in by Eric, 15 years ago

[NBC_News]

  • Initial commit for Piwigo 2.0.x : Not fully functionnal and a lot work to do...
  • Property svn:eol-style set to LF
File size: 4.4 KB
Line 
1<?php
2
3if(!defined("NBC_NEWS_PATH"))
4  define('NBC_NEWS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
5
6include_once(NBC_NEWS_PATH.'include/constants.php');
7
8
9function plugin_install()
10{
11  $q = '
12    INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
13    VALUES ("nbc_News","3;10;5,10,25,50;","Parametres nbc_News");
14  ';
15
16  pwg_query($q);
17
18  $q = '
19    CREATE TABLE '.NEWS_TABLE.' (
20      id smallint(5) unsigned NOT NULL auto_increment,
21      date datetime NOT NULL default \'0000-00-00 00:00:00\',
22      author varchar(255) default NULL,
23      status enum(\'public\',\'private\') NOT NULL default \'public\',
24      PRIMARY KEY (id)
25    ) ENGINE=MyISAM;
26  ';
27  pwg_query($q);
28
29  $q = '
30    insert into phpwebgallery_news values (1, \'2008-01-01 12:00:00\', \'Nicco\', \'public\');
31  ';
32  pwg_query($q);
33
34  $q = '
35    CREATE TABLE '.NEWS_GROUP_ACCESS_TABLE.' (
36      group_id smallint(5) unsigned NOT NULL default \'0\',
37      new_id smallint(5) unsigned NOT NULL default \'0\',
38      PRIMARY KEY (group_id, new_id)
39    ) ENGINE=MyISAM;
40  ';
41  pwg_query($q);
42 
43  $q = '
44    CREATE TABLE '.NEWS_GROUP_REFUSED_TABLE.' (
45      group_id smallint(5) unsigned NOT NULL default \'0\',
46      new_id smallint(5) unsigned NOT NULL default \'0\',
47      PRIMARY KEY (group_id, new_id)
48    ) ENGINE=MyISAM;
49  ';
50  pwg_query($q);
51
52
53
54  $q = '
55    CREATE TABLE '.NEWS_TRANSLATION_TABLE.' (
56      id smallint(6) unsigned NOT NULL auto_increment,
57      new_id smallint(5) unsigned NOT NULL default \'0\',
58      language varchar(50) NOT NULL default \'fr_FR.iso-8859-1\',
59      title varchar(150) default NULL,
60      content longtext ,
61      PRIMARY KEY (id)
62    ) ENGINE=MyISAM;
63  ';
64  pwg_query($q);
65 
66  $q = '
67    insert  into '.NEWS_TRANSLATION_TABLE.' values
68      (1, 1, \'fr_FR.iso-8859-1\', \'Systeme de News PWG installe\', \'Felicitation ! Le systeme de News pour PWG a ete installe !\'),
69      (2, 1, \'en_UK.iso-8859-1\', \'PWG News system installed\', \'Congratulation ! The news system for PWG has been installed !\');
70  ';
71  pwg_query($q);
72
73  $q = '
74    CREATE TABLE '.NEWS_USER_ACCESS_TABLE.' (
75      user_id smallint(5) NOT NULL,
76      new_id smallint(5) NOT NULL
77    ) ENGINE=MyISAM;
78  ';
79  pwg_query($q);
80 
81  $q = '
82    CREATE TABLE '.NEWS_USER_REFUSED_TABLE.' (
83      user_id smallint(5) NOT NULL,
84      new_id smallint(5) NOT NULL
85    ) ENGINE=MyISAM;
86  ';
87  pwg_query($q);
88
89}
90
91function plugin_deactivate()
92{
93  @unlink( PHPWG_ROOT_PATH.'news.php' );
94}
95
96function plugin_uninstall()
97{
98  global $conf;
99
100  if (isset($conf['nbc_News']))
101  {
102    $q = '
103      DELETE FROM '.CONFIG_TABLE.'
104      WHERE param="nbc_News" LIMIT 1;
105    ';
106
107    pwg_query($q);
108  }
109
110  $q = 'DROP TABLE '.NEWS_TABLE.'_SAV';
111  pwg_query($q);
112 
113  $q = 'DROP TABLE '.NEWS_GROUP_ACCESS_TABLE.'_SAV';
114  pwg_query($q);
115 
116  $q = 'DROP TABLE '.NEWS_GROUP_REFUSED_TABLE.'_SAV';
117  pwg_query($q);
118
119  $q = 'DROP TABLE '.NEWS_TRANSLATION_TABLE.'_SAV';
120  pwg_query($q);
121 
122  $q = 'DROP TABLE '.NEWS_USER_ACCESS_TABLE.'_SAV';
123  pwg_query($q);
124 
125  $q = 'DROP TABLE '.NEWS_USER_REFUSED_TABLE.'_SAV';
126  pwg_query($q);
127
128
129
130  $q = 'CREATE TABLE '.NEWS_TABLE.'_SAV AS SELECT * FROM '.NEWS_TABLE.'';
131  pwg_query($q);
132 
133  $q = 'CREATE TABLE '.NEWS_GROUP_ACCESS_TABLE.'_SAV AS SELECT * FROM '.NEWS_GROUP_ACCESS_TABLE.'';
134  pwg_query($q);
135 
136  $q = 'CREATE TABLE '.NEWS_GROUP_REFUSED_TABLE.'_SAV AS SELECT * FROM '.NEWS_GROUP_REFUSED_TABLE.'';
137  pwg_query($q);
138
139  $q = 'CREATE TABLE '.NEWS_TRANSLATION_TABLE.'_SAV AS SELECT * FROM '.NEWS_TRANSLATION_TABLE.'';
140  pwg_query($q);
141 
142  $q = 'CREATE TABLE '.NEWS_USER_ACCESS_TABLE.'_SAV AS SELECT * FROM '.NEWS_USER_ACCESS_TABLE.'';
143  pwg_query($q);
144 
145  $q = 'CREATE TABLE '.NEWS_USER_REFUSED_TABLE.'_SAV AS SELECT * FROM '.NEWS_USER_REFUSED_TABLE.'';
146  pwg_query($q);
147
148
149
150  $q = 'DROP TABLE '.NEWS_TABLE.'';
151  pwg_query($q);
152 
153  $q = 'DROP TABLE '.NEWS_GROUP_ACCESS_TABLE.'';
154  pwg_query($q);
155 
156  $q = 'DROP TABLE '.NEWS_GROUP_REFUSED_TABLE.'';
157  pwg_query($q);
158
159  $q = 'DROP TABLE '.NEWS_TRANSLATION_TABLE.'';
160  pwg_query($q);
161 
162  $q = 'DROP TABLE '.NEWS_USER_ACCESS_TABLE.'';
163  pwg_query($q);
164 
165  $q = 'DROP TABLE '.NEWS_USER_REFUSED_TABLE.'';
166  pwg_query($q);
167 
168  @unlink( dirname(__FILE__).'/_nbcnews_config.dat' );
169}
170
171function plugin_activate()
172{
173  $dir_name = basename( dirname(__FILE__) );
174  $c = <<<EOD
175<?php
176define('PHPWG_ROOT_PATH','./');
177include_once( PHPWG_ROOT_PATH. 'plugins/$dir_name/news.php');
178?>
179EOD;
180  $fp = fopen( PHPWG_ROOT_PATH.'news.php', 'w' );
181  fwrite( $fp, $c);
182  fclose( $fp );
183}
184
185?>
Note: See TracBrowser for help on using the repository browser.