Commit 1af9bcd8 authored by Benjamin Sonntag's avatar Benjamin Sonntag

fixing -for good- the webmail and /webmail redirect

parent 5e23aa74
......@@ -88,8 +88,16 @@ if (!$_SERVER[HTTPS]) {
// Here we used to have a form to enter the squirrelmail's webmail.
// Following the "rule of less astonishment, we try to put it here again, even though the webmail is now a plugin.
$res=$hooks->invoke("hook_admin_webmail");
foreach($res as $r) if ($r!==false) echo $r;
if (($wr=get_variable("webmail_redirect")) && isset($res[$wr]) && $res[$wr]) {
$url=$res[$wr];
} else {
foreach($res as $r) if ($r!==false) { $url=$r; break; }
}
if ($url) {
?>
<p><a href="<?php echo $url; ?>"><?php __("To read your mail in a browser, click here to use the Squirrelmail Webmail"); ?></a></p>
<?php
}
?></td><td>
</td></tr>
......
......@@ -25,9 +25,16 @@
require_once("../class/config_nochk.php");
if ($webmail=variable_get("webmail_redirect","")) {
header("Location: /$webmail");
$res=$hooks->invoke("hook_admin_webmail");
if (($wr=get_variable("webmail_redirect")) && isset($res[$wr]) && $res[$wr]) {
$url=$res[$wr];
} else {
foreach($res as $r) if ($r!==false) { $url=$r; break; }
}
if ($url) {
header("Location: $url");
} else {
header("Location: /nowebmail.php");
header("Location: /nowebmail");
}
......@@ -29,6 +29,12 @@
*/
class m_squirrelmail {
/* ----------------------------------------------------------------- */
/** Hook called by the homepage or the /webmail link
* to redirect the user to a known webmail url.
* the variable 'webmail_redirect' tells which webmail has the priority.
* @return string the URL of the webmail
*/
function hook_admin_webmail() {
global $db;
// not found ? use admin account (2000)
......@@ -42,7 +48,7 @@ class m_squirrelmail {
$db->query("SELECT * FROM sub_domaines s WHERE s.domaine='".addslashes($dompart)."' AND s.type='squirrelmail';");
if ($db->next_record()) {
$domain=$db->Record;
return "<p><a href=\"http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"]."\">"._("To read your mail in a browser, click here to use the Squirrelmail Webmail")."</a></p>\n";
return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
}
$i++;
} while (strpos($dompart,'.')!==false);
......@@ -51,7 +57,7 @@ class m_squirrelmail {
$db->query("SELECT * FROM sub_domaines s WHERE s.compte=2000 AND s.type='squirrelmail';");
if ($db->next_record()) {
$domain=$db->Record;
return "<p><a href=\"http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"]."\">"._("To read your mail in a browser, click here to go to the Squirrelmail Webmail")."</a></p>\n";
return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment