Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-07-31 00:07:19 +02:00
commit 2f19fd9612
7 changed files with 75 additions and 81 deletions

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Pierre Morin <pierre.morin@auguria.net>
*
* This program is free software; you can redistribute it and/or modify
@ -54,7 +54,7 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$upload_dir = dirname(str_replace("../","/", $conf->ecm->dir_output.'/'.$file));
$ecmdir = new EcmDirectory($db);
@ -121,7 +121,7 @@ if (! isset($mode) || $mode != 'noajax')
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
top_httphead();
}
@ -137,7 +137,7 @@ if (! dol_is_dir($upload_dir))
}
print '<!-- TYPE='.$type.' -->'."\n";
print '<!-- Page called with mode='.$mode.' url='.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
print '<!-- Page called with mode='.(isset($mode)?$mode:'').' url='.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
$param='';
$param.=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
@ -252,7 +252,7 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
if ($section)
{
$param.=($param?'?':'').(preg_replace('/^&/','',$param));
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php');
$useglobalvars=1;
$form = new Form($db);

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -23,8 +23,8 @@
* \brief Module to generate box of last products/services
*/
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
include_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
/**
@ -105,7 +105,8 @@ class box_produits extends ModeleBoxes
if ($resultd)
{
$objtp = $db->fetch_object($resultd);
if ($objtp->label != '') $objp->label = $objtp->label;
if (isset($objtp->label) && $objtp->label != '')
$objp->label = $objtp->label;
}
}

View File

@ -581,7 +581,8 @@ class FormFile
&& ! preg_match('/\.meta$/i',$file['name']))
{
// Define relative path used to store the file
if (! $relativepath) $relativepath=dol_sanitizeFileName($object->ref).'/';
if (empty($relativepath))
$relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/';
$var=!$var;
print '<tr '.$bc[$var].'>';
@ -725,14 +726,14 @@ class FormFile
$id=0; $ref=''; $label='';
// To show ref or specific information according to view to show (defined by $module)
if ($modulepart == 'company') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=$reg[1]; }
if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=$reg[1]; }
if ($modulepart == 'invoice_supplier') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=$reg[1]; }
if ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=$reg[1]; }
if ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=$reg[1]; }
if ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=$reg[1]; }
if ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=$reg[1]; }
if ($modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=$reg[1]; }
if ($modulepart == 'company') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'invoice_supplier') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'propal') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'order') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'order_supplier') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'contract') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:''); }
if ($modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:''); }
if (! $id && ! $ref) continue;

View File

@ -287,7 +287,7 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0)
if ($mode == 1)
{
$tmp=explode('/',$mime);
return $tmp[1];
return (! empty($tmp[1])?$tmp[1]:$tmp[0]);
}
if ($mode == 2)
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2009 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -529,7 +529,7 @@ class EcmDirectory // extends CommonObject
{
global $conf;
if (empty($force) && $this->full_arbo_loaded)
if (empty($force) && ! empty($this->full_arbo_loaded))
{
return $this->cats;
}
@ -561,7 +561,7 @@ class EcmDirectory // extends CommonObject
while ($obj = $this->db->fetch_object($resql))
{
$this->cats[$obj->rowid]['id'] = $obj->rowid;
$this->cats[$obj->rowid]['id_mere'] = $this->motherof[$obj->rowid];
$this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid])?$this->motherof[$obj->rowid]:'');
$this->cats[$obj->rowid]['label'] = $obj->label;
$this->cats[$obj->rowid]['description'] = $obj->description;
$this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc;
@ -617,7 +617,7 @@ class EcmDirectory // extends CommonObject
function build_path_from_id_categ($id_categ,$protection=0)
{
// Define fullpath
if (isset($this->cats[$id_categ]['id_mere']))
if (! empty($this->cats[$id_categ]['id_mere']))
{
$this->cats[$id_categ]['fullpath'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
$this->cats[$id_categ]['fullpath'].='_'.$id_categ;
@ -638,7 +638,7 @@ class EcmDirectory // extends CommonObject
// Traite ces enfants
$protection++;
if ($protection > 20) return; // On ne traite pas plus de 20 niveaux
if (is_array($this->cats[$id_categ]['id_children']))
if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children']))
{
foreach($this->cats[$id_categ]['id_children'] as $key => $val)
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -39,10 +39,12 @@ $langs->load("bills");
$langs->load("contracts");
$langs->load("categories");
if (!$user->rights->ecm->setup) accessforbidden();
if (! $user->rights->ecm->setup) accessforbidden();
// Get parameters
$socid = GETPOST("socid","int");
$socid = GETPOST('socid','int');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
// Security check
if ($user->societe_id > 0)
@ -51,9 +53,9 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
$section=$_GET["section"];
if (! $section) $section='misc';
$upload_dir = $conf->ecm->dir_output.'/'.$section;
$section=$urlsection=GETPOST('section');
if (empty($urlsection)) $urlsection='misc';
$upload_dir = $conf->ecm->dir_output.'/'.$urlsection;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@ -66,9 +68,9 @@ if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="label";
$ecmdir = new EcmDirectory($db);
if (! empty($_GET["section"]))
if (! empty($section))
{
$result=$ecmdir->fetch($_GET["section"]);
$result=$ecmdir->fetch($section);
if (! $result > 0)
{
dol_print_error($db,$ecmdir->error);
@ -77,14 +79,12 @@ if (! empty($_GET["section"]))
}
/*******************************************************************
* ACTIONS
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
/*
* Actions
*/
// Action ajout d'un produit ou service
if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
if ($action == 'add' && $user->rights->ecm->setup)
{
if (! empty($_POST["cancel"]))
{
@ -100,8 +100,8 @@ if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
if (! $ecmdir->label)
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
$_GET["action"] = "create";
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors');
$action = 'create';
$ok=false;
}
@ -117,34 +117,32 @@ if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
else
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans($ecmdir->error).'</div>';
$_GET["action"] = "create";
setEventMessage($langs->trans($ecmdir->error), 'errors');
$action = 'create';
}
}
}
// Suppression fichier
if ($_POST['action'] == 'confirm_deletesection' && $_POST['confirm'] == 'yes')
if ($action == 'confirm_deletesection' && $confirm == 'yes')
{
$result=$ecmdir->delete($user);
$mesg = '<div class="ok">'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'</div>';
setEventMessage($langs->trans("ECMSectionWasRemoved", $ecmdir->label));
}
/*******************************************************************
* PAGE
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
/*
* View
*/
llxHeader();
$form=new Form($db);
$formecm=new FormEcm($db);
if ($_GET["action"] == 'create')
if ($action == 'create')
{
//***********************
// Create
@ -155,7 +153,6 @@ if ($_GET["action"] == 'create')
$title=$langs->trans("ECMNewSection");
print_fiche_titre($title);
if ($mesg) { print $mesg."<br>"; }
print '<table class="border" width="100%">';
@ -186,7 +183,7 @@ if ($_GET["action"] == 'create')
}
if (! $_GET["action"] || $_GET["action"] == 'delete_section')
if (empty($action) || $action == 'delete_section')
{
//***********************
// List
@ -204,15 +201,12 @@ if (! $_GET["action"] || $_GET["action"] == 'delete_section')
*/
// Confirmation de la suppression d'une ligne categorie
if ($_GET['action'] == 'delete_section')
if ($action == 'delete_section')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_GET["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection');
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection');
if ($ret == 'html') print '<br>';
}
if ($mesg) { print $mesg."<br>"; }
// Construit fiche rubrique
@ -231,7 +225,6 @@ if (! $_GET["action"] || $_GET["action"] == 'delete_section')
// End of page
$db->close();
llxFooter();
$db->close();
?>

View File

@ -34,6 +34,9 @@ $langs->load("ecm");
$langs->load("companies");
$langs->load("other");
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@ -101,12 +104,12 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
// Echec transfert (fichier depassant la limite ?)
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
setEventMessage($langs->trans("ErrorFailToCreateDir",$upload_dir), 'errors');
}
}
// Remove file
if (GETPOST('action') == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
$langs->load("other");
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
@ -118,7 +121,7 @@ if (GETPOST('action') == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
}
// Remove dir
if (GETPOST('action') == 'confirm_deletedir' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_deletedir' && $confirm == 'yes')
{
// Fetch was already done
$result=$ecmdir->delete($user);
@ -129,12 +132,12 @@ if (GETPOST('action') == 'confirm_deletedir' && GETPOST('confirm') == 'yes')
}
else
{
$mesg = '<div class="error">'.$langs->trans($ecmdir->error,$ecmdir->label).'</div>';
setEventMessage($langs->trans($ecmdir->error,$ecmdir->label), 'errors');
}
}
// Update description
if (GETPOST('action') == 'update' && ! GETPOST('cancel'))
if ($action == 'update' && ! GETPOST('cancel'))
{
$error=0;
@ -151,8 +154,7 @@ if (GETPOST('action') == 'update' && ! GETPOST('cancel'))
if ($result > 0)
{
// Try to rename file if changed
if ($oldlabel != $ecmdir->label
&& file_exists($olddir))
if ($oldlabel != $ecmdir->label && file_exists($olddir))
{
$newdir=$ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory
$newdir=$conf->ecm->dir_output.'/'.$newdir;
@ -161,7 +163,7 @@ if (GETPOST('action') == 'update' && ! GETPOST('cancel'))
if (! $result)
{
$langs->load('errors');
$mesg='<div class="error">'.$langs->trans('ErrorFailToRenameDir',$olddir,$newdir).'</div>';
setEventMessage($langs->trans('ErrorFailToRenameDir',$olddir,$newdir), 'errors');
$error++;
}
}
@ -181,7 +183,7 @@ if (GETPOST('action') == 'update' && ! GETPOST('cancel'))
else
{
$db->rollback();
$mesg='<div class="error">'.$ecmdir->error.'</div>';
setEventMessage($ecmdir->error, 'errors');
}
}
@ -210,7 +212,7 @@ foreach($filearray as $key => $file)
$head = ecm_prepare_head($ecmdir);
dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), '', 'dir');
if ($_GET["action"] == 'edit')
if ($action == 'edit')
{
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -228,7 +230,7 @@ $i=0;
while ($tmpecmdir && $result > 0)
{
$tmpecmdir->ref=$tmpecmdir->label;
if ($i == 0 && $_GET["action"] == 'edit')
if ($i == 0 && $action == 'edit')
{
$s='<input type="text" name="label" size="40" maxlength="32" value="'.$tmpecmdir->label.'">';
}
@ -249,7 +251,7 @@ print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$l
print $s;
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
if ($_GET["action"] == 'edit')
if ($action == 'edit')
{
print '<textarea class="flat" name="description" cols="80">';
print $ecmdir->description;
@ -274,7 +276,7 @@ print '</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>';
print dol_print_size($totalsize);
print '</td></tr>';
if ($_GET["action"] == 'edit')
if ($action == 'edit')
{
print '<tr><td colspan="2" align="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">';
@ -283,7 +285,7 @@ if ($_GET["action"] == 'edit')
print '</td></tr>';
}
print '</table>';
if ($_GET["action"] == 'edit')
if ($action == 'edit')
{
print '</form>';
}
@ -292,7 +294,7 @@ print '</div>';
// Actions buttons
if ($_GET["action"] != 'edit' && $_GET['action'] != 'delete')
if ($action != 'edit' && $action != 'delete')
{
print '<div class="tabsAction">';
@ -328,18 +330,15 @@ if ($_GET["action"] != 'edit' && $_GET['action'] != 'delete')
print '</div>';
}
if ($mesg) { print '<br>'.$mesg.'<br>'; }
// Confirm remove file
if ($_GET['action'] == 'delete')
if ($action == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&amp;urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
if ($ret == 'html') print '<br>';
}
// Confirm remove file
if ($_GET['action'] == 'delete_dir')
if ($action == 'delete_dir')
{
$relativepathwithoutslash=preg_replace('/[\/]$/','',$relativepath);
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1);