True,
'css' => True,
'deleteProfile' => True,
'editProfile' => True,
'listProfiles' => True,
'saveProfile' => True
);
var $cats;
var $nextmatchs;
var $t;
var $boqmailldap;
function ui()
{
$this->cats = CreateObject('phpgwapi.categories');
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
$this->t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
#$this->grants = $phpgw->acl->get_grants('notes');
#$this->grants[$this->account] = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
$this->boemailadmin = CreateObject('emailadmin.bo');
}
function addProfile()
{
$this->display_app_header();
$this->t->set_file(array("body" => "editprofile.tpl"));
$this->t->set_block('body','main');
$this->translate();
#$this->t->set_var('profile_name',$profileList[0]['description']);
$this->t->set_var('smtpActiveTab','1');
$this->t->set_var('imapActiveTab','1');
$linkData = array
(
'menuaction' => 'emailadmin.ui.saveProfile'
);
$this->t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$linkData));
$linkData = array
(
'menuaction' => 'emailadmin.ui.listProfiles'
);
$this->t->set_var('back_url',$GLOBALS['phpgw']->link('/index.php',$linkData));
foreach($this->boemailadmin->getSMTPServerTypes() as $key => $value)
{
$this->t->set_var("lang_smtp_option_$key",$value);
};
foreach($this->boemailadmin->getIMAPServerTypes() as $key => $value)
{
$this->t->set_var("lang_imap_option_$key",$value['description']);
};
$this->t->parse("out","main");
print $this->t->get('out','main');
}
function css()
{
$appCSS =
'th.activetab
{
color:#000000;
background-color:#D3DCE3;
border-top-width : 1px;
border-top-style : solid;
border-top-color : Black;
border-left-width : 1px;
border-left-style : solid;
border-left-color : Black;
border-right-width : 1px;
border-right-style : solid;
border-right-color : Black;
}
th.inactivetab
{
color:#000000;
background-color:#E8F0F0;
border-bottom-width : 1px;
border-bottom-style : solid;
border-bottom-color : Black;
}
.td_left { border-left : 1px solid Gray; border-top : 1px solid Gray; }
.td_right { border-right : 1px solid Gray; border-top : 1px solid Gray; }
div.activetab{ display:inline; }
div.inactivetab{ display:none; }';
return $appCSS;
}
function deleteProfile()
{
$this->boemailadmin->deleteProfile($_GET['profileid']);
$this->listProfiles();
}
function display_app_header()
{
if(!@is_object($GLOBALS['phpgw']->js))
{
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
}
$GLOBALS['phpgw']->js->validate_file('tabs','tabs');
switch($_GET['menuaction'])
{
case 'emailadmin.ui.addProfile':
case 'emailadmin.ui.editProfile':
$GLOBALS['phpgw']->js->validate_file('jscode','editProfile','emailadmin');
$GLOBALS['phpgw']->js->set_onload('javascript:initAll();');
#$GLOBALS['phpgw']->js->set_onload('smtp.init();');
break;
}
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
}
function editProfile($_profileID='')
{
if($_profileID != '')
{
$profileID = $_profileID;
}
elseif(is_int(intval($_GET['profileid'])) && !empty($_GET['profileid']))
{
$profileID = intval($_GET['profileid']);
}
else
{
return false;
}
$profileList = $this->boemailadmin->getProfileList($profileID);
$profileData = $this->boemailadmin->getProfile($profileID);
$this->display_app_header();
$this->t->set_file(array("body" => "editprofile.tpl"));
$this->t->set_block('body','main');
$this->translate();
foreach($profileData as $key => $value)
{
//print "$key $value
";
switch($key)
{
case 'imapEnableCyrusAdmin':
case 'imapEnableSieve':
case 'imapTLSAuthentication':
case 'imapTLSEncryption':
case 'smtpAuth':
case 'smtpLDAPUseDefault':
case 'userDefinedAccounts':
case 'imapoldcclient':
if($value == 'yes')
$this->t->set_var('selected_'.$key,'checked="1"');
break;
case 'imapType':
case 'smtpType':
case 'imapLoginType':
$this->t->set_var('selected_'.$key.'_'.$value,'selected="1"');
break;
case 'imapDelimiter':
if ($value == '/')
$this->t->set_var('selected_'.$key.'_slash','selected="1"');
elseif ($value == '.')
$this->t->set_var('selected_'.$key.'_dot','selected="1"');
break;
default:
$this->t->set_var('value_'.$key,$value);
break;
}
}
$linkData = array
(
'menuaction' => 'emailadmin.ui.saveProfile',
'profileID' => $profileID
);
$this->t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$linkData));
$linkData = array
(
'menuaction' => 'emailadmin.ui.listProfiles'
);
$this->t->set_var('back_url',$GLOBALS['phpgw']->link('/index.php',$linkData));
foreach($this->boemailadmin->getSMTPServerTypes() as $key => $value)
{
$this->t->set_var("lang_smtp_option_$key",$value);
};
foreach($this->boemailadmin->getIMAPServerTypes() as $key => $value)
{
$this->t->set_var("lang_imap_option_$key",$value['description']);
};
$this->t->parse("out","main");
print $this->t->get('out','main');
}
function listProfiles()
{
$this->display_app_header();
$this->t->set_file(array("body" => "listprofiles.tpl"));
$this->t->set_block('body','main');
$this->translate();
$profileList = $this->boemailadmin->getProfileList();
// create the data array
if ($profileList)
{
for ($i=0; $i < count($profileList); $i++)
{
$linkData = array
(
'menuaction' => 'emailadmin.ui.editProfile',
'nocache' => '1',
'tabpage' => '3',
'profileid' => $profileList[$i]['profileID']
);
$imapServerLink = ''.$profileList[$i]['imapServer'].'';
$linkData = array
(
'menuaction' => 'emailadmin.ui.editProfile',
'nocache' => '1',
'tabpage' => '1',
'profileid' => $profileList[$i]['profileID']
);
$descriptionLink = ''.$profileList[$i]['description'].'';
$linkData = array
(
'menuaction' => 'emailadmin.ui.editProfile',
'nocache' => '1',
'tabpage' => '2',
'profileid' => $profileList[$i]['profileID']
);
$smtpServerLink = ''.$profileList[$i]['smtpServer'].'';
$linkData = array
(
'menuaction' => 'emailadmin.ui.deleteProfile',
'profileid' => $profileList[$i]['profileID']
);
$deleteLink = ''.
lang('delete').'';
$data[] = array(
$descriptionLink,
$smtpServerLink,
$imapServerLink,
$deleteLink
);
}
}
// create the array containing the table header
$rows = array(
lang('description'),
lang('smtp server name'),
lang('imap/pop3 server name'),
lang('delete')
);
// create the table html code
$this->t->set_var('server_next_match',$this->nextMatchTable(
$rows,
$data,
lang('profile list'),
$_start,
$_total,
$_menuAction)
);
$linkData = array
(
'menuaction' => 'emailadmin.ui.addProfile'
);
$this->t->set_var('add_link',$GLOBALS['phpgw']->link('/index.php',$linkData));
$this->t->parse("out","main");
print $this->t->get('out','main');
}
function nextMatchTable($_rows, $_data, $_description, $_start, $_total, $_menuAction)
{
$template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$template->set_file(array("body" => "nextMatch.tpl"));
$template->set_block('body','row_list','rowList');
$template->set_block('body','header_row','headerRow');
$var = Array(
'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
'left_next_matchs' => $this->nextmatchs->left('/index.php',$start,$total,'menuaction=emailadmin.ui.listServers'),
'right_next_matchs' => $this->nextmatchs->right('/admin/groups.php',$start,$total,'menuaction=emailadmin.ui.listServers'),
'lang_groups' => lang('user groups'),
'sort_name' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('name'),'menuaction=emailadmin.ui.listServers'),
'description' => $_description,
'header_edit' => lang('Edit'),
'header_delete' => lang('Delete')
);
$template->set_var($var);
$data = '';
if(is_array($_rows))
{
foreach($_rows as $value)
{
$data .= "