| Line 41... |
Line 41... |
| 41 |
if (self::ARRET_SERVICE) {
|
41 |
if (self::ARRET_SERVICE) {
|
| 42 |
$this->messages[] = "Désactivation temporaire du service d'envoi des données au CEL.";
|
42 |
$this->messages[] = "Désactivation temporaire du service d'envoi des données au CEL.";
|
| 43 |
} else if (array_key_exists('projet', $requeteDonnees)) {
|
43 |
} else if (array_key_exists('projet', $requeteDonnees)) {
|
| 44 |
$this->debug[] = 'Projet : '.$requeteDonnees['projet'];
|
44 |
$this->debug[] = 'Projet : '.$requeteDonnees['projet'];
|
| 45 |
if ($requeteDonnees['projet'] != "base") {
|
45 |
if ($requeteDonnees['projet'] != "base") {
|
| 46 |
$this->projet = $requeteDonnees['projet'];
|
46 |
$this->projet = $requeteDonnees['projet'] ?? null;
|
| 47 |
$this->projetId = $requeteDonnees['id_projet'] ?? null;
|
47 |
$this->projetId = $requeteDonnees['id_projet'] ?? null;
|
| 48 |
}
|
48 |
}
|
| Line 49... |
Line 49... |
| 49 |
|
49 |
|
| 50 |
// Si c'est une obs Pl@ntNet
|
50 |
// Si c'est une obs Pl@ntNet
|
| Line 123... |
Line 123... |
| 123 |
$obsAAjouter['geometry'] = $obs['geometry'] ?? json_encode([
|
123 |
$obsAAjouter['geometry'] = $obs['geometry'] ?? json_encode([
|
| 124 |
'type' => 'Point',
|
124 |
'type' => 'Point',
|
| 125 |
'coordinates' => [ (float)$obs['longitude'], (float)$obs['latitude'] ]
|
125 |
'coordinates' => [ (float)$obs['longitude'], (float)$obs['latitude'] ]
|
| 126 |
]); // CONCAT('{\"type\":\"Point\",\"coordinates\":[', longitude, ',', latitude,']}'),
|
126 |
]); // CONCAT('{\"type\":\"Point\",\"coordinates\":[', longitude, ',', latitude,']}'),
|
| 127 |
$obsAAjouter['geodatum'] = 'WGS84';
|
127 |
$obsAAjouter['geodatum'] = 'WGS84';
|
| - |
|
128 |
$obsAAjouter['published_location'] = ($this->tagsObs != null && in_array('sensible', $this->tagsObs) == true) ?
|
| - |
|
129 |
"localité" : "précise";
|
| Line 128... |
Line 130... |
| 128 |
|
130 |
|
| 129 |
$obsAAjouter['phenology'] = isset($obs['phenologie']) ? $obs['phenologie'] : null;
|
131 |
$obsAAjouter['phenology'] = isset($obs['phenologie']) ? $obs['phenologie'] : null;
|
| Line 130... |
Line 132... |
| 130 |
$obsAAjouter['coef'] = isset($obs['abondance']) ? $obs['abondance'] : null;
|
132 |
$obsAAjouter['coef'] = isset($obs['abondance']) ? $obs['abondance'] : null;
|
| Line 135... |
Line 137... |
| 135 |
$obsAAjouter['date_published'] = $obsAAjouter['date_created'];
|
137 |
$obsAAjouter['date_published'] = $obsAAjouter['date_created'];
|
| Line 136... |
Line 138... |
| 136 |
|
138 |
|
| 137 |
$obsAAjouter['image_nom'] = $obs['image_nom'] ?? null;
|
139 |
$obsAAjouter['image_nom'] = $obs['image_nom'] ?? null;
|
| Line 138... |
Line 140... |
| 138 |
$obsAAjouter['image_b64'] = $obs['image_b64'] ?? null;
|
140 |
$obsAAjouter['image_b64'] = $obs['image_b64'] ?? null;
|
| 139 |
|
141 |
|
| 140 |
$obsAAjouter['certainty'] = '';
|
142 |
$obsAAjouter['certainty'] = null;
|
| 141 |
if (isset($obs['certitude'])) {
|
143 |
if (isset($obs['certitude'])) {
|
| 142 |
switch ($obs['certitude']) {
|
144 |
switch ($obs['certitude']) {
|
| 143 |
case 'certaine':
|
145 |
case 'certaine':
|
| Line 149... |
Line 151... |
| 149 |
default:
|
151 |
default:
|
| 150 |
$obsAAjouter['certainty'] = $obs['certitude'];
|
152 |
$obsAAjouter['certainty'] = $obs['certitude'];
|
| 151 |
break;
|
153 |
break;
|
| 152 |
}
|
154 |
}
|
| 153 |
}
|
155 |
}
|
| - |
|
156 |
$obsAAjouter['certainty'] = ($this->projet == "aDeterminer") ? 'à déterminer' : $obsAAjouter['certainty'];
|
| 154 |
$obsAAjouter['input_source'] = 'widget';
|
157 |
$obsAAjouter['input_source'] = 'widget';
|
| 155 |
$obsAAjouter['project_id'] = $this->projetId;
|
158 |
$obsAAjouter['project_id'] = $this->projetId;
|
| 156 |
$obsAAjouter['project'] = $this->projet;
|
159 |
// racommodage en attendant mieux
|
| - |
|
160 |
$obsAAjouter['project'] = ($this->projetId == null) ? null : ($this->projetId == 53) ? "missions-flore" : $this->projet ;
|
| 157 |
if ($this->isFromPlantNet) {
|
161 |
if ($this->isFromPlantNet) {
|
| 158 |
$obsAAjouter['input_source'] = 'PlantNet';
|
162 |
$obsAAjouter['input_source'] = 'PlantNet';
|
| 159 |
$obsAAjouter['plantnet_id'] = $obs['obs_id'];
|
163 |
$obsAAjouter['plantnet_id'] = $obs['obs_id'];
|
| 160 |
}
|
164 |
}
|
| 161 |
if ($this->isSauvages) {
|
165 |
if ($this->isSauvages) {
|
| Line 661... |
Line 665... |
| 661 |
return $tag;
|
665 |
return $tag;
|
| 662 |
}
|
666 |
}
|
| Line 663... |
Line 667... |
| 663 |
|
667 |
|
| 664 |
private function traiterNomFichierImage($fichierNom) {
|
668 |
private function traiterNomFichierImage($fichierNom) {
|
| - |
|
669 |
$fichierNom = preg_replace('/[.](jpeg|jpg)$/i', '.jpg', strtolower(trim($fichierNom)));
|
| 665 |
$fichierNom = preg_replace('/[.](jpeg|jpg)$/i', '.jpg', strtolower(trim($fichierNom)));
|
670 |
|
| 666 |
return $fichierNom;
|
671 |
return $fichierNom;
|
| Line 667... |
Line 672... |
| 667 |
}
|
672 |
}
|
| 668 |
|
673 |
|
| Line 747... |
Line 752... |
| 747 |
$infosImage['date_linked_to_occurrence'] = 'NOW()';
|
752 |
$infosImage['date_linked_to_occurrence'] = 'NOW()';
|
| 748 |
$this->debug[] = 'Nom fichier img meta :'.$nomFichierImage;
|
753 |
$this->debug[] = 'Nom fichier img meta :'.$nomFichierImage;
|
| 749 |
$requete = $this->construireRequeteInsertionImage($infosImage);
|
754 |
$requete = $this->construireRequeteInsertionImage($infosImage);
|
| 750 |
$resultat = Cel::db()->executer($requete);
|
755 |
$resultat = Cel::db()->executer($requete);
|
| 751 |
if ($resultat !== false) {
|
756 |
if ($resultat !== false) {
|
| 752 |
$idImage = $this->traiterEtRecupererIdImage($nomFichierImage);
|
757 |
$idImage = $this->traiterEtRecupererIdImage($nomFichierImage, $id_obs);
|
| 753 |
if ($idImage !== false) {
|
758 |
if ($idImage !== false) {
|
| 754 |
$infosImage['url'] = 'https://api.tela-botanica.org/img:'.str_pad($idImage, 9, '0', STR_PAD_LEFT).'O';
|
759 |
$infosImage['url'] = 'https://api.tela-botanica.org/img:'.str_pad($idImage, 9, '0', STR_PAD_LEFT).'O';
|
| Line 755... |
Line 760... |
| 755 |
|
760 |
|
| 756 |
$manipulateurImage = new ImageRecreation($this->config);
|
761 |
$manipulateurImage = new ImageRecreation($this->config);
|
| Line 797... |
Line 802... |
| 797 |
$ok = $manipulateurImage->detruireImageSurDisque($idImageASupprimer);
|
802 |
$ok = $manipulateurImage->detruireImageSurDisque($idImageASupprimer);
|
| Line 798... |
Line 803... |
| 798 |
|
803 |
|
| 799 |
return $ok;
|
804 |
return $ok;
|
| Line 800... |
Line 805... |
| 800 |
}
|
805 |
}
|
| 801 |
|
- |
|
| 802 |
private function traiterEtRecupererIdImage($original_name) {
|
- |
|
| 803 |
$id_utilisateur = Cel::db()->proteger($this->userId);
|
806 |
|
| - |
|
807 |
private function traiterEtRecupererIdImage($original_name, $id_obs) {
|
| 804 |
$email_utilisateur = Cel::db()->proteger($this->userEmail);
|
808 |
$original_name = Cel::db()->proteger($original_name);
|
| 805 |
$original_name = Cel::db()->proteger($original_name);
|
809 |
$id_obs = Cel::db()->proteger($id_obs);
|
| 806 |
|
810 |
|
| 807 |
$requete = 'SELECT id '.
|
811 |
$requete = 'SELECT id '.
|
| 808 |
'FROM photo '.
|
812 |
'FROM photo '.
|
| 809 |
"WHERE (user_id = $id_utilisateur OR user_email = $email_utilisateur)".
|
813 |
"WHERE occurrence_id = ".$id_obs.
|
| 810 |
" AND original_name = $original_name ";
|
814 |
" AND original_name = $original_name ";
|
| Line 811... |
Line 815... |
| 811 |
$resultat = Cel::db()->requeter($requete);
|
815 |
$resultat = Cel::db()->requeter($requete);
|