require_once "../shared/logincheck.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
require_once "../shared/header.php";
#****************************************************************************
#*  Checking for query string flag to read data from database.
#****************************************************************************
if (isset($_GET["code"])) {
    unset($_SESSION["postVars"]);
    unset($_SESSION["pageErrors"]);
    $code = $_GET["code"];
    $postVars["code"] = $code;
    include_once "../classes/Mf.php";
    include_once "../classes/MfQuery.php";
    include_once "../functions/errorFuncs.php";
    $mfQ = new MfQuery();
    $mfQ->connect();
    $mf = $mfQ->get1("member_fields", $code);
    $postVars["code"] = $mf->getCode();
    $postVars["data"] = $mf->getData();
    $mfQ->close();
} else {
    require "../shared/get_form_vars.php";
}
?>

<form name="editfieldform" method="POST" action="../admin/member_fields_edit.php">
<input type="hidden" name="code" value="<?php 
echo H($postVars["code"]);
?>
">
require_once "../functions/errorFuncs.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
#****************************************************************************
#*  Checking for query string.  Go back to list if none found.
#****************************************************************************
if (!isset($_GET["code"])) {
    header("Location: ../admin/member_fields_list.php");
    exit;
}
$code = $_GET["code"];
$data = $_GET["data"];
#**************************************************************************
#*  Delete row
#**************************************************************************
$mfQ = new MfQuery();
$mfQ->connect();
$mfQ->delete("member_fields", $code);
$mfQ->close();
#**************************************************************************
#*  Show success page
#**************************************************************************
require_once "../shared/header.php";
echo $loc->getText("Member field, %data%, has been deleted.", array('data' => $data));
?>
<br><br>
<a href="../admin/member_fields_list.php"><?php 
echo $loc->getText("return to member field list");
?>
</a>
if (!isset($_POST['data']) or !$_POST['data']) {
    $pageErrors['data'] = 'This is a required field.';
}
if (!empty($pageErrors)) {
    $_SESSION["postVars"] = $_POST;
    $_SESSION["pageErrors"] = $pageErrors;
    header("Location: ../admin/member_fields_new_form.php");
    exit;
}
#**************************************************************************
#*  Insert new domain table row
#**************************************************************************
$mf = new Mf();
$mf->setCode($_POST["code"]);
$mf->setData($_POST["data"]);
$mfQ = new MfQuery();
$mfQ->connect();
$mfQ->insert("member_fields", $mf);
$mfQ->close();
#**************************************************************************
#*  Destroy form values and errors
#**************************************************************************
unset($_SESSION["postVars"]);
unset($_SESSION["pageErrors"]);
#**************************************************************************
#*  Show success page
#**************************************************************************
require_once "../shared/header.php";
echo $loc->getText("Member field, %data%, has been added.", array('data' => $mf->getData()));
?>
<br><br>
$mf->setCode($_POST["code"]);
$_POST["code"] = $mf->getCode();
$mf->setData($_POST["data"]);
$_POST["data"] = $mf->getData();
if (!$mf->validateData()) {
    $pageErrors["data"] = $mf->getDataError();
    $_SESSION["postVars"] = $_POST;
    $_SESSION["pageErrors"] = $pageErrors;
    header("Location: ../admin/member_fields_edit_form.php");
    exit;
}
#**************************************************************************
#*  Update domain table row
#**************************************************************************
print_r($mf);
$mfQ = new MfQuery();
$mfQ->connect();
$mfQ->update("member_fields", $mf);
$mfQ->close();
#**************************************************************************
#*  Destroy form values and errors
#**************************************************************************
unset($_SESSION["postVars"]);
unset($_SESSION["pageErrors"]);
#**************************************************************************
#*  Show success page
#**************************************************************************
require_once "../shared/header.php";
echo $loc->getText("Member field, %data%, has been updated.", array('data' => $mf->getData()));
?>
<br><br>
 */
require_once "../shared/common.php";
$tab = "admin";
$nav = "member_fields";
//
require_once "../classes/Mf.php";
//
require_once "../classes/MfQuery.php";
//
require_once "../functions/errorFuncs.php";
//
require_once "../shared/logincheck.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
require_once "../shared/header.php";
$mfQ = new MfQuery();
$mfQ->connect();
$mfs = $mfQ->get("member_fields");
$mfQ->close();
?>
<a href="../admin/member_fields_new_form.php?reset=Y"><?php 
echo $loc->getText("Add new custom field");
?>
</a><br>
<h1> <?php 
echo $loc->getText("Custom Member Fields");
?>
</h1>
<table class="primary">
  <tr>
    <th colspan="2" valign="top">