Visible = true; $this->Errors = new clsErrors(); $this->ds = new clscontact_logDataSource(); $this->InsertAllowed = true; if($this->Visible) { $this->ComponentName = "contact_log"; $CCSForm = split(":", CCGetFromGet("ccsForm", ""), 2); if(sizeof($CCSForm) == 1) $CCSForm[1] = ""; list($FormName, $FormMethod) = $CCSForm; $this->EditMode = ($FormMethod == "Edit"); $this->FormSubmitted = ($FormName == $this->ComponentName); $Method = $this->FormSubmitted ? ccsPost : ccsGet; $this->from_email = new clsControl(ccsTextBox, "from_email", "From Email", ccsText, "", CCGetRequestParam("from_email", $Method)); $this->from_email->Required = true; $this->from_name = new clsControl(ccsTextBox, "from_name", "From Name", ccsText, "", CCGetRequestParam("from_name", $Method)); $this->from_name->Required = true; $this->message_comments = new clsControl(ccsTextArea, "message_comments", "Message Comments", ccsMemo, "", CCGetRequestParam("message_comments", $Method)); $this->message_comments->Required = true; $this->Insert = new clsButton("Insert"); $this->sending_date = new clsControl(ccsHidden, "sending_date", "Sending Date", ccsDate, Array("yyyy", "/", "mm", "/", "dd"), CCGetRequestParam("sending_date", $Method)); } } //End Class_Initialize Event //Initialize Method @4-D5D1F644 function Initialize() { if(!$this->Visible) return; $this->ds->Parameters["urllog_id"] = CCGetFromGet("log_id", ""); } //End Initialize Method //Validate Method @4-99E18EC0 function Validate() { $Validation = true; $Where = ""; if(strlen($this->from_email->GetText()) && !preg_match ("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $this->from_email->GetText())) { $this->from_email->Errors->addError("Mask validation failed for field From Email."); } $Validation = ($this->from_email->Validate() && $Validation); $Validation = ($this->from_name->Validate() && $Validation); $Validation = ($this->message_comments->Validate() && $Validation); $Validation = ($this->sending_date->Validate() && $Validation); $this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate"); return (($this->Errors->Count() == 0) && $Validation); } //End Validate Method //CheckErrors Method @4-DFA21251 function CheckErrors() { $errors = false; $errors = ($errors || $this->from_email->Errors->Count()); $errors = ($errors || $this->from_name->Errors->Count()); $errors = ($errors || $this->message_comments->Errors->Count()); $errors = ($errors || $this->sending_date->Errors->Count()); $errors = ($errors || $this->Errors->Count()); $errors = ($errors || $this->ds->Errors->Count()); return $errors; } //End CheckErrors Method //Operation Method @4-A7F12BCE function Operation() { if(!$this->Visible) return; global $Redirect; global $FileName; $this->ds->Prepare(); $this->EditMode = $this->ds->AllParametersSet; if(!$this->FormSubmitted) return; if($this->FormSubmitted) { $this->PressedButton = "Insert"; if(strlen(CCGetParam("Insert", ""))) { $this->PressedButton = "Insert"; } } $Redirect = "contact.php?" . CCGetQueryString("QueryString", Array("ccsForm", "Insert")); if($this->Validate()) { if($this->PressedButton == "Insert") { if(!CCGetEvent($this->Insert->CCSEvents, "OnClick") || !$this->InsertRow()) { $Redirect = ""; } } } else { $Redirect = ""; } } //End Operation Method //InsertRow Method @4-646BFBD4 function InsertRow() { $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeInsert"); if(!$this->InsertAllowed) return false; $this->ds->from_email->SetValue($this->from_email->GetValue()); $this->ds->from_name->SetValue($this->from_name->GetValue()); $this->ds->message_comments->SetValue($this->message_comments->GetValue()); $this->ds->sending_date->SetValue($this->sending_date->GetValue()); $this->ds->Insert(); $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterInsert"); if($this->ds->Errors->Count() > 0) { echo "Error in Record " . $this->ComponentName . " / Insert Operation"; $this->ds->Errors->Clear(); $this->Errors->AddError("Database command error."); } return ($this->Errors->Count() == 0); } //End InsertRow Method //Show Method @4-6D72761F function Show() { global $Tpl; global $FileName; $Error = ""; if(!$this->Visible) return; $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect"); $this->ds->open(); $RecordBlock = "Record " . $this->ComponentName; $ParentPath = $Tpl->block_path; $Tpl->block_path = $ParentPath . "/" . $RecordBlock; if($this->EditMode) { if($this->Errors->Count() == 0) { if($this->ds->Errors->Count() > 0) { echo "Error in Record contact_log"; } else if($this->ds->next_record()) { $this->ds->SetValues(); if(!$this->FormSubmitted) { $this->from_email->SetValue($this->ds->from_email->GetValue()); $this->from_name->SetValue($this->ds->from_name->GetValue()); $this->message_comments->SetValue($this->ds->message_comments->GetValue()); $this->sending_date->SetValue($this->ds->sending_date->GetValue()); } } else { $this->EditMode = false; } } } if(!$this->FormSubmitted) { } if($this->FormSubmitted || $this->CheckErrors()) { $Error .= $this->from_email->Errors->ToString(); $Error .= $this->from_name->Errors->ToString(); $Error .= $this->message_comments->Errors->ToString(); $Error .= $this->sending_date->Errors->ToString(); $Error .= $this->Errors->ToString(); $Error .= $this->ds->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); $this->Insert->Visible = !$this->EditMode; $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow"); if(!$this->Visible) { $Tpl->block_path = $ParentPath; return; } $this->from_email->Show(); $this->from_name->Show(); $this->message_comments->Show(); $this->Insert->Show(); $this->sending_date->Show(); $Tpl->parse(); $Tpl->block_path = $ParentPath; $this->ds->close(); } //End Show Method } //End contact_log Class @4-FCB6E20C class clscontact_logDataSource extends clsDBbeVisitorPortal { //contact_logDataSource Class @4-84E81918 //DataSource Variables @4-F90F4D13 var $CCSEvents = ""; var $CCSEventResult; var $ErrorBlock; var $InsertParameters; var $wp; var $AllParametersSet; // Datasource fields var $from_email; var $from_name; var $message_comments; var $sending_date; //End DataSource Variables //Class_Initialize Event @4-D012FD85 function clscontact_logDataSource() { $this->ErrorBlock = "Record contact_log/Error"; $this->Initialize(); $this->from_email = new clsField("from_email", ccsText, ""); $this->from_name = new clsField("from_name", ccsText, ""); $this->message_comments = new clsField("message_comments", ccsMemo, ""); $this->sending_date = new clsField("sending_date", ccsDate, Array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss")); } //End Class_Initialize Event //Prepare Method @4-9AEDFFBD function Prepare() { $this->wp = new clsSQLParameters($this->ErrorBlock); $this->wp->AddParameter("1", "urllog_id", ccsInteger, "", "", $this->Parameters["urllog_id"], ""); $this->AllParametersSet = $this->wp->AllParamsSet(); $this->wp->Criterion[1] = $this->wp->Operation(opEqual, "log_id", $this->wp->GetDBValue("1"), $this->ToSQL($this->wp->GetDBValue("1"), ccsInteger)); $this->Where = $this->wp->Criterion[1]; } //End Prepare Method //Open Method @4-6A31B40C function Open() { $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect"); $this->SQL = "SELECT * " . "FROM contact_log"; $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect"); $this->query(CCBuildSQL($this->SQL, $this->Where, $this->Order)); $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect"); $this->MoveToPage($this->AbsolutePage); } //End Open Method //SetValues Method @4-71FD1841 function SetValues() { $this->from_email->SetDBValue($this->f("from_email")); $this->from_name->SetDBValue($this->f("from_name")); $this->message_comments->SetDBValue($this->f("message_comments")); $this->sending_date->SetDBValue(trim($this->f("sending_date"))); } //End SetValues Method //Insert Method @4-C26E0EE0 function Insert() { $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert"); $this->SQL = "INSERT INTO contact_log (" . "from_email, " . "from_name, " . "message_comments, " . "sending_date" . ") VALUES (" . $this->ToSQL($this->from_email->GetDBValue(), $this->from_email->DataType) . ", " . $this->ToSQL($this->from_name->GetDBValue(), $this->from_name->DataType) . ", " . $this->ToSQL($this->message_comments->GetDBValue(), $this->message_comments->DataType) . ", " . $this->ToSQL($this->sending_date->GetDBValue(), $this->sending_date->DataType) . ")"; $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert"); $this->query($this->SQL); $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert"); if($this->Errors->Count() > 0) $this->Errors->AddError($this->Errors->ToString()); $this->close(); } //End Insert Method } //End contact_logDataSource Class @4-FCB6E20C //Include Page implementation @3-EFAB2CA0 include_once("./footer.php"); //End Include Page implementation //Initialize Page @1-6E10A952 // Variables $FileName = ""; $Redirect = ""; $Tpl = ""; $TemplateFileName = ""; $BlockToParse = ""; $ComponentName = ""; // Events; $CCSEvents = ""; $CCSEventResult = ""; $FileName = "contact.php"; $Redirect = ""; $TemplateFileName = "contact.html"; $BlockToParse = "main"; $PathToRoot = "./"; //End Initialize Page //Initialize Objects @1-98298663 $DBbeVisitorPortal = new clsDBbeVisitorPortal(); // Controls $header = new clsheader(); $header->BindEvents(); $header->TemplatePath = "./"; $header->Initialize(); $contact_log = new clsRecordcontact_log(); $footer = new clsfooter(); $footer->BindEvents(); $footer->TemplatePath = "./"; $footer->Initialize(); $contact_log->Initialize(); // Events include("./contact_events.php"); BindEvents(); $CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize"); //End Initialize Objects //Initialize HTML Template @1-A0111C9D $CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView"); $Tpl = new clsTemplate(); $Tpl->LoadTemplate(TemplatePath . $TemplateFileName, "main"); $CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow"); //End Initialize HTML Template //Execute Components @1-7F37BDAC $header->Operations(); $contact_log->Operation(); $footer->Operations(); //End Execute Components //Go to destination page @1-BEB91355 if($Redirect) { $CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload"); header("Location: " . $Redirect); exit; } //End Go to destination page //Show Page @1-632663C0 $footer->Show("footer"); $contact_log->Show(); $header->Show("header"); $Tpl->PParse("main", false); //End Show Page //Unload Page @1-AB7622EF $CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload"); unset($Tpl); //End Unload Page ?>