2
0
forked from Wavyzz/dolibarr

New: Upload of joined files need create/modify permissions to work

This commit is contained in:
Laurent Destailleur
2009-03-03 00:12:56 +00:00
parent 8476a218e5
commit ba14103659
13 changed files with 121 additions and 111 deletions

View File

@@ -35,6 +35,9 @@ For users:
- New: Add a first version of a module for Paybox.
- New: Can add contact to suppliers orders.
- New: Changements to support the external BitTorrent module.
- New: Can filter on social contribution type in list.
- New: Upload of joined files need create/modify permissions to work.
- Fix: Partial payment on social contributions not shown on main page.
- Fix: Handle correctly the comment in status changing of supplier orders.
- Fix: Author, title and topic are correctly encoded in PDF.
- Fix: Now HTML output is always UTF8, this solve bad PDF encoding on old users.

View File

@@ -19,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
\file htdocs/comm/action/document.php
\ingroup agenda
@@ -43,10 +43,10 @@ if (isset($_GET["error"])) $error=$_GET["error"];
$objectid = isset($_GET["id"])?$_GET["id"]:'';
// Security check
if ($user->societe_id > 0)
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$action='';
$socid = $user->societe_id;
}
@@ -118,7 +118,7 @@ if ($objectid > 0)
$company=new Societe($db);
$company->fetch($act->societe->id);
$act->societe=$company;
$author=new User($db);
$author->id=$act->author->id;
$author->fetch();
@@ -127,37 +127,37 @@ if ($objectid > 0)
$contact=new Contact($db);
$contact->fetch($act->contact->id);
$act->contact=$contact;
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objectid;
$head[$h][1] = $langs->trans("CardAction");
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$objectid;
$head[$h][1] = $langs->trans('Documents');
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/action/info.php?id='.$objectid;
$head[$h][1] = $langs->trans('Info');
$h++;
dol_fiche_head($head, $hselected, $langs->trans("Action"));
// Affichage fiche action en mode visu
print '<table class="border" width="100%"';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$act->id.'</td></tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>';
// Libelle
print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$act->label.'</td></tr>';
// Societe - contact
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$act->societe->getNomUrl(1).'</td>';
print '<td>'.$langs->trans("Contact").'</td>';
@@ -170,9 +170,9 @@ if ($objectid > 0)
{
print $langs->trans("None");
}
print '</td></tr>';
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
@@ -180,22 +180,22 @@ if ($objectid > 0)
{
$totalsize+=$file['size'];
}
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
if ($mesg) { print $mesg."<br>"; }
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id,'',0,0,($user->rights->agenda->myactions->create||$user->rights->agenda->actions->create));
// List of document
$param='&id='.$act->id;
$formfile->list_of_documents($filearray,$act,'actions',$param);
@@ -203,7 +203,7 @@ if ($objectid > 0)
else
{
dol_print_error($db);
}
}
}
else
{

View File

@@ -1984,7 +1984,7 @@ else
{
$propalstatic=new Propal($db);
$userstatic=new User($db);
$num = $db->num_rows($result);
$param='&amp;socid='.$socid.'&amp;viewstatut='.$viewstatut;
@@ -2012,7 +2012,7 @@ else
print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET['search_ref'].'">';
print '</td>';
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="28" name="search_societe" value="'.$_GET['search_societe'].'">';
print '<input class="flat" type="text" size="16" name="search_societe" value="'.$_GET['search_societe'].'">';
print '</td>';
print '<td class="liste_titre" colspan="1" align="right">';
print $langs->trans('Month').': <input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
@@ -2105,12 +2105,15 @@ else
$userstatic->id=$objp->fk_user_author;
$userstatic->login=$objp->login;
print '<td align="center">'.$userstatic->getLoginUrl(1)."</td>\n";
print '<td align="center">';
if ($userstatic->id) print $userstatic->getLoginUrl(1);
else print '&nbsp;';
print "</td>\n";
print '<td align="right">'.$propalstatic->LibStatut($objp->fk_statut,5)."</td>\n";
print '<td>&nbsp;</td>';
print "</tr>\n";
$total = $total + $objp->total_ht;

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
*
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
/**
\file htdocs/comm/propal/document.php
\ingroup propale
\brief Page de gestion des documents attach<63>es <20> une proposition commerciale
@@ -40,10 +40,10 @@ $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action'
$propalid = isset($_GET["propalid"])?$_GET["propalid"]:'';
// Security check
if ($user->societe_id)
if ($user->societe_id)
{
unset($_GET["action"]);
$action='';
$action='';
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'propale', $propalid, 'propal');
@@ -64,7 +64,7 @@ $pagenext = $page + 1;
/*
* Actions
*/
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
@@ -74,7 +74,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
$upload_dir = $conf->propal->dir_output . "/" . sanitizeFileName($propal->ref);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0) > 0)
@@ -111,7 +111,7 @@ if ($action=='delete')
/*
* Affichage
*/
llxHeader();
if ($propalid > 0)
@@ -127,7 +127,7 @@ if ($propalid > 0)
$head = propal_prepare_head($propal);
dol_fiche_head($head, 'document', $langs->trans('Proposal'));
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
@@ -135,7 +135,7 @@ if ($propalid > 0)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
@@ -156,7 +156,7 @@ if ($propalid > 0)
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id,'',0,0,$user->rights->propale->creer);
// List of document

