From bf0f19ef2644f5837f4acaf827df616682a65c11 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Mon, 13 Aug 2001 17:08:00 +0000 Subject: [PATCH] Adding peer server admin --- admin/addserver.php | 122 +++++++++++++++++++ admin/deleteserver.php | 68 +++++++++++ admin/editserver.php | 150 ++++++++++++++++++++++++ admin/inc/hook_admin.inc.php | 3 +- admin/servers.php | 113 ++++++++++++++++++ admin/templates/default/listservers.tpl | 55 +++++++++ admin/templates/default/server_form.tpl | 89 ++++++++++++++ 7 files changed, 599 insertions(+), 1 deletion(-) create mode 100644 admin/addserver.php create mode 100644 admin/deleteserver.php create mode 100644 admin/editserver.php create mode 100644 admin/servers.php create mode 100644 admin/templates/default/listservers.tpl create mode 100644 admin/templates/default/server_form.tpl diff --git a/admin/addserver.php b/admin/addserver.php new file mode 100644 index 0000000000..e2c7feac7b --- /dev/null +++ b/admin/addserver.php @@ -0,0 +1,122 @@ +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(); +?> diff --git a/admin/deleteserver.php b/admin/deleteserver.php new file mode 100644 index 0000000000..c3aa5c3c76 --- /dev/null +++ b/admin/deleteserver.php @@ -0,0 +1,68 @@ + True, + 'nonavbar' => True + ); + } + + $phpgw_info['flags']['currentapp'] = 'admin'; + include('../header.inc.php'); + + if (!$server_id) + { + Header('Location: ' . $phpgw->link('/admin/servers.php')); + } + + if ($confirm) + { + $is->delete($server_id); + Header('Location: ' . $phpgw->link('/admin/servers.php',"start=$start&query=$query&sort=$sort&order=$order&filter=$filter")); + } + else + { + $hidden_vars = + '\n" + . '\n" + . '\n" + . '\n" + . '\n" + . '' . "\n"; + + $phpgw->template->set_file(array('server_delete' => 'delete_common.tpl')); + $phpgw->template->set_var('messages',lang('Are you sure you want to delete this server?')); + + $nolinkf = $phpgw->link('/admin/servers.php',"server_id=$server_id&start=$start&query=$query&sort=$sort&order=$order&filter=$filter"); + $nolink = "" . lang('No') .""; + $phpgw->template->set_var('no',$nolink); + + $yeslinkf = $phpgw->link('/admin/deleteserver.php',"server_id=$server_id&confirm=True"); + $yeslinkf = '
' + . $hidden_vars + . '' + . '' + . '' + . '
'; + + $yeslink = '' . lang('Yes') .''; + $yeslink = $yeslinkf; + $phpgw->template->set_var('yes',$yeslink); + + $phpgw->template->pparse('out','server_delete'); + } + + $phpgw->common->phpgw_footer(); +?> diff --git a/admin/editserver.php b/admin/editserver.php new file mode 100644 index 0000000000..bb7536585d --- /dev/null +++ b/admin/editserver.php @@ -0,0 +1,150 @@ +link('/admin/servers.php',"sort=$sort&order=$order&query=$query&start=$start" + . "&filter=$filter")); + } + + $phpgw->t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); + $phpgw->template->set_file(array('form' => 'server_form.tpl')); + $phpgw->template->set_block('form','add','addhandle'); + $phpgw->template->set_block('form','edit','edithandle'); + + function formatted_list($name,$list,$id='',$default=False,$java=False) + { + $select = "\n" .''."\n"; + + return $select; + } + + $is = CreateObject('phpgwapi.interserver',$server_id); + $server = $is->read_repository($server_id); + + $hidden_vars = "\n" + . "\n" + . "\n" + . "\n" + . "\n" + . "\n"; + + if ($submit) + { + $errorcount = 0; + + $tmp = $is->name2id($server_name); + if($tmp != $server_id) + { + $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), + 'trust_level' => intval($trust_level), + 'trust_rel' => intval($trust_rel), + 'username' => addslashes($server_username), + 'password' => $server_password ? $server_password : $server['password'], + 'server_mode' => addslashes($server_mode), + 'server_security' => addslashes($server_security), + 'admin_name' => addslashes($admin_name), + 'admin_email' => addslashes($admin_email) + ); + + $is->server = $server_info; + $is->save_repository($server_id); + $server = $is->read_repository($server_id); + } + } + + 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 updated !",$server_name)); + } + if ((!$submit) && (!$error) && (!$errorcount)) + { + $phpgw->template->set_var('message',''); + } + + $phpgw->template->set_var('title_servers',lang('Edit Peer Server')); + $phpgw->template->set_var('actionurl',$phpgw->link('/admin/editserver.php')); + $phpgw->template->set_var('deleteurl',$phpgw->link('/admin/deleteserver.php',"server_id=$server_id&start=$start&query=$query&sort=$sort&order=$order&filter=$filter")); + $phpgw->template->set_var('doneurl',$phpgw->link('/admin/servers.php',"start=$start&query=$query&sort=$sort&order=$order&filter=$filter")); + + $phpgw->template->set_var('lang_name',lang('Server name')); + $phpgw->template->set_var('lang_url',lang('Server URL')); + $phpgw->template->set_var('lang_trust',lang('Trust Level')); + $phpgw->template->set_var('lang_relationship',lang('Trust Relationship')); + $phpgw->template->set_var('lang_username',lang('Server Username')); + $phpgw->template->set_var('lang_password',lang('Server Password')); + $phpgw->template->set_var('lang_mode',lang('Server Type(mode)')); + $phpgw->template->set_var('lang_security',lang('Security')); + $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_edit',lang('Edit')); + $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('hidden_vars',$hidden_vars); + $phpgw->template->set_var('lang_delete',lang('Delete')); + + $phpgw->template->set_var('server_name',$server['server_name']); + $phpgw->template->set_var('server_url',$server['server_url']); + $phpgw->template->set_var('server_username',$server['username']); + $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('pass_note',lang('(Stored password will not be shown here)')); + $phpgw->template->set_var('trust_level',formatted_list('trust_level',$is->trust_levels,$server['trust_level'])); + $phpgw->template->set_var('trust_relationship',formatted_list('trust_rel',$is->trust_relationships,$server['trust_rel'],True)); + $phpgw->template->set_var('admin_name',$phpgw->strip_html($server['admin_name'])); + $phpgw->template->set_var('admin_email',$phpgw->strip_html($server['admin_email'])); + + $phpgw->template->set_var('edithandle',''); + $phpgw->template->set_var('addhandle',''); + + $phpgw->template->pparse('out','form'); + $phpgw->template->pparse('edithandle','edit'); + + $phpgw->common->phpgw_footer(); +?> diff --git a/admin/inc/hook_admin.inc.php b/admin/inc/hook_admin.inc.php index f81651d677..200a26a61b 100644 --- a/admin/inc/hook_admin.inc.php +++ b/admin/inc/hook_admin.inc.php @@ -16,6 +16,7 @@ $title = $appname; $file = Array( 'Site Configuration' => $phpgw->link('/admin/config.php','appname=' . $appname), + 'Peer Servers' => $phpgw->link('/admin/servers.php'), 'User Accounts' => $phpgw->link('/admin/accounts.php'), 'User Groups' => $phpgw->link('/admin/groups.php'), 'Applications' => $phpgw->link('/admin/applications.php'), @@ -23,7 +24,7 @@ 'Change Main Screen Message' => $phpgw->link('/admin/mainscreen_message.php'), 'View Sessions' => $phpgw->link('/admin/currentusers.php'), 'View Access Log' => $phpgw->link('/index.php','menuaction=admin.uiaccess_history.list_history'), - 'View Error Log' => $phpgw->link('/admin/log.php'), //j3rry + 'View Error Log' => $phpgw->link('/admin/log.php'), 'phpInfo' => $phpgw->link('/admin/phpinfo.php') ); //Do not modify below this line diff --git a/admin/servers.php b/admin/servers.php new file mode 100644 index 0000000000..7873399e17 --- /dev/null +++ b/admin/servers.php @@ -0,0 +1,113 @@ + 'admin', + 'enable_config_class' => True, + 'enable_nextmatchs_class' => True); + + include('../header.inc.php'); + + $phpgw->template->set_file(array('server_list_t' => 'listservers.tpl')); + $phpgw->template->set_block('server_list_t','server_list','list'); + + $common_hidden_vars = + '\n" + . '\n" + . '\n" + . '\n" + . '\n"; + + $phpgw->template->set_var('lang_action',lang('Server List')); + $phpgw->template->set_var('add_action',$phpgw->link('/admin/addserver.php')); + $phpgw->template->set_var('lang_add',lang('Add')); + $phpgw->template->set_var('title_servers',lang('Peer Servers')); + $phpgw->template->set_var('lang_search',lang('Search')); + $phpgw->template->set_var('actionurl',$phpgw->link('/admin/servers.php')); + $phpgw->template->set_var('lang_done',lang('Done')); + $phpgw->template->set_var('doneurl',$phpgw->link('/admin/index.php')); + + if(!$start) + { + $start = 0; + } + + if($phpgw_info['user']['preferences']['common']['maxmatchs'] && + $phpgw_info['user']['preferences']['common']['maxmatchs'] > 0) + { + $limit = $phpgw_info['user']['preferences']['common']['maxmatchs']; + } + else + { + $limit = 15; + } + + if(!$sort) + { + $sort = 'ASC'; + } + + if($order) + { + $ordermethod = "ORDER BY $order $sort "; + } + else + { + $ordermethod = " ORDER BY server_name ASC "; + } + + if ($query) + { + $querymethod = " WHERE name like '%$query%' OR title like '%$query%'"; + } + + $is = CreateObject('phpgwapi.interserver'); + $servers = $is->get_list(); + + $left = $phpgw->nextmatchs->left('/admin/servers.php',$start,$total_records); + $right = $phpgw->nextmatchs->right('/admin/servers.php',$start,$total_records); + $phpgw->template->set_var('left',$left); + $phpgw->template->set_var('right',$right); + + $phpgw->template->set_var('lang_showing',$phpgw->nextmatchs->show_hits($total_records,$start)); + + $phpgw->template->set_var('th_bg',$phpgw_info['theme']['th_bg']); + $phpgw->template->set_var('sort_name',$phpgw->nextmatchs->show_sort_order($sort,'server_name',$order,'/admin/servers.php',lang('Name'))); + $phpgw->template->set_var('sort_url', $phpgw->nextmatchs->show_sort_order($sort,'server_url',$order,'/admin/servers.php',lang('URL'))); + $phpgw->template->set_var('lang_default',lang('Default')); + $phpgw->template->set_var('lang_edit',lang('Edit')); + $phpgw->template->set_var('lang_delete',lang('Delete')); + + while(list($key,$server) = @each($servers)) + { + $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); + $phpgw->template->set_var('tr_color',$tr_color); + $server_id = $server['server_id']; + + $phpgw->template->set_var(array( + 'server_name' => $phpgw->strip_html($server['server_name']), + 'server_url' => $phpgw->strip_html($server['server_url']) + )); + + $phpgw->template->set_var('edit',$phpgw->link('/admin/editserver.php',"server_id=$server_id&start=$start&query=$query&sort=$sort&order=$order&filter=$filter")); + $phpgw->template->set_var('lang_edit_entry',lang('Edit')); + + $phpgw->template->set_var('delete',$phpgw->link('/admin/deleteserver.php',"server_id=$server_id&start=$start&query=$query&sort=$sort&order=$order&filter=$filter")); + $phpgw->template->set_var('lang_delete_entry',lang('Delete')); + $phpgw->template->parse('list','server_list',True); + } + + $phpgw->template->parse('out','server_list_t',True); + $phpgw->template->p('out'); + + $phpgw->common->phpgw_footer(); +?> diff --git a/admin/templates/default/listservers.tpl b/admin/templates/default/listservers.tpl new file mode 100644 index 0000000000..0e9007d9f7 --- /dev/null +++ b/admin/templates/default/listservers.tpl @@ -0,0 +1,55 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{title_servers}
+ + + {left} + + {right} + +
{lang_showing}
+
  +
+  
{sort_name}{sort_url}{lang_edit}{lang_delete}
{server_name}{server_url}{lang_edit_entry}{lang_delete_entry}
+
+
+
+
+
+
+
diff --git a/admin/templates/default/server_form.tpl b/admin/templates/default/server_form.tpl new file mode 100644 index 0000000000..5f66666aea --- /dev/null +++ b/admin/templates/default/server_form.tpl @@ -0,0 +1,89 @@ + +
+ + + + +
{title_servers}
+ {message} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{lang_name}:
{lang_url}:
{lang_mode}:{server_mode}
{lang_security}:{server_security} {ssl_note}
{lang_trust}:{trust_level}
{lang_relationship}:{trust_relationship}
{lang_username}:
{lang_password}: {pass_note}
{lang_admin_name}:
{lang_admin_email}:
+ + + + + + + + +
+ {hidden_vars} + + +
+ {hidden_vars} +
+
+ + + + + + + + + +
+ {hidden_vars} + +
+ {hidden_vars} +
+
+ {hidden_vars} +
+ + + +