Dotclear

source: plugins/rateIt/inc/class.rateit.install.php @ 1307

Revision 1307, 2.8 KB checked in by JcDenis, 14 years ago (diff)

rateIt 0.5:

  • fixed PostgreSQL compatibility
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of rateIt, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009 JC Denis and contributors
6# jcdenis@gdwd.com
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11#
12# -- END LICENSE BLOCK ------------------------------------
13
14if (!defined('DC_RC_PATH')) return;
15
16class rateItInstall
17{
18     public static function pluginsBeforeDelete($plugin)
19     {
20          if($plugin['id'] == 'rateIt') {
21               http::redirect('plugin.php?p=rateIt&t=uninstall');
22               exit;
23          }
24     }
25
26     public static function setTable(&$core)
27     {
28          $s = new dbStruct($core->con,$core->prefix);
29          $s->rateit
30               ->blog_id ('varchar',32,false)
31               ->rateit_id ('varchar',255,false)
32               ->rateit_type('varchar',64,false)
33               ->rateit_note ('float',0,false)
34               ->rateit_quotient ('float',0,false)
35               ->rateit_ip ('varchar',64,false)
36               ->rateit_time ('timestamp',0,false,'now()')
37               ->primary('pk_rateit','blog_id','rateit_type','rateit_id','rateit_ip')
38               ->index('idx_rateit_blog_id','btree','blog_id')
39               ->index('idx_rateit_rateit_type','btree','rateit_type')
40               ->index('idx_rateit_rateit_id','btree','rateit_id')
41               ->index('idx_rateit_rateit_ip','btree','rateit_ip');
42
43          $si = new dbStruct($core->con,$core->prefix);
44          $changes = $si->synchronize($s);
45     }
46
47     public static function delTable(&$core)
48     {
49          @$core->con->execute('TRUNCATE TABLE '.$core->con->escape($core->prefix.'rateit').'');
50          @$core->con->execute('DROP TABLE '.$core->con->escape($core->prefix.'rateit').'');
51     }
52
53     public static function setSettings(&$core,$glob=false,$force=false)
54     {
55          $core->blog->settings->setNameSpace('rateit');
56          $core->blog->settings->put('rateit_active',false,'boolean','rateit plugin enabled',$force,$glob);
57          $core->blog->settings->put('rateit_poststpl',false,'boolean','rateit template on post',$force,$glob);
58          $core->blog->settings->put('rateit_quotient',5,'integer','rateit maximum note',$force,$glob);
59          $core->blog->settings->put('rateit_digit',1,'integer','rateit note digits number',$force,$glob);
60          $core->blog->settings->put('rateit_msgthanks','Thank you for having voted','string','rateit message when voted',$force,$glob);
61          $core->blog->settings->put('rateit_userident',0,'integer','rateit use cookie and/or ip',$force,$glob);
62     }
63
64     public static function delSettings(&$core)
65     {
66          $core->con->execute('DELETE FROM '.$core->prefix.'setting WHERE setting_ns = \'rateit\' ');
67     }
68
69     public static function setVersion(&$core)
70     {
71          $core->setVersion('rateIt',$core->plugins->moduleInfo('rateIt','version'));
72     }
73
74     public static function delVersion(&$core)
75     {
76          $core->delVersion('rateIt');
77     }
78
79     public static function delModule(&$core)
80     {
81          $core->plugins->deleteModule('rateIt');
82     }
83}
84?>
Note: See TracBrowser for help on using the repository browser.

Sites map