<?php
/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
+ * Copyright (C) 2003-2007 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
function PhotoReq($_uid, $_data, $_stamp=0)
{
+ $this->Validate($_uid, true, 'photo', $_stamp);
+ $this->_get_image($_data);
+ }
+
+ // }}}
+ // {{{ function _get_image()
+
+ function _get_image($_data)
+ {
global $page;
- $this->Validate($_uid, true, 'photo', $_stamp);
+ VarStream::init();
// calcul de la taille de l'image
- require_once dirname(__FILE__).'/../../classes/VarStream.php';
$GLOBALS['photoreq'] = $_data;
$image_infos = getimagesize('var://photoreq');
unset ($GLOBALS['photoreq']);
if (empty($image_infos)) {
$page->trig("Image invalide");
- return ($this = null);
+ return false;
}
list($this->x, $this->y, $this->mimetype) = $image_infos;
case 3: $this->mimetype = "png"; break;
default:
$page->trig("Type d'image invalide");
- return ($this = null);
+ return false;
}
if (strlen($_data) > SIZE_MAX) {
$img = imagecreatefromstring($_data);
if (!$img) {
$page->trig("image trop grande et impossible à retailler automatiquement");
- return ($this = null);
+ return false;
}
$nx = $x = imagesx($img);
unlink($file);
}
$this->data = $_data;
+ return true;
}
// }}}
function get_request($uid)
{
- return parent::get_request($uid,'photo');
+ return parent::get_typed_request($uid,'photo');
}
// }}}
{ return 'include/form.valid.photos.tpl'; }
// }}}
+ // {{{ function editor()
+
+ function editor()
+ {
+ return 'include/form.valid.edit-photo.tpl';
+ }
+
+ // }}}
+ // {{{ function handle_editor()
+
+ function handle_editor()
+ {
+ if (isset($_FILES['userfile']['tmp_name'])) {
+ $file = $_FILES['userfile']['tmp_name'];
+ if ($data = file_get_contents($file)) {
+ if ($this->_get_image($data)) {
+ return true;
+ }
+ } else {
+ $page->trig('Fichier inexistant ou vide');
+ }
+ }
+ return false;
+ }
+
+ // }}}
// {{{ function _mail_subj
function _mail_subj()