Adding peer server admin

This commit is contained in:
Miles Lott 2001-08-13 17:08:00 +00:00
parent c05949d6f2
commit bf0f19ef26
7 changed files with 599 additions and 1 deletions

122
admin/addserver.php Normal file
View File

@ -0,0 +1,122 @@
<?php
/**************************************************************************\
* phpGroupWare - Chora *
* http://www.phpgroupware.org *
* Written by Bettina Gille [ceb@phpgroupware.org] *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_info["flags"]["currentapp"] = 'admin';
include('../header.inc.php');
$phpgw->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" .'<select name="' . $name . '"' . ">\n";
if($default)
{
$select .= '<option value="">' . lang('Please Select') . '</option>'."\n";
}
while (list($val,$key) = each($list))
{
$select .= '<option value="' . $key . '"';
if ($key == $id && $id != '')
{
$select .= ' selected';
}
$select .= '>' . lang($val) . '</option>'."\n";
}
$select .= '</select>'."\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','<input type="hidden" name="server_id" value="' . $server_id . '">');
$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();
?>

68
admin/deleteserver.php Normal file
View File

@ -0,0 +1,68 @@
<?php
/**************************************************************************\
* phpGroupWare - Admin *
* (http://www.phpgroupware.org) *
* Written by Bettina Gille [ceb@phpgroupware.org] *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
if ($confirm)
{
$phpgw_info["flags"] = array(
'noheader' => 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 =
'<input type="hidden" name="sort" value="' . $sort . '"' . ">\n"
. '<input type="hidden" name="order" value="' . $order . '"' . ">\n"
. '<input type="hidden" name="query" value="' . $query . '"' . ">\n"
. '<input type="hidden" name="start" value="' . $start . '"' . ">\n"
. '<input type="hidden" name="filter" value="' . $filter . '"' . ">\n"
. '<input type="hidden" name="server_id" value="' . $server_id . '">' . "\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 = "<a href=\"$nolinkf\">" . lang('No') ."</a>";
$phpgw->template->set_var('no',$nolink);
$yeslinkf = $phpgw->link('/admin/deleteserver.php',"server_id=$server_id&confirm=True");
$yeslinkf = '<form method="POST" name=yesbutton action="' . $phpgw->link('/admin/deleteserver.php') . '">'
. $hidden_vars
. '<input type=hidden name="server_id" value="' . $server_id . '">'
. '<input type=hidden name="confirm" value="True">'
. '<input type=submit name="yesbutton" value=Yes>'
. '</form><script>document.yesbutton.yesbutton.focus()</script>';
$yeslink = '<a href="' . $yeslinkf . '">' . lang('Yes') .'</a>';
$yeslink = $yeslinkf;
$phpgw->template->set_var('yes',$yeslink);
$phpgw->template->pparse('out','server_delete');
}
$phpgw->common->phpgw_footer();
?>

150
admin/editserver.php Normal file
View File

@ -0,0 +1,150 @@
<?php
/**************************************************************************\
* phpGroupWare - Admin *
* http://www.phpgroupware.org *
* Written by Bettina Gille [ceb@phpgroupware.org] *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_info["flags"]["currentapp"] = 'admin';
include('../header.inc.php');
if (!$server_id)
{
Header('Location: ' . $phpgw->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" .'<select name="' . $name . '"' . ">\n";
if($default)
{
$select .= '<option value="">' . lang('Please Select') . '</option>'."\n";
}
while (list($val,$key) = each($list))
{
$select .= '<option value="' . $key . '"';
if ($key == $id && $id != '')
{
$select .= ' selected';
}
$select .= '>' . lang($val) . '</option>'."\n";
}
$select .= '</select>'."\n";
return $select;
}
$is = CreateObject('phpgwapi.interserver',$server_id);
$server = $is->read_repository($server_id);
$hidden_vars = "<input type=\"hidden\" name=\"sort\" value=\"$sort\">\n"
. "<input type=\"hidden\" name=\"order\" value=\"$order\">\n"
. "<input type=\"hidden\" name=\"query\" value=\"$query\">\n"
. "<input type=\"hidden\" name=\"start\" value=\"$start\">\n"
. "<input type=\"hidden\" name=\"filter\" value=\"$filter\">\n"
. "<input type=\"hidden\" name=\"server_id\" value=\"$server_id\">\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();
?>

View File

@ -16,6 +16,7 @@
$title = $appname; $title = $appname;
$file = Array( $file = Array(
'Site Configuration' => $phpgw->link('/admin/config.php','appname=' . $appname), 'Site Configuration' => $phpgw->link('/admin/config.php','appname=' . $appname),
'Peer Servers' => $phpgw->link('/admin/servers.php'),
'User Accounts' => $phpgw->link('/admin/accounts.php'), 'User Accounts' => $phpgw->link('/admin/accounts.php'),
'User Groups' => $phpgw->link('/admin/groups.php'), 'User Groups' => $phpgw->link('/admin/groups.php'),
'Applications' => $phpgw->link('/admin/applications.php'), 'Applications' => $phpgw->link('/admin/applications.php'),
@ -23,7 +24,7 @@
'Change Main Screen Message' => $phpgw->link('/admin/mainscreen_message.php'), 'Change Main Screen Message' => $phpgw->link('/admin/mainscreen_message.php'),
'View Sessions' => $phpgw->link('/admin/currentusers.php'), 'View Sessions' => $phpgw->link('/admin/currentusers.php'),
'View Access Log' => $phpgw->link('/index.php','menuaction=admin.uiaccess_history.list_history'), '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') 'phpInfo' => $phpgw->link('/admin/phpinfo.php')
); );
//Do not modify below this line //Do not modify below this line

113
admin/servers.php Normal file
View File

@ -0,0 +1,113 @@
<?php
/**************************************************************************\
* phpGroupWare - phpgroupware Peer Servers *
* http://www.phpgroupware.org *
* ----------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_info['flags'] = array(
'currentapp' => '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 =
'<input type="hidden" name="sort" value="' . $sort . '"' . ">\n"
. '<input type="hidden" name="order" value="' . $order . '"' . ">\n"
. '<input type="hidden" name="query" value="' . $query . '"' . ">\n"
. '<input type="hidden" name="start" value="' . $start . '"' . ">\n"
. '<input type="hidden" name="filter" value="' . $filter . '"' . ">\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();
?>

View File

@ -0,0 +1,55 @@
<center>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td colspan="5" align="center" bgcolor="#c9c9c9"><b>{title_servers}<b/></td>
</tr>
<tr>
<td colspan="5" align="left">
<table border="0" width="100%">
<tr>
{left}
<td align="center">{lang_showing}</td>
{right}
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="4" align="right">
<form method="post" action="{actionurl}">
<input type="text" name="query">&nbsp;<input type="submit" name="search" value="{lang_search}"></form></td>
</tr>
<tr bgcolor="{th_bg}">
<td width="20%" bgcolor="{th_bg}">{sort_name}</td>
<td width="32%" bgcolor="{th_bg}">{sort_url}</td>
<td width="8%" bgcolor="{th_bg}" align="center">{lang_edit}</td>
<td width="8%" bgcolor="{th_bg}" align="center">{lang_delete}</td>
</tr>
<!-- BEGIN server_list -->
<tr bgcolor="{tr_color}">
<td>{server_name}</td>
<td>{server_url}</td>
<td align="center"><a href="{edit}">{lang_edit_entry}</a></td>
<td align="center"><a href="{delete}">{lang_delete_entry}</a></td>
</tr>
<!-- END server_list -->
<!-- BEGIN add -->
<tr valign="bottom">
<td>
<form method="POST" action="{add_action}">
<input type="submit" name="add" value="{lang_add}"></form>
</td>
</tr>
<tr valign="bottom">
<td>
<form method="POST" action="{doneurl}">
<input type="submit" name="done" value="{lang_done}"></form>
</td>
</tr>
<!-- END add -->
</table>
</center>

View File

@ -0,0 +1,89 @@
<!-- BEGIN form -->
<center>
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="1" align="center" bgcolor="#c9c9c9"><b>{title_servers}<b/></td>
</tr>
</table>
{message}
<table border="0" width="80%" cellspacing="2" cellpadding="2">
<form name="form" action="{actionurl}" method="POST">
<tr>
<td>{lang_name}:</td>
<td><input name="server_name" size="50" value="{server_name}"></td>
</tr>
<tr>
<td>{lang_url}:</td>
<td><input name="server_url" size="50" value="{server_url}"></td>
</tr>
<tr>
<td>{lang_mode}:</td>
<td>{server_mode}</td>
</tr>
<tr>
<td>{lang_security}:</td>
<td>{server_security}&nbsp;{ssl_note}</td>
</tr>
<tr>
<td>{lang_trust}:</td>
<td>{trust_level}</td>
</tr>
<tr>
<td>{lang_relationship}:</td>
<td>{trust_relationship}</td>
</tr>
<tr>
<td>{lang_username}:</td>
<td><input name="server_username" size="30" value="{server_username}"></td>
</tr>
<tr>
<td>{lang_password}:</td>
<td><input type="password" name="server_password" size="30" value="">&nbsp;{pass_note}</td>
</tr>
<tr>
<td>{lang_admin_name}:</td>
<td><input name="admin_name" size="50" value="{admin_name}"></td>
</tr>
<tr>
<td>{lang_admin_email}:</td>
<td><input name="admin_email" size="50" value="{admin_email}"></td>
</tr>
</table>
<!-- BEGIN add -->
<table width="50%" border="0" cellspacing="2" cellpadding="2">
<tr valign="bottom">
<td height="50" align="center">
{hidden_vars}
<input type="submit" name="submit" value="{lang_add}"></td>
<td height="50" align="center">
<input type="reset" name="reset" value="{lang_reset}"></form></td>
<td height="50" align="center">
<form method="POST" action="{doneurl}">
{hidden_vars}
<input type="submit" name="done" value="{lang_done}"></form></td>
</tr>
</table>
</center>
<!-- END add -->
<!-- BEGIN edit -->
<table width="50%" border="0" cellspacing="2" cellpadding="2">
<tr valign="bottom">
<td height="50" align="center">
{hidden_vars}
<input type="submit" name="submit" value="{lang_edit}"></form></td>
<td height="50" align="center">
<form method="POST" action="{deleteurl}">
{hidden_vars}
<input type="submit" name="delete" value="{lang_delete}"></form></td>
<td height="50" align="center">
<form method="POST" action="{doneurl}">
{hidden_vars}
<input type="submit" name="done" value="{lang_done}"></form></td>
</tr>
</table>
</center>
<!-- END edit -->
<!-- END form -->