template->set_file(array('form' => 'server_form.tpl'));
$phpgw->template->set_block('form','add','addhandle');
$phpgw->template->set_block('form','edit','edithandle');
$is = CreateObject('phpgwapi.interserver');
function formatted_list($name,$list,$id='',$default=False,$java=False)
{
$select = "\n" .''."\n";
return $select;
}
if ($submit)
{
$errorcount = 0;
if($is->name2id($server_name))
{
$error[$errorcount++] = lang('That server name has been used already !');
}
if (!$server_name)
{
$error[$errorcount++] = lang('Please enter a name for that server !');
}
if (!$error)
{
$server_info = array(
'server_name' => addslashes($server_name),
'server_url' => addslashes($server_url),
'server_mode' => addslashes($server_mode),
'server_security' => addslashes($server_security),
'trust_level' => intval($trust_level),
'admin_name' => addslashes($admin_name),
'admin_email' => addslashes($admin_email)
);
$is->create($server_info);
}
}
if ($errorcount)
{
$phpgw->template->set_var('message',$phpgw->common->error_list($error));
}
if (($submit) && (! $error) && (! $errorcount))
{
$phpgw->template->set_var('message',lang('Server x has been added !', $server_name));
}
if ((!$submit) && (!$error) && (!$errorcount))
{
$phpgw->template->set_var('message','');
}
$phpgw->template->set_var('title_servers',lang('Add Peer Server'));
$phpgw->template->set_var('actionurl',$phpgw->link('/admin/addserver.php'));
$phpgw->template->set_var('doneurl',$phpgw->link('/admin/servers.php'));
$phpgw->template->set_var('hidden_vars','');
$phpgw->template->set_var('lang_name',lang('Server name'));
$phpgw->template->set_var('lang_url',lang('Server URL'));
$phpgw->template->set_var('lang_mode',lang('Server Type(mode)'));
$phpgw->template->set_var('lang_security',lang('Security'));
$phpgw->template->set_var('lang_trust',lang('Trust Level'));
$phpgw->template->set_var('lang_relationship',lang('Trust Relationship'));
$phpgw->template->set_var('lang_admin_name',lang('Admin Name'));
$phpgw->template->set_var('lang_admin_email',lang('Admin Email'));
$phpgw->template->set_var('lang_add',lang('Add'));
$phpgw->template->set_var('lang_default',lang('Default'));
$phpgw->template->set_var('lang_reset',lang('Clear Form'));
$phpgw->template->set_var('lang_done',lang('Done'));
$phpgw->template->set_var('server_name',$server_name);
$phpgw->template->set_var('server_url',$server_url);
$phpgw->template->set_var('server_mode',formatted_list('server_mode',$is->server_modes,$server['server_mode']));
$phpgw->template->set_var('server_security',formatted_list('server_security',$is->security_types,$server['server_security']));
$phpgw->template->set_var('ssl_note',lang('Note: SSL available only if PHP is compiled with curl support'));
$phpgw->template->set_var('trust_level',formatted_list('trust_level',$is->trust_levels,$trust_level));
$phpgw->template->set_var('trust_relationship',formatted_list('trust_relationship',$is->trust_relationships,$server['trust_relationship'],True));
$phpgw->template->set_var('admin_name',$phpgw->strip_html($admin_name));
$phpgw->template->set_var('admin_email',$phpgw->strip_html($admin_email));
$phpgw->template->set_var('edithandle','');
$phpgw->template->set_var('addhandle','');
$phpgw->template->pparse('out','form');
$phpgw->template->pparse('addhandle','add');
$phpgw->common->phpgw_footer();
?>