| Current Path : /var/www/cesa.co.za/cpdadmin/ |
| Current File : /var/www/cesa.co.za/cpdadmin/CPDAdminUsersadd.php |
<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "CPDAdminUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php
// Create page object
$CPDAdminUsers_add = new cCPDAdminUsers_add();
$Page =& $CPDAdminUsers_add;
// Page init
$CPDAdminUsers_add->Page_Init();
// Page main
$CPDAdminUsers_add->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
// Create page object
var CPDAdminUsers_add = new ew_Page("CPDAdminUsers_add");
// page properties
CPDAdminUsers_add.PageID = "add"; // page ID
CPDAdminUsers_add.FormID = "fCPDAdminUsersadd"; // form ID
var EW_PAGE_ID = CPDAdminUsers_add.PageID; // for backward compatibility
// extend page with ValidateForm function
CPDAdminUsers_add.ValidateForm = function(fobj) {
ew_PostAutoSuggest(fobj);
if (!this.ValidateRequired)
return true; // ignore validation
if (fobj.a_confirm && fobj.a_confirm.value == "F")
return true;
var i, elm, aelm, infix;
var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
for (i=0; i<rowcnt; i++) {
infix = (fobj.key_count) ? String(i+1) : "";
elm = fobj.elements["x" + infix + "_adminusername"];
if (elm && !ew_HasValue(elm))
return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($CPDAdminUsers->adminusername->FldCaption()) ?>");
elm = fobj.elements["x" + infix + "_adminpassword"];
if (elm && !ew_HasValue(elm))
return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($CPDAdminUsers->adminpassword->FldCaption()) ?>");
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
}
return true;
}
// extend page with Form_CustomValidate function
CPDAdminUsers_add.Form_CustomValidate =
function(fobj) { // DO NOT CHANGE THIS LINE!
// Your custom validation code here, return false if invalid.
return true;
}
<?php if (EW_CLIENT_VALIDATE) { ?>
CPDAdminUsers_add.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CPDAdminUsers_add.ValidateRequired = false; // no JavaScript validation
<?php } ?>
//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js");
//-->
</script>
<p><span class="phpmaker"><?php echo $Language->Phrase("Add") ?> <?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CPDAdminUsers->TableCaption() ?><br><br>
<a href="<?php echo $CPDAdminUsers->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$CPDAdminUsers_add->ShowMessage();
?>
<form name="fCPDAdminUsersadd" id="fCPDAdminUsersadd" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CPDAdminUsers_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="CPDAdminUsers">
<input type="hidden" name="a_add" id="a_add" value="A">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($CPDAdminUsers->adminusername->Visible) { // adminusername ?>
<tr<?php echo $CPDAdminUsers->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CPDAdminUsers->adminusername->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $CPDAdminUsers->adminusername->CellAttributes() ?>><span id="el_adminusername">
<input type="text" name="x_adminusername" id="x_adminusername" title="<?php echo $CPDAdminUsers->adminusername->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CPDAdminUsers->adminusername->EditValue ?>"<?php echo $CPDAdminUsers->adminusername->EditAttributes() ?>>
</span><?php echo $CPDAdminUsers->adminusername->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CPDAdminUsers->adminpassword->Visible) { // adminpassword ?>
<tr<?php echo $CPDAdminUsers->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CPDAdminUsers->adminpassword->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $CPDAdminUsers->adminpassword->CellAttributes() ?>><span id="el_adminpassword">
<input type="text" name="x_adminpassword" id="x_adminpassword" title="<?php echo $CPDAdminUsers->adminpassword->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CPDAdminUsers->adminpassword->EditValue ?>"<?php echo $CPDAdminUsers->adminpassword->EditAttributes() ?>>
</span><?php echo $CPDAdminUsers->adminpassword->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CPDAdminUsers->zemail->Visible) { // email ?>
<tr<?php echo $CPDAdminUsers->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CPDAdminUsers->zemail->FldCaption() ?></td>
<td<?php echo $CPDAdminUsers->zemail->CellAttributes() ?>><span id="el_zemail">
<input type="text" name="x_zemail" id="x_zemail" title="<?php echo $CPDAdminUsers->zemail->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CPDAdminUsers->zemail->EditValue ?>"<?php echo $CPDAdminUsers->zemail->EditAttributes() ?>>
</span><?php echo $CPDAdminUsers->zemail->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CPDAdminUsers->activated->Visible) { // activated ?>
<tr<?php echo $CPDAdminUsers->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CPDAdminUsers->activated->FldCaption() ?></td>
<td<?php echo $CPDAdminUsers->activated->CellAttributes() ?>><span id="el_activated">
<div id="tp_x_activated" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x_activated" id="x_activated" title="<?php echo $CPDAdminUsers->activated->FldTitle() ?>" value="{value}"<?php echo $CPDAdminUsers->activated->EditAttributes() ?>></label></div>
<div id="dsl_x_activated" repeatcolumn="5">
<?php
$arwrk = $CPDAdminUsers->activated->EditValue;
if (is_array($arwrk)) {
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($CPDAdminUsers->activated->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
if ($selwrk <> "") $emptywrk = FALSE;
// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x_activated" id="x_activated" title="<?php echo $CPDAdminUsers->activated->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $CPDAdminUsers->activated->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
}
}
?>
</div>
</span><?php echo $CPDAdminUsers->activated->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CPDAdminUsers->level->Visible) { // level ?>
<tr<?php echo $CPDAdminUsers->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CPDAdminUsers->level->FldCaption() ?></td>
<td<?php echo $CPDAdminUsers->level->CellAttributes() ?>><span id="el_level">
<?php if (!$Security->IsAdmin() && $Security->IsLoggedIn()) { // Non system admin ?>
<div<?php echo $CPDAdminUsers->level->ViewAttributes() ?>><?php echo $CPDAdminUsers->level->EditValue ?></div>
<?php } else { ?>
<select id="x_level" name="x_level" title="<?php echo $CPDAdminUsers->level->FldTitle() ?>"<?php echo $CPDAdminUsers->level->EditAttributes() ?>>
<?php
if (is_array($CPDAdminUsers->level->EditValue)) {
$arwrk = $CPDAdminUsers->level->EditValue;
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($CPDAdminUsers->level->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
}
}
?>
</select>
<?php } ?>
</span><?php echo $CPDAdminUsers->level->CustomMsg ?></td>
</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("AddBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<?php include "footer.php" ?>
<?php
$CPDAdminUsers_add->Page_Terminate();
?>
<?php
//
// Page class
//
class cCPDAdminUsers_add {
// Page ID
var $PageID = 'add';
// Table name
var $TableName = 'CPDAdminUsers';
// Page object name
var $PageObjName = 'CPDAdminUsers_add';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $CPDAdminUsers;
if ($CPDAdminUsers->UseTokenInUrl) $PageUrl .= "t=" . $CPDAdminUsers->TableVar . "&"; // Add page token
return $PageUrl;
}
// Page URLs
var $AddUrl;
var $EditUrl;
var $CopyUrl;
var $DeleteUrl;
var $ViewUrl;
var $ListUrl;
// Export URLs
var $ExportPrintUrl;
var $ExportHtmlUrl;
var $ExportExcelUrl;
var $ExportWordUrl;
var $ExportXmlUrl;
var $ExportCsvUrl;
// Update URLs
var $InlineAddUrl;
var $InlineCopyUrl;
var $InlineEditUrl;
var $GridAddUrl;
var $GridEditUrl;
var $MultiDeleteUrl;
var $MultiUpdateUrl;
// Message
function getMessage() {
return @$_SESSION[EW_SESSION_MESSAGE];
}
function setMessage($v) {
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
} else {
$_SESSION[EW_SESSION_MESSAGE] = $v;
}
}
// Show message
function ShowMessage() {
$sMessage = $this->getMessage();
$this->Message_Showing($sMessage);
if ($sMessage <> "") { // Message in Session, display
echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
}
}
// Validate page request
function IsPageRequest() {
global $objForm, $CPDAdminUsers;
if ($CPDAdminUsers->UseTokenInUrl) {
if ($objForm)
return ($CPDAdminUsers->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($CPDAdminUsers->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function __construct() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (CPDAdminUsers)
$GLOBALS["CPDAdminUsers"] = new cCPDAdminUsers();
// Page ID
if (!defined("EW_PAGE_ID"))
define("EW_PAGE_ID", 'add', TRUE);
// Table name (for backward compatibility)
if (!defined("EW_TABLE_NAME"))
define("EW_TABLE_NAME", 'CPDAdminUsers', TRUE);
// Start timer
$GLOBALS["gsTimer"] = new cTimer();
// Open connection
$conn = ew_Connect();
}
//
// Page_Init
//
function Page_Init() {
global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
global $CPDAdminUsers;
// User profile
$UserProfile = new cUserProfile();
$UserProfile->LoadProfile(@$_SESSION[EW_SESSION_USER_PROFILE]);
// Security
$Security = new cAdvancedSecurity();
if (IsPasswordExpired())
$this->Page_Terminate("changepwd.php");
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
if (!$Security->IsLoggedIn()) {
$Security->SaveLastUrl();
$this->Page_Terminate("login.php");
}
$Security->TablePermission_Loading();
$Security->LoadCurrentUserLevel($this->TableName);
$Security->TablePermission_Loaded();
if (!$Security->IsLoggedIn()) {
$Security->SaveLastUrl();
$this->Page_Terminate("login.php");
}
if (!$Security->CanAdd()) {
$Security->SaveLastUrl();
$this->Page_Terminate("CPDAdminUserslist.php");
}
$Security->UserID_Loading();
if ($Security->IsLoggedIn()) $Security->LoadUserID();
$Security->UserID_Loaded();
if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
$_SESSION[EW_SESSION_MESSAGE] = $Language->Phrase("NoPermission");
$this->Page_Terminate("CPDAdminUserslist.php");
}
// Create form object
$objForm = new cFormObj();
// Global Page Loading event (in userfn*.php)
Page_Loading();
// Page Load event
$this->Page_Load();
}
//
// Page_Terminate
//
function Page_Terminate($url = "") {
global $conn;
// Page Unload event
$this->Page_Unload();
// Global Page Unloaded event (in userfn*.php)
Page_Unloaded();
// Close connection
$conn->Close();
// Go to URL if specified
$this->Page_Redirecting($url);
if ($url <> "") {
if (!EW_DEBUG_ENABLED && ob_get_length())
ob_end_clean();
header("Location: " . $url);
}
exit();
}
var $sDbMasterFilter = "";
var $sDbDetailFilter = "";
var $lPriv = 0;
//
// Page main
//
function Page_Main() {
global $objForm, $Language, $gsFormError, $CPDAdminUsers;
// Load key values from QueryString
$bCopy = TRUE;
if (@$_GET["adminuserid"] != "") {
$CPDAdminUsers->adminuserid->setQueryStringValue($_GET["adminuserid"]);
} else {
$bCopy = FALSE;
}
// Process form if post back
if (@$_POST["a_add"] <> "") {
$CPDAdminUsers->CurrentAction = $_POST["a_add"]; // Get form action
$this->LoadFormValues(); // Load form values
// Validate form
if (!$this->ValidateForm()) {
$CPDAdminUsers->CurrentAction = "I"; // Form error, reset action
$this->setMessage($gsFormError);
}
} else { // Not post back
if ($bCopy) {
$CPDAdminUsers->CurrentAction = "C"; // Copy record
} else {
$CPDAdminUsers->CurrentAction = "I"; // Display blank record
$this->LoadDefaultValues(); // Load default values
}
}
// Perform action based on action code
switch ($CPDAdminUsers->CurrentAction) {
case "I": // Blank record, no action required
break;
case "C": // Copy an existing record
if (!$this->LoadRow()) { // Load record based on key
$this->setMessage($Language->Phrase("NoRecord")); // No record found
$this->Page_Terminate("CPDAdminUserslist.php"); // No matching record, return to list
}
break;
case "A": // ' Add new record
$CPDAdminUsers->SendEmail = TRUE; // Send email on add success
if ($this->AddRow()) { // Add successful
$this->setMessage($Language->Phrase("AddSuccess")); // Set up success message
$sReturnUrl = $CPDAdminUsers->getReturnUrl();
if (ew_GetPageName($sReturnUrl) == "CPDAdminUsersview.php")
$sReturnUrl = $CPDAdminUsers->ViewUrl(); // View paging, return to view page with keyurl directly
$this->Page_Terminate($sReturnUrl); // Clean up and return
} else {
$this->RestoreFormValues(); // Add failed, restore form values
}
}
// Render row based on row type
$CPDAdminUsers->RowType = EW_ROWTYPE_ADD; // Render add type
// Render row
$this->RenderRow();
}
// Get upload files
function GetUploadFiles() {
global $objForm, $CPDAdminUsers;
// Get upload data
}
// Load default values
function LoadDefaultValues() {
global $CPDAdminUsers;
$CPDAdminUsers->adminpassword->CurrentValue = GenStrongPassword();
$CPDAdminUsers->level->CurrentValue = 11;
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $CPDAdminUsers;
$CPDAdminUsers->adminusername->setFormValue($objForm->GetValue("x_adminusername"));
$CPDAdminUsers->adminpassword->setFormValue($objForm->GetValue("x_adminpassword"));
$CPDAdminUsers->zemail->setFormValue($objForm->GetValue("x_zemail"));
$CPDAdminUsers->activated->setFormValue($objForm->GetValue("x_activated"));
$CPDAdminUsers->level->setFormValue($objForm->GetValue("x_level"));
$CPDAdminUsers->adminuserid->setFormValue($objForm->GetValue("x_adminuserid"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $CPDAdminUsers;
$CPDAdminUsers->adminuserid->CurrentValue = $CPDAdminUsers->adminuserid->FormValue;
$CPDAdminUsers->adminusername->CurrentValue = $CPDAdminUsers->adminusername->FormValue;
$CPDAdminUsers->adminpassword->CurrentValue = $CPDAdminUsers->adminpassword->FormValue;
$CPDAdminUsers->zemail->CurrentValue = $CPDAdminUsers->zemail->FormValue;
$CPDAdminUsers->activated->CurrentValue = $CPDAdminUsers->activated->FormValue;
$CPDAdminUsers->level->CurrentValue = $CPDAdminUsers->level->FormValue;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $CPDAdminUsers;
$sFilter = $CPDAdminUsers->KeyFilter();
// Call Row Selecting event
$CPDAdminUsers->Row_Selecting($sFilter);
// Load SQL based on filter
$CPDAdminUsers->CurrentFilter = $sFilter;
$sSql = $CPDAdminUsers->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$CPDAdminUsers->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $CPDAdminUsers;
$CPDAdminUsers->adminuserid->setDbValue($rs->fields('adminuserid'));
$CPDAdminUsers->adminusername->setDbValue($rs->fields('adminusername'));
$CPDAdminUsers->adminpassword->setDbValue($rs->fields('adminpassword'));
$CPDAdminUsers->profile->setDbValue($rs->fields('profile'));
$CPDAdminUsers->zemail->setDbValue($rs->fields('email'));
$CPDAdminUsers->activated->setDbValue($rs->fields('activated'));
$CPDAdminUsers->level->setDbValue($rs->fields('level'));
$CPDAdminUsers->pwdchanged->setDbValue($rs->fields('pwdchanged'));
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $CPDAdminUsers;
// Initialize URLs
// Call Row_Rendering event
$CPDAdminUsers->Row_Rendering();
// Common render codes for all row types
// adminusername
$CPDAdminUsers->adminusername->CellCssStyle = ""; $CPDAdminUsers->adminusername->CellCssClass = "";
$CPDAdminUsers->adminusername->CellAttrs = array(); $CPDAdminUsers->adminusername->ViewAttrs = array(); $CPDAdminUsers->adminusername->EditAttrs = array();
// adminpassword
$CPDAdminUsers->adminpassword->CellCssStyle = ""; $CPDAdminUsers->adminpassword->CellCssClass = "";
$CPDAdminUsers->adminpassword->CellAttrs = array(); $CPDAdminUsers->adminpassword->ViewAttrs = array(); $CPDAdminUsers->adminpassword->EditAttrs = array();
// email
$CPDAdminUsers->zemail->CellCssStyle = ""; $CPDAdminUsers->zemail->CellCssClass = "";
$CPDAdminUsers->zemail->CellAttrs = array(); $CPDAdminUsers->zemail->ViewAttrs = array(); $CPDAdminUsers->zemail->EditAttrs = array();
// activated
$CPDAdminUsers->activated->CellCssStyle = ""; $CPDAdminUsers->activated->CellCssClass = "";
$CPDAdminUsers->activated->CellAttrs = array(); $CPDAdminUsers->activated->ViewAttrs = array(); $CPDAdminUsers->activated->EditAttrs = array();
// level
$CPDAdminUsers->level->CellCssStyle = ""; $CPDAdminUsers->level->CellCssClass = "";
$CPDAdminUsers->level->CellAttrs = array(); $CPDAdminUsers->level->ViewAttrs = array(); $CPDAdminUsers->level->EditAttrs = array();
if ($CPDAdminUsers->RowType == EW_ROWTYPE_VIEW) { // View row
// adminuserid
$CPDAdminUsers->adminuserid->ViewValue = $CPDAdminUsers->adminuserid->CurrentValue;
$CPDAdminUsers->adminuserid->CssStyle = "";
$CPDAdminUsers->adminuserid->CssClass = "";
$CPDAdminUsers->adminuserid->ViewCustomAttributes = "";
// adminusername
$CPDAdminUsers->adminusername->ViewValue = $CPDAdminUsers->adminusername->CurrentValue;
$CPDAdminUsers->adminusername->CssStyle = "";
$CPDAdminUsers->adminusername->CssClass = "";
$CPDAdminUsers->adminusername->ViewCustomAttributes = "";
// adminpassword
$CPDAdminUsers->adminpassword->ViewValue = $CPDAdminUsers->adminpassword->CurrentValue;
$CPDAdminUsers->adminpassword->CssStyle = "";
$CPDAdminUsers->adminpassword->CssClass = "";
$CPDAdminUsers->adminpassword->ViewCustomAttributes = "";
// email
$CPDAdminUsers->zemail->ViewValue = $CPDAdminUsers->zemail->CurrentValue;
$CPDAdminUsers->zemail->CssStyle = "";
$CPDAdminUsers->zemail->CssClass = "";
$CPDAdminUsers->zemail->ViewCustomAttributes = "";
// activated
if (strval($CPDAdminUsers->activated->CurrentValue) <> "") {
switch ($CPDAdminUsers->activated->CurrentValue) {
case "1":
$CPDAdminUsers->activated->ViewValue = "Yes";
break;
case "0":
$CPDAdminUsers->activated->ViewValue = "No";
break;
default:
$CPDAdminUsers->activated->ViewValue = $CPDAdminUsers->activated->CurrentValue;
}
} else {
$CPDAdminUsers->activated->ViewValue = NULL;
}
$CPDAdminUsers->activated->CssStyle = "";
$CPDAdminUsers->activated->CssClass = "";
$CPDAdminUsers->activated->ViewCustomAttributes = "";
// level
if ($Security->CanAdmin()) { // System admin
if (strval($CPDAdminUsers->level->CurrentValue) <> "") {
$sFilterWrk = "`userlevelid` = " . ew_AdjustSql($CPDAdminUsers->level->CurrentValue) . "";
$sSqlWrk = "SELECT `userlevelname` FROM `userlevels`";
$sWhereWrk = "";
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . "userlevelid IN (10,11)" . ")";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$rswrk = $conn->Execute($sSqlWrk);
if ($rswrk && !$rswrk->EOF) { // Lookup values found
$CPDAdminUsers->level->ViewValue = $rswrk->fields('userlevelname');
$rswrk->Close();
} else {
$CPDAdminUsers->level->ViewValue = $CPDAdminUsers->level->CurrentValue;
}
} else {
$CPDAdminUsers->level->ViewValue = NULL;
}
} else {
$CPDAdminUsers->level->ViewValue = "********";
}
$CPDAdminUsers->level->CssStyle = "";
$CPDAdminUsers->level->CssClass = "";
$CPDAdminUsers->level->ViewCustomAttributes = "";
// pwdchanged
$CPDAdminUsers->pwdchanged->ViewValue = $CPDAdminUsers->pwdchanged->CurrentValue;
$CPDAdminUsers->pwdchanged->ViewValue = ew_FormatDateTime($CPDAdminUsers->pwdchanged->ViewValue, 5);
$CPDAdminUsers->pwdchanged->CssStyle = "";
$CPDAdminUsers->pwdchanged->CssClass = "";
$CPDAdminUsers->pwdchanged->ViewCustomAttributes = "";
// adminusername
$CPDAdminUsers->adminusername->HrefValue = "";
$CPDAdminUsers->adminusername->TooltipValue = "";
// adminpassword
$CPDAdminUsers->adminpassword->HrefValue = "";
$CPDAdminUsers->adminpassword->TooltipValue = "";
// email
$CPDAdminUsers->zemail->HrefValue = "";
$CPDAdminUsers->zemail->TooltipValue = "";
// activated
$CPDAdminUsers->activated->HrefValue = "";
$CPDAdminUsers->activated->TooltipValue = "";
// level
$CPDAdminUsers->level->HrefValue = "";
$CPDAdminUsers->level->TooltipValue = "";
} elseif ($CPDAdminUsers->RowType == EW_ROWTYPE_ADD) { // Add row
// adminusername
$CPDAdminUsers->adminusername->EditCustomAttributes = "";
$CPDAdminUsers->adminusername->EditValue = ew_HtmlEncode($CPDAdminUsers->adminusername->CurrentValue);
// adminpassword
$CPDAdminUsers->adminpassword->EditCustomAttributes = "";
$CPDAdminUsers->adminpassword->EditValue = ew_HtmlEncode($CPDAdminUsers->adminpassword->CurrentValue);
// email
$CPDAdminUsers->zemail->EditCustomAttributes = "";
$CPDAdminUsers->zemail->EditValue = ew_HtmlEncode($CPDAdminUsers->zemail->CurrentValue);
// activated
$CPDAdminUsers->activated->EditCustomAttributes = "";
$arwrk = array();
$arwrk[] = array("1", "Yes");
$arwrk[] = array("0", "No");
$CPDAdminUsers->activated->EditValue = $arwrk;
// level
$CPDAdminUsers->level->EditCustomAttributes = "";
if (!$Security->CanAdmin()) { // System admin
$CPDAdminUsers->level->EditValue = "********";
} else {
$sFilterWrk = "";
$sSqlWrk = "SELECT `userlevelid`, `userlevelname`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `userlevels`";
$sWhereWrk = "";
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . "userlevelid IN (10,11)" . ")";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$rswrk = $conn->Execute($sSqlWrk);
$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
if ($rswrk) $rswrk->Close();
array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
$CPDAdminUsers->level->EditValue = $arwrk;
}
}
// Call Row Rendered event
if ($CPDAdminUsers->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$CPDAdminUsers->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $CPDAdminUsers;
// Initialize form error message
$gsFormError = "";
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
if (!is_null($CPDAdminUsers->adminusername->FormValue) && $CPDAdminUsers->adminusername->FormValue == "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $CPDAdminUsers->adminusername->FldCaption();
}
if (!is_null($CPDAdminUsers->adminpassword->FormValue) && $CPDAdminUsers->adminpassword->FormValue == "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $CPDAdminUsers->adminpassword->FldCaption();
}
// Return validate result
$ValidateForm = ($gsFormError == "");
// Call Form_CustomValidate event
$sFormCustomError = "";
$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
if ($sFormCustomError <> "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $sFormCustomError;
}
return $ValidateForm;
}
// Add record
function AddRow() {
global $conn, $Language, $Security, $CPDAdminUsers;
$rsnew = array();
// adminusername
$CPDAdminUsers->adminusername->SetDbValueDef($rsnew, $CPDAdminUsers->adminusername->CurrentValue, NULL, FALSE);
// adminpassword
$CPDAdminUsers->adminpassword->SetDbValueDef($rsnew, $CPDAdminUsers->adminpassword->CurrentValue, NULL, FALSE);
// email
$CPDAdminUsers->zemail->SetDbValueDef($rsnew, $CPDAdminUsers->zemail->CurrentValue, NULL, FALSE);
// activated
$CPDAdminUsers->activated->SetDbValueDef($rsnew, $CPDAdminUsers->activated->CurrentValue, NULL, FALSE);
// level
if ($Security->CanAdmin()) { // System admin
$CPDAdminUsers->level->SetDbValueDef($rsnew, $CPDAdminUsers->level->CurrentValue, NULL, FALSE);
}
// adminuserid
// Call Row Inserting event
$bInsertRow = $CPDAdminUsers->Row_Inserting($rsnew);
if ($bInsertRow) {
$conn->raiseErrorFn = 'ew_ErrorFn';
$AddRow = $conn->Execute($CPDAdminUsers->InsertSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($CPDAdminUsers->CancelMessage <> "") {
$this->setMessage($CPDAdminUsers->CancelMessage);
$CPDAdminUsers->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("InsertCancelled"));
}
$AddRow = FALSE;
}
if ($AddRow) {
$CPDAdminUsers->adminuserid->setDbValue($conn->Insert_ID());
$rsnew['adminuserid'] = $CPDAdminUsers->adminuserid->DbValue;
// Call Row Inserted event
$CPDAdminUsers->Row_Inserted($rsnew);
}
return $AddRow;
}
// Page Load event
function Page_Load() {
//echo "Page Load";
}
// Page Unload event
function Page_Unload() {
//echo "Page Unload";
}
// Page Redirecting event
function Page_Redirecting(&$url) {
// Example:
//$url = "your URL";
}
// Message Showing event
function Message_Showing(&$msg) {
// Example:
//$msg = "your new message";
}
// Form Custom Validate event
function Form_CustomValidate(&$CustomError) {
// Return error message in CustomError
return TRUE;
}
}
?>