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

This commit is contained in:
Regis Houssin 2012-07-29 15:47:40 +02:00
commit 1591a5ac3b
9 changed files with 84 additions and 86 deletions

View File

@ -632,27 +632,27 @@ else if ($action == 'addline' && $user->rights->commande->creer)
{
// Insert line
$result = $object->addline(
$object->id,
$desc,
$pu_ht,
GETPOST('qty'),
$tva_tx,
$localtax1_tx,
$localtax2_tx,
GETPOST('idprod'),
GETPOST('remise_percent'),
$info_bits,
0,
$price_base_type,
$pu_ttc,
$date_start,
$date_end,
$type,
-1,
'',
GETPOST('fk_parent_line'),
GETPOST('np_fournprice'),
GETPOST('np_buying_price')
$object->id,
$desc,
$pu_ht,
GETPOST('qty'),
$tva_tx,
$localtax1_tx,
$localtax2_tx,
GETPOST('idprod'),
GETPOST('remise_percent'),
$info_bits,
0,
$price_base_type,
$pu_ttc,
$date_start,
$date_end,
$type,
-1,
'',
GETPOST('fk_parent_line'),
GETPOST('np_fournprice'),
GETPOST('np_buying_price')
);
if ($result > 0)

View File

@ -43,9 +43,9 @@ class RemiseCheque extends CommonObject
/**
* Constructor
*
* @param DoliDB $DB Database handler
* @param DoliDB $db Database handler
*/
function RemiseCheque($DB)
function RemiseCheque($db)
{
$this->db = $DB;
$this->next_id = 0;

View File

@ -44,7 +44,7 @@ function SetXmlHeaders()
header('Pragma: no-cache');
// Set the response format.
header( 'Content-Type: text/xml; charset=utf-8' );
header('Content-Type: text/xml; charset=utf-8');
}
function CreateXmlHeader( $command, $resourceType, $currentFolder )
@ -58,7 +58,7 @@ function CreateXmlHeader( $command, $resourceType, $currentFolder )
echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">' ;
// Add the current folder node.
echo '<CurrentFolder path="' . ConvertToXmlAttribute( $currentFolder ) . '" url="' . ConvertToXmlAttribute( GetUrlFromPath( $resourceType, $currentFolder, $command ) ) . '" />' ;
echo '<CurrentFolder path="' . ConvertToXmlAttribute($currentFolder) . '" url="' . ConvertToXmlAttribute(GetUrlFromPath($resourceType, $currentFolder, $command)) . '" />' ;
$GLOBALS['HeaderSent'] = true ;
}
@ -68,14 +68,21 @@ function CreateXmlFooter()
echo '</Connector>' ;
}
function SendError( $number, $text )
/**
* SendError
*
* @param unknown_type $number Number
* @param unknown_type $text Text
* @return void
*/
function SendError($number, $text)
{
if ( $_GET['Command'] == 'FileUpload' )
SendUploadResults( $number, "", "", $text );
SendUploadResults($number, "", "", $text);
if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] )
{
SendErrorNode( $number, $text );
SendErrorNode($number, $text);
CreateXmlFooter();
}
else
@ -87,17 +94,17 @@ function SendError( $number, $text )
echo '<Connector>' ;
SendErrorNode( $number, $text );
SendErrorNode($number, $text);
echo '</Connector>' ;
}
exit ;
}
function SendErrorNode( $number, $text )
function SendErrorNode($number, $text)
{
if ($text)
echo '<Error number="' . $number . '" text="' . htmlspecialchars( $text ) . '" />' ;
echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ;
else
echo '<Error number="' . $number . '" />' ;
}

View File