View File

@@ -65,7 +65,7 @@ $pagenext = $page + 1;
$id = $_GET['id'];
$ref= $_GET['ref'];
$commande = new Commande($db);
if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
{
dol_print_error($db);
}
@@ -153,13 +153,13 @@ if ($id > 0 || ! empty($ref))
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/commande/document.php?id='.$commande->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/commande/document.php?id='.$commande->id,'',0,0,$user->rights->commande->creer);
// List of document
$param='&id='.$commande->id;
$formfile->list_of_documents($filearray,$commande,'commande',$param);
}
else
{

View File

@@ -156,7 +156,7 @@ if ($facid > 0)
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$facture->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/facture/document.php?facid='.$facture->id,'',0,0,$user->rights->facture->creer);
// List of document

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
@@ -19,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
\file htdocs/contrat/document.php
\ingroup contrat
@@ -40,10 +40,10 @@ if (!$user->rights->contrat->lire)
accessforbidden();
// Security check
if ($user->societe_id > 0)
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$action='';
$socid = $user->societe_id;
}
@@ -97,7 +97,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
/*
*
*/
$html = new Form($db);
llxHeader("","",$langs->trans("CardProduct".$product->type));
@@ -109,7 +109,7 @@ if ($contrat->id)
$soc->fetch($contrat->societe->id);
if ( $error_msg )
{
{
echo '<div class="error">'.$error_msg.'</div><br>';
}
@@ -132,8 +132,8 @@ if ($contrat->id)
{
$totalsize+=$file['size'];
}
print '<table class="border" width="100%">';
// Reference
@@ -152,11 +152,11 @@ if ($contrat->id)
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id,'',0,0,$user->rights->contrat->creer);
// List of document
$param='&id='.$contrat->id;
$param='&id='.$contrat->id;
$formfile->list_of_documents($filearray,$contrat,'contract',$param);
}

View File

@@ -154,7 +154,7 @@ if ($object->id)
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id,'',0,0,$user->rights->ficheinter->creer);
// List of document

View File

