Commit 649d6397 authored by redray's avatar redray

fixed form problems ... http://www.sprawsm.com/uni-form/

parent 62ff29cc
......@@ -120,17 +120,19 @@ class app {
<head>
<title>Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../themes/default/style.css" rel="stylesheet" type="text/css" />
<link href="../themes/default/css/central.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br /><br /><br />
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="error"><b>Error:</b><br />'.$msg;
if($next_link != '') $msg .= '<a href="'.$next_link.'">Next</a><br />';
$msg .= '</td>
</tr>
</table>
<div class="uniForm">
<div id="errorMsg">
<h3>Error</h3>
<ol>
<li>'.$msg;
if($next_link != '') $msg .= '<a href="'.$next_link.'">Next</a>';
$msg .= '</li>
</ol>
</div>
</div>
</body>
</html>';
die($msg);
......
<?php
/*
Copyright (c) 2007, 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 auth {
public function is_admin() {
if($_SESSION['s']['user']['typ'] == 'admin') {
return true;
} else {
return false;
}
}
public function has_clients($userid) {
global $app, $conf;
$userid = intval($userid);
$client = $app->db->queryOneRecord("SELECT client.limit_client FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
if($client['limit_client'] > 0) {
return true;
} else {
return false;
}
}
//** This function adds a given group id to a given user.
public function add_group_to_user($userid,$groupid) {
global $app;
$userid = intval($userid);
$groupid = intval($groupid);
if($userid > 0 && $groupid > 0) {
$user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
$groups = explode(',',$user['groups']);
if(!in_array($groupid,$groups)) $groups[] = $groupid;
$groups_string = implode(',',$groups);
$sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid";
$app->db->query($sql);
return true;
} else {
return false;
}
}
//** This function removes a given group id from a given user.
public function remove_group_from_user($userid,$groupid) {
global $app;
$userid = intval($userid);
$groupid = intval($groupid);
if($userid > 0 && $groupid > 0) {
$user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
$groups = explode(',',$user['groups']);
$key = array_search($groupid,$groups);
unset($groups[$key]);
$groups_string = implode(',',$groups);
$sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid";
$app->db->query($sql);
return true;
} else {
return false;
}
}
public function check_module_permissions($module) {
// Check if the current user has the permissions to access this module
if(!stristr($_SESSION["s"]["user"]["modules"],$module)) {
// echo "LOGIN_REDIRECT:/index.php";
header("Location: /index.php");
exit;
}
}
}
<?php
/*
Copyright (c) 2007, 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 auth {
public function is_admin() {
if($_SESSION['s']['user']['typ'] == 'admin') {
return true;
} else {
return false;
}
}
public function has_clients($userid) {
global $app, $conf;
$userid = intval($userid);
$client = $app->db->queryOneRecord("SELECT client.limit_client FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
if($client['limit_client'] > 0) {
return true;
} else {
return false;
}
}
//** This function adds a given group id to a given user.
public function add_group_to_user($userid,$groupid) {
global $app;
$userid = intval($userid);
$groupid = intval($groupid);
if($userid > 0 && $groupid > 0) {
$user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
$groups = explode(',',$user['groups']);
if(!in_array($groupid,$groups)) $groups[] = $groupid;
$groups_string = implode(',',$groups);
$sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid";
$app->db->query($sql);
return true;
} else {
return false;
}
}
//** This function removes a given group id from a given user.
public function remove_group_from_user($userid,$groupid) {
global $app;
$userid = intval($userid);
$groupid = intval($groupid);
if($userid > 0 && $groupid > 0) {
$user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
$groups = explode(',',$user['groups']);
$key = array_search($groupid,$groups);
unset($groups[$key]);
$groups_string = implode(',',$groups);
$sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid";
$app->db->query($sql);
return true;
} else {
return false;
}
}
public function check_module_permissions($module) {
// Check if the current user has the permissions to access this module
if(!stristr($_SESSION["s"]["user"]["modules"],$module)) {
// echo "LOGIN_REDIRECT:/index.php";
header("Location: /index.php");
exit;
}
}
}
?>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -265,7 +265,7 @@ class tform_actions {
function onError() {
global $app, $conf;
$app->tpl->setVar("error","<b>".$app->lng('Error').":</b><br />".$app->tform->errorMessage);
$app->tpl->setVar("error","<li>".$app->tform->errorMessage."</li>");
$app->tpl->setVar($this->dataRecord);
$this->onShow();
}
......
......@@ -37,112 +37,85 @@ class tform_tpl_generator {
$module = $_SESSION["s"]["module"]["name"];
$html = '<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_'.$formDef['name'].'">
<div class="pnl_formsarea">
<fieldset id="wf_area_'.$formDef['name'].'"><legend>'.$formDef['tabs'][$tab]['title'].'</legend>';
<fieldset class="inlineLabels"><legend>'.$formDef['tabs'][$tab]['title'].'</legend>';
$lang = array();
$html_reqestedelement = "<em>*</em> ";
foreach($formDef['tabs'][$tab]['fields'] as $key => $field) {
if ($field['required'] == true ) { $html_reqcode = $html_reqestedelement; } else { $html_reqcode = ''; }
switch ($field['formtype']) {
case 'TEXT':
$html .= "\r\n <span class=\"wf_oneField\">
<label for=\"".$key."\" class=\"wf_preField\">{tmpl_var name='".$key."_txt'}</label>
<input type=\"text\" id=\"".$key."\" name=\"".$key."\" value=\"{tmpl_var name='".$key."'}\" size=\"".$field['width']."\" maxlength=\"".$field['maxlength']."\"";
if ($field['required'] == true ) {
$html .= " class=\"wf_required\"><span class=\"wf_reqMark\">*</span><br />";
} else {
$html .= ">";
}
$html .= "\r\n </span>";
$html .= "
<div class=\"ctrlHolder\">
<label for=\"".$key."\">".$html_reqcode."{tmpl_var name='".$key."_txt'}</label>
<input name=\"".$key."\" id=\"".$key."\" value=\"{tmpl_var name='".$key."'}\" size=\"".$field['width']."\" maxlength=\"".$field['maxlength']."\" type=\"text\" class=\"textInput\" />
</div>";
break;
case 'TEXTAREA':
$html .= "\r\n <span class=\"wf_oneField\">
<label for=\"".$key."\" class=\"wf_preField\">{tmpl_var name='".$key."_txt'}</label>
<textarea id=\"".$key."\" name=\"".$key."\" cols='".$field['cols']."' rows='".$field['rows']."'";
if ($field['required'] == true ) {
$html .= " class=\"wf_required\">";
} else {
$html .= ">";
}
$html .= "{tmpl_var name='".$key."'}</textarea>";
if ($field['required'] == true ) {
$html .= "<span class=\"wf_reqMark\">*</span><br />";
}
$html .= "\r\n </span>";
$html .= "
<div class=\"ctrlHolder\">
<label for=\"".$key."\">".$html_reqcode."{tmpl_var name='".$key."_txt'}</label>
<textarea name=\"".$key."\" id=\"".$key."\" rows='".$field['rows']."' cols='".$field['cols']."'>{tmpl_var name='".$key."'}</textarea>
</div>";
break;
case 'SELECT':
$html .= "\r\n <span class=\"wf_oneField\">
<label for=\"".$key."\" class=\"wf_preField\">{tmpl_var name='".$key."_txt'}</label>
<select id=\"".$key."\" name=\"".$key."\"";
if ($field['required'] == true ) {
$html .= " class=\"wf_required\">";
} else {
$html .= ">";
}
$html .= "{tmpl_var name='".$key."'}</select>";
if ($field['required'] == true ) {
$html .= "<span class=\"wf_reqMark\">*</span><br />";
}
$html .= "\r\n </span>";
$html .= "
<div class=\"ctrlHolder\">
<label for=\"".$key."\">".$html_reqcode."{tmpl_var name='".$key."_txt'}</label>
<select name=\"".$key."\" id=\"".$key."\" class=\"selectInput\">
{tmpl_var name='".$key."'}
</select>
</div>";
break;
case 'MULTIPLE':
$html .= "\r\n <span class=\"wf_oneField\">
<label for=\"".$key."\" class=\"wf_preField\">{tmpl_var name='".$key."_txt'}</label>
<select multiple id=\"".$key."\" name=\"".$key."\"";
if ($field['required'] == true ) {
$html .= " class=\"wf_required\">";
} else {
$html .= ">";
}
$html .= "{tmpl_var name='".$key."'}</select>";
if ($field['required'] == true ) {
$html .= "<span class=\"wf_reqMark\">*</span><br />";
}
$html .= "\r\n </span>";
$html .= "
<div class=\"ctrlHolder\">
<label for=\"".$key."\">".$html_reqcode."{tmpl_var name='".$key."_txt'}</label>
<select multiple name=\"".$key."\" id=\"".$key."\" class=\"selectInput\">
{tmpl_var name='".$key."'}
</select>
</div>";
break;
case 'PASSWORD':
$html .= "\r\n <span class=\"wf_oneField\">
<label for=\"".$key."\" class=\"wf_preField\">{tmpl_var name='".$key."_txt'}</label>
<input type=\"password\" id=\"".$key."\" name=\"".$key."\" value=\"{tmpl_var name='".$key."'}\" size=\"".$field['width']."\" maxlength=\"".$field['maxlength']."\"";
if ($field['required'] == true ) {
$html .= " class=\"wf_required\"><span class=\"wf_reqMark\">*</span><br />";
} else {
$html .= ">";
}
$html .= "\r\n </span>";
$html .= "
<div class=\"ctrlHolder\">
<label for=\"".$key."\">".$html_reqcode."{tmpl_var name='".$key."_txt'}</label>
<input name=\"".$key."\" id=\"".$key."\" value=\"{tmpl_var name='".$key."'}\" size=\"".$field['width']."\" maxlength=\"".$field['maxlength']."\" type=\"password\" class=\"textInput\" />
</div>";
break;
case 'CHECKBOX':
$html .= "\r\n <span class=\"wf_oneField\">
<label for=\"".$key."\" class=\"wf_preField\">{tmpl_var name='".$key."_txt'}</label>";
if ($field['required'] == true ) {
$html .= " <span class=\"wf_required\">
{tmpl_var name='".$key."'}
</span>
<span class=\"wf_reqMark\">*</span><br />";
} else {
$html .= " <span class=\"\">
{tmpl_var name='".$key."'}
</span>";
}
$html .= "\r\n </span>";
$html .= "
<div class=\"ctrlHolder\">
<p class=\"label\">".$html_reqcode."{tmpl_var name='".$key."_txt'}</p>
<div class=\"multiField\">
{tmpl_var name='".$key."'}
</div>
</div>";
break;
case 'CHECKBOXARRAY':
$html .= "\r\n <span class=\"wf_oneField\">
<span class=\"wf_label wf_preField\">{tmpl_var name='".$key."_txt'}</span>";
$html .= " <fieldset>
{tmpl_var name='".$key."'}
</fieldset>";
$html .= "\r\n </span>";
$html .= "
<div class=\"ctrlHolder\">
<p class=\"label\">".$html_reqcode."{tmpl_var name='".$key."_txt'}</p>
<div class=\"multiField\">
{tmpl_var name='".$key."'}
</div>
</div>";
break;
case 'RADIO':
$html .= " <span class=\"wf_oneField\">
<span class=\"wf_label wf_preField\">{tmpl_var name='".$key."_txt'}</span>";
$html .= " <fieldset>
{tmpl_var name='".$key."'}
</fieldset>";
$html .= "\r\n </span>";
$html .= "
<div class=\"ctrlHolder\">
<p class=\"label\">".$html_reqcode."{tmpl_var name='".$key."_txt'}</p>
<div class=\"multiField\">
{tmpl_var name='".$key."'}
</div>
</div>";
break;
}
......@@ -162,7 +135,7 @@ class tform_tpl_generator {
<input type=\"hidden\" name=\"id\" value=\"{tmpl_var name='id'}\">
<div class=\"wf_actions buttons\">
<div class=\"buttonHolder buttons\">
<button class=\"positive iconstxt icoPositive\" type=\"button\" value=\"{tmpl_var name='btn_save_txt'}\" onClick=\"submitForm('pageForm','".$module."/".$formDef["action"]."');\"><span>{tmpl_var name='btn_save_txt'}</span></button>
<button class=\"negative iconstxt icoNegative\" type=\"button\" value=\"{tmpl_var name='btn_cancel_txt'}\" onClick=\"loadContent('".$module."/".$formDef["list_default"]."');\"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
</div>
......
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_firewall">
<div class="pnl_formsarea">
<fieldset id="wf_area_firewall"><legend>Firewall</legend>
<span class="wf_oneField">
<label for="server_id" class="wf_preField">{tmpl_var name='server_id_txt'}</label>
<select id="server_id" name="server_id">{tmpl_var name='server_id'}</select>
</span>
<span class="wf_oneField">
<label for="tcp_port" class="wf_preField">{tmpl_var name='tcp_port_txt'}</label>
<input type="text" id="tcp_port" name="tcp_port" value="{tmpl_var name='tcp_port'}" size="30" maxlength="255">
</span>
<span class="wf_oneField">
<label for="udp_port" class="wf_preField">{tmpl_var name='udp_port_txt'}</label>
<input type="text" id="udp_port" name="udp_port" value="{tmpl_var name='udp_port'}" size="30" maxlength="255">
</span>
<span class="wf_oneField">
<label for="active" class="wf_preField">{tmpl_var name='active_txt'}</label>
<span class="">{tmpl_var name='active'}</span>
</span>
<fieldset class="inlineLabels"><legend>Firewall</legend>
<div class="ctrlHolder">
<label for="server_id">{tmpl_var name='server_id_txt'}</label>
<select name="server_id" id="server_id" class="selectInput">
{tmpl_var name='server_id'}
</select>
</div>
<div class="ctrlHolder">
<label for="tcp_port">{tmpl_var name='tcp_port_txt'}</label>
<input name="tcp_port" id="tcp_port" value="{tmpl_var name='tcp_port'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="udp_port">{tmpl_var name='udp_port_txt'}</label>
<input name="udp_port" id="udp_port" value="{tmpl_var name='udp_port'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='active_txt'}</p>
<div class="multiField">
{tmpl_var name='active'}
</div>
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
<div class="wf_actions buttons">
<div class="buttonHolder buttons">
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/firewall_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/firewall_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
</div>
......
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_firewall">
......
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_groups">
<div class="pnl_formsarea">
<fieldset id="wf_area_groups"><legend>Groups</legend>
<span class="wf_oneField">
<label for="name" class="wf_preField">{tmpl_var name='name_txt'}</label>
<input type="text" id="name" name="name" value="{tmpl_var name='name'}" size="30" maxlength="255">
</span>
<span class="wf_oneField">
<label for="description" class="wf_preField">{tmpl_var name='description_txt'}</label>
<textarea id="description" name="description" cols='30' rows='5'>{tmpl_var name='description'}</textarea>
</span>
<fieldset class="inlineLabels"><legend>Groups</legend>
<div class="ctrlHolder">
<label for="name">{tmpl_var name='name_txt'}</label>
<input name="name" id="name" value="{tmpl_var name='name'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="description">{tmpl_var name='description_txt'}</label>
<textarea name="description" id="description" rows='5' cols='30'>{tmpl_var name='description'}</textarea>
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
<div class="wf_actions buttons">
<div class="buttonHolder buttons">
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/groups_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/groups_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
</div>
......
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_groups">
......
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_language_add">
<tmpl_if name="msg">
<div class="box box_msg"><tmpl_var name="msg"></div>
</tmpl_if>
<tmpl_if name="error">
<div class="box box_error"><tmpl_var name="error"></div>
</tmpl_if>
<div class="pnl_formsarea">
<fieldset id="wf_area_language_add"><legend>Language Add</legend>
<span class="wf_oneField">
<span class="wf_oneField">
<label for="lng_select" class="wf_preField">{tmpl_var name='language_select_txt'}</label>
<select name="lng_select" class="withicons" id="language">{tmpl_var name='language_option'}</select>
</span>
<span class="wf_oneField">
<label for="lng_new" class="wf_preField">{tmpl_var name='language_new_txt'}</label>
<input type="text" id="lng_new" name="lng_new" value="" size="2" maxlength="2">
</span>
</span>
<fieldset class="inlineLabels"><legend>Language Add</legend>
<div class="ctrlHolder">
<label for="lng_select">{tmpl_var name='language_select_txt'}</label>
<select name="lng_select" id="language" class="selectInput withicons">
{tmpl_var name='language_option'}
</select>
</div>
<div class="ctrlHolder">
<label for="lng_new">{tmpl_var name='language_new_txt'}</label>
<input name="lng_new" id="lng_new" value="" size="30" maxlength="255" type="text" class="textInput" />
</div>
</fieldset>
<div class="wf_actions buttons">
<input type="hidden" name="id" value="{tmpl_var name='id'}">
<div class="buttonHolder buttons">
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/language_add.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/language_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
</div>
......
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_language_complete">
<tmpl_if name="msg">