Commit be7d7f8a authored by tbrehm's avatar tbrehm
Browse files

Separated clients and resellers and

Fixed FS#775 - Client can choose the servers for it's client 
parent 9f4944b0
......@@ -64,6 +64,32 @@ class custom_datasource {
}
function client_servers($field, $record) {
global $app, $conf;
$server_type = $field['name'];
if($_SESSION["s"]["user"]["typ"] == 'user') {
// Get the limits of the client
$client_group_id = $_SESSION["s"]["user"]["default_group"];
$sql = "SELECT $server_type as server_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id";
$client = $app->db->queryOneRecord($sql);
$sql = "SELECT server_id,server_name FROM server WHERE server_id = ".$client['server_id'];
} else {
$sql = "SELECT server_id,server_name FROM server WHERE dns_server = 1 ORDER BY server_name";
}
$records = $app->db->queryAllRecords($sql);
$records_new = array();
if(is_array($records)) {
foreach($records as $rec) {
$key = $rec['server_id'];
$records_new[$key] = $rec['server_name'];
}
}
return $records_new;
}
}
......
<?php
/*
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class validate_reseller {
/*
Validator function to check if a given cron command is in correct form (url only).
*/
function limit_client($field_name, $field_value, $validator) {
global $app;
if($field_value <= 0) {
return $app->tform->lng('limit_client_error_positive');
} else {
return '';
}
}
}
\ No newline at end of file
......@@ -122,7 +122,7 @@ $form["tabs"]['services'] = array (
)
);
/*
$form["tabs"]['config'] = array (
'title' => "Config",
'width' => 100,
......@@ -146,6 +146,6 @@ $form["tabs"]['config'] = array (
##################################
)
);
*/
?>
\ No newline at end of file
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_server_config">
<div class="pnl_toolsarea">
<fieldset><legend>Tools</legend>
<div class="buttons">
<button class="iconstxt icoAdd" type="button" onClick="loadContent('admin/server_config_edit.php');">
<span>{tmpl_var name="add_new_record_txt"}</span>
</button>
</div>
</fieldset>
</div>
<div class="pnl_listarea">
<fieldset><legend><tmpl_var name="list_head_txt"></legend>
<table class="list">
<thead>
<tr>
<th class="tbl_col_server_name" scope="col"><tmpl_var name="server_name_txt"></th>
<th class="tbl_col_buttons" scope="col">&nbsp;</th>
</tr>
<tr>
<td class="tbl_col_server_name"><input type="text" name="search_server_name" value="{tmpl_var name='search_server_name'}" /></td>
<td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','admin/server_config_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
</tr>
</thead>
<tbody>
<tmpl_loop name="records">
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td class="tbl_col_server_name"><a href="#" onClick="loadContent('admin/server_config_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="server_name"}</a></td>
<td class="tbl_col_buttons">
<div class="buttons icons16">
<a class="icons16 icoDelete" href="javascript: del_record('admin/server_config_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
</div>
</td>
</tr>
</tmpl_loop>
</tbody>
<tfoot>
<tr>
<td class="tbl_footer tbl_paging" colspan="2"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
</fieldset>
</div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_server_config">
<div class="pnl_listarea">
<fieldset><legend><tmpl_var name="list_head_txt"></legend>
<table class="list">
<thead>
<tr>
<th class="tbl_col_server_name" scope="col"><tmpl_var name="server_name_txt"></th>
<th class="tbl_col_buttons" scope="col">&nbsp;</th>
</tr>
<tr>
<td class="tbl_col_server_name"><input type="text" name="search_server_name" value="{tmpl_var name='search_server_name'}" /></td>
<td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','admin/server_config_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
</tr>
</thead>
<tbody>
<tmpl_loop name="records">
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td class="tbl_col_server_name"><a href="#" onClick="loadContent('admin/server_config_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="server_name"}</a></td>
<td class="tbl_col_buttons">
<div class="buttons icons16">
<a class="icons16 icoDelete" href="javascript: del_record('admin/server_config_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
</div>
</td>
</tr>
</tmpl_loop>
</tbody>
<tfoot>
<tr>
<td class="tbl_footer tbl_paging" colspan="2"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
</fieldset>
</div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_server">
<div class="pnl_toolsarea">
<fieldset><legend>Tools</legend>
<div class="buttons">
<button class="iconstxt icoAdd" type="button" onClick="loadContent('admin/server_edit.php');">
<span>{tmpl_var name="add_new_record_txt"}</span>
</button>
</div>
</fieldset>
</div>
<div class="pnl_listarea">
<fieldset><legend><tmpl_var name="list_head_txt"></legend>
<table class="list">
<thead>
<tr>
<th class="tbl_col_server_name" scope="col"><tmpl_var name="server_name_txt"></th>
<th class="tbl_col_mail_server" scope="col"><tmpl_var name="mail_server_txt"></th>
<th class="tbl_col_web_server" scope="col"><tmpl_var name="web_server_txt"></th>
<th class="tbl_col_dns_server" scope="col"><tmpl_var name="dns_server_txt"></th>
<th class="tbl_col_file_server" scope="col"><tmpl_var name="file_server_txt"></th>
<th class="tbl_col_db_server" scope="col"><tmpl_var name="db_server_txt"></th>
<th class="tbl_col_vserver_server" scope="col"><tmpl_var name="vserver_server_txt"></th>
<th class="tbl_col_buttons" scope="col">&nbsp;</th>
</tr>
<tr>
<td class="tbl_col_server_name"><input type="text" name="search_server_name" value="{tmpl_var name='search_server_name'}" /></td>
<td class="tbl_col_mail_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_mail_server'}</select></td>
<td class="tbl_col_web_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_web_server'}</select></td>
<td class="tbl_col_dns_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_dns_server'}</select></td>
<td class="tbl_col_file_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_file_server'}</select></td>
<td class="tbl_col_db_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_db_server'}</select></td>
<td class="tbl_col_vserver_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_vserver_server'}</select></td>
<td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','admin/server_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
</tr>
</thead>
<tbody>
<tmpl_loop name="records">
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td class="tbl_col_server_name"><a href="#" onClick="loadContent('admin/server_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="server_name"}</a></td>
<td class="tbl_col_mail_server">{tmpl_var name="mail_server"}</td>
<td class="tbl_col_web_server">{tmpl_var name="web_server"}</td>
<td class="tbl_col_dns_server">{tmpl_var name="dns_server"}</td>
<td class="tbl_col_file_server">{tmpl_var name="file_server"}</td>
<td class="tbl_col_db_server">{tmpl_var name="db_server"}</td>
<td class="tbl_col_vserver_server">{tmpl_var name="vserver_server"}</td>
<td class="tbl_col_buttons">
<div class="buttons icons16">
<a class="icons16 icoDelete" href="javascript: del_record('admin/server_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
</div>
</td>
</tr>
</tmpl_loop>
</tbody>
<tfoot>
<tr>
<td class="tbl_footer tbl_paging" colspan="8"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
</fieldset>
</div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_server">
<div class="pnl_listarea">
<fieldset><legend><tmpl_var name="list_head_txt"></legend>
<table class="list">
<thead>
<tr>
<th class="tbl_col_server_name" scope="col"><tmpl_var name="server_name_txt"></th>
<th class="tbl_col_mail_server" scope="col"><tmpl_var name="mail_server_txt"></th>
<th class="tbl_col_web_server" scope="col"><tmpl_var name="web_server_txt"></th>
<th class="tbl_col_dns_server" scope="col"><tmpl_var name="dns_server_txt"></th>
<th class="tbl_col_file_server" scope="col"><tmpl_var name="file_server_txt"></th>
<th class="tbl_col_db_server" scope="col"><tmpl_var name="db_server_txt"></th>
<th class="tbl_col_vserver_server" scope="col"><tmpl_var name="vserver_server_txt"></th>
<th class="tbl_col_buttons" scope="col">&nbsp;</th>
</tr>
<tr>
<td class="tbl_col_server_name"><input type="text" name="search_server_name" value="{tmpl_var name='search_server_name'}" /></td>
<td class="tbl_col_mail_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_mail_server'}</select></td>
<td class="tbl_col_web_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_web_server'}</select></td>
<td class="tbl_col_dns_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_dns_server'}</select></td>
<td class="tbl_col_file_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_file_server'}</select></td>
<td class="tbl_col_db_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_db_server'}</select></td>
<td class="tbl_col_vserver_server"><select name="search_active" onChange="submitForm('pageForm','admin/server_list.php');">{tmpl_var name='search_vserver_server'}</select></td>
<td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','admin/server_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
</tr>
</thead>
<tbody>
<tmpl_loop name="records">
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td class="tbl_col_server_name"><a href="#" onClick="loadContent('admin/server_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="server_name"}</a></td>
<td class="tbl_col_mail_server">{tmpl_var name="mail_server"}</td>
<td class="tbl_col_web_server">{tmpl_var name="web_server"}</td>
<td class="tbl_col_dns_server">{tmpl_var name="dns_server"}</td>
<td class="tbl_col_file_server">{tmpl_var name="file_server"}</td>
<td class="tbl_col_db_server">{tmpl_var name="db_server"}</td>
<td class="tbl_col_vserver_server">{tmpl_var name="vserver_server"}</td>
<td class="tbl_col_buttons">
<div class="buttons icons16">
<a class="icons16 icoDelete" href="javascript: del_record('admin/server_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
</div>
</td>
</tr>
</tmpl_loop>
</tbody>
<tfoot>
<tr>
<td class="tbl_footer tbl_paging" colspan="8"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
</fieldset>
</div>
</div>
......@@ -18,6 +18,7 @@ $app->auth->check_module_permissions('client');
$app->uses('listform_actions');
$app->listform_actions->SQLOrderBy = 'ORDER BY company_name, contact_name, client_id';
$app->listform_actions->SQLExtWhere = "limit_client = 0";
$app->listform_actions->onLoad();
......
This diff is collapsed.
<?php
/*
Form Definition
Tabledefinition
Datatypes:
- INTEGER (Forces the input to Int)
- DOUBLE
- CURRENCY (Formats the values to currency notation)
- VARCHAR (no format check, maxlength: 255)
- TEXT (no format check)
- DATE (Dateformat, automatic conversion to timestamps)
Formtype:
- TEXT (Textfield)
- TEXTAREA (Textarea)
- PASSWORD (Password textfield, input is not shown when edited)
- SELECT (Select option field)
- RADIO
- CHECKBOX
- CHECKBOXARRAY
- FILE
VALUE:
- Wert oder Array
Hint:
The ID field of the database table is not part of the datafield definition.
The ID field must be always auto incement (int or bigint).
*/
$form["title"] = "Reseller";
$form["description"] = "";
$form["name"] = "reseller";
$form["action"] = "reseller_edit.php";
$form["db_table"] = "client";
$form["db_table_idx"] = "client_id";
$form["db_history"] = "yes";
$form["tab_default"] = "address";
$form["list_default"] = "reseller_list.php";
$form["auth"] = 'yes';
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
if ($file != '.' && $file != '..') {
if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
$tmp = substr($file, 0, 2);
$language_list[$tmp] = $tmp;
}
}
}
$form["tabs"]['address'] = array (
'title' => "Address",
'width' => 100,
'template' => "templates/reseller_edit_address.htm",
'fields' => array (
##################################
# Begin Datatable fields
##################################
'company_name' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'contact_name' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'contact_error_empty'),
),
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'username' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'username_error_empty'),
1 => array ( 'type' => 'CUSTOM',
'class' => 'validate_client',
'function' => 'username_unique',
'errmsg'=> 'username_error_unique'),
2 => array ( 'type' => 'REGEX',
'regex' => '/^[\w\.\-\_]{0,64}$/',
'errmsg'=> 'username_error_regex'),
),
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'password' => array (
'datatype' => 'VARCHAR',
'formtype' => 'PASSWORD',
'encryption'=> 'CRYPT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'language' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => $conf["language"],
'value' => $language_list,
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'usertheme' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'default',
'value' => array('default' => 'default'),
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'street' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'zip' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '10',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'city' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'state' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'country' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'DE',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
'keyfield'=> 'iso',
'valuefield'=> 'printable_name'
),
'value' => ''
),
'telephone' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'mobile' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'fax' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'email' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'internet' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => 'http://',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => ''
),
'icq' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',