[horde] Set "from_addr" as pre populated "enum" field

Nicolás Valera nvalera at gmail.com
Fri Apr 26 10:52:54 UTC 2013


It worked!

Michael, thanks for the help.

This is the code if anyone needs it:

$userId = $registry->getAuth();
global $conf;
require dirname( __FILE__ ) . '/../config/conf.php';

$dbhost   = $conf['auth']['params']['hostspec'];
$dbuser   = $conf['auth']['params']['username'];
$dbpasswd = $conf['auth']['params']['password'];
$dbname   = $conf['auth']['params']['database'];

$mysqli = new mysqli( $dbhost, $dbuser, $dbpasswd, $dbname );
if( $mysqli->connect_error ) { die( 'Cannot connect to database' ); }

$query = $mysqli->query( " SELECT alias FROM virtual_aliases WHERE 
virtual_user_email like'%$userId%' " );

if( ! $query ) { Horde::logMessage( $mysqli->error, 'ERR' ); die( 
'Cannot query from_addr' ); }

if( $result === false ) { die( 'Cannot read email from database' ); }

$newarray = array();
while ($result = $query->fetch_array()) { $newarray[$result[0]] = 
$result[0]; }

$mysqli->close();

$_prefs['from_addr']['type'] = 'enum';
$_prefs['from_addr']['enum'] = $newarray;
if( ! $newarray ) {
  $_prefs['from_addr']['locked'] = true;
  $_prefs['default_identity']['locked'] = true;
}

If you see any mistakes, please let me know!!!


More information about the horde mailing list