* Copyright (C) 2009 Meos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/product/product.class.php"); $langs->load("products"); $modulepart=$_REQUEST['modulepart']?$_REQUEST['modulepart']:'produit|service'; if (isset($_GET["id"])) { $id = isset($_GET["id"])?$_GET["id"]:''; } $original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):''; // Security check if ($modulepart=='produit|service') $result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid); else accessforbidden('Bad value for modulepart'); if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); /* * Actions */ if ($_POST["action"] == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) { $fullpath=$conf->produit->dir_output."/".$original_file; $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); if ($result == $fullpath) { header("Location: ".DOL_URL_ROOT."/product/photos.php?id=".$_POST["product"].'&action=addthumb&file='.urldecode($_POST["file"])); exit; } else { $mesg=$result; $_GET['file']=$_POST["file"]; $_GET['id']=$_POST["id"]; } } // Crop d'une image if ($_POST["action"] == 'confirm_crop') { $fullpath=$conf->produit->dir_output."/".$original_file; $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); if ($result == $fullpath) { header("Location: ".DOL_URL_ROOT."/product/photos.php?id=".$_POST["product"].'&action=addthumb&file='.urldecode($_POST["file"])); exit; } else { $mesg=$result; $_GET['file']=$_POST["file"]; $_GET['id']=$_POST["id"]; } } /* * View */ llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('includes/jcrop/js/jquery.min.js','includes/jcrop/js/jquery.Jcrop.min.js','lib/lib_photosresize.js'), array(DOL_URL_ROOT.'/includes/jcrop/css/jquery.Jcrop.css')); print_fiche_titre($langs->trans("Image")); if ($mesg) print '