by yokaiface » Tue Jul 28, 2009 6:06 am
Hi Steve,
Thanks for your prompt reply, however, I still have some problem implementing that code.
Below are the tables in question
CREATE TABLE IF NOT EXISTS `virtual_domains` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL,
`account_Number` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE IF NOT EXISTS `virtual_users` (
`id` int(11) NOT NULL auto_increment,
`domain_id` int(11) NOT NULL,
`user` varchar(40) NOT NULL,
`password` varchar(32) NOT NULL,
`account_Number` varchar(10) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQUE_EMAIL` (`domain_id`,`user`)
)
CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(11) NOT NULL auto_increment,
`account_Number` varchar(10) NOT NULL,
`Name` varchar(30) NOT NULL,
`contact_Number` varchar(15) NOT NULL,
`profile` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL,
`Role` enum('READ ONLY','EDIT','NO ACCESS','ADMIN') NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `account_Number` (`account_Number`)
)
You could see that I have account_Number in all of the tables. Below is the corresponding method I tried to implement on the virtual_users table on the field domain_id. Actually I want the dynamic values list "domains" on the domain_id field.
function valuelist__domains(){
static $values = 0;
if ( !is_array($values) ){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
$sql = "select id, name from virtual_domains";
if ( $user ){
$sql = ." where accountNumber='".addslashes($user->val('account_Number'))."'";
$res = mysql_query($sql, df_db());
$values = array();
while ($row = mysql_fetch_row($res) ) $values[$row[0]] = $row[1];
@mysql_free_result($res);
} else {
$values = array();
}
}
return $values;
}
The username_column for the login is account_Number in the accounts table. Below is my field.ini file for the virtual_users table. With the implementation of the above method I get a blank page. What am I missing?
[domain_id]
widget:label = "Domain Name"
widget:type = select
vocabulary = domains
[user]
widget:label = "Account"
[account_Number]
visibility = hidden