@ -29,10 +29,9 @@ require('./util.php');
require('./io.php');
require('./basexml.php');
require('./commands.php');
require('./phpcompat.php');
if ( !$Config['Enabled'] )
SendError( 1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file' );
SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file');
DoResponse();
@ -50,33 +49,33 @@ function DoResponse()
$sCurrentFolder = GetCurrentFolder();
// Check if it is an allowed command
if ( ! IsAllowedCommand( $sCommand ) )
SendError( 1, 'The "' . $sCommand . '" command isn\'t allowed' );
if (! IsAllowedCommand($sCommand))
SendError(1, 'The "' . $sCommand . '" command isn\'t allowed');
// Check if it is an allowed type.
if ( !IsAllowedType( $sResourceType ) )
SendError( 1, 'Invalid type specified' );
if (! IsAllowedType($sResourceType))
SendError(1, 'Invalid type specified');
// File Upload doesn't have to Return XML, so it must be intercepted before anything.
if ( $sCommand == 'FileUpload' )
{
FileUpload( $sResourceType, $sCurrentFolder, $sCommand );
FileUpload($sResourceType, $sCurrentFolder, $sCommand);
return ;
}
CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder );
CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder);
// Execute the required command.
switch ( $sCommand )
{
case 'GetFolders' :
GetFolders( $sResourceType, $sCurrentFolder );
GetFolders($sResourceType, $sCurrentFolder);
break ;
case 'GetFoldersAndFiles' :
GetFoldersAndFiles( $sResourceType, $sCurrentFolder );
GetFoldersAndFiles($sResourceType, $sCurrentFolder);
break ;
case 'CreateFolder' :
CreateFolder( $sResourceType, $sCurrentFolder );
CreateFolder($sResourceType, $sCurrentFolder);
break ;
}

View File

@ -1,16 +0,0 @@
<?php
if ( !isset( $_SERVER ) ) {
$_SERVER = $HTTP_SERVER_VARS ;
}
if ( !isset( $_GET ) ) {
$_GET = $HTTP_GET_VARS ;
}
if ( !isset( $_FILES ) ) {
$_FILES = $HTTP_POST_FILES ;
}
if (! defined('DIRECTORY_SEPARATOR'))
{
define('DIRECTORY_SEPARATOR', strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/');
}

View File

@ -26,17 +26,16 @@ require('./config.php');
require('./util.php');
require('./io.php');
require('./commands.php');
require('./phpcompat.php');
function SendError( $number, $text )
{
SendUploadResults( $number, '', '', $text );
SendUploadResults($number, '', '', $text);
}
// Check if this uploader has been enabled.
if ( !$Config['Enabled'] )
SendUploadResults( '1', '', '', 'This file uploader is disabled. Please check the "editor/filemanager/connectors/php/config.php" file' );
SendUploadResults('1', '', '', 'This file uploader is disabled. Please check the "editor/filemanager/connectors/php/config.php" file');
$sCommand = 'QuickUpload' ;
@ -46,12 +45,12 @@ $sType = isset( $_GET['Type'] ) ? $_GET['Type'] : 'File' ;
$sCurrentFolder = "/" ;
// Is enabled the upload?
if ( ! IsAllowedCommand( $sCommand ) )
SendUploadResults( '1', '', '', 'The ""' . $sCommand . '"" command isn\'t allowed' );
if (! IsAllowedCommand($sCommand))
SendUploadResults('1', '', '', 'The ""' . $sCommand . '"" command isn\'t allowed');
// Check if it is an allowed type.
if ( !IsAllowedType( $sType ) )
SendUploadResults( 1, '', '', 'Invalid type specified' );
if (! IsAllowedType($sType))
SendUploadResults(1, '', '', 'Invalid type specified');
// DOL_CHANGE

View File

@ -25,15 +25,20 @@
function RemoveFromStart( $sourceString, $charToRemove )
{
$sPattern = '|^' . $charToRemove . '+|' ;
return preg_replace( $sPattern, '', $sourceString );
return preg_replace($sPattern, '', $sourceString);
}
function RemoveFromEnd( $sourceString, $charToRemove )
function RemoveFromEnd( $sourceString, $charToRemove)
{
$sPattern = '|' . $charToRemove . '+$|' ;
return preg_replace( $sPattern, '', $sourceString );
return preg_replace($sPattern, '', $sourceString);
}
/**
* FindBadUtf8
*
* @param unknown_type $string String
*/
function FindBadUtf8( $string )
{
$regex =
@ -57,6 +62,11 @@ function FindBadUtf8( $string )
return false;
}
/**
* ConvertToXmlAttribute
*
* @param unknown_type $value
*/
function ConvertToXmlAttribute( $value )
{
if ( defined( 'PHP_OS' ) )
@ -173,10 +183,9 @@ function DetectHtml( $filePath )
* Currently this function validates only image files.
* Returns false if file is invalid.
*
* @param string $filePath absolute path to file
* @param string $extension file extension
* @param integer $detectionLevel 0 = none, 1 = use getimagesize for images, 2 = use DetectHtml for images
* @return boolean
* @param string $filePath Absolute path to file
* @param string $extension File extension
* @return boolean True or false
*/
function IsImageValid( $filePath, $extension )
{
@ -206,11 +215,11 @@ function IsImageValid( $filePath, $extension )
}
}
if ( !in_array( $extension, $imageCheckExtensions ) ) {
if (!in_array($extension, $imageCheckExtensions) ) {
return true;
}
if ( @getimagesize( $filePath ) === false ) {
if (@getimagesize($filePath) === false) {
return false ;
}

View File

@ -784,7 +784,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
$langs->load("suppliers");
$newmenu->add("/fourn/liste.php?leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers');
if ($user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/societe/soc.php?leftmenu=suppliers&amp;action=create&amp;type=f",$langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && $user->rights->fournisseur->lire);
}
@ -808,7 +808,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
$langs->load("categories");
// Categories prospects/customers
$newmenu->add("/categories/index.php?leftmenu=cat&amp;type=2", $langs->trans("CustomersProspectsCategoriesShort"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat');
if ($user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/categories/fiche.php?action=create&amp;type=2", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
}
@ -816,7 +816,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
if ($conf->fournisseur->enabled)
{
$newmenu->add("/categories/index.php?leftmenu=cat&amp;type=1", $langs->trans("SuppliersCategoriesShort"), 0, $user->rights->categorie->lire);
if ($user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/categories/fiche.php?action=create&amp;type=1", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
}
@ -913,7 +913,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
{
$langs->load("bills");
$newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills');
if ($user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/compta/clients.php?action=facturer&amp;leftmenu=customers_bills",$langs->trans("NewBill"),1,$user->rights->facture->creer);
}
@ -939,7 +939,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
{
$langs->load("bills");
$newmenu->add("/fourn/facture/index.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
if (! isset($user->societe_id) || $user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer);
}
@ -1126,7 +1126,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
if (! empty($conf->product->enabled))
{
$newmenu->add("/product/index.php?leftmenu=product&amp;type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product');
if ($user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/product/fiche.php?leftmenu=product&amp;action=create&amp;type=0", $langs->trans("NewProduct"), 1, $user->rights->produit->creer);
$newmenu->add("/product/liste.php?leftmenu=product&amp;type=0", $langs->trans("List"), 1, $user->rights->produit->lire);
@ -1145,7 +1145,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
if (! empty($conf->service->enabled))
{
$newmenu->add("/product/index.php?leftmenu=service&amp;type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service');
if ($user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/product/fiche.php?leftmenu=service&amp;action=create&amp;type=1", $langs->trans("NewService"), 1, $user->rights->service->creer);
}
@ -1161,7 +1161,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
{
$langs->load("categories");
$newmenu->add("/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat');
if ($user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/categories/fiche.php?action=create&amp;type=0", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer);
}
@ -1204,7 +1204,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
$newmenu->add("/fourn/index.php?leftmenu=suppliers", $langs->trans("Suppliers"), 0, $user->rights->societe->lire && $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers');
// Security check
if ($user->societe_id == 0)
if (empty($user->societe_id))
{
$newmenu->add("/societe/soc.php?leftmenu=suppliers&amp;action=create&amp;type=f",$langs->trans("NewSupplier"), 1, $user->rights->societe->creer && $user->rights->fournisseur->lire);
}
@ -1367,7 +1367,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
$tabMenu=array();
$menuArbo = new Menubase($db,'eldy','left');
$newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'eldy',$tabMenu);
$newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,(empty($user->societe_id)?0:1),'eldy',$tabMenu);
}

View File

@ -700,7 +700,7 @@ function write_main_file($mainfile,$main_dir)
{
clearstatcache();
fputs($fp, '<?php'."\n");
fputs($fp, "# Wrapper to include main into htdocs\n");
fputs($fp, "// Wrapper to include main into htdocs\n");
fputs($fp, "include_once('".$main_dir."/main.inc.php');\n");
fputs($fp, '?>');
fclose($fp);
@ -722,7 +722,7 @@ function write_master_file($masterfile,$main_dir)
{
clearstatcache();
fputs($fp, '<?php'."\n");
fputs($fp, "# Wrapper to include master into htdocs\n");
fputs($fp, "// Wrapper to include master into htdocs\n");
fputs($fp, "include_once('".$main_dir."/master.inc.php');\n");
fputs($fp, '?>');
fclose($fp);