New: #11194 Can delete uploaded photos
This commit is contained in:
parent
2ee6c0bcc9
commit
95de083d90
@ -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 .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
|
||||
@ -860,10 +869,12 @@ if ($action == 'edit')
|
||||
print $html->showphoto('memberphoto',$adh)."\n";
|
||||
if ($caneditfieldmember)
|
||||
{
|
||||
print '<br><br><table class="nobordernopadding"><tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||
print '<tr><td>';
|
||||
print '<input type="file" class="flat" name="photo">';
|
||||
print '</td></tr></table>';
|
||||
if ($adh->photo) print "<br>\n";
|
||||
print '<table class="nobordernopadding">';
|
||||
if ($adh->photo) print '<tr><td align="center"><input type="checkbox" class="flat" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
@ -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.='<img alt="Photo" class="photologo" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($file).'">';
|
||||
}
|
||||
else if ($altfile && file_exists($dir."/".$altfile))
|
||||
{
|
||||
$ret.='<img alt="Photo" class="photologo" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($altfile).'">';
|
||||
$ret.='<img alt="Photo alt" class="photologo" width="'.$width.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($altfile).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -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 '<tr><td>'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').'</td><td><input type="text" name="email" size="32" value="'.$soc->email.'"></td>';
|
||||
print '<td>'.$langs->trans('Web').'</td><td><input type="text" name="url" size="32" value="'.$soc->url.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
|
||||
print '<tr>';
|
||||
// IdProf1 (SIREN for France)
|
||||
$idprof=$langs->transcountry('ProfId1',$soc->pays_code);
|
||||
@ -867,37 +873,6 @@ else
|
||||
else print '<td> </td><td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Legal Form
|
||||
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td>';
|
||||
print '<td colspan="3">';
|
||||
if ($soc->pays_id)
|
||||
{
|
||||
$formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $countrynotdefined;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Type
|
||||
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>'."\n";
|
||||
print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id);
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans("Staff").'</td><td>';
|
||||
print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id);
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("DefaultLang").'</td><td colspan="3">'."\n";
|
||||
print $formadmin->select_language(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Assujeti TVA
|
||||
$html = new Form($db);
|
||||
print '<tr><td>'.$langs->trans('VATIsUsed').'</td>';
|
||||
@ -929,12 +904,36 @@ else
|
||||
$s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print $s;
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
// Type - Size
|
||||
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>'."\n";
|
||||
print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id);
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans("Staff").'</td><td>';
|
||||
print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id);
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Legal Form
|
||||
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td>';
|
||||
print '<td colspan="3">';
|
||||
if ($soc->pays_id)
|
||||
{
|
||||
$formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $countrynotdefined;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Capital
|
||||
print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Local Taxes
|
||||
// TODO add specific function by country
|
||||
if($mysoc->pays_code=='ES')
|
||||
@ -962,6 +961,14 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("DefaultLang").'</td><td colspan="3">'."\n";
|
||||
print $formadmin->select_language(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if ($user->rights->societe->client->voir)
|
||||
{
|
||||
// Assign a Name
|
||||
@ -976,7 +983,7 @@ else
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Logo").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print '<input class="flat" type="file" name="logo" />';
|
||||
print '<input class="flat" type="file" name="photo" id="photoinput" />';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -1326,9 +1333,7 @@ else
|
||||
$s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print $s;
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -1360,12 +1365,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
|
||||
$formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
|
||||
print '</td></tr>';
|
||||
|
||||
// Type - Size
|
||||
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
|
||||
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 '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
|
||||
$formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
|
||||
print '</td></tr>';
|
||||
|
||||
// Capital
|
||||
print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Default language
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
@ -1387,7 +1394,19 @@ else
|
||||
// Logo
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Logo").'</span></td>';
|
||||
print '<td colspan="3"><input type="file" name="logo" /></td>';
|
||||
print '<td colspan="3">';
|
||||
if ($soc->logo) print $form->showphoto('societe',$soc,50);
|
||||
$caneditfield=1;
|
||||
if ($caneditfield)
|
||||
{
|
||||
if ($soc->logo) print "<br>\n";
|
||||
print '<table class="nobordernopadding">';
|
||||
if ($soc->logo) print '<tr><td><input type="checkbox" class="flat" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
@ -1644,7 +1663,6 @@ else
|
||||
print ' ';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
// Local Taxes
|
||||
@ -1674,20 +1692,20 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
// Type + Staff
|
||||
$arr = $formcompany->typent_array(1);
|
||||
$soc->typent= $arr[$soc->typent_code];
|
||||
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>'.$soc->typent.'</td><td>'.$langs->trans("Staff").'</td><td>'.$soc->effectif.'</td></tr>';
|
||||
|
||||
// Legal
|
||||
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$soc->forme_juridique.'</td></tr>';
|
||||
|
||||
// Capital
|
||||
print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3">';
|
||||
if ($soc->capital) print $soc->capital.' '.$langs->trans("Currency".$conf->monnaie);
|
||||
else print ' ';
|
||||
print '</td></tr>';
|
||||
|
||||
// Legal
|
||||
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$soc->forme_juridique.'</td></tr>';
|
||||
|
||||
// Type + Staff
|
||||
$arr = $formcompany->typent_array(1);
|
||||
$soc->typent= $arr[$soc->typent_code];
|
||||
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>'.$soc->typent.'</td><td>'.$langs->trans("Staff").'</td><td>'.$soc->effectif.'</td></tr>';
|
||||
|
||||
// Default language
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
|
||||
@ -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.='<div class="error">'.$edituser->error.'</div>';
|
||||
}
|
||||
} */
|
||||
|
||||
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 '<br>';
|
||||
}
|
||||
|
||||
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 "</div>\n";
|
||||
|
||||
if ($message) { print $message; }
|
||||
|
||||
|
||||
/*
|
||||
* Barre d'actions
|
||||
@ -1333,10 +1331,12 @@ else
|
||||
print $html->showphoto('userphoto',$fuser);
|
||||
if ($caneditfield)
|
||||
{
|
||||
print '<br><br><table class="nobordernopadding"><tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||
print '<tr><td>';
|
||||
print '<input type="file" class="flat" name="photo">';
|
||||
print '</td></tr></table>';
|
||||
if ($fuser->photo) print "<br>\n";
|
||||
print '<table class="nobordernopadding">';
|
||||
if ($fuser->photo) print '<tr><td align="center"><input type="checkbox" class="flat" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user