diff --git a/htdocs/includes/boxes/box_bookmarks.php b/htdocs/includes/boxes/box_bookmarks.php
index 0ebec730f27..6b86c442ce2 100644
--- a/htdocs/includes/boxes/box_bookmarks.php
+++ b/htdocs/includes/boxes/box_bookmarks.php
@@ -105,7 +105,12 @@ class box_bookmarks extends ModeleBoxes {
$i++;
}
- if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/liste.php', 'text'=>$langs->trans("NoRecordedBookmarks"));
+ if ($num==0)
+ {
+ $mytxt=$langs->trans("NoRecordedBookmarks");
+ if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickHereToAdd");
+ $this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/liste.php', 'text'=>$mytxt);
+ }
}
else
{
diff --git a/htdocs/includes/menus/standard/auguria.lib.php b/htdocs/includes/menus/standard/auguria.lib.php
index de745205516..ed478602153 100644
--- a/htdocs/includes/menus/standard/auguria.lib.php
+++ b/htdocs/includes/menus/standard/auguria.lib.php
@@ -63,7 +63,7 @@ function print_auguria_menu($db,$atarget,$type_user)
}
else
{
- dol_file_exists($tabMenu[$i]['url'],1);
+ $url=dol_file_exists($tabMenu[$i]['url'],1);
if (! preg_match('/\?/',$url)) $url.='?';
else $url.='&';
if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url))
@@ -275,7 +275,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after)
}
// Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser.
- dol_files_exists($menu_array[$i]['url'],1);
+ $url=dol_file_exists($menu_array[$i]['url'],1);
if (! preg_match('/mainmenu=/i',$menu_array[$i]['url']))
{
diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang
index de996d84739..d212162b723 100644
--- a/htdocs/langs/en_US/boxes.lang
+++ b/htdocs/langs/en_US/boxes.lang
@@ -44,7 +44,8 @@ BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier's invoices
BoxMyLastBookmarks=My last %s bookmarks
FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s
LastRefreshDate=Last refresh date
-NoRecordedBookmarks=No bookmarks defined. Click here to add bookmarks.
+NoRecordedBookmarks=No bookmarks defined.
+ClickToAdd=Click here to add.
NoRecordedCustomers=No recorded customers
BoxTitleLastActionsToDo=Last %s actions to do
BoxTitleLastContracts=Last %s contracts
diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang
index 3b98d5d66f7..909bc24558f 100644
--- a/htdocs/langs/fr_FR/boxes.lang
+++ b/htdocs/langs/fr_FR/boxes.lang
@@ -44,7 +44,8 @@ BoxTitleTotalUnpaidSuppliersBills=Impayés fournisseurs
BoxMyLastBookmarks=Mes %s derniers marque-pages
FailedToRefreshDataInfoNotUpToDate=Échec du rafraichissement du flux RSS. Date du dernier rafraichissement: %s
LastRefreshDate=Date dernier rafraichissement
-NoRecordedBookmarks=Pas de bookmarks personnels. Cliquer ici pour en ajouter.
+NoRecordedBookmarks=Pas de bookmarks personnels.
+ClickToAdd=Cliquer ici pour ajouter.
NoRecordedCustomers=Pas de client enregistré
BoxTitleLastActionsToDo=Les %s dernières actions à faire
BoxTitleLastContracts=Les %s derniers contrats
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index acce17baf87..455a8640c55 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -87,30 +87,41 @@ function dol_require_once($relpath)
// Forced to use file_exists otherwise there is a blank page
//$res=@require_once(DOL_DOCUMENT_ROOT.$relpath);
//if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@require_once(DOL_DOCUMENT_ROOT_ALT.$relpath);
- $res=@require_once(dol_file_exists($relpath));
-
+ $res=require_once(dol_file_exists($relpath));
+
return $res;
}
/**
- * Make an file_exists using default root and alternate root if it fails.
+ * Return path of url or filesystem. Return default_root or alternate root if file_exist fails.
+ * TODO Rename function into dol_buildpath
* @param path Relative or absolute path to file (Ie: mydir/myfile, ../myfile, ...)
- * @return int Result
+ * @param mode 0=Used for a Filesystem path, 1=Used for an URL path
+ * @return string Full filsystem path (if mode=0), Relative url path (if mode=1)
*/
-function dol_file_exists($path,$absolute=0)
+function dol_file_exists($path,$mode=0)
{
- $res=false;
-
- if ($absolute)
+ if (empty($mode)) // For a filesystem path
{
- preg_match('/^([^<]+\.php)/i',$path,$regs);
- $res=DOL_URL_ROOT.$path;
- if (defined('DOL_URL_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $res=DOL_URL_ROOT_ALT.$path;
+ $res = DOL_DOCUMENT_ROOT.$path; // Standard value
+ if (defined('DOL_DOCUMENT_ROOT_ALT') && DOL_DOCUMENT_ROOT_ALT) // We check only if alternate feature is used
+ {
+ if (! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path;
+ }
}
- else
+ else // For an url path
{
- $res = DOL_DOCUMENT_ROOT.$path;
- if (defined('DOL_DOCUMENT_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path;
+ $res = DOL_URL_ROOT.$path; // Standard value
+ if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT) // We check only if alternate feature is used
+ {
+ // We try to get local path of file on filesystem from url
+ // FIXME Trying to know if a file on disk exist by forging path on disk from url
+ // works only for some web server and some setup. This is bugged when
+ // using proxy, rewriting, virtual path, etc...
+ preg_match('/^([^<]+\.php)$/i',$path,$regs); // Why a "<" char ?
+ if (! empty($regs[1])) $path = $regs[1];
+ if (! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_URL_ROOT_ALT.$path;
+ }
}
return $res;
diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php
index 652a704a11a..bb5f4d0613e 100644
--- a/htdocs/public/demo/index.php
+++ b/htdocs/public/demo/index.php
@@ -32,6 +32,7 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require("../../main.inc.php");
$langs->load("main");
+$langs->load("install");
$langs->load("other");
// Security check
@@ -228,16 +229,21 @@ foreach ($demoprofiles as $profilarray)
{
$url=$_SERVER["PHP_SELF"].'?action=gotodemo&urlfrom='.urlencode($_SERVER["PHP_SELF"]);
$urlwithmod=$url.'&demochoice='.$profilarray['key'];
+ // Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr'
+ //print "xx".$_SERVER["PHP_SELF"].' '.DOL_URL_ROOT.'
';
+ $urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/i','',$_SERVER["PHP_SELF"]);
+ //print $urlfrom;
+
//if ($i % $NBOFCOLS == 0) print '