Viewing file: admin_maint.php (19 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//Include Common Files @1-CA918419
define("RelativePath", ".");
define("PathToCurrentPage", "/");
define("FileName", "admin_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 @11-3DD2EFDC
include_once(RelativePath . "/Header.php");
//End Include Page implementation
class clsRecordadmin { //admin Class @2-FBCDAC12
//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-4D78F26A
function clsRecordadmin($RelativePath, & $Parent)
{
global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->Visible = true;
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record admin/Error";
$this->DataSource = new clsadminDataSource($this);
$this->ds = & $this->DataSource;
$this->InsertAllowed = true;
$this->UpdateAllowed = true;
$this->DeleteAllowed = true;
$this->ReadAllowed = true;
if($this->Visible)
{
$this->ComponentName = "admin";
$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->username_admin = & new clsControl(ccsTextBox, "username_admin", "Username Admin", ccsText, "", CCGetRequestParam("username_admin", $Method), $this);
$this->password_admin = & new clsControl(ccsTextBox, "password_admin", "Password Admin", ccsText, "", CCGetRequestParam("password_admin", $Method), $this);
$this->grupa = & new clsControl(ccsTextBox, "grupa", "Grupa", ccsInteger, "", CCGetRequestParam("grupa", $Method), $this);
$this->Insert = & new clsButton("Insert", $Method, $this);
$this->Update = & new clsButton("Update", $Method, $this);
$this->Delete = & new clsButton("Delete", $Method, $this);
}
}
//End Class_Initialize Event
//Initialize Method @2-1BBE22B3
function Initialize()
{
if(!$this->Visible)
return;
$this->DataSource->Parameters["urladmin_id"] = CCGetFromGet("admin_id", "");
}
//End Initialize Method
//Validate Method @2-5481003D
function Validate()
{
global $CCSLocales;
$Validation = true;
$Where = "";
$Validation = ($this->username_admin->Validate() && $Validation);
$Validation = ($this->password_admin->Validate() && $Validation);
$Validation = ($this->grupa->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);
$Validation = $Validation && ($this->username_admin->Errors->Count() == 0);
$Validation = $Validation && ($this->password_admin->Errors->Count() == 0);
$Validation = $Validation && ($this->grupa->Errors->Count() == 0);
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method
//CheckErrors Method @2-1E5176EC
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->username_admin->Errors->Count());
$errors = ($errors || $this->password_admin->Errors->Count());
$errors = ($errors || $this->grupa->Errors->Count());
$errors = ($errors || $this->Errors->Count());
$errors = ($errors || $this->DataSource->Errors->Count());
return $errors;
}
//End CheckErrors Method
//Operation Method @2-8FBF5257
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 ? "Update" : "Insert";
if($this->Insert->Pressed) {
$this->PressedButton = "Insert";
} else if($this->Update->Pressed) {
$this->PressedButton = "Update";
} else if($this->Delete->Pressed) {
$this->PressedButton = "Delete";
}
}
$Redirect = "admin_list.php" . "?" . CCGetQueryString("QueryString", array("ccsForm"));
if($this->PressedButton == "Delete") {
if(!CCGetEvent($this->Delete->CCSEvents, "OnClick", $this->Delete) || !$this->DeleteRow()) {
$Redirect = "";
}
} else if($this->Validate()) {
if($this->PressedButton == "Insert") {
if(!CCGetEvent($this->Insert->CCSEvents, "OnClick", $this->Insert) || !$this->InsertRow()) {
$Redirect = "";
}
} else if($this->PressedButton == "Update") {
if(!CCGetEvent($this->Update->CCSEvents, "OnClick", $this->Update) || !$this->UpdateRow()) {
$Redirect = "";
}
}
} else {
$Redirect = "";
}
if ($Redirect)
$this->DataSource->close();
}
//End Operation Method
//InsertRow Method @2-EAD8D7DD
function InsertRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeInsert", $this);
if(!$this->InsertAllowed) return false;
$this->DataSource->username_admin->SetValue($this->username_admin->GetValue());
$this->DataSource->password_admin->SetValue($this->password_admin->GetValue());
$this->DataSource->grupa->SetValue($this->grupa->GetValue());
$this->DataSource->Insert();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterInsert", $this);
return (!$this->CheckErrors());
}
//End InsertRow Method
//UpdateRow Method @2-FDED1ECC
function UpdateRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeUpdate", $this);
if(!$this->UpdateAllowed) return false;
$this->DataSource->username_admin->SetValue($this->username_admin->GetValue());
$this->DataSource->password_admin->SetValue($this->password_admin->GetValue());
$this->DataSource->grupa->SetValue($this->grupa->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-49FD8EC8
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->username_admin->SetValue($this->DataSource->username_admin->GetValue());
$this->password_admin->SetValue($this->DataSource->password_admin->GetValue());
$this->grupa->SetValue($this->DataSource->grupa->GetValue());
}
} else {
$this->EditMode = false;
}
}
if($this->FormSubmitted || $this->CheckErrors()) {
$Error = "";
$Error = ComposeStrings($Error, $this->username_admin->Errors->ToString());
$Error = ComposeStrings($Error, $this->password_admin->Errors->ToString());
$Error = ComposeStrings($Error, $this->grupa->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->Insert->Visible = !$this->EditMode && $this->InsertAllowed;
$this->Update->Visible = $this->EditMode && $this->UpdateAllowed;
$this->Delete->Visible = $this->EditMode && $this->DeleteAllowed;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
if(!$this->Visible) {
$Tpl->block_path = $ParentPath;
return;
}
$this->username_admin->Show();
$this->password_admin->Show();
$this->grupa->Show();
$this->Insert->Show();
$this->Update->Show();
$this->Delete->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
$this->DataSource->close();
}
//End Show Method
} //End admin Class @2-FCB6E20C
class clsadminDataSource extends clsDBConnection1 { //adminDataSource Class @2-45192E89
//DataSource Variables @2-CA3E8C5F
var $Parent = "";
var $CCSEvents = "";
var $CCSEventResult;
var $ErrorBlock;
var $CmdExecution;
var $InsertParameters;
var $UpdateParameters;
var $DeleteParameters;
var $wp;
var $AllParametersSet;
// Datasource fields
var $username_admin;
var $password_admin;
var $grupa;
//End DataSource Variables
//DataSourceClass_Initialize Event @2-5F4646AA
function clsadminDataSource(& $Parent)
{
$this->Parent = & $Parent;
$this->ErrorBlock = "Record admin/Error";
$this->Initialize();
$this->username_admin = new clsField("username_admin", ccsText, "");
$this->password_admin = new clsField("password_admin", ccsText, "");
$this->grupa = new clsField("grupa", ccsInteger, "");
}
//End DataSourceClass_Initialize Event
//Prepare Method @2-2C60116A
function Prepare()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->wp = new clsSQLParameters($this->ErrorBlock);
$this->wp->AddParameter("1", "urladmin_id", ccsInteger, "", "", $this->Parameters["urladmin_id"], "", false);
$this->AllParametersSet = $this->wp->AllParamsSet();
$this->wp->Criterion[1] = $this->wp->Operation(opEqual, "admin_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-1AE9522F
function Open()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
$this->SQL = "SELECT * " .
"FROM admin {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-8856D1EB
function SetValues()
{
$this->username_admin->SetDBValue($this->f("username_admin"));
$this->password_admin->SetDBValue($this->f("password_admin"));
$this->grupa->SetDBValue(trim($this->f("grupa")));
}
//End SetValues Method
//Insert Method @2-31C64449
function Insert()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->CmdExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert", $this->Parent);
$this->SQL = "INSERT INTO admin ("
. "username_admin, "
. "password_admin, "
. "grupa"
. ") VALUES ("
. $this->ToSQL($this->username_admin->GetDBValue(), $this->username_admin->DataType) . ", "
. $this->ToSQL($this->password_admin->GetDBValue(), $this->password_admin->DataType) . ", "
. $this->ToSQL($this->grupa->GetDBValue(), $this->grupa->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-7BB73AE6
function Update()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->CmdExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildUpdate", $this->Parent);
$this->SQL = "UPDATE admin SET "
. "username_admin=" . $this->ToSQL($this->username_admin->GetDBValue(), $this->username_admin->DataType) . ", "
. "password_admin=" . $this->ToSQL($this->password_admin->GetDBValue(), $this->password_admin->DataType) . ", "
. "grupa=" . $this->ToSQL($this->grupa->GetDBValue(), $this->grupa->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-E30C7821
function Delete()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->CmdExecution = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildDelete", $this->Parent);
$this->SQL = "DELETE FROM admin";
$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 adminDataSource Class @2-FCB6E20C
//Include Page implementation @12-58DBA1E3
include_once(RelativePath . "/Footer.php");
//End Include Page implementation
//Initialize Page @1-2B44673F
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
// Events;
$CCSEvents = "";
$CCSEventResult = "";
$FileName = FileName;
$Redirect = "";
$TemplateFileName = "admin_maint.html";
$BlockToParse = "main";
$TemplateEncoding = "CP1252";
$PathToRoot = "./";
//End Initialize Page
//Authenticate User @1-DC94A87D
CCSecurityRedirect("1", "");
//End Authenticate User
//Initialize Objects @1-19816C5C
$DBConnection1 = new clsDBConnection1();
$MainPage->Connections["Connection1"] = & $DBConnection1;
// Controls
$Header = & new clsHeader("", "Header", $MainPage);
$Header->Initialize();
$admin = & new clsRecordadmin("", $MainPage);
$Footer = & new clsFooter("", "Footer", $MainPage);
$Footer->Initialize();
$MainPage->Header = & $Header;
$MainPage->admin = & $admin;
$MainPage->Footer = & $Footer;
$admin->Initialize();
$CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize", $MainPage);
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-EF502D0D
$Header->Operations();
$admin->Operation();
$Footer->Operations();
//End Execute Components
//Go to destination page @1-DEF7AD75
if($Redirect)
{
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBConnection1->close();
header("Location: " . $Redirect);
$Header->Class_Terminate();
unset($Header);
unset($admin);
$Footer->Class_Terminate();
unset($Footer);
unset($Tpl);
exit;
}
//End Go to destination page
//Show Page @1-AD353A24
$Header->Show();
$admin->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-545F716F
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBConnection1->close();
$Header->Class_Terminate();
unset($Header);
unset($admin);
$Footer->Class_Terminate();
unset($Footer);
unset($Tpl);
//End Unload Page
?>
|