Line 33... |
Line 33... |
33 |
public function executer() {
|
33 |
public function executer() {
|
34 |
$cmd = $this->getParametre('a');
|
34 |
$cmd = $this->getParametre('a');
|
35 |
$this->mode_verbeux = $this->getParametre('v');
|
35 |
$this->mode_verbeux = $this->getParametre('v');
|
Line 36... |
Line 36... |
36 |
|
36 |
|
- |
|
37 |
switch($cmd) {
|
- |
|
38 |
case 'tout' :
|
- |
|
39 |
$this->migrerObservations();
|
- |
|
40 |
$this->migrerObsEtendusChampsUtilisateur();
|
- |
|
41 |
$this->migrerObsEtendusUtilisateur();
|
- |
|
42 |
$this->migrerObsEtendusProjet();
|
- |
|
43 |
$this->migrerMotsClesObs();
|
- |
|
44 |
$this->migrerMotsClesObsLiaison();
|
- |
|
45 |
$this->migrerImages();
|
- |
|
46 |
$this->migrerMotsClesImages();
|
- |
|
47 |
$this->migrerMotsClesImagesLiaison();
|
- |
|
48 |
$this->ajouterIdProjet();
|
37 |
switch($cmd) {
|
49 |
break;
|
38 |
case 'obs':
|
50 |
case 'obs':
|
39 |
$this->migrerObservations();
|
51 |
$this->migrerObservations();
|
40 |
break;
|
52 |
break;
|
41 |
case 'obs_etendus':
|
53 |
case 'obs_etendus':
|
Line 52... |
Line 64... |
52 |
break;
|
64 |
break;
|
53 |
case 'images_tag':
|
65 |
case 'images_tag':
|
54 |
$this->migrerMotsClesImages();
|
66 |
$this->migrerMotsClesImages();
|
55 |
$this->migrerMotsClesImagesLiaison();
|
67 |
$this->migrerMotsClesImagesLiaison();
|
56 |
break;
|
68 |
break;
|
- |
|
69 |
case 'projet_id':
|
- |
|
70 |
$this->ajouterIdProjet();
|
- |
|
71 |
break;
|
57 |
default:
|
72 |
default:
|
58 |
echo 'Méthode inconnue, les méthodes possibles sont obs et images'."\n";
|
73 |
echo 'Méthode inconnue, les méthodes possibles sont obs et images'."\n";
|
59 |
}
|
74 |
}
|
60 |
}
|
75 |
}
|
Line 76... |
Line 91... |
76 |
private function migrerObsEtendusChampsUtilisateur() {
|
91 |
private function migrerObsEtendusChampsUtilisateur() {
|
77 |
$requete = "ALTER TABLE ".$this->bd_new_cel.".`user_custom_field` ADD `field_id` VARCHAR(500) NOT NULL AFTER `default_value`;";
|
92 |
$requete = "ALTER TABLE ".$this->bd_new_cel.".`user_custom_field` ADD `field_id` VARCHAR(500) NOT NULL AFTER `default_value`;";
|
78 |
$this->bdd->requeter($requete);
|
93 |
$this->bdd->requeter($requete);
|
79 |
$requete = "INSERT INTO ".$this->bd_new_cel.".`user_custom_field`
|
94 |
$requete = "INSERT INTO ".$this->bd_new_cel.".`user_custom_field`
|
80 |
(name, data_type, default_value, field_id)
|
95 |
(name, data_type, default_value, field_id)
|
81 |
SELECT label, type, valeur, cle
|
96 |
SELECT label, 'text', '', cle
|
82 |
FROM ".$this->bd_cel.".`cel_catalogue_champs_etendus`
|
97 |
FROM ".$this->bd_cel.".`cel_catalogue_champs_etendus`
|
83 |
WHERE `cle` not in (SELECT `champ` FROM `cel_catalogue_champs_etendus_liaison`)";
|
98 |
WHERE `cle` not in (SELECT `champ` FROM `cel_catalogue_champs_etendus_liaison`)";
|
84 |
$this->bdd->requeter($requete);
|
99 |
$this->bdd->requeter($requete);
|
85 |
}
|
100 |
}
|
Line 86... |
Line 101... |
86 |
|
101 |
|
87 |
private function migrerObsEtendusUtilisateur() {
|
102 |
private function migrerObsEtendusUtilisateur() {
|
88 |
$requete = "INSERT INTO ".$this->bd_new_cel.".`user_custom_field_occurrence`
|
103 |
$requete = "INSERT INTO ".$this->bd_new_cel.".`user_custom_field_occurrence`
|
89 |
(`occurrence_id`, `user_custom_field_id`, `value`)
|
104 |
(`occurrence_id`, `user_custom_field_id`, `value`)
|
90 |
SELECT `id_observation`, id, `valeur`
|
105 |
SELECT `id_observation`, id, `valeur`
|
91 |
FROM ".$this->bd_cel.".`cel_obs_etendues`
|
106 |
FROM ".$this->bd_cel.".`cel_obs_etendues`
|
- |
|
107 |
RIGHT JOIN ".$this->bd_new_cel.".`user_custom_field` ON field_id = cle
|
92 |
LEFT JOIN ".$this->bd_new_cel.".`user_custom_field` ON field_id = cle";
|
108 |
WHERE id_observation in (select id FROM `occurrence`)";
|
93 |
$this->bdd->requeter($requete);
|
109 |
$this->bdd->requeter($requete);
|
Line 94... |
Line 110... |
94 |
}
|
110 |
}
|
95 |
|
111 |
|
96 |
|
112 |
|
97 |
private function migrerObsEtendusProjet() {
|
113 |
private function migrerObsEtendusProjet() {
|
98 |
$requete = "INSERT INTO ".$this->bd_new_cel.".`extended_field_occurrence`
|
114 |
$requete = "INSERT INTO ".$this->bd_new_cel.".`extended_field_occurrence`
|
99 |
(`occurrence_id`, `extended_field_id`, `value`)
|
115 |
(`occurrence_id`, `extended_field_id`, `value`)
|
100 |
SELECT `id_observation`, id, `valeur`
|
116 |
SELECT `id_observation`, id, `valeur`
|
101 |
FROM ".$this->bd_cel.".`cel_obs_etendues`
|
117 |
FROM ".$this->bd_cel.".`cel_obs_etendues`
|
102 |
RIGHT JOIN ".$this->bd_new_cel.".`extended_field` ON field_id = cle
|
118 |
RIGHT JOIN ".$this->bd_new_cel.".`extended_field` ON field_id = cle
|
Line 103... |
Line 119... |
103 |
WHERE id_observation in (select id FROM `occurrence`)";
|
119 |
WHERE id_observation in (select id FROM ".$this->bd_new_cel.".`occurrence`)";
|
104 |
$this->bdd->requeter($requete);
|
120 |
$this->bdd->requeter($requete);
|
Line 125... |
Line 141... |
125 |
date_updated, date_created, date_linked_to_occurrence, content_url, url)
|
141 |
date_updated, date_created, date_linked_to_occurrence, content_url, url)
|
126 |
SELECT id_image, ce_observation, ce_utilisateur, prenom_utilisateur,
|
142 |
SELECT id_image, ce_observation, ce_utilisateur, prenom_utilisateur,
|
127 |
courriel_utilisateur, date_prise_de_vue, nom_original,'' , date_modification,
|
143 |
courriel_utilisateur, date_prise_de_vue, nom_original,'' , date_modification,
|
128 |
date_creation, date_liaison, '', concat('http://api.tela-botanica.org/img:000', '', `id_image`,
|
144 |
date_creation, date_liaison, '', concat('http://api.tela-botanica.org/img:000', '', `id_image`,
|
129 |
'O.jpg')
|
145 |
'O.jpg')
|
130 |
FROM ".$this->bd_cel.".cel_images
|
146 |
FROM ".$this->bd_cel.".cel_images";
|
131 |
WHERE ";
|
- |
|
132 |
$this->bdd->requeter($requete);
|
147 |
$this->bdd->requeter($requete);
|
133 |
}
|
148 |
}
|
Line 134... |
Line 149... |
134 |
|
149 |
|
135 |
private function migrerMotsClesImages() {
|
150 |
private function migrerMotsClesImages() {
|
Line 144... |
Line 159... |
144 |
$requete = "INSERT INTO ".$this->bd_new_cel.".photo_tag_photo
|
159 |
$requete = "INSERT INTO ".$this->bd_new_cel.".photo_tag_photo
|
145 |
(photo_id, photo_tag_id)
|
160 |
(photo_id, photo_tag_id)
|
146 |
SELECT `id_element_lie`, `id_mot_cle` FROM ".$this->bd_cel.".`cel_mots_cles_images_liaison`";
|
161 |
SELECT `id_element_lie`, `id_mot_cle` FROM ".$this->bd_cel.".`cel_mots_cles_images_liaison`";
|
147 |
$this->bdd->requeter($requete);
|
162 |
$this->bdd->requeter($requete);
|
148 |
}
|
163 |
}
|
- |
|
164 |
|
- |
|
165 |
private function ajouterIdProjet() {
|
- |
|
166 |
$requete = "UPDATE ".$this->bd_new_cel.".`project_settings` SET `project_id` = `id`";
|
- |
|
167 |
$this->bdd->requeter($requete);
|
- |
|
168 |
$requete = "INSERT INTO `tb_project`(`id`, `label`, `is_private`) SELECT `id`, `project`, '0' FROM `project_settings` ";
|
- |
|
169 |
$this->bdd->requeter($requete);
|
- |
|
170 |
$requete = "UPDATE `extended_field` f right join `project_settings` s on
|
- |
|
171 |
s.`project` = f.`project` SET f.`project_id` = s.`project_id`";
|
- |
|
172 |
$this->bdd->requeter($requete);
|
- |
|
173 |
$requete = "UPDATE `occurrence` o right join `project_settings` s on
|
- |
|
174 |
s.`project` = o.`project` SET o.`project_id` = s.`project_id`";
|
- |
|
175 |
$this->bdd->requeter($requete);
|
- |
|
176 |
}
|
Line 149... |
Line 177... |
149 |
|
177 |
|
150 |
|
178 |
|