@@ -203,7 +203,7 @@ if ($id > 0 || ! empty($ref))
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/commande/document.php?id='.$commande->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/commande/document.php?id='.$commande->id,'',0,0,$user->rights->fournisseur->commande->creer);
// List of document

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
*
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
/**
\file htdocs/fourn/facture/document.php
\ingroup facture, fournisseur
\brief Page de gestion des documents attach<63>es <20> une facture fournisseur
@@ -44,10 +44,10 @@ $facid=empty($_GET['facid']) ? 0 : intVal($_GET['facid']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Security check
if ($user->societe_id > 0)
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$action='';
$socid = $user->societe_id;
}
@@ -68,7 +68,7 @@ $pagenext = $page + 1;
/*
* Actions
*/
// Envoi fichier
if ($_POST['sendit'] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
@@ -78,7 +78,7 @@ if ($_POST['sendit'] && ! empty($conf->global->MAIN_UPLOAD_DOC))
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($facture->id,2).$facture->id;
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . '/' . $_FILES['userfile']['name'],0) > 0)
@@ -116,7 +116,7 @@ if ($action=='delete')
/*
* Affichage
*/
llxHeader();
if ($facid > 0)
@@ -139,7 +139,7 @@ if ($facid > 0)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
@@ -163,16 +163,16 @@ if ($facid > 0)
if ($mesg) { print $mesg.'<br>'; }
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$facture->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$facture->id,'',0,0,$user->rights->fournisseur->facture->creer);
// List of document
$param='&facid='.$facture->id;
$formfile->list_of_documents($filearray,$facture,'facture_fournisseur',$param);
}
else
{

View File

@@ -51,9 +51,10 @@ class FormFile
* \param titre Titre zone
* \param addcancel 1=Ajoute un bouton 'Annuler'
* \param sectionid If upload must be done inside a particular ECM section
* \param perm Value of permission ot allow upload
* \return int <0 si ko, >0 si ok
*/
function form_attach_new_file($url,$titre='',$addcancel=0, $sectionid=0)
function form_attach_new_file($url,$titre='',$addcancel=0, $sectionid=0, $perm=1)
{
global $conf,$langs;
@@ -80,11 +81,11 @@ class FormFile
print '<input type="hidden" name="max_file_size" value="'.($max*1024).'">';
}
print '<input class="flat" type="file" name="userfile" size="70"';
print (empty($conf->global->MAIN_UPLOAD_DOC)?' disabled="true"':'');
print (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="true"':'');
print '>';
print ' &nbsp; ';
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"';
print (empty($conf->global->MAIN_UPLOAD_DOC)?' disabled="true"':'');
print (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="true"':'');
print '>';
if ($addcancel)
@@ -95,9 +96,12 @@ class FormFile
if (! empty($conf->global->MAIN_UPLOAD_DOC))
{
print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb");
print ' '.info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
print ')';
if ($perm)
{
print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb");
print ' '.info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
print ')';
}
}
else
{

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
@@ -19,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
\file htdocs/product/document.php
\ingroup product
@@ -42,10 +42,10 @@ if (!$user->rights->produit->lire)
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Security check
if ($user->societe_id > 0)
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$action='';
$socid = $user->societe_id;
}
@@ -103,7 +103,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
/*
*
*/
$html = new Form($db);
llxHeader("","",$langs->trans("CardProduct".$product->type));
@@ -112,7 +112,7 @@ llxHeader("","",$langs->trans("CardProduct".$product->type));
if ($product->id)
{
if ( $error_msg )
{
{
echo '<div class="error">'.$error_msg.'</div><br>';
}
@@ -135,8 +135,8 @@ if ($product->id)
{
$totalsize+=$file['size'];
}
print '<table class="border" width="100%">';
// Reference
@@ -175,13 +175,13 @@ if ($product->id)
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/document.php?id='.$product->id);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/document.php?id='.$product->id,'',0,0,$user->rights->produit->creer);
// List of document
$param='&id='.$product->id;
$formfile->list_of_documents($filearray,$product,'produit',$param);
}
else
{

View File

@@ -37,10 +37,10 @@ $mesg = "";
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:(! empty($_GET["id"])?$_GET["id"]:'');
if ($user->societe_id > 0)
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$action='';
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'societe', $socid);
@@ -74,7 +74,7 @@ $courrier_dir = $conf->societe->dir_output . "/courrier/" . get_exdir($socid) ;
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
{
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0);
@@ -121,11 +121,11 @@ if ($socid > 0)
* Affichage onglets
*/
$head = societe_prepare_head($societe);
$html=new Form($db);
dol_fiche_head($head, 'document', $langs->trans("ThirdParty"));
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
@@ -134,28 +134,28 @@ if ($socid > 0)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
// Ref
print '<tr><td width="30%">'.$langs->trans("Name").'</td><td colspan="3">'.$societe->nom.'</td></tr>';
// Prefix
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$societe->prefix_comm.'</td></tr>';
// Nbre fichiers
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
//Total taille
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
if ($mesg) { print "$mesg<br>"; }
/*
* Confirmation de la suppression d'une ligne produit
*/
@@ -164,27 +164,27 @@ if ($socid > 0)
$html->form_confirm($_SERVER["PHP_SELF"].'?socid='.$_GET["id"].'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
print '<br>';
}
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/societe/document.php?socid='.$socid);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/societe/document.php?socid='.$socid,'',0,0,$user->rights->societe->creer);
// List of document
$param='&socid='.$societe->id;
$formfile->list_of_documents($filearray,$societe,'societe',$param);
print "<br><br>";
// Courriers
// Les courriers sont des documents speciaux generes par des scripts
// situes dans scripts/courrier.
// Voir Rodo
if ($conf->global->MAIN_MODULE_EDITEUR)
{
$filearray=array();
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($courrier_dir);
@@ -201,7 +201,7 @@ if ($socid > 0)
}
}
closedir($handle);
}
}
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre"><td>'.$langs->trans("Courriers").'</td><td align="right">'.$langs->trans("Size").'</td><td align="center">'.$langs->trans("Date").'</td></tr>';