diff --git a/htdocs/includes/menus/standard/auguria.lib.php b/htdocs/includes/menus/standard/auguria.lib.php index 25d9bf34730..de745205516 100644 --- a/htdocs/includes/menus/standard/auguria.lib.php +++ b/htdocs/includes/menus/standard/auguria.lib.php @@ -63,9 +63,7 @@ function print_auguria_menu($db,$atarget,$type_user) } else { - preg_match('/^([^<]+\.php)/i',$tabMenu[$i]['url'],$regs); - $url=DOL_URL_ROOT.$tabMenu[$i]['url']; - if (DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.$tabMenu[$i]['url'])) $url=DOL_URL_ROOT_ALT.$tabMenu[$i]['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)) @@ -277,9 +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. - preg_match('/^([^<]+\.php)/i',$menu_array[$i]['url'],$regs); - $url=DOL_URL_ROOT.$menu_array[$i]['url']; - if (DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $url=DOL_URL_ROOT_ALT.$menu_array[$i]['url']; + dol_files_exists($menu_array[$i]['url'],1); if (! preg_match('/mainmenu=/i',$menu_array[$i]['url'])) { diff --git a/htdocs/includes/menus/standard/eldy.lib.php b/htdocs/includes/menus/standard/eldy.lib.php index bf341aff200..c83f760255f 100644 --- a/htdocs/includes/menus/standard/eldy.lib.php +++ b/htdocs/includes/menus/standard/eldy.lib.php @@ -453,8 +453,7 @@ function print_eldy_menu($db,$atarget,$type_user) } else { - $url=DOL_URL_ROOT.$tabMenu[$i]['url']; - if (DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.$tabMenu[$i]['url'])) $url=DOL_URL_ROOT_ALT.$tabMenu[$i]['url']; + $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)) @@ -1386,9 +1385,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) } // For external modules - preg_match('/^([^<]+\.php)/i',$menu_array[$i]['url'],$regs); - $url=DOL_URL_ROOT.$menu_array[$i]['url']; - if (DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $url=DOL_URL_ROOT_ALT.$menu_array[$i]['url']; + $url = dol_file_exists($menu_array[$i]['url'], 1); // Menu niveau 0 if ($menu_array[$i]['level'] == 0) diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index f36d62ceed4..5f7d09e2656 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -122,7 +122,7 @@ function societe_prepare_head($objsoc) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$objsoc->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/contact.lib.php b/htdocs/lib/contact.lib.php index b6aa624c1e9..dffc7049876 100644 --- a/htdocs/lib/contact.lib.php +++ b/htdocs/lib/contact.lib.php @@ -79,7 +79,7 @@ function contact_prepare_head($object) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$object->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/contract.lib.php b/htdocs/lib/contract.lib.php index 8c88bfc3744..dd2d2297675 100644 --- a/htdocs/lib/contract.lib.php +++ b/htdocs/lib/contract.lib.php @@ -24,33 +24,33 @@ \version $Id$ */ -function contract_prepare_head($contrat) +function contract_prepare_head($object) { global $langs, $conf; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; + $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$object->id; $head[$h][1] = $langs->trans("ContractCard"); $head[$h][2] = 'card'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id; + $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; $head[$h][1] = $langs->trans("ContractContacts"); $head[$h][2] = 'contact'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$contrat->id; + $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id; + $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; + $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -65,7 +65,7 @@ function contract_prepare_head($contrat) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$contrat->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/fichinter.lib.php b/htdocs/lib/fichinter.lib.php index 4a5bddc17e9..f6310bf3248 100644 --- a/htdocs/lib/fichinter.lib.php +++ b/htdocs/lib/fichinter.lib.php @@ -27,7 +27,7 @@ * Ensemble de fonctions de base de dolibarr sous forme d'include */ -function fichinter_prepare_head($fichinter) +function fichinter_prepare_head($object) { global $langs, $conf, $user; $langs->load("fichinter"); @@ -35,35 +35,35 @@ function fichinter_prepare_head($fichinter) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/fichinter/fiche.php?id='.$fichinter->id; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/fiche.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$fichinter->id; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('InterventionContact'); $head[$h][2] = 'contact'; $h++; if ($conf->use_preview_tabs) { - $head[$h][0] = DOL_URL_ROOT.'/fichinter/apercu.php?id='.$fichinter->id; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/apercu.php?id='.$object->id; $head[$h][1] = $langs->trans('Preview'); $head[$h][2] = 'preview'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$fichinter->id; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$fichinter->id; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$fichinter->id; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$object->id; $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; @@ -78,7 +78,7 @@ function fichinter_prepare_head($fichinter) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$fichinter->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/fourn.lib.php b/htdocs/lib/fourn.lib.php index 6bda9e0101b..1f2a3ae4316 100644 --- a/htdocs/lib/fourn.lib.php +++ b/htdocs/lib/fourn.lib.php @@ -24,28 +24,28 @@ * \version $Id$ */ -function facturefourn_prepare_head($fac) +function facturefourn_prepare_head($object) { global $langs, $conf; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$object->id; $head[$h][1] = $langs->trans('Card'); $head[$h][2] = 'card'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; $head[$h][1] = $langs->trans('BillContacts'); $head[$h][2] = 'contact'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; $head[$h][1] = $langs->trans('Notes'); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; /*$filesdir = $conf->fournisseur->dir_output.'/facture/'.get_exdir($fac->id,2).$fac->id; include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); $listoffiles=dol_dir_list($filesdir,'files',1); @@ -54,7 +54,7 @@ function facturefourn_prepare_head($fac) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$object->id; $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; @@ -69,7 +69,7 @@ function facturefourn_prepare_head($fac) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$fac->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; @@ -80,13 +80,13 @@ function facturefourn_prepare_head($fac) } -function ordersupplier_prepare_head($commande) +function ordersupplier_prepare_head($object) { global $langs, $conf; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderCard"); $head[$h][2] = 'card'; $h++; @@ -94,23 +94,23 @@ function ordersupplier_prepare_head($commande) if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) { $langs->load("stocks"); - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderDispatch"); $head[$h][2] = 'dispatch'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('OrderContact'); $head[$h][2] = 'contact'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id; /*$filesdir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref); include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); $listoffiles=dol_dir_list($filesdir,'files',1); @@ -119,7 +119,7 @@ function ordersupplier_prepare_head($commande) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderFollow"); $head[$h][2] = 'info'; $h++; @@ -134,7 +134,7 @@ function ordersupplier_prepare_head($commande) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$commande->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index c2d5c7d738c..c123263852d 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -74,6 +74,43 @@ function dol_include_once($relpath) return $res; } +/** + * Make an require_once using default root and alternate root if it fails. + * @param relpath Relative path to file (Ie: mydir/myfile, ../myfile, ...) + * @return int Result + */ +function dol_require_once($relpath) +{ + $res=@require_once(DOL_DOCUMENT_ROOT.$relpath); + if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@require_once(DOL_DOCUMENT_ROOT_ALT.$relpath); + return $res; +} + +/** + * Make an file_exists using default root and alternate root if it fails. + * @param path Relative or absolute path to file (Ie: mydir/myfile, ../myfile, ...) + * @return int Result + */ +function dol_file_exists($path,$absolute=0) +{ + $res=''; + + if ($absolute) + { + preg_match('/^([^<]+\.php)/i',$path,$regs); + $path = (! empty($regs[1]) ? $regs[1] : $path); + $res=DOL_URL_ROOT.$path; + if (defined('DOL_URL_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$path)) $url=DOL_URL_ROOT_ALT.$path; + } + else + { + $res = DOL_DOCUMENT_ROOT.$path; + if (defined('DOL_DOCUMENT_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$path)) $res = DOL_DOCUMENT_ROOT_ALT.$path; + } + + return $res; +} + /** * Create a clone of instance of object (new instance with same properties) * This function works for both PHP4 and PHP5. diff --git a/htdocs/lib/invoice.lib.php b/htdocs/lib/invoice.lib.php index d2ed90a3883..a72f0d29317 100644 --- a/htdocs/lib/invoice.lib.php +++ b/htdocs/lib/invoice.lib.php @@ -26,25 +26,25 @@ * Ensemble de fonctions de base de dolibarr sous forme d'include */ -function facture_prepare_head($fac) +function facture_prepare_head($object) { global $langs, $conf; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$object->id; $head[$h][1] = $langs->trans('CardBill'); $head[$h][2] = 'compta'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; $head[$h][1] = $langs->trans('BillContacts'); $head[$h][2] = 'contact'; $h++; if ($conf->use_preview_tabs) { - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$object->id; $head[$h][1] = $langs->trans('Preview'); $head[$h][2] = 'preview'; $h++; @@ -53,18 +53,18 @@ function facture_prepare_head($fac) //if ($fac->mode_reglement_code == 'PRE') if ($conf->prelevement->enabled) { - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id; $head[$h][1] = $langs->trans('StandingOrders'); $head[$h][2] = 'standingorders'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; $head[$h][1] = $langs->trans('Notes'); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id; /*$filesdir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($fac->ref); include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); $listoffiles=dol_dir_list($filesdir,'files',1); @@ -73,7 +73,7 @@ function facture_prepare_head($fac) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$object->id; $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; @@ -88,7 +88,7 @@ function facture_prepare_head($fac) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$fac->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/member.lib.php b/htdocs/lib/member.lib.php index 78385948733..89c2af8168e 100644 --- a/htdocs/lib/member.lib.php +++ b/htdocs/lib/member.lib.php @@ -25,14 +25,14 @@ * Ensemble de fonctions de base de dolibarr sous forme d'include */ -function member_prepare_head($member) +function member_prepare_head($object) { global $langs, $conf, $user; $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$member->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$object->id; $head[$h][1] = $langs->trans("MemberCard"); $head[$h][2] = 'general'; $h++; @@ -41,7 +41,7 @@ function member_prepare_head($member) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$member->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$object->id; $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; @@ -49,7 +49,7 @@ function member_prepare_head($member) if ($user->rights->adherent->cotisation->lire) { - $head[$h][0] = DOL_URL_ROOT.'/adherents/card_subscriptions.php?rowid='.$member->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/card_subscriptions.php?rowid='.$object->id; $head[$h][1] = $langs->trans("Subscriptions"); $head[$h][2] = 'subscription'; $h++; @@ -58,23 +58,23 @@ function member_prepare_head($member) // Show category tab if ($conf->categorie->enabled && $user->rights->categorie->lire) { - $head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$member->id.'&type=3'; + $head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type=3'; $head[$h][1] = $langs->trans('Categories'); $head[$h][2] = 'category'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$member->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$member->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); $head[$h][2] = 'document'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/info.php?id='.$member->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -89,7 +89,7 @@ function member_prepare_head($member) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$member->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/order.lib.php b/htdocs/lib/order.lib.php index 892fa72d54b..748460df2e4 100644 --- a/htdocs/lib/order.lib.php +++ b/htdocs/lib/order.lib.php @@ -27,7 +27,7 @@ * \version $Id$ */ -function commande_prepare_head($commande) +function commande_prepare_head($object) { global $langs, $conf, $user; if ($conf->expedition->enabled) $langs->load("sendings"); @@ -38,7 +38,7 @@ function commande_prepare_head($commande) if ($conf->commande->enabled && $user->rights->commande->lire) { - $head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderCard"); $head[$h][2] = 'order'; $h++; @@ -47,7 +47,7 @@ function commande_prepare_head($commande) if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) { - $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; if ($conf->expedition_bon->enabled) $text=$langs->trans("Sendings"); if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); $head[$h][1] = $text; @@ -66,18 +66,18 @@ function commande_prepare_head($commande) */ if ($conf->use_preview_tabs) { - $head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$object->id; $head[$h][1] = $langs->trans("Preview"); $head[$h][2] = 'preview'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('OrderContact'); $head[$h][2] = 'contact'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; /*$filesdir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($commande->ref); include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); $listoffiles=dol_dir_list($filesdir,'files',1); @@ -86,12 +86,12 @@ function commande_prepare_head($commande) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id; + $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -106,7 +106,7 @@ function commande_prepare_head($commande) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$commande->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/prelevement.lib.php b/htdocs/lib/prelevement.lib.php index 47f8152bc4a..163c5d24deb 100644 --- a/htdocs/lib/prelevement.lib.php +++ b/htdocs/lib/prelevement.lib.php @@ -32,7 +32,7 @@ * @param prelevement class BonPrelevement * @return array head */ -function prelevement_prepare_head($prelevement) +function prelevement_prepare_head($object) { global $langs, $conf, $user; $langs->load("withdrawals"); @@ -40,35 +40,35 @@ function prelevement_prepare_head($prelevement) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$prelevement->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'prelevement'; $h++; if ($conf->use_preview_tabs) { - $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/bon.php?id='.$prelevement->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/bon.php?id='.$object->id; $head[$h][1] = $langs->trans("Preview"); $head[$h][2] = 'preview'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/lignes.php?id='.$prelevement->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/lignes.php?id='.$object->id; $head[$h][1] = $langs->trans("Lines"); $head[$h][2] = 'lines'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$prelevement->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$object->id; $head[$h][1] = $langs->trans("Bills"); $head[$h][2] = 'invoices'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php?id='.$prelevement->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php?id='.$object->id; $head[$h][1] = $langs->trans("Rejects"); $head[$h][2] = 'rejects'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php?id='.$prelevement->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php?id='.$object->id; $head[$h][1] = $langs->trans("Statistics"); $head[$h][2] = 'statistics'; $h++; @@ -83,7 +83,7 @@ function prelevement_prepare_head($prelevement) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$propal->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/product.lib.php b/htdocs/lib/product.lib.php index d409696947b..9a183eef844 100644 --- a/htdocs/lib/product.lib.php +++ b/htdocs/lib/product.lib.php @@ -28,7 +28,7 @@ * Ensemble de fonctions de base de dolibarr sous forme d'include */ -function product_prepare_head($product, $user) +function product_prepare_head($object, $user) { global $langs, $conf; $langs->load("products"); @@ -36,25 +36,25 @@ function product_prepare_head($product, $user) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; - $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; $head[$h][1] = $langs->trans("CustomerPrices"); $head[$h][2] = 'price'; $h++; if ($conf->fournisseur->enabled && $user->rights->fournisseur->lire) { - $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; $head[$h][1] = $langs->trans("SuppliersPrices"); $head[$h][2] = 'suppliers'; $h++; } - $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id; $head[$h][1] = $langs->trans("Photos"); $head[$h][2] = 'photos'; $h++; @@ -62,7 +62,7 @@ function product_prepare_head($product, $user) // Show category tab if ($conf->categorie->enabled && $user->rights->categorie->lire) { - $head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$product->id.'&type=0'; + $head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type=0'; $head[$h][1] = $langs->trans('Categories'); $head[$h][2] = 'category'; $h++; @@ -71,7 +71,7 @@ function product_prepare_head($product, $user) // Show barcode tab if ($conf->global->MAIN_MODULE_BARCODE && $user->rights->barcode->lire) { - $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$object->id; $head[$h][1] = $langs->trans("BarCode"); $head[$h][2] = 'barcode'; $h++; @@ -80,7 +80,7 @@ function product_prepare_head($product, $user) // Multilangs if($conf->global->MAIN_MULTILANGS) { - $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id; $head[$h][1] = $langs->trans("Translation"); $head[$h][2] = 'translation'; $h++; @@ -89,32 +89,32 @@ function product_prepare_head($product, $user) // Sub products if($conf->global->PRODUIT_SOUSPRODUITS) { - $head[$h][0] = DOL_URL_ROOT."/product/composition/fiche.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/composition/fiche.php?id=".$object->id; $head[$h][1] = $langs->trans('AssociatedProducts'); $head[$h][2] = 'subproduct'; $h++; } - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$object->id; $head[$h][1] = $langs->trans('Statistics'); $head[$h][2] = 'stats'; $h++; - $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$object->id; $head[$h][1] = $langs->trans('Referers'); $head[$h][2] = 'referers'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; + $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); $head[$h][2] = 'documents'; $h++; - if($product->isproduct()) // Si produit stockable + if($object->isproduct()) // Si produit stockable { if ($conf->stock->enabled && $user->rights->stock->lire) { - $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; + $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id; $head[$h][1] = $langs->trans("Stock"); $head[$h][2] = 'stock'; $h++; @@ -131,7 +131,7 @@ function product_prepare_head($product, $user) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$product->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; @@ -139,9 +139,9 @@ function product_prepare_head($product, $user) } // More tabs from canvas - if (is_array($product->onglets)) + if (is_array($object->onglets)) { - foreach ($product->onglets as $onglet) + foreach ($object->onglets as $onglet) { $head[$h] = $onglet; $h++; diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 9910d5efa6d..6bb27a76110 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -76,7 +76,7 @@ function project_prepare_head($object) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$object->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; @@ -156,7 +156,7 @@ function task_prepare_head($object) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$objsoc->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/propal.lib.php b/htdocs/lib/propal.lib.php index fb782ae5de1..025c5e5a43b 100644 --- a/htdocs/lib/propal.lib.php +++ b/htdocs/lib/propal.lib.php @@ -27,7 +27,7 @@ * Ensemble de fonctions de base de dolibarr sous forme d'include */ -function propal_prepare_head($propal) +function propal_prepare_head($object) { global $langs, $conf, $user; $langs->load("propal"); @@ -36,7 +36,7 @@ function propal_prepare_head($propal) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?id='.$propal->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?id='.$object->id; $head[$h][1] = $langs->trans('ProposalCard'); $head[$h][2] = 'comm'; $h++; @@ -46,7 +46,7 @@ function propal_prepare_head($propal) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)))) { $langs->load("sendings"); - $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$propal->id; + $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; if ($conf->expedition_bon->enabled) $text=$langs->trans("Sendings"); if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); $head[$h][1] = $text; @@ -61,23 +61,23 @@ function propal_prepare_head($propal) */ if ($conf->use_preview_tabs) { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?id='.$propal->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?id='.$object->id; $head[$h][1] = $langs->trans("Preview"); $head[$h][2] = 'preview'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$propal->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ProposalContact'); $head[$h][2] = 'contact'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$propal->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$propal->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; /*$filesdir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($propal->ref); include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); $listoffiles=dol_dir_list($filesdir,'files',1); @@ -86,7 +86,7 @@ function propal_prepare_head($propal) $head[$h][2] = 'document'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$propal->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$object->id; $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; @@ -101,7 +101,7 @@ function propal_prepare_head($propal) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$propal->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/sendings.lib.php b/htdocs/lib/sendings.lib.php index 8d042d5e365..b7b14e15b4d 100644 --- a/htdocs/lib/sendings.lib.php +++ b/htdocs/lib/sendings.lib.php @@ -59,7 +59,7 @@ function shipping_prepare_head($object) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$commande->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; @@ -102,7 +102,7 @@ function delivery_prepare_head($object) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$commande->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/stock.lib.php b/htdocs/lib/stock.lib.php index 0e2f915b761..6e986a70ae9 100644 --- a/htdocs/lib/stock.lib.php +++ b/htdocs/lib/stock.lib.php @@ -80,7 +80,7 @@ function stock_prepare_head($object) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$object->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/usergroups.lib.php b/htdocs/lib/usergroups.lib.php index b9de7e3f9a0..a2372500f66 100644 --- a/htdocs/lib/usergroups.lib.php +++ b/htdocs/lib/usergroups.lib.php @@ -97,7 +97,7 @@ function user_prepare_head($object) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$object->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; @@ -153,7 +153,7 @@ function group_prepare_head($object) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); - $head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$object->id,$values[3]); + $head[$h][0] = dol_file_exists(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dd70e99e091..a2697ec66f2 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -843,7 +843,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs { foreach($conf->css_modules as $cssfile) { // cssfile is an absolute path - print ''."\n"; + print ''."\n"; } } // CSS forced by page in top_htmlhead call (relative url starting with /)