New file |
0,0 → 1,59 |
<?php |
/** |
* PHP Version 5 |
* |
* @category PHP |
* @package cel |
* @author aurelien <aurelien@tela-botanica.org> |
* @copyright 2015 Tela-Botanica |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @version SVN: <svn_id> |
*/ |
|
/** |
* Migre les observations et les images d'un utilisateur, lorsqu'il change d'adresse email |
* (ou les migre d'un utilisateur à l'autre) |
* |
* Utilisation : http://domain/service:cel/Modification/?mail=oldemail@example.fr&nouveau_mail=newemail@example.fr |
*/ |
class Modification extends Cel { |
|
public $table_image = "photo"; |
public $table_obs = "occurrence"; |
|
public function getRessource() { |
return $this->getElement(array()); |
} |
|
public function getElement($uid) { |
|
$ancien_mail = (isset($_GET['mail'])) ? $_GET['mail'] : false; |
$nouveau_mail = (isset($_GET['nouveau_mail'])) ? $_GET['nouveau_mail'] : false; |
|
if(!$ancien_mail) { |
$this->envoyer("false"); |
return; |
} |
|
// si le mail n'a pas changé, on ne change rien |
if($ancien_mail == $nouveau_mail) { |
$this->envoyer("OK"); |
return; |
} |
|
// Sinon on doit changer des trucs dans les obs et les images |
|
$requete_maj_mail_obs = "UPDATE ".$this->table_obs." SET user_email = ".Cel::db()->proteger($nouveau_mail)." ". |
"WHERE user_email = ".Cel::db()->proteger($ancien_mail); |
|
Cel::db()->executer($requete_maj_mail_obs); |
|
$requete_maj_mail_img = "UPDATE ".$this->table_image." SET user_email = ".Cel::db()->proteger($nouveau_mail)." ". |
"WHERE user_email = ".Cel::db()->proteger($ancien_mail); |
|
Cel::db()->executer($requete_maj_mail_img); |
|
$this->envoyer("OK"); |
return; |
} |
} |