diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index dbc56bc6394..7395491e4b6 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -28,6 +28,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); @@ -88,6 +89,11 @@ if ($rowid) $caneditfieldmember=$user->rights->adherent->creer; } +// Define size of logo small and mini (might be set into other pages) +$maxwidthsmall=270;$maxheightsmall=150; +$maxwidthmini=128;$maxheightmini=72; +$quality = 80; + /* @@ -244,6 +250,8 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe $adh->amount = $_POST["amount"]; + $adh->photo = $_FILES['photo']['name']; + // Get status and public property $adh->statut = $_POST["statut"]; $adh->public = $_POST["public"]; @@ -277,19 +285,27 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe { if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { + $dir= $conf->adherent->dir_output . '/' . get_exdir($adh->id,2,0,1); - // If photo is provided - if (! is_dir($conf->adherent->dir_output)) + create_exdir($dir); + + if (@is_dir($dir)) { - create_exdir($conf->adherent->dir_output); - } - if (is_dir($conf->adherent->dir_output)) - { - $newfile=$conf->adherent->dir_output . "/" . $adh->id . ".jpg"; + $newfile=$dir.'/'.$_FILES['photo']['name']; if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1) > 0) { $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; } + else + { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + } } } diff --git a/htdocs/admin/adherent.php b/htdocs/admin/adherent.php index 7af2ed6914f..8ea91dd988c 100644 --- a/htdocs/admin/adherent.php +++ b/htdocs/admin/adherent.php @@ -219,11 +219,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 1) * Edition info modele document */ $constantes=array( + 'ADHERENT_CARD_TYPE', 'ADHERENT_CARD_HEADER_TEXT', 'ADHERENT_CARD_TEXT', 'ADHERENT_CARD_TEXT_RIGHT', - 'ADHERENT_CARD_FOOTER_TEXT', - 'ADHERENT_CARD_TYPE' + 'ADHERENT_CARD_FOOTER_TEXT' ); print_fiche_titre($langs->trans("MembersCards"),'',''); @@ -232,13 +232,31 @@ form_constantes($constantes); print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%, '; print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%, '; -print '%YEAR%, %MONTH%, %DAY%, %LOGO%, %PHOTO%'; +print '%YEAR%, %MONTH%, %DAY%, %PHOTO%'; //print '%INFOS%'; Deprecated print '
'; print '
'; +/* + * Edition info modele document + */ +$constantes=array( + 'ADHERENT_ETIQUETTE_TYPE' + ); +print_fiche_titre($langs->trans("MembersTickets"),'',''); + +form_constantes($constantes); + +print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; +print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%, '; +print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%, '; +print '%YEAR%, %MONTH%, %DAY%, %PHOTO%'; +//print '%INFOS%'; Deprecated +print '
'; + +print '
'; /* * Edition des variables globales non rattache a un theme specifique */ @@ -252,7 +270,7 @@ $constantes=array( 'ADHERENT_MAIL_RESIL_SUBJECT', 'ADHERENT_MAIL_RESIL', 'ADHERENT_MAIL_FROM', - 'ADHERENT_ETIQUETTE_TYPE' + ); print_fiche_titre($langs->trans("Other"),'',''); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index dd26dee484f..dbc9b5b9b61 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -38,7 +38,7 @@ $langs->load("companies"); if (!$user->admin) accessforbidden(); -// Define size of logo small and mini +// Define size of logo small and mini (might be set into other pages) $maxwidthsmall=270;$maxheightsmall=150; $maxwidthmini=128;$maxheightmini=72; $quality = 80; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 58fd299dab9..507a49f0785 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -2914,7 +2914,7 @@ class Form /** * \brief Return HTML code to output a photo * \param modulepart Id to define module concerned - * \param object Object containing data to retreive file name + * \param object Object containing data to retrieve file name * \param width Width of photo * \return string HTML code to output photo */ @@ -2927,13 +2927,15 @@ class Form if ($modulepart=='userphoto') { $dir=$conf->user->dir_output; - $file=$object->id.".jpg"; + $file=get_exdir($object->id,2).$object->photo; + $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; } if ($modulepart=='memberphoto') { $dir=$conf->adherent->dir_output; - $file=$object->id.".jpg"; + $file=get_exdir($object->id,2).$object->photo; + $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; } @@ -2942,6 +2944,10 @@ class Form if (file_exists($dir."/".$file)) { $ret.='Photo'; + } + else if (file_exists($dir."/".$altfile)) + { + $ret.='Photo'; } else { diff --git a/htdocs/install/mysql/migration/2.7.0-2.8.0.sql b/htdocs/install/mysql/migration/2.7.0-2.8.0.sql index 67d35fe795b..774defc8aa8 100755 --- a/htdocs/install/mysql/migration/2.7.0-2.8.0.sql +++ b/htdocs/install/mysql/migration/2.7.0-2.8.0.sql @@ -51,6 +51,7 @@ ALTER TABLE llx_projet ADD COLUMN model_pdf varchar(50) AFTER note; ALTER TABLE llx_societe ADD COLUMN localtax1_assuj tinyint DEFAULT 0 after tva_assuj; ALTER TABLE llx_societe ADD COLUMN localtax2_assuj tinyint DEFAULT 0 after localtax1_assuj; +ALTER TABLE llx_user ADD COLUMN photo varchar(255) after statut; -- Create table of extra fields create table llx_extra_fields diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index af6f908ddf4..cfc45cb1dbd 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -47,7 +47,7 @@ create table llx_adherent phone_perso varchar(30), phone_mobile varchar(30), naiss date, -- date de naissance - photo varchar(255), -- url vers photo + photo varchar(255), -- filename or url of photo statut smallint NOT NULL DEFAULT 0, public smallint NOT NULL DEFAULT 0, -- certain champ de la fiche sont ils public ou pas ? datefin datetime, -- date de fin de validite de la cotisation diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 50019bc38d3..f0cfc98c7b9 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -51,6 +51,7 @@ create table llx_user egroupware_id integer, ldap_sid varchar(255) DEFAULT NULL, statut tinyint DEFAULT 1, + photo varchar(255), -- filename or url of photo lang varchar(6) )type=innodb; diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 3c54193ef22..9a4b335f8dc 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -2640,15 +2640,16 @@ function yn($yesno, $case=1, $color=0) * \remarks Examples: '001' with level 3->"0/0/1/", '015' with level 3->"0/1/5/" * \remarks Examples: 'ABC-1' with level 3 ->"0/0/1/", '015' with level 1->"5/" */ -function get_exdir($num,$level=3,$alpha=0) +function get_exdir($num,$level=3,$alpha=0,$withoutslash=0) { $path = ''; if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num); else $num = preg_replace('/^.*\-/i','',$num); $num = substr("000".$num, -$level); - if ($level == 1) $path = substr($num,0,1).'/'; - if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1).'/'; - if ($level == 3) $path = substr($num,2,1).'/'.substr($num,1,1).'/'.substr($num,0,1).'/'; + if ($level == 1) $path = substr($num,0,1); + if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1); + if ($level == 3) $path = substr($num,2,1).'/'.substr($num,1,1).'/'.substr($num,0,1); + if (empty($withoutslash)) $path.='/'; return $path; } diff --git a/htdocs/lib/images.lib.php b/htdocs/lib/images.lib.php index d1c00f79cf7..58eb43104aa 100644 --- a/htdocs/lib/images.lib.php +++ b/htdocs/lib/images.lib.php @@ -30,14 +30,14 @@ * \brief Create a thumbnail from an image file (une small et un mini) * \brief Les extensions prises en compte sont jpg et png * \param file Chemin du fichier image a redimensionner - * \param maxWidth Largeur maximum que dois faire la miniature (160 par defaut) - * \param maxHeight Hauteur maximum que dois faire l'image (120 par defaut) + * \param maxWidth Largeur maximum que dois faire la miniature (-1=unchanged, 160 par defaut) + * \param maxHeight Hauteur maximum que dois faire l'image (-1=unchanged, 120 par defaut) * \param extName Extension pour differencier le nom de la vignette * \param quality Quality of compression (0=worst, 100=best) * \return string Full path of thumb * \remarks With file=myfile.jpg -> myfile_small.jpg */ -function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50) +function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs') { require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); @@ -63,23 +63,26 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ { return 'This file '.$file.' does not seem to be an image format file name.'; } - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < 0){ + elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) return 'Valeur de la largeur incorrecte.'; } - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < 0){ + elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) return 'Valeur de la hauteur incorrecte.'; } - $fichier = realpath($file); // Chemin canonique absolu de l'image - $dir = dirname($file).'/'; // Chemin du dossier contenant l'image - $dirthumb = $dir.'thumbs/'; // Chemin du dossier contenant les vignettes + $fichier = realpath($file); // Chemin canonique absolu de l'image + $dir = dirname($file); // Chemin du dossier contenant l'image + $dirthumb = $dir.($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes $infoImg = getimagesize($fichier); // Recuperation des infos de l'image $imgWidth = $infoImg[0]; // Largeur de l'image $imgHeight = $infoImg[1]; // Hauteur de l'image + if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged + if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged + // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) { @@ -114,10 +117,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ } // On cree le repertoire contenant les vignettes - if (! file_exists($dirthumb)) - { - create_exdir($dirthumb); - } + create_exdir($dirthumb); // Initialisation des variables selon l'extension de l'image switch($infoImg[2]) @@ -214,7 +214,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse $fileName = basename($fileName); - $imgThumbName = $dirthumb.$fileName.$extName.$extImg; // Chemin complet du fichier de la vignette + $imgThumbName = $dirthumb.'/'.$fileName.$extName.$extImg; // Chemin complet du fichier de la vignette // Check if permission are ok //$fp = fopen($imgThumbName, "w"); @@ -278,7 +278,7 @@ function moneyMeter($actualValue=0, $pendingValue=0, $intentValue=0) $imageColorActual = $imageDir . "therm_color_actual.png"; $imageColorPending = $imageDir . "therm_color_pending.png"; $imageColorIntent = $imageDir . "therm_color_intent.png"; - + $htmlThermTop = ' @@ -293,7 +293,7 @@ function moneyMeter($actualValue=0, $pendingValue=0, $intentValue=0) $htmlSection = ' '; - + $htmlThermbottom = '
@@ -304,7 +304,7 @@ function moneyMeter($actualValue=0, $pendingValue=0, $intentValue=0) - '; + '; // legenda diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 137ef4cc25c..a05c774c050 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -2308,15 +2308,14 @@ class Product extends CommonObject */ function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) { - $dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/"; - $dir .= "photos/"; + $dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/photos"; create_exdir($dir); $dir_osencoded=$dir; - if (file_exists($dir_osencoded)) + if (is_dir($dir_osencoded)) { - $originImage = $dir . $file['name']; + $originImage = $dir . '/' . $file['name']; // Cree fichier en taille origine $result=dol_move_uploaded_file($file['tmp_name'], $originImage, 1); diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index d1d7806a2bf..24d5a17d5fa 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify