Subversion Repositories eFlore/Applications.cel

Rev

Rev 3584 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3584 Rev 3585
1
<?php
1
<?php
2
/**
2
/**
3
 * PHP Version 5
3
 * PHP Version 5
4
*
4
*
5
* @category  PHP
5
* @category  PHP
6
* @package   cel
6
* @package   cel
7
* @author    aurelien <aurelien@tela-botanica.org>
7
* @author    aurelien <aurelien@tela-botanica.org>
8
* @copyright 2015 Tela-Botanica
8
* @copyright 2015 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
10
* @version   SVN: <svn_id>
11
*/
11
*/
12
 
12
 
13
/**
13
/**
14
 * Migre les observations et les images d'un utilisateur, lorsqu'il change d'adresse email
14
 * Migre les observations et les images d'un utilisateur, lorsqu'il change d'adresse email
15
 * (ou les migre d'un utilisateur à l'autre)
15
 * (ou les migre d'un utilisateur à l'autre)
16
 * 
16
 * 
17
 * Utilisation : http://domain/service:cel/Modification/?mail=oldemail@example.fr&nouveau_mail=newemail@example.fr
17
 * Utilisation : http://domain/service:cel/Modification/?mail=oldemail@example.fr&nouveau_mail=newemail@example.fr
18
 */
18
 */
19
class Modification extends Cel {
19
class Modification extends Cel {
20
 
20
 
21
	public $table_image = "photo";
21
	public $table_image = "photo";
22
	public $table_obs = "occurrence";
22
	public $table_obs = "occurrence";
23
 
23
 
24
	public function getRessource() {
24
	public function getRessource() {
25
		return $this->getElement(array());
25
		return $this->getElement(array());
26
	}
26
	}
27
 
27
 
28
	public function getElement($uid) {
28
	public function getElement($uid) {
29
 
29
 
30
		$ancien_mail = (isset($_GET['mail'])) ? $_GET['mail'] : false;
30
		$ancien_mail = (isset($_GET['mail'])) ? $_GET['mail'] : false;
31
		$nouveau_mail = (isset($_GET['nouveau_mail'])) ? $_GET['nouveau_mail'] : false;
31
		$nouveau_mail = (isset($_GET['nouveau_mail'])) ? $_GET['nouveau_mail'] : false;
32
 
32
 
33
		if(!$ancien_mail) {
33
		if(!$ancien_mail) {
34
			$this->envoyer("false");
34
			$this->envoyer("false");
35
			return;
35
			return;
36
		}
36
		}
37
 
37
 
38
		// si le mail n'a pas changé, on ne change rien
38
		// si le mail n'a pas changé, on ne change rien
39
		if($ancien_mail == $nouveau_mail) {
39
		if($ancien_mail == $nouveau_mail) {
40
			$this->envoyer("OK");
40
			$this->envoyer("OK");
41
			return;
41
			return;
42
		}
42
		}
43
 
43
 
44
		// Sinon on doit changer des trucs dans les obs et les images
44
		// Sinon on doit changer des trucs dans les obs et les images
45
 
45
 
46
		$requete_maj_mail_obs = "UPDATE ".$this->table_obs." SET user_email = ".Cel::db()->proteger($nouveau_mail)." ".
46
		$requete_maj_mail_obs = "UPDATE ".$this->table_obs." SET user_email = ".Cel::db()->proteger($nouveau_mail)." ".
47
			"WHERE user_email = ".Cel::db()->proteger($ancien_mail);
47
			"WHERE user_email = ".Cel::db()->proteger($ancien_mail);
48
 
48
 
49
		Cel::db()->executer($requete_maj_mail_obs);
49
		Cel::db()->executer($requete_maj_mail_obs);
50
 
50
 
51
		$requete_maj_mail_img = "UPDATE ".$this->table_image." SET user_email = ".Cel::db()->proteger($nouveau_mail)." ".
51
		$requete_maj_mail_img = "UPDATE ".$this->table_image." SET user_email = ".Cel::db()->proteger($nouveau_mail)." ".
52
			"WHERE user_email = ".Cel::db()->proteger($ancien_mail);
52
			"WHERE user_email = ".Cel::db()->proteger($ancien_mail);
53
 
53
 
54
		Cel::db()->executer($requete_maj_mail_img);
54
		Cel::db()->executer($requete_maj_mail_img);
55
 
-
 
56
		$requete_maj_ordre_img = "SELECT @ordval := 0; ".
-
 
57
			"UPDATE ".$this->table_image." ".
-
 
58
			"SET ordre = (SELECT @ordval := @ordval + 1) ".
-
 
59
			"WHERE user_email = ".Cel::db()->proteger($nouveau_mail)." ".
-
 
60
			"ORDER BY date_creation ";
-
 
61
 
-
 
62
		Cel::db()->executerRequete($requete_maj_ordre_img);
-
 
63
 
55
 
64
		$this->envoyer("OK");
56
		$this->envoyer("OK");
65
		return;
57
		return;
66
	}
58
	}
67
}
59
}