From 0c2155f2704d10a32f07fbf0b711574129adc261 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 9 Jul 2004 18:21:01 +0000 Subject: [PATCH] using eGW's new account-selection widget --- etemplate/inc/class.select_widget.inc.php | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/etemplate/inc/class.select_widget.inc.php b/etemplate/inc/class.select_widget.inc.php index 0fc5cb2b16..08761d3f70 100644 --- a/etemplate/inc/class.select_widget.inc.php +++ b/etemplate/inc/class.select_widget.inc.php @@ -120,6 +120,7 @@ $this->monthnames[$k] = lang($name); } } + $this->ui = $ui; } function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) @@ -213,27 +214,46 @@ break; case 'select-account': // options: #rows,{accounts(default)|both|groups},{0(=lid)|1(default=name)|2(=lid+name))} - $cell['no_lang'] = True; // in case of readonly, we read/create only the needed entries, as reading accounts is expensive if ($cell['readonly'] || $readonlys) { + $cell['no_lang'] = True; foreach(is_array($value) ? $value : array($value) as $id) { $cell['sel_options'][$id] = $this->accountInfo($id,$acc,$type2,$type=='both'); } break; } + if ($this->ui == 'html' && $type != 'groups') // use eGW's new account-selection (html only) + { + if (!is_object($GLOBALS['phpgw']->uiaccountsel)) + { + $GLOBALS['phpgw']->uiaccountsel = CreateObject('phpgwapi.uiaccountsel'); + } + $help = (int)$cell['no_lang'] < 2 ? lang($cell['help']) : $cell['help']; + $onFocus = "self.status='".addslashes(htmlspecialchars($help))."'; return true;"; + $onBlur = "self.status=''; return true;"; + $value = $GLOBALS['phpgw']->uiaccountsel->selection($name,'eT_accountsel_'.str_replace(array('[','][',']'),array('_','_',''),$name), + $value,$type,$rows > 0 ? $rows : 0,False,' onfocus="'.$onFocus.'" onblur="'.$onBlur.'"', + $cell['onchange'] == '1' ? 'this.form.submit();' : $cell['onchange'], + !empty($rows) && 0+$rows <= 0 ? lang($rows < 0 ? 'all' : $rows) : False); + $cell['type'] = 'html'; + $cell['size'] = ''; // is interpreted as link otherwise + $GLOBALS['phpgw_info']['etemplate']['to_process'][$name] = 'select'; + break; + } + $cell['no_lang'] = True; $accs = $GLOBALS['phpgw']->accounts->get_list(empty($type) ? 'accounts' : $type); // default is accounts foreach($accs as $acc) { - if ($acc['account_type'] == 'g') + if ($acc['account_type'] == 'u') { $cell['sel_options'][$acc['account_id']] = $this->accountInfo($acc['account_id'],$acc,$type2,$type=='both'); } } foreach($accs as $acc) { - if ($acc['account_type'] == 'u') + if ($acc['account_type'] == 'g') { $cell['sel_options'][$acc['account_id']] = $this->accountInfo($acc['account_id'],$acc,$type2,$type=='both'); }