diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index 6c6ccdb042b..2ee79ab04d7 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -244,7 +244,8 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe
$adh->amount = $_POST["amount"];
- $adh->photo = ($_FILES['photo']['name']?$_FILES['photo']['name']:$adh->oldcopy->photo);
+ if (GETPOST('deletephoto')) $adh->photo='';
+ $adh->photo = ($_FILES['photo']['name']?dol_sanitizeFileName($_FILES['photo']['name']):$adh->oldcopy->photo);
// Get status and public property
$adh->statut = $_POST["statut"];
@@ -277,7 +278,15 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe
$result=$adh->update($user,0,$nosyncuser,$nosyncuserpass);
if ($result >= 0 && ! sizeof($adh->errors))
{
- if (!empty($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
+ if (GETPOST('deletephoto') && $adh->photo)
+ {
+ $fileimg=$conf->adherent->dir_output.'/'.get_exdir($adh->id,2,0,1).'/photos/'.$adh->photo;
+ $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($adh->id,2,0,1).'/photos/thumbs';
+ dol_delete_file($fileimg);
+ dol_delete_dir_recursive($dirthumbs);
+ }
+
+ if (!empty($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
{
$dir= $conf->adherent->dir_output . '/' . get_exdir($adh->id,2,0,1).'/photos/';
@@ -285,7 +294,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe
if (@is_dir($dir))
{
- $newfile=$dir.'/'.$_FILES['photo']['name'];
+ $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0)
{
$message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
';
@@ -860,10 +869,12 @@ if ($action == 'edit')
print $html->showphoto('memberphoto',$adh)."\n";
if ($caneditfieldmember)
{
- print ' ';
+ if ($adh->photo) print " \n";
+ print '';
}
print '';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 06ef10ff0ad..6e21bd3f9eb 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3324,39 +3324,39 @@ class Form
{
global $conf;
- $ret='';$dir='';$file='';$email='';
+ $ret='';$dir='';$file='';$altfile='';$email='';
if ($modulepart=='societe')
{
$dir=$conf->societe->dir_output;
$smallfile=$object->logo;
$smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile);
- $file=$object->id.'/logos/thumbs/'.$smallfile;
+ if ($object->logo) $file=$object->id.'/logos/thumbs/'.$smallfile;
}
else if ($modulepart=='userphoto')
{
$dir=$conf->user->dir_output;
- $file=get_exdir($object->id,2).$object->photo;
- $altfile=$object->id.".jpg"; // For backward compatibility
+ if ($object->photo) $file=get_exdir($object->id,2).$object->photo;
+ if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email;
}
else if ($modulepart=='memberphoto')
{
$dir=$conf->adherent->dir_output;
- $file=get_exdir($object->id,2).'photos/'.$object->photo;
- $altfile=$object->id.".jpg"; // For backward compatibility
+ if ($object->photo) $file=get_exdir($object->id,2).'photos/'.$object->photo;
+ if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email;
}
- if ($dir && $file)
+ if ($dir)
{
- if (file_exists($dir."/".$file))
+ if ($file && file_exists($dir."/".$file))
{
$ret.=' ';
}
else if ($altfile && file_exists($dir."/".$altfile))
{
- $ret.=' ';
+ $ret.=' ';
}
else
{
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 5476e23f176..d45e694e176 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -156,7 +156,7 @@ else
$soc->tel = $_POST["tel"];
$soc->fax = $_POST["fax"];
$soc->email = trim($_POST["email"]);
- $soc->url = $_POST["url"];
+ $soc->url = trim($_POST["url"]);
$soc->siren = $_POST["idprof1"];
$soc->siret = $_POST["idprof2"];
$soc->ape = $_POST["idprof3"];
@@ -169,7 +169,7 @@ else
$soc->tva_intra = $_POST["tva_intra"];
$soc->tva_assuj = $_POST["assujtva_value"];
- $soc->status = $_POST["status"];
+ $soc->status = $_POST["status"];
// Local Taxes
$soc->localtax1_assuj = $_POST["localtax1assuj_value"];
@@ -193,7 +193,8 @@ else
$soc->commercial_id = $_POST["commercial_id"];
$soc->default_lang = $_POST["default_lang"];
- $soc->logo = dol_sanitizeFileName($_FILES['logo']['name']);
+ if (GETPOST('deletephoto')) $soc->logo = '';
+ $soc->logo = dol_sanitizeFileName($_FILES['photo']['name']);
// Check parameters
if (empty($_POST["cancel"]))
@@ -258,17 +259,17 @@ else
### Gestion du logo de la société
$dir = $conf->societe->dir_output."/".$soc->id."/logos/";
- $file_OK = is_uploaded_file($_FILES['logo']['tmp_name']);
+ $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
- if (image_format_supported($_FILES['logo']['name']))
+ if (image_format_supported($_FILES['photo']['name']))
{
create_exdir($dir);
if (@is_dir($dir))
{
- $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['logo']['name']);
- $result = dol_move_uploaded_file($_FILES['logo']['tmp_name'], $newfile, 1);
+ $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
+ $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
if (! $result > 0)
{
@@ -328,24 +329,32 @@ else
//var_dump($soc);exit;
$result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable());
- if ($result < 0)
+ if ($result <= 0)
{
$error = $soc->error; $errors = $soc->errors;
}
### Gestion du logo de la société
$dir = $conf->societe->dir_output."/".$soc->id."/logos/";
- $file_OK = is_uploaded_file($_FILES['logo']['tmp_name']);
+ $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
- if (image_format_supported($_FILES['logo']['name']))
+ if (GETPOST('deletephoto') && $soc->logo)
+ {
+ $fileimg=$conf->societe->dir_output.'/'.$soc->id.'/logos/'.$soc->logo;
+ $dirthumbs=$conf->societe->dir_output.'/'.$soc->id.'/logos/thumbs';
+ dol_delete_file($fileimg);
+ dol_delete_dir_recursive($dirthumbs);
+ }
+
+ if (image_format_supported($_FILES['photo']['name']))
{
create_exdir($dir);
if (@is_dir($dir))
{
- $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['logo']['name']);
- $result = dol_move_uploaded_file($_FILES['logo']['tmp_name'], $newfile, 1);
+ $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
+ $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
if (! $result > 0)
{
@@ -366,7 +375,7 @@ else
}
### Gestion du logo de la société
- if ($result >= 0)
+ if (! $error && ! sizeof($errors))
{
Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
@@ -570,21 +579,21 @@ else
$soc->commercial_id=$_POST["commercial_id"];
$soc->default_lang=$_POST["default_lang"];
- $soc->logo = dol_sanitizeFileName($_FILES['logo']['name']);
+ $soc->logo = dol_sanitizeFileName($_FILES['photo']['name']);
### Gestion du logo de la société
- $dir = $conf->societe->dir_output."/".$soc->id."/logos/";
- $file_OK = is_uploaded_file($_FILES['logo']['tmp_name']);
+ $dir = $conf->societe->dir_output."/".$soc->id."/logos";
+ $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
- if (image_format_supported($_FILES['logo']['name']))
+ if (image_format_supported($_FILES['photo']['name']))
{
create_exdir($dir);
if (@is_dir($dir))
{
- $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['logo']['name']);
- $result = dol_move_uploaded_file($_FILES['logo']['tmp_name'], $newfile, 1);
+ $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
+ $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
if (! $result > 0)
{
@@ -823,9 +832,6 @@ else
print ''.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').' ';
print ''.$langs->trans('Web').' ';
- print ''.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).' ';
-
-
print '';
// IdProf1 (SIREN for France)
$idprof=$langs->transcountry('ProfId1',$soc->pays_code);
@@ -867,37 +873,6 @@ else
else print ' ';
print ' ';
- // Legal Form
- print ''.$langs->trans('JuridicalStatus').' ';
- print '';
- if ($soc->pays_id)
- {
- $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
- }
- else
- {
- print $countrynotdefined;
- }
- print ' ';
-
- // Type
- print ''.$langs->trans("ThirdPartyType").' '."\n";
- print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id);
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- print ' ';
- print ''.$langs->trans("Staff").' ';
- print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id);
- if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
- print ' ';
-
- if ($conf->global->MAIN_MULTILANGS)
- {
- print ''.$langs->trans("DefaultLang").' '."\n";
- print $formadmin->select_language(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
- print ' ';
- print ' ';
- }
-
// Assujeti TVA
$html = new Form($db);
print ''.$langs->trans('VATIsUsed').' ';
@@ -929,12 +904,36 @@ else
$s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').' ';
}
}
-
print $s;
print '';
-
print ' ';
+ // Type - Size
+ print ''.$langs->trans("ThirdPartyType").' '."\n";
+ print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id);
+ if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ print ' ';
+ print ''.$langs->trans("Staff").' ';
+ print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id);
+ if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ print ' ';
+
+ // Legal Form
+ print ''.$langs->trans('JuridicalStatus').' ';
+ print '';
+ if ($soc->pays_id)
+ {
+ $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
+ }
+ else
+ {
+ print $countrynotdefined;
+ }
+ print ' ';
+
+ // Capital
+ print ''.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).' ';
+
// Local Taxes
// TODO add specific function by country
if($mysoc->pays_code=='ES')
@@ -962,6 +961,14 @@ else
}
}
+ if ($conf->global->MAIN_MULTILANGS)
+ {
+ print ''.$langs->trans("DefaultLang").' '."\n";
+ print $formadmin->select_language(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
+ print ' ';
+ print ' ';
+ }
+
if ($user->rights->societe->client->voir)
{
// Assign a Name
@@ -976,7 +983,7 @@ else
print '';
print ''.$langs->trans("Logo").' ';
print '';
- print ' ';
+ print ' ';
print ' ';
print ' ';
@@ -1326,9 +1333,7 @@ else
$s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').' ';
}
}
-
print $s;
-
print '';
print '';
@@ -1360,12 +1365,7 @@ else
}
}
- print ''.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).' ';
-
- print ''.$langs->trans('JuridicalStatus').' ';
- $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
- print ' ';
-
+ // Type - Size
print ''.$langs->trans("ThirdPartyType").' ';
print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
@@ -1375,6 +1375,13 @@ else
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print ' ';
+ print ''.$langs->trans('JuridicalStatus').' ';
+ $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
+ print ' ';
+
+ // Capital
+ print ''.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).' ';
+
// Default language
if ($conf->global->MAIN_MULTILANGS)
{
@@ -1387,7 +1394,19 @@ else
// Logo
print '';
print ''.$langs->trans("Logo").' ';
- print ' ';
+ print '';
+ if ($soc->logo) print $form->showphoto('societe',$soc,50);
+ $caneditfield=1;
+ if ($caneditfield)
+ {
+ if ($soc->logo) print " \n";
+ print '';
+ }
+ print ' ';
print ' ';
print '';
@@ -1644,7 +1663,6 @@ else
print ' ';
}
print '';
-
print '';
// Local Taxes
@@ -1674,20 +1692,20 @@ else
}
}
+ // Type + Staff
+ $arr = $formcompany->typent_array(1);
+ $soc->typent= $arr[$soc->typent_code];
+ print ''.$langs->trans("ThirdPartyType").' '.$soc->typent.' '.$langs->trans("Staff").' '.$soc->effectif.' ';
+
+ // Legal
+ print ''.$langs->trans('JuridicalStatus').' '.$soc->forme_juridique.' ';
+
// Capital
print ''.$langs->trans('Capital').' ';
if ($soc->capital) print $soc->capital.' '.$langs->trans("Currency".$conf->monnaie);
else print ' ';
print ' ';
- // Legal
- print ''.$langs->trans('JuridicalStatus').' '.$soc->forme_juridique.' ';
-
- // Type + Staff
- $arr = $formcompany->typent_array(1);
- $soc->typent= $arr[$soc->typent_code];
- print ''.$langs->trans("ThirdPartyType").' '.$soc->typent.' '.$langs->trans("Staff").' '.$soc->effectif.' ';
-
// Default language
if ($conf->global->MAIN_MULTILANGS)
{
diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php
index ed2b95961ba..55cdb0c025d 100644
--- a/htdocs/user/fiche.php
+++ b/htdocs/user/fiche.php
@@ -289,7 +289,8 @@ if ($action == 'update' && ! $_POST["cancel"])
$edituser->phenix_login = $_POST["phenix_login"];
$edituser->phenix_pass = $_POST["phenix_pass"];
$edituser->entity = ( (! empty($_POST["superadmin"]) && ! empty($_POST["admin"])) ? 0 : $_POST["entity"]);
- if (! empty($_FILES['photo']['name'])) $edituser->photo = $_FILES['photo']['name'];
+ if (GETPOST('deletephoto')) $edituser->photo='';
+ if (! empty($_FILES['photo']['name'])) $edituser->photo = dol_sanitizeFileName($_FILES['photo']['name']);
$ret=$edituser->update($user);
if ($ret < 0)
@@ -305,19 +306,17 @@ if ($action == 'update' && ! $_POST["cancel"])
}
}
- /* Already included into update function
- if ($ret >= 0 && ! sizeof($edituser->errors) && isset($_POST["password"]) && $_POST["password"] !='')
- {
- $ret=$edituser->setPassword($user,$_POST["password"],0,1);
- if ($ret < 0)
- {
- $message.=''.$edituser->error.'
';
- }
- } */
-
if ($ret >=0 && ! sizeof($edituser->errors))
{
- if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
+ if (GETPOST('deletephoto') && $edituser->photo)
+ {
+ $fileimg=$conf->user->dir_output.'/'.get_exdir($edituser->id,2,0,1).'/logos/'.$edituser->photo;
+ $dirthumbs=$conf->user->dir_output.'/'.get_exdir($edituser->id,2,0,1).'/logos/thumbs';
+ dol_delete_file($fileimg);
+ dol_delete_dir_recursive($dirthumbs);
+ }
+
+ if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
{
$dir= $conf->user->dir_output . '/' . get_exdir($edituser->id,2,0,1);
@@ -325,7 +324,7 @@ if ($action == 'update' && ! $_POST["cancel"])
if (@is_dir($dir))
{
- $newfile=$dir.'/'.$_FILES['photo']['name'];
+ $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
$result=dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']);
if (! $result > 0)
@@ -895,7 +894,8 @@ else
if ($ret == 'html') print ' ';
}
- dol_htmloutput_errors($message);
+ if (! preg_match('/class="error"/',$message)) dol_htmloutput_mesg($message);
+ else dol_htmloutput_errors($message);
/*
* Fiche en mode visu
@@ -1128,8 +1128,6 @@ else
print "\n";
- if ($message) { print $message; }
-
/*
* Barre d'actions
@@ -1333,10 +1331,12 @@ else
print $html->showphoto('userphoto',$fuser);
if ($caneditfield)
{
- print ' ';
+ if ($fuser->photo) print " \n";
+ print '';
}
print '';
print '';