This commit is contained in:
Florian Henry 2013-10-25 10:02:05 +02:00
commit fc9752964f
3 changed files with 48 additions and 25 deletions

View File

@ -152,26 +152,29 @@ if (! empty($dolibarr_main_document_root_alt))
// Define DOL_MAIN_URL_ROOT and DOL_URL_ROOT // Define DOL_MAIN_URL_ROOT and DOL_URL_ROOT
$tmp=''; $tmp='';
$found=0; $found=0;
$real_dolibarr_main_document_root=str_replace('\\','/',realpath($dolibarr_main_document_root)); // A) Ex: C:/xxx/dolibarr/htdocs $real_dolibarr_main_document_root=str_replace('\\','/',realpath($dolibarr_main_document_root)); // A) Value found into config file, to say where are store htdocs files. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
$pathroot=$_SERVER["DOCUMENT_ROOT"]; // B) Ex: C:/Program Files/wamp/www/ $pathroot=$_SERVER["DOCUMENT_ROOT"]; // B) Value reported by web server setup, to say where is root of web server instance. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
$paths=explode('/',str_replace('\\','/',$_SERVER["SCRIPT_NAME"])); // C) Ex: /dolibarr/htdocs/admin/system/phpinfo.php $paths=explode('/',str_replace('\\','/',$_SERVER["SCRIPT_NAME"])); // C) Value reported by web server, to say full path on filesystem of a file. Ex: /dolibarr/htdocs/admin/system/phpinfo.php
// Try to detect if $_SERVER["DOCUMENT_ROOT"]+start of $_SERVER["SCRIPT_NAME"] is $dolibarr_main_document_root. If yes, relative url to add before dol files is this start part.
$concatpath=''; $concatpath='';
foreach($paths as $tmppath) // We check to find (B+start of C)=A foreach($paths as $tmppath) // We check to find (B+start of C)=A
{ {
if ($tmppath) $concatpath.='/'.$tmppath; if (empty($tmppath)) continue;
$concatpath.='/'.$tmppath;
//if ($tmppath) $concatpath.='/'.$tmppath;
//print $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).'<br>'; //print $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).'<br>';
if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) // @ avoid warning when safe_mode is on. if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) // @ avoid warning when safe_mode is on.
{ {
$tmp3=$concatpath; //print "Found relative url = ".$concatpath;
//print "Found relative url = ".$tmp3; $tmp3=$concatpath;
$found=1; $found=1;
break; break;
} }
//else print "Not found yet for concatpath=".$concatpath."<br>\n"; //else print "Not found yet for concatpath=".$concatpath."<br>\n";
} }
if (! $found) $tmp=$dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT. if (! $found) $tmp=$dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
else $tmp='http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]!=443))?'':'s').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]==80||$_SERVER["SERVER_PORT"]==443)?'':':'.$_SERVER["SERVER_PORT"]).($tmp3?(preg_match('/^\//',$tmp3)?'':'/').$tmp3:''); else $tmp='http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]!=443))?'':'s').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]==80||$_SERVER["SERVER_PORT"]==443)?'':':'.$_SERVER["SERVER_PORT"]).($tmp3?(preg_match('/^\//',$tmp3)?'':'/').$tmp3:'');
//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp; //print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp."\n";
if (! empty($dolibarr_main_force_https)) $tmp=preg_replace('/^http:/i','https:',$tmp); if (! empty($dolibarr_main_force_https)) $tmp=preg_replace('/^http:/i','https:',$tmp);
define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...) define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...)
$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http* $uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*

View File

@ -123,16 +123,16 @@ if (empty($reshook))
if ($action == 'setaccountancy_code_buy') if ($action == 'setaccountancy_code_buy')
{ {
$result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy')); $result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy'));
if ($result < 0) if ($result < 0) setEventMessage(join(',',$object->errors), 'errors');
setEventMessage(join(',',$object->errors), 'errors'); else $object->accountancy_code_buy=GETPOST('accountancy_code_buy');
$action=""; $action="";
} }
if ($action == 'setaccountancy_code_sell') if ($action == 'setaccountancy_code_sell')
{ {
$result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell')); $result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell'));
if ($result < 0) if ($result < 0) setEventMessage(join(',',$object->errors), 'errors');
setEventMessage(join(',',$object->errors), 'errors'); else $object->accountancy_code_sell=GETPOST('accountancy_code_sell');
$action=""; $action="";
} }

View File

@ -211,22 +211,42 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0)
{
$error++;
}
}
$result=$object->update($user); if (! $error)
{
$result=$object->update($user);
if ($result < 0)
{
$error++;
setEventMessage($object->errors,'errors');
}
}
if (GETPOST("reportdate") && ($object->date_start!=$old_start_date)) if (! $error)
{ {
$result=$object->shiftTaskDate($old_start_date); if (GETPOST("reportdate") && ($object->date_start!=$old_start_date))
if (!$result) {
{ $result=$object->shiftTaskDate($old_start_date);
$error++; if ($result < 0)
$mesg='<div class="error">'.$langs->trans("ErrorShiftTaskDate").':'.$object->error.'</div>'; {
} $error++;
} $mesg='<div class="error">'.$langs->trans("ErrorShiftTaskDate").':'.$object->error.'</div>';
}
}
}
if ($error)
{
$action='edit';
} }
else else
{ {
$action='edit'; $object->societe->fetch(GETPOST('socid','int'));
} }
} }