Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
416 aurelien 1
<?php
2458 jpm 2
// declare(encoding='UTF-8');
3
/**
4
 * Service rendant publique une observation.
5
 *
6
 * @internal   Mininum PHP version : 5.2
7
 * @category   CEL
8
 * @package    Services
9
 * @subpackage Observations
10
 * @version    0.1
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
12
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
13
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
14
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
15
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
16
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
1867 raphael 17
 */
762 aurelien 18
class InventoryTransmit extends Cel  {
1301 aurelien 19
 
2458 jpm 20
	public function updateElement($uid, $pairs) {
21
		// Controle detournement utilisateur
22
		$this->controleUtilisateur($uid[0]);
23
		if (!isset($uid[1])) {
24
			return false;
25
		}
1860 raphael 26
		$transmission = intval($pairs['transmission']);
2458 jpm 27
		if ($transmission != 0 && $transmission != 1) {
28
			return false;
29
		}
416 aurelien 30
 
2458 jpm 31
		$ids = array_filter(array_map(create_function('$v','return intval($v);'), explode(',', $uid[1])), 'strlen');
32
 
1949 aurelien 33
		$date = ($transmission == 1) ? 'now()' : 'NULL';
34
		//TODO: modification pour passer ceci dans la classe gestion observation
2458 jpm 35
		$requete = 'UPDATE cel_obs '.
36
			'SET transmission = '.$pairs['transmission'].', '.
37
			'date_modification = now(), date_transmission = '.$date.' '.
38
			'WHERE ce_utilisateur = '.Cel::db()->proteger($uid[0]).' '.
39
			'AND ordre in ('.implode(',', $ids).') '.
40
			' -- '.__FILE__.':'.__LINE__;
41
		$resultat = Cel::db()->executer($requete);
42
		return ($resultat != 0);
416 aurelien 43
	}
2458 jpm 44
}