-
Notifications
You must be signed in to change notification settings - Fork 0
/
pseudo_hasard_administrations.php
executable file
·53 lines (45 loc) · 1.48 KB
/
pseudo_hasard_administrations.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
<?php
/*
* Plugin Pseudo Hasard
* (c) 2015 Julien Tessier
* Distribue sous licence GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
function pseudo_hasard_upgrade($nom_meta_base_version,$version_cible){
include_spip('base/objets');
$tables_objets = array_keys(lister_tables_objets_sql());
$maj = array();
$maj['create'] = array();
$trouver_table = charger_fonction('trouver_table','base');
foreach($tables_objets as $table){
$desc = $trouver_table($table);
if (!isset($desc['field']['pseudo_hasard'])) {
$maj['create'][] = array('sql_alter',"TABLE $table ADD pseudo_hasard FLOAT DEFAULT 0 NOT NULL");
}
}
include_spip('base/upgrade');
maj_plugin($nom_meta_base_version, $version_cible, $maj);
}
function pseudo_hasard_check_upgrade(){
include_spip('base/objets');
$tables_objets = array_keys(lister_tables_objets_sql());
$trouver_table = charger_fonction('trouver_table','base');
foreach($tables_objets as $table){
$desc = $trouver_table($table);
if (!isset($desc['field']['pseudo_hasard'])) {
sql_alter("TABLE $table ADD pseudo_hasard REAL DEFAULT 0 NOT NULL");
sql_update($table, array('pseudo_hasard' => 'RAND()'));
}
}
}
function pseudo_hasard_vider_tables($nom_meta_base_version) {
include_spip('inc/meta');
include_spip('base/abstract_sql');
include_spip('base/objets');
$tables_objets = array_keys(lister_tables_objets_sql());
foreach($tables_objets as $table){
sql_alter("TABLE $table DROP pseudo_hasard");
}
effacer_meta($nom_meta_base_version);
}