Viewing file: nas_maint.php (23.09 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//Include Common Files @1-6891C40E
define("RelativePath", ".");
define("PathToCurrentPage", "/");
define("FileName", "nas_maint.php");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");
//End Include Common Files
//Include Page implementation @14-3DD2EFDC
include_once(RelativePath . "/Header.php");
//End Include Page implementation
class clsRecordnas { //nas Class @2-90F2ABBD
//Variables @2-F607D3A5
// Public variables
var $ComponentType = "Record";
var $ComponentName;
var $Parent;
var $HTMLFormAction;
var $PressedButton;
var $Errors;
var $ErrorBlock;
var $FormSubmitted;
var $FormEnctype;
var $Visible;
var $Recordset;
var $CCSEvents = "";
var $CCSEventResult;
var $RelativePath = "";
var $InsertAllowed = false;
var $UpdateAllowed = false;
var $DeleteAllowed = false;
var $ReadAllowed = false;
var $EditMode = false;
var $ds;
var $DataSource;
var $ValidatingControls;
var $Controls;
// Class variables
//End Variables
//Class_Initialize Event @2-CBC7606E
function clsRecordnas($RelativePath, & $Parent)
{
global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->Visible = true;
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record nas/Error";
$this->DataSource = new clsnasDataSource($this);
$this->ds = & $this->DataSource;
$this->InsertAllowed = true;
$this->UpdateAllowed = true;
$this->DeleteAllowed = true;
$this->ReadAllowed = true;
if($this->Visible)
{
$this->ComponentName = "nas";
$CCSForm = split(":", CCGetFromGet("ccsForm", ""), 2);
if(sizeof($CCSForm) == 1)
$CCSForm[1] = "";
list($FormName, $FormMethod) = $CCSForm;
$this->EditMode = ($FormMethod == "Edit");
$this->FormEnctype = "application/x-www-form-urlencoded";
$this->FormSubmitted = ($FormName == $this->ComponentName);
$Method = $this->FormSubmitted ? ccsPost : ccsGet;
$this->nasname = & new clsControl(ccsTextBox, "nasname", "Name", ccsText, "", CCGetRequestParam("nasname", $Method), $this);
$this->nasname->Required = true;
$this->shortname = & new clsControl(ccsTextBox, "shortname", "Shortname", ccsText, "", CCGetRequestParam("shortname", $Method), $this);
$this->type = & new clsControl(ccsTextBox, "type", "Type", ccsText, "", CCGetRequestParam("type", $Method), $this);
$this->ports = & new clsControl(ccsTextBox, "ports", "Ports", ccsInteger, "", CCGetRequestParam("ports", $Method), $this);
$this->secret = & new clsControl(ccsTextBox, "secret", "Secret", ccsText, "", CCGetRequestParam("secret", $Method), $this);
$this->secret->Required = true;
$this->community = & new clsControl(ccsTextBox, "community", "Community", ccsText, "", CCGetRequestParam("community", $Method), $this);
$this->description = & new clsControl(ccsTextBox, "description", "Description", ccsText, "", CCGetRequestParam("description", $Method), $this);
$this->Button_Insert = & new clsButton("Button_Insert", $Method, $this);
$this->Button_Update = & new clsButton("Button_Update", $Method, $this);
$this->Button_Delete = & new clsButton("Button_Delete", $Method, $this);
}
}
//End Class_Initialize Event
//Initialize Method @2-7410BFC5
function Initialize()
{
if(!$this->Visible)
return;
$this->DataSource->Parameters["urlid"] = CCGetFromGet("id", "");
}
//End Initialize Method
//Validate Method @2-5B214739
function Validate()
{
global $CCSLocales;
$Validation = true;
$Where = "";
$Validation = ($this->nasname->Validate() && $Validation);
$Validation = ($this->shortname->Validate() && $Validation);
$Validation = ($this->type->Validate() && $Validation);
$Validation = ($this->ports->Validate() && $Validation);
$Validation = ($this->secret->Validate() && $Validation);
$Validation = ($this->community->Validate() && $Validation);
$Validation = ($this->description->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);
$Validation = $Validation && ($this->nasname->Errors->Count() == 0);
$Validation = $Validation && ($this->shortname->Errors->Count() == 0);
$Validation = $Validation && ($this->type->Errors->Count() == 0);
$Validation = $Validation && ($this->ports->Errors->Count() == 0);
$Validation = $Validation && ($this->secret->Errors->Count() == 0);
$Validation = $Validation && ($this->community->Errors->Count() == 0);
$Validation = $Validation && ($this->description->Errors->Count() == 0);
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method
//CheckErrors Method @2-E7F2DD0D
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->nasname->Errors->Count());
$errors = ($errors || $this->shortname->Errors->Count());
$errors = ($errors || $this->type->Errors->Count());
$errors = ($errors || $this->ports->Errors->Count());
$errors = ($errors || $this->secret->Errors->Count());
$errors = ($errors || $this->community->Errors->Count());
$errors = ($errors || $this->description->Errors->Count());
$errors = ($errors || $this->Errors->Count());
$errors = ($errors || $this->DataSource->Errors->Count());
return $errors;
}
//End CheckErrors Method
//Operation Method @2-A4090BC2
function Operation()
{
if(!$this->Visible)
return;
global $Redirect;
global $FileName;
$this->DataSource->Prepare();
if(!$this->FormSubmitted) {
$this->EditMode = $this->DataSource->AllParametersSet;
return;
}
if($this->FormSubmitted) {
$this->PressedButton = $this->EditMode ? "Button_Update" : "Button_Insert";
if($this->Button_Insert->Pressed) {
$this->PressedButton = "Button_Insert";
} else if($this->Button_Update->Pressed) {
$this->PressedButton = "Button_Update";
} else if($this->Button_Delete->Pressed) {
$this->PressedButton = "Button_Delete";
}
}
$Redirect = "nas_list.php" . "?" . CCGetQueryString("QueryString", array("ccsForm"));
if($this->PressedButton == "Button_Delete") {
if(!CCGetEvent($this->Button_Delete->CCSEvents, "OnClick", $this->Button_Delete) || !$this->DeleteRow()) {
$Redirect = "";
}
} else if($this->Validate()) {
if($this->PressedButton == "Button_Insert") {
if(!CCGetEvent($this->Button_Insert->CCSEvents, "OnClick", $this->Button_Insert) || !$this->InsertRow()) {
$Redirect = "";
}
} else if($this->PressedButton == "Button_Update") {
if(!CCGetEvent($this->Button_Update->CCSEvents, "OnClick", $this->Button_Update) || !$this->UpdateRow()) {
$Redirect = "";
}
}
} else {
$Redirect = "";
}
if ($Redirect)
$this->DataSource->close();
}
//End Operation Method
//InsertRow Method @2-9D8F89DE
function InsertRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeInsert", $this);
if(!$this->InsertAllowed) return false;
$this->DataSource->nasname->SetValue($this->nasname->GetValue());
$this->DataSource->shortname->SetValue($this->shortname->GetValue());
$this->DataSource->type->SetValue($this->type->GetValue());
$this->DataSource->ports->SetValue($this->ports->GetValue());
$this->DataSource->secret->SetValue($this->secret->GetValue());
$this->DataSource->community->SetValue($this->community->GetValue());
$this->DataSource->description->SetValue($this->description->GetValue());
$this->DataSource->Insert();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterInsert", $this);
return (!$this->CheckErrors());
}
//End InsertRow Method
//UpdateRow Method @2-BF845D6D
function UpdateRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeUpdate", $this);
if(!$this->UpdateAllowed) return false;
$this->DataSource->nasname->SetValue($this->nasname->GetValue());
$this->DataSource->shortname->SetValue($this->shortname->GetValue());
$this->DataSource->type->SetValue($this->type->GetValue());
$this->DataSource->ports->SetValue($this->ports->GetValue());
$this->DataSource->secret->SetValue($this->secret->GetValue());
$this->DataSource->community->SetValue($this->community->GetValue());
$this->DataSource->description->SetValue($this->description->GetValue());
$this->DataSource->Update();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterUpdate", $this);
return (!$this->CheckErrors());
}
//End UpdateRow Method
//DeleteRow Method @2-299D98C3
function DeleteRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeDelete", $this);
if(!$this->DeleteAllowed) return false;
$this->DataSource->Delete();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterDelete", $this);
return (!$this->CheckErrors());
}
//End DeleteRow Method
//Show Method @2-53DDE326
function Show()
{
global $Tpl;
global $FileName;
global $CCSLocales;
$Error = "";
if(!$this->Visible)
return;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);
$RecordBlock = "Record " . $this->ComponentName;
$ParentPath = $Tpl->block_path;
$Tpl->block_path = $ParentPath . "/" . $RecordBlock;
$this->EditMode = $this->EditMode && $this->ReadAllowed;
if($this->EditMode) {
if($this->DataSource->Errors->Count()){
$this->Errors->AddErrors($this->DataSource->Errors);
$this->DataSource->Errors->clear();
}
$this->DataSource->Open();
if($this->DataSource->Errors->Count() == 0 && $this->DataSource->next_record()) {
$this->DataSource->SetValues();
if(!$this->FormSubmitted){
$this->nasname->SetValue($this->DataSource->nasname->GetValue());
$this->shortname->SetValue($this->DataSource->shortname->GetValue());
$this->type->SetValue($this->DataSource->type->GetValue());
$this->ports->SetValue($this->DataSource->ports->GetValue());
$this->secret->SetValue($this->DataSource->secret->GetValue());
$this->community->SetValue($this->DataSource->community->GetValue());
$this->description->SetValue($this->DataSource->description->GetValue());
}
} else {
$this->EditMode = false;
}
}
if($this->FormSubmitted || $this->CheckErrors()) {
$Error = "";
$Error = ComposeStrings($Error, $this->nasname->Errors->ToString());
$Error = ComposeStrings($Error, $this->shortname->Errors->ToString());
$Error = ComposeStrings($Error, $this->type->Errors->ToString());
$Error = ComposeStrings($Error, $this->ports->Errors->ToString());
$Error = ComposeStrings($Error, $this->secret->Errors->ToString());
$Error = ComposeStrings($Error, $this->community->Errors->ToString());
$Error = ComposeStrings($Error, $this->description->Errors->ToString());
$Error = ComposeStrings($Error, $this->Errors->ToString());
$Error = ComposeStrings($Error, $this->DataSource->Errors->ToString());
$Tpl->SetVar("Error", $Error);
$Tpl->Parse("Error", false);
}
$CCSForm = $this->EditMode ? $this->ComponentName . ":" . "Edit" : $this->ComponentName;
$this->HTMLFormAction = $FileName . "?" . CCAddParam(CCGetQueryString("QueryString", ""), "ccsForm", $CCSForm);
$Tpl->SetVar("Action", $this->HTMLFormAction);
$Tpl->SetVar("HTMLFormName", $this->ComponentName);
$Tpl->SetVar("HTMLFormEnctype", $this->FormEnctype);
$this->Button_Insert->Visible = !$this->EditMode && $this->InsertAllowed;
$this->Button_Update->Visible = $this->EditMode && $this->UpdateAllowed;
$this->Button_Delete->Visible = $this->EditMode && $this->DeleteAllowed;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
if(!$this->Visible) {
$Tpl->block_path = $ParentPath;
return;
}
$this->nasname->Show();
$this->shortname->Show();
$this->type->Show();
$this->ports->Show();
$this->secret->Show();
$this->community->Show();
$this->description->Show();
$this->Button_Insert->Show();
$this->Button_Update->Show();
$this->Button_Delete->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
$this->DataSource->close();
}
//End Show Method
} //End nas Class @2-FCB6E20C
class clsnasDataSource extends clsDBConnection1 { //nasDataSource Class @2-1561CEED
//DataSource Variables @2-008D360B
var $Parent = "";
var $CCSEvents = "";
var $CCSEventResult;
var $ErrorBlock;
var $CmdExecution;
var $InsertParameters;
var $UpdateParameters;
var $DeleteParameters;
var $wp;
var $AllParametersSet;
// Datasource fields
var $nasname;
var $shortname;
var $type;
var $ports;
var $secret;
var $community;
var $description;
//End DataSource Variables
//DataSourceClass_Initialize Event @2-F9EEC144
function clsnasDataSource(& $Parent)
{
$this->Parent = & $Parent;
$this->ErrorBlock = "Record nas/Error";
$this->Initialize();
$this->nasname = new clsField("nasname", ccsText, "");
$this->shortname = new clsField("shortname", ccsText, "");
$this->type = new clsField("type", ccsText, "");
$this->ports = new clsField("ports", ccsInteger, "");
$this->secret = new clsField("secret", ccsText, "");
$this->community = new clsField("community", ccsText, "");
$this->description = new clsField("description", ccsText, "");
}
//End DataSourceClass_Initialize Event
//Prepare Method @2-35B33087
function Prepare()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->wp = new clsSQLParameters($this->ErrorBlock);
$this->wp->AddParameter("1", "urlid", ccsInteger, "", "", $this->Parameters["urlid"], "", false);
$this->AllParametersSet = $this->wp->AllParamsSet();
$this->wp->Criterion[1] = $this->wp->Operation(opEqual, "id", $this->wp->GetDBValue("1"), $this->ToSQL($this->wp->GetDBValue("1"), ccsInteger),false);
$this->Where =
$this->wp->Criterion[1];
}
//End Prepare Method
//Open Method @2-6285FEC1
function Open()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
$this->SQL = "SELECT * " .
"FROM nas {SQL_Where} {SQL_OrderBy}";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
$this->PageSize = 1;
$this->query($this->OptimizeSQL(CCBuildSQL($this->SQL, $this->Where, $this->Order)));
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
}
//End Open Method
//SetValues Method @2-F8E3B21C
function SetValues()
{
$this->nasname->SetDBValue($this->f("nasname"));
$this->shortname->SetDBValue($this->f("shortname"));
$this->type->SetDBValue($this->f("type"));
$this->ports->SetDBValue(trim($this->f("ports")));
$this->secret->SetDBValue($this->f("secret"));
$this->community->SetDBValue($this->f("community"));
$this->description->SetDBValue($this->f("description"));
}
//End SetValues Method
//Insert Method @2-783314E1
function Insert()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->CmdExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert", $this->Parent);
$this->SQL = "INSERT INTO nas ("
. "nasname, "
. "shortname, "
. "type, "
. "ports, "
. "secret, "
. "community, "
. "description"
. ") VALUES ("
. $this->ToSQL($this->nasname->GetDBValue(), $this->nasname->DataType) . ", "
. $this->ToSQL($this->shortname->GetDBValue(), $this->shortname->DataType) . ", "
. $this->ToSQL($this->type->GetDBValue(), $this->type->DataType) . ", "
. $this->ToSQL($this->ports->GetDBValue(), $this->ports->DataType) . ", "
. $this->ToSQL($this->secret->GetDBValue(), $this->secret->DataType) . ", "
. $this->ToSQL($this->community->GetDBValue(), $this->community->DataType) . ", "
. $this->ToSQL($this->description->GetDBValue(), $this->description->DataType)
. ")";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert", $this->Parent);
if($this->Errors->Count() == 0 && $this->CmdExecution) {
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert", $this->Parent);
}
}
//End Insert Method
//Update Method @2-47AE9BFA
function Update()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->CmdExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildUpdate", $this->Parent);
$this->SQL = "UPDATE nas SET "
. "nasname=" . $this->ToSQL($this->nasname->GetDBValue(), $this->nasname->DataType) . ", "
. "shortname=" . $this->ToSQL($this->shortname->GetDBValue(), $this->shortname->DataType) . ", "
. "type=" . $this->ToSQL($this->type->GetDBValue(), $this->type->DataType) . ", "
. "ports=" . $this->ToSQL($this->ports->GetDBValue(), $this->ports->DataType) . ", "
. "secret=" . $this->ToSQL($this->secret->GetDBValue(), $this->secret->DataType) . ", "
. "community=" . $this->ToSQL($this->community->GetDBValue(), $this->community->DataType) . ", "
. "description=" . $this->ToSQL($this->description->GetDBValue(), $this->description->DataType);
$this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteUpdate", $this->Parent);
if($this->Errors->Count() == 0 && $this->CmdExecution) {
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteUpdate", $this->Parent);
}
}
//End Update Method
//Delete Method @2-A6CD6DFE
function Delete()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->CmdExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildDelete", $this->Parent);
$this->SQL = "DELETE FROM nas";
$this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteDelete", $this->Parent);
if($this->Errors->Count() == 0 && $this->CmdExecution) {
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteDelete", $this->Parent);
}
}
//End Delete Method
} //End nasDataSource Class @2-FCB6E20C
//Include Page implementation @15-58DBA1E3
include_once(RelativePath . "/Footer.php");
//End Include Page implementation
//Initialize Page @1-1532735F
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
// Events;
$CCSEvents = "";
$CCSEventResult = "";
$FileName = FileName;
$Redirect = "";
$TemplateFileName = "nas_maint.html";
$BlockToParse = "main";
$TemplateEncoding = "CP1252";
$PathToRoot = "./";
//End Initialize Page
//Initialize Objects @1-61DFBDF9
$DBConnection1 = new clsDBConnection1();
$MainPage->Connections["Connection1"] = & $DBConnection1;
// Controls
$Header = & new clsHeader("", "Header", $MainPage);
$Header->Initialize();
$nas = & new clsRecordnas("", $MainPage);
$Footer = & new clsFooter("", "Footer", $MainPage);
$Footer->Initialize();
$MainPage->Header = & $Header;
$MainPage->nas = & $nas;
$MainPage->Footer = & $Footer;
$nas->Initialize();
$CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize", $MainPage);
$Charset = $Charset ? $Charset : "windows-1252";
if ($Charset)
header("Content-Type: text/html; charset=" . $Charset);
//End Initialize Objects
//Initialize HTML Template @1-8F4531F3
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView", $MainPage);
$Tpl = new clsTemplate($FileEncoding, $TemplateEncoding);
$Tpl->LoadTemplate(PathToCurrentPage . $TemplateFileName, $BlockToParse, "CP1252");
$Tpl->block_path = "/$BlockToParse";
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow", $MainPage);
//End Initialize HTML Template
//Execute Components @1-D9B66DB7
$Header->Operations();
$nas->Operation();
$Footer->Operations();
//End Execute Components
//Go to destination page @1-0CD0223A
if($Redirect)
{
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBConnection1->close();
header("Location: " . $Redirect);
$Header->Class_Terminate();
unset($Header);
unset($nas);
$Footer->Class_Terminate();
unset($Footer);
unset($Tpl);
exit;
}
//End Go to destination page
//Show Page @1-24D61451
$Header->Show();
$nas->Show();
$Footer->Show();
$Tpl->block_path = "";
$Tpl->Parse($BlockToParse, false);
$main_block = $Tpl->GetVar($BlockToParse);
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeOutput", $MainPage);
if ($CCSEventResult) echo $main_block;
//End Show Page
//Unload Page @1-C83ED63B
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBConnection1->close();
$Header->Class_Terminate();
unset($Header);
unset($nas);
$Footer->Class_Terminate();
unset($Footer);
unset($Tpl);
//End Unload Page
?>
|