-
Notifications
You must be signed in to change notification settings - Fork 0
/
method.install.php
137 lines (115 loc) · 3.64 KB
/
method.install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
#-------------------------------------------------------------------------
# Module: Inscriptions
# Version: 0.5, Claude SIOHAN
# Method: Install
#-------------------------------------------------------------------------
/**
* For separated methods, you'll always want to start with the following
* line which check to make sure that method was called from the module
* API, and that everything's safe to continue:
*/
if (!isset($gCms)) exit;
/**
* After this, the code is identical to the code that would otherwise be
* wrapped in the Install() method in the module body.
*/
$db = $gCms->GetDb();
// mysql-specific, but ignored by other database
$taboptarray = array( 'mysql' => 'ENGINE=MyISAM' );
$dict = NewDataDictionary( $db );
// table schema description
$flds = "
id I(11) AUTO KEY,
nom C(255),
description X,
date_limite I(11),
date_debut I(11),
date_fin I(11),
actif I(1) DEFAULT 0,
groupe I(3) DEFAULT 0,
choix_multi I(1),
group_notif I(3),
timbre I(11) DEFAULT 0,
occurence I(11),
ext I(1),
start_collect I(11),
collect_mode I(1) DEFAULT 0,
end_collect I(11),
tag C(255),
partners I(2) DEFAULT 0";
$sqlarray = $dict->CreateTableSQL( cms_db_prefix()."module_inscriptions_inscriptions", $flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
//
// mysql-specific, but ignored by other database
$taboptarray = array( 'mysql' => 'ENGINE=MyISAM' );
$dict = NewDataDictionary( $db );
// table schema description
$flds = "
id I(11) AUTO KEY,
id_inscription I(11),
nom C(255),
description X,
date_debut I(11),
date_fin I(11),
actif I(1),
tarif F,
groupe I(1) DEFAULT 0,
timbre I(11) DEFAULT 0,
jauge I(9) DEFAULT 0";
$sqlarray = $dict->CreateTableSQL( cms_db_prefix()."module_inscriptions_options", $flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
//
// mysql-specific, but ignored by other database
$taboptarray = array( 'mysql' => 'ENGINE=MyISAM' );
$dict = NewDataDictionary( $db );
// table schema description
$flds = "
id I(11) AUTO KEY,
id_inscription I(11),
id_option I(11),
genid I(11),
referent I(11),
checked I(1) DEFAULT 0,
timbre I(11)";
$sqlarray = $dict->CreateTableSQL( cms_db_prefix()."module_inscriptions_belongs", $flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
//
// mysql-specific, but ignored by other database
$taboptarray = array( 'mysql' => 'ENGINE=MyISAM' );
//Permissions
$this->CreatePermission('Inscriptions use', 'Utiliser le module Inscriptions');
//mails templates
# Mails templates
$fn = cms_join_path(dirname(__FILE__),'templates','orig_relanceemailtemplate.tpl');
if( file_exists( $fn ) )
{
$template = file_get_contents( $fn );
$this->SetTemplate('relanceemail',$template);
}
$fn = cms_join_path(dirname(__FILE__),'templates','orig_send_email.tpl');
if( file_exists( $fn ) )
{
$template = file_get_contents( $fn );
$this->SetTemplate('send_email',$template);
}
# Les index
//on créé un index sur la table
$idxoptarray = array('UNIQUE');
$sqlarray = $dict->CreateIndexSQL(cms_db_prefix().'choix_multi',
cms_db_prefix().'module_inscriptions_belongs', 'id_option,genid',$idxoptarray);
$dict->ExecuteSQLArray($sqlarray);
# Les préférences
$this->SetPreference('admin_email', 'root@localhost.com');
$this->SetPreference('last_updated', time());
$this->SetPreference('default_group', 0);
$this->SetPreference('pageid_inscriptions', '');
$this->SetPreference('LastSendNotification', time());
$this->SetPreference('Interval', 900);
$this->SetPreference('collect_mode', 0);
$this->SetPreference('use_messages', 0);
// put mention into the admin log
$this->Audit( 0,
$this->Lang('friendlyname'),
$this->Lang('installed', $this->GetVersion()) );
?>