hastlaug
17th April 2006, 07:08
Although this post seems long: Read it - it's (almost) just copy and paste in 2 positions. No big changes. Don't be afraid :)
If you setup Horde IMP as webmailer, you might want to have the sender mail address and the sender name correctly be set.
That's not that easy because you need (non-existing) hook functions retrieving the data. But as I wrote such functions for me, you don't need to do this again ;)
First locate the horde config files.
In horde3/config/prefs.php change the following:
$_prefs['fullname'] = array(
'value' => '',
'locked' => false,
'shared' => true,
'type' => 'text',
'hook' => true,
'desc' => _("Your full name:")
);
$_prefs['from_addr'] = array(
'value' => '',
'locked' => true,
'shared' => true,
'type' => 'text',
'hook' => true,
'desc' => _("Your From: address:")
);
Especially 'hook' has to be true. I suggest setting 'locked' of 'from_addr' to true if you don't want users to be able to modify their from-address.
Then you have to add the following to your horde3/config/hooks.php:
if (!function_exists('_prefs_hook_from_addr')) {
function _prefs_hook_from_addr($user=null) {
$dsn = 'mysql://sqluser:sqlpass@localhost/db_ispconfig';
if (is_null($user)) {
$user = Auth::getAuth();
}
$db =& DB::connect($dsn, true);
if (PEAR::isError($db)) {
return $user;
}
$query = 'SELECT user_email,domain_domain FROM (isp_isp_user INNER JOIN isp_dep ON (isp_isp_user.doc_id=child_doc_id AND isp_isp_user.doctype_id=child_doctype_id))';
$query .= ' INNER JOIN isp_isp_domain ON (parent_doc_id=isp_isp_domain.doc_id AND parent_doctype_id=isp_isp_domain.doctype_id) WHERE user_username=' . $db->quote($user);
$result =& $db->query($query);
if ($result->fetchInto($row, DB_FETCHMODE_ASSOC)) {
$return = $row['user_email'] . "@" . $row['domain_domain'];
} else {
$return = $query;
}
$db->disconnect();
return $return;
}
}
if (!function_exists('_prefs_hook_fullname')) {
function _prefs_hook_fullname($user=null) {
$dsn = 'mysql://sqluser:sqlpass@localhost/db_ispconfig';
if (is_null($user)) {
$user = Auth::getAuth();
}
$db =& DB::connect($dsn, true);
if (PEAR::isError($db)) {
return $user;
}
$query = 'SELECT * FROM isp_isp_user WHERE user_username=' . $db->quote($user);
$result =& $db->query($query);
if ($result->fetchInto($row, DB_FETCHMODE_ASSOC)) {
$return = $row['user_name'];
} else {
$return = $user;
}
$db->disconnect();
return $return;
}
}
Make sure you replace sqluser by your sql user with sufficient rights to query the ispconfig database and replace sqlpassword by its password. Maybe you also want to replace localhost by the correct sql server and db_ispconfig by the correct sql database. Please note that you have these changes TWO times in the code above.
Done ;)
If you setup Horde IMP as webmailer, you might want to have the sender mail address and the sender name correctly be set.
That's not that easy because you need (non-existing) hook functions retrieving the data. But as I wrote such functions for me, you don't need to do this again ;)
First locate the horde config files.
In horde3/config/prefs.php change the following:
$_prefs['fullname'] = array(
'value' => '',
'locked' => false,
'shared' => true,
'type' => 'text',
'hook' => true,
'desc' => _("Your full name:")
);
$_prefs['from_addr'] = array(
'value' => '',
'locked' => true,
'shared' => true,
'type' => 'text',
'hook' => true,
'desc' => _("Your From: address:")
);
Especially 'hook' has to be true. I suggest setting 'locked' of 'from_addr' to true if you don't want users to be able to modify their from-address.
Then you have to add the following to your horde3/config/hooks.php:
if (!function_exists('_prefs_hook_from_addr')) {
function _prefs_hook_from_addr($user=null) {
$dsn = 'mysql://sqluser:sqlpass@localhost/db_ispconfig';
if (is_null($user)) {
$user = Auth::getAuth();
}
$db =& DB::connect($dsn, true);
if (PEAR::isError($db)) {
return $user;
}
$query = 'SELECT user_email,domain_domain FROM (isp_isp_user INNER JOIN isp_dep ON (isp_isp_user.doc_id=child_doc_id AND isp_isp_user.doctype_id=child_doctype_id))';
$query .= ' INNER JOIN isp_isp_domain ON (parent_doc_id=isp_isp_domain.doc_id AND parent_doctype_id=isp_isp_domain.doctype_id) WHERE user_username=' . $db->quote($user);
$result =& $db->query($query);
if ($result->fetchInto($row, DB_FETCHMODE_ASSOC)) {
$return = $row['user_email'] . "@" . $row['domain_domain'];
} else {
$return = $query;
}
$db->disconnect();
return $return;
}
}
if (!function_exists('_prefs_hook_fullname')) {
function _prefs_hook_fullname($user=null) {
$dsn = 'mysql://sqluser:sqlpass@localhost/db_ispconfig';
if (is_null($user)) {
$user = Auth::getAuth();
}
$db =& DB::connect($dsn, true);
if (PEAR::isError($db)) {
return $user;
}
$query = 'SELECT * FROM isp_isp_user WHERE user_username=' . $db->quote($user);
$result =& $db->query($query);
if ($result->fetchInto($row, DB_FETCHMODE_ASSOC)) {
$return = $row['user_name'];
} else {
$return = $user;
}
$db->disconnect();
return $return;
}
}
Make sure you replace sqluser by your sql user with sufficient rights to query the ispconfig database and replace sqlpassword by its password. Maybe you also want to replace localhost by the correct sql server and db_ispconfig by the correct sql database. Please note that you have these changes TWO times in the code above.
Done ;)