1 |
<?php |
2 |
/** |
3 |
* |
4 |
* |
5 |
* @package openmairie |
6 |
* @version SVN : $Id$ |
7 |
*/ |
8 |
|
9 |
require_once "../gen/obj/om_logo.class.php"; |
10 |
|
11 |
class om_logo extends om_logo_gen { |
12 |
|
13 |
function om_logo($id, &$db, $debug) { |
14 |
$this->constructeur($id, $db, $debug); |
15 |
} |
16 |
|
17 |
function setType(&$form, $maj) { |
18 |
// |
19 |
parent::setType($form, $maj); |
20 |
// ajouter et modifier |
21 |
if ($maj == 0 || $maj == 1) { |
22 |
// |
23 |
if ($this->retourformulaire == 'om_collectivite') { |
24 |
$form->setType('fichier', 'upload2'); |
25 |
} else { |
26 |
$form->setType('fichier', 'upload'); |
27 |
} |
28 |
} |
29 |
if ($maj == 2) { |
30 |
$form->setType('fichier', 'filestatic'); |
31 |
} |
32 |
if ($maj == 3) { |
33 |
$form->setType('fichier', 'file'); |
34 |
} |
35 |
|
36 |
} |
37 |
|
38 |
function verifier($val = array(), &$db = NULL, $DEBUG = false) { |
39 |
// On appelle la methode de la classe parent |
40 |
parent::verifier($val, $db, $DEBUG); |
41 |
// On verifie si il y a un autre id 'actif' pour la collectivite |
42 |
if ($this->valF['actif'] == "Oui") { |
43 |
// |
44 |
if ($this->getParameter("maj") == 0) { |
45 |
// |
46 |
$this->verifieractif($db, $val, $DEBUG, "]"); |
47 |
} else { |
48 |
// |
49 |
$this->verifieractif($db, $val, $DEBUG, $val[$this->clePrimaire]); |
50 |
} |
51 |
} |
52 |
} |
53 |
|
54 |
/** |
55 |
* verification sur existence d un etat deja actif pour la collectivite |
56 |
*/ |
57 |
function verifieractif(&$db, $val, $DEBUG, $id) { |
58 |
// |
59 |
$table = "om_logo"; |
60 |
$primary_key = "om_logo"; |
61 |
// |
62 |
$sql = " SELECT ".$table.".".$primary_key." "; |
63 |
$sql .= " FROM ".DB_PREFIXE."".$table." "; |
64 |
$sql .= " WHERE ".$table.".id='".$val['id']."' "; |
65 |
$sql .= " AND ".$table.".om_collectivite='".$val['om_collectivite']."' "; |
66 |
$sql .= " AND ".$table.".actif IS TRUE "; |
67 |
if ($id != "]") { |
68 |
$sql .=" AND ".$table.".".$primary_key."<>'".$id."' "; |
69 |
} |
70 |
// |
71 |
$res = $this->db->query($sql); |
72 |
$this->addToLog("db->query(\"".$sql."\");", VERBOSE_MODE); |
73 |
// |
74 |
if (database::isError($res)) { |
75 |
// |
76 |
die($res->getMessage()." => Echec ".$sql); |
77 |
} else { |
78 |
// |
79 |
$nbligne = $res->numrows(); |
80 |
if ($nbligne > 0) { |
81 |
$this->correct = false; |
82 |
$msg = $nbligne." "; |
83 |
$msg .= _("logo(s) existant(s) dans l'etat actif. Il ". |
84 |
"n'est pas possible d'avoir plus d'un logo"); |
85 |
$msg .= " \"".$val["id"]."\" "._("actif par collectivite."); |
86 |
$this->addToMessage($msg); |
87 |
} |
88 |
} |
89 |
} |
90 |
|
91 |
} |
92 |
|
93 |
?> |