Fix: Using bad root url.

This commit is contained in:
Laurent Destailleur 2012-12-12 14:46:13 +01:00
parent 2c2465ffad
commit bdb112c820
7 changed files with 50 additions and 32 deletions

View File

@ -130,15 +130,22 @@ clearstatcache();
//if ($mesg) print "<br>$mesg<br>"; //if ($mesg) print "<br>$mesg<br>";
print "<br>"; print "<br>";
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Show message // Show message
$message=''; $message='';
$urlvcal='<a href="'.DOL_MAIN_URL_ROOT.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.DOL_MAIN_URL_ROOT.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>'; $urlvcal='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal); $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
$message.='<br>'; $message.='<br>';
$urlical='<a href="'.DOL_MAIN_URL_ROOT.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.DOL_MAIN_URL_ROOT.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>'; $urlical='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'ical/ics',$urlical); $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'ical/ics',$urlical);
$message.='<br>'; $message.='<br>';
$urlrss='<a href="'.DOL_MAIN_URL_ROOT.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.DOL_MAIN_URL_ROOT.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>'; $urlrss='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'rss',$urlrss); $message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'rss',$urlrss);
$message.='<br>'; $message.='<br>';
$message.='<br>'; $message.='<br>';

View File

@ -952,8 +952,11 @@ class ActionComm extends CommonObject
$event['location']=$obj->location; $event['location']=$obj->location;
$event['transparency']='TRANSPARENT'; // OPAQUE (busy) or TRANSPARENT (not busy) $event['transparency']='TRANSPARENT'; // OPAQUE (busy) or TRANSPARENT (not busy)
$event['category']=$obj->libelle; // libelle type action $event['category']=$obj->libelle; // libelle type action
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root); // Define $urlwithroot
$url=$urlwithouturlroot.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$obj->id; $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url=$urlwithroot.'/comm/action/fiche.php?id='.$obj->id;
$event['url']=$url; $event['url']=$url;
$event['created']=$this->db->jdate($obj->datec); $event['created']=$this->db->jdate($obj->datec);
$event['modified']=$this->db->jdate($obj->datem); $event['modified']=$this->db->jdate($obj->datem);

View File

@ -172,26 +172,30 @@ class Notify
$message.= "\n"; $message.= "\n";
$message.= $texte; $message.= $texte;
// Add link // Add link
$link='';
switch($objet_type) switch($objet_type)
{ {
case 'ficheinter': case 'ficheinter':
$link=DOL_URL_ROOT.'/fichinter/fiche.php?id='.$objet_id; $link='/fichinter/fiche.php?id='.$objet_id;
break; break;
case 'propal': case 'propal':
$link=DOL_URL_ROOT.'/comm/propal.php?id='.$objet_id; $link='/comm/propal.php?id='.$objet_id;
break; break;
case 'facture': case 'facture':
$link=DOL_URL_ROOT.'/compta/facture.php?facid='.$objet_id; $link='/compta/facture.php?facid='.$objet_id;
break; break;
case 'order': case 'order':
$link=DOL_URL_ROOT.'/commande/fiche.php?facid='.$objet_id; $link='/commande/fiche.php?facid='.$objet_id;
break; break;
case 'order_supplier': case 'order_supplier':
$link=DOL_URL_ROOT.'/fourn/commande/fiche.php?facid='.$objet_id; $link='/fourn/commande/fiche.php?facid='.$objet_id;
break; break;
} }
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root); // Define $urlwithroot
if ($link) $message.="\n".$urlwithouturlroot.$link; $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
if ($link) $message.="\n".$urlwithroot.$link;
$filename = basename($file); $filename = basename($file);

View File

@ -322,8 +322,11 @@ function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter=''
'<lastBuildDate>'.$date.'</lastBuildDate>'."\n". '<lastBuildDate>'.$date.'</lastBuildDate>'."\n".
'<generator>Dolibarr</generator>'."\n"; '<generator>Dolibarr</generator>'."\n";
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root); // Define $urlwithroot
$url=$urlwithouturlroot.DOL_URL_ROOT.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY); $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
$form.='<link><![CDATA['.$url.']]></link>'."\n"; $form.='<link><![CDATA['.$url.']]></link>'."\n";
//print $form; //print $form;

View File

@ -75,9 +75,13 @@ if (! GETPOST("action"))
} }
} }
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlok=$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/paymentok.php?'; $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlko=$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/paymentko.php?'; //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$urlok=$urlwithroot.'/public/paybox/paymentok.php?';
$urlko=$urlwithroot.'/public/paybox/paymentko.php?';
// Complete urls // Complete urls
$SOURCE=GETPOST("source",'alpha'); $SOURCE=GETPOST("source",'alpha');

View File

@ -86,9 +86,13 @@ if (! GETPOST("action"))
} }
} }
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); // Define $urlwithroot
$urlok=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentok.php?'; //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlko=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentko.php?'; //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$urlok=$urlwithroot.'/public/paypal/paymentok.php?';
$urlko=$urlwithroot.'/public/paypal/paymentko.php?';
// Complete urls for post treatment // Complete urls for post treatment
$SOURCE=GETPOST("source",'alpha'); $SOURCE=GETPOST("source",'alpha');

View File

@ -1462,17 +1462,10 @@ class User extends CommonObject
$outputlangs=$langs; $outputlangs=$langs;
} }
// Define urlwithouturlroot // Define $urlwithroot
if (! empty($_SERVER["HTTP_HOST"])) // Autodetect main url root //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
{ //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithouturlroot='http://'.preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$_SERVER["HTTP_HOST"]); $urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
}
else
{
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root);
}
if (! empty($dolibarr_main_force_https)
|| (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on')) $urlwithouturlroot=preg_replace('/http:/i','https:',$urlwithouturlroot);
// TODO Use outputlangs to translate messages // TODO Use outputlangs to translate messages
if (! $changelater) if (! $changelater)
@ -1482,7 +1475,7 @@ class User extends CommonObject
$mesg.= $langs->trans("Login")." : $this->login\n"; $mesg.= $langs->trans("Login")." : $this->login\n";
$mesg.= $langs->trans("Password")." : $password\n\n"; $mesg.= $langs->trans("Password")." : $password\n\n";
$mesg.= "\n"; $mesg.= "\n";
$url = $urlwithouturlroot.DOL_URL_ROOT; $url = $urlwithroot;
$mesg.= 'Click here to go to Dolibarr: '.$url."\n\n"; $mesg.= 'Click here to go to Dolibarr: '.$url."\n\n";
$mesg.= "--\n"; $mesg.= "--\n";
$mesg.= $user->getFullName($langs); // Username that make then sending $mesg.= $user->getFullName($langs); // Username that make then sending
@ -1495,7 +1488,7 @@ class User extends CommonObject
$mesg.= $langs->trans("Password")." : $password\n\n"; $mesg.= $langs->trans("Password")." : $password\n\n";
$mesg.= "\n"; $mesg.= "\n";
$mesg.= "You must click on the folowing link to validate its change.\n"; $mesg.= "You must click on the folowing link to validate its change.\n";
$url = $urlwithouturlroot.DOL_URL_ROOT.'/user/passwordforgotten.php?action=validatenewpassword&username='.$this->login."&passwordmd5=".dol_hash($password); $url = $urlwithroot.'/user/passwordforgotten.php?action=validatenewpassword&username='.$this->login."&passwordmd5=".dol_hash($password);
$mesg.= $url."\n\n"; $mesg.= $url."\n\n";
$mesg.= "If you didn't ask anything, just forget this email\n\n"; $mesg.= "If you didn't ask anything, just forget this email\n\n";
dol_syslog(get_class($this)."::send_password url=".$url); dol_syslog(get_class($this)."::send_password url=".$url);