$art = array();
if (Post::v('valid') == 'Visualiser' || Post::v('valid') == 'Enregistrer'
- || Post::v('valid') == 'Supprimer l\'image') {
+ || Post::v('valid') == 'Supprimer l\'image' || Post::v('valid') == 'Pas d\'image') {
if (!is_null($aid)) {
$art['id'] = $aid;
}
$upload->rm();
Post::kill('valid');
}
- $art['photo'] = $upload->exists();
+ $art['photo'] = $upload->exists() || Post::i('photo');
+ if (Post::v('valid') == 'Pas d\'image' && !is_null($aid)) {
+ XDB::query("DELETE FROM groupex.announces_photo WHERE eid = {?}", $aid);
+ $upload->rm();
+ Post::kill('valid');
+ $art['photo'] = false;
+ }
}
if (Post::v('valid') == 'Enregistrer') {
$art['titre'], $art['texte'], $art['contacts'], $art['peremption'],
$promo_min, $promo_max, $flags,
$art['id'], $globals->asso('id'));
+ if ($art['photo'] && $upload->exists()) {
+ list($imgx, $imgy, $imgtype) = $upload->imageInfo();
+ XDB::execute("REPLACE INTO groupex.announces_photo
+ SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}",
+ $aid, $imgtype, $imgx, $imgy, $upload->getContents());
+ $upload->rm();
+ }
}
}
if (Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Annuler') {
if (empty($art) && !is_null($aid)) {
$res = XDB::query("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife,
- FIND_IN_SET('public', a.flags) AS public
+ FIND_IN_SET('public', a.flags) AS public,
+ FIND_IN_SET('photo', a.flags) AS photo
FROM groupex.announces AS a
INNER JOIN auth_user_md5 AS u USING(user_id)
INNER JOIN aliases AS l ON (l.id = u.user_id AND l.type = 'a_vie')
<tr style="border-top: 1px solid gray">
<td class="titre">Illustration</td>
<td>
- {if $art.id && $art.img}
+ {if $art.id && $art.photo}
<div style="float: left; text-align: center">
<em>Image actuelle</em><br />
<img src="{$platal->ns}announce/photo/{$art.id}" alt="Image actuelle" /><br />
<input type="submit" name="valid" value="Pas d'image" />
+ <input type="hidden" name="photo" value="1" />
</div>
{/if}
- {if $upload && $art.photo}
+ {if $upload && $upload->exists()}
<div style="float: right; text-align: center">
<em>Nouvelle image</em><br />
<img src="{$platal->ns}announce/photo" alt="Nouvelle Image" /><br />