// new form, we (re)set the session data
    SmartyValidate::connect($smarty, true);
    #register criteria
    SmartyValidate::register_criteria('alreadyExists', 'check');
    // register our validators
    SmartyValidate::register_validator('prof', 'profiles', 'notEmpty');
    SmartyValidate::register_validator('newprof', 'newname', 'notEmpty');
    // display form
} else {
    // validate after a POST
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        SmartyValidate::disconnect();
        require_once './classes/security.class.php';
        #get $_POST info
        $profile_id = $profile->get_selectedItemKey();
        $new_name = trim($_POST['newname']);
        #get the old profile name first
        $oldSQL = "SELECT profile FROM sionapros_profiles WHERE profile_id = {$profile_id}";
        $old = $db->execute($oldSQL);
        $security = new Security($db);
        if ($security->updateProfile($profile_id, $new_name)) {
            $msg = "The profile name was changed from {$old[0]['profile']} to {$new_name}.";
            $smarty->assign('updateMsg', $msg);
        } else {
            #update failed
            $msg = "Action Failed. Please try again later.";
            $smarty->assign('updateMsg', $msg);
        }
        unset($_SESSION['profiles']);
        unset($_SESSION['prevPath']);
#db users
$usrSQL = "SELECT username FROM sionapros_users WHERE account_status = 'Active' AND username != 'SADMIN'";
$user = new classListBox($db, "users");
$user->set_query($usrSQL, "username", "username");
$user->set_postback(true);
$chUser = $user->display();
$smarty->assign('user', $chUser);
#their profiles
$profSQL = "SELECT user.profile_id,profiles.profile FROM sionapros_user_profiles AS user INNER JOIN sionapros_profiles AS profiles ON";
$profSQL .= " user.profile_id = profiles.profile_id WHERE user.username = '******'";
$profiles = new classListBox($db, "userprofiles");
$profiles->set_query($profSQL, "profile_id", "profile");
$profiles->set_postback(true);
$userProf = $profiles->display();
$smarty->assign('userProf', $userProf);
if ($profiles->get_selectedItemKey() != '') {
    $smarty->assign('button', 'visible');
    unset($_SESSION['userprofiles']);
}
if (!isset($_POST['submit'])) {
    // new form, we (re)set the session data
    SmartyValidate::connect($smarty, true);
    // register our validators
    SmartyValidate::register_validator('usr', 'users', 'notEmpty');
    SmartyValidate::register_validator('prof', 'userprofiles', 'notEmpty');
    // display form
} else {
    // validate after a POST
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        SmartyValidate::disconnect();
<?php

include_once "./classes/classListbox.php";
include_once './classes/security.class.php';
$usrSQL = "SELECT username FROM sionapros_users WHERE account_status = 'Active' AND username != 'SADMIN'";
$user = new classListBox($db, "dbusers");
$user->set_query($usrSQL, "username", "username");
$user->set_postback(true);
$chUser = $user->display();
$smarty->assign('user', $chUser);
$security = new Security($db);
$profAssigned = $security->userProfiles($user->get_selectedItemKey());
if (count($profAssigned) == 0) {
    $msg = 'none';
}
$smarty->assign('msg', $msg);
$smarty->assign('profiles', $profAssigned);
$content = $smarty->fetch('./security/tm0.security.user_profile.tpl.html');
<?php

include_once "./classes/classListbox.php";
include_once './classes/security.class.php';
$profSQL = "SELECT profile,profile_id FROM sionapros_profiles";
$profile = new classListBox($db, "profiles");
$profile->set_query($profSQL, "profile_id", "profile");
$profile->set_postback(true);
$profiles = $profile->display();
$smarty->assign('profiles', $profiles);
$security = new Security($db);
$objects = $security->objectProfiles($profile->get_selectedItemKey());
if (count($objects) == 0) {
    $msg = 'none';
}
$smarty->assign('msg', $msg);
$smarty->assign('objects', $objects);
$content = $smarty->fetch('./security/tm0.security.objects_profile.tpl.html');
$grps = $con->display();
$smarty->assign('cons', $grps);
if (empty($_POST)) {
    // new form, we (re)set the session data
    SmartyValidate::connect($smarty, true);
    // register our validators
    SmartyValidate::register_validator('grp', 'con', 'notEmpty');
    // display form
    #$content = $smarty->fetch('./main/allergy/tm0.allergy.del_allergy_group.tpl.html');
} else {
    // validate after a POST
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        require_once './classes/cats.class.php';
        #get $_POST info
        $id = $con->get_selectedItemKey();
        $SQL = "SELECT * FROM sionapros_faqs WHERE category = '{$id}'";
        $res = $db->execute($SQL);
        $SQL1 = "SELECT * FROM sionapros_news WHERE category = '{$id}'";
        $res1 = $db->execute($SQL1);
        $SQL2 = "SELECT * FROM sionapros_pubs WHERE category = '{$id}'";
        $res2 = $db->execute($SQL2);
        if (count($res) == 0 || count($res1) == 0 || count($res2) == 0) {
            SmartyValidate::disconnect();
            $Cos = new Cats($db);
            if ($Cos->delCategory($id)) {
                $msg = "The Category was successfully deleted";
                $smarty->assign('updateMsg', $msg);
                #$content = $smarty->fetch('./main/allergy/del_allergy_group.tpl.html');
            } else {
                #update failed
    SmartyValidate::connect($smarty, true);
    #register criteria
    SmartyValidate::register_criteria('alreadyExists', 'check');
    // register our validators
    SmartyValidate::register_validator('grp', 'cats', 'notEmpty');
    SmartyValidate::register_validator('newgrp', 'newname', 'notEmpty');
    // display form
    #$content = $smarty->fetch('./main/allergy/tm0.allergy.chg_allergy_group.tpl.html');
} else {
    // validate after a POST
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        SmartyValidate::disconnect();
        require_once './classes/cats.class.php';
        #get $_POST info
        $id = $cat->get_selectedItemKey();
        $new_name = trim($_POST['newname']);
        $con = new Cats($db);
        if ($con->updCategory($id, $new_name)) {
            $msg = "The category name was successfully changed";
            $smarty->assign('updateMsg', $msg);
            #$content = $smarty->fetch('./main/allergy/chg_allergy_group.tpl.html');
        } else {
            #update failed
            $msg = "The category name could not be changed. Please try again later.";
            $smarty->assign('updateMsg', $msg);
            #$content = $smarty->fetch('./main/allergy/chg_allergy_group.tpl.html');
        }
        unset($_SESSION['prevPath']);
        unset($_SESSION['cats']);
    } else {
<?php

include_once "./classes/classListbox.php";
#db profiles
$profSQL = "SELECT profile_id,profile FROM sionapros_profiles";
$profiles = new classListBox($db, "dbProfiles");
$profiles->set_query($profSQL, "profile_id", "profile");
$profiles->set_postback(true);
$dbProf = $profiles->display();
$smarty->assign('profiles', $dbProf);
#print_r($_POST);
#db users
$obSQL = "SELECT object FROM sionapros_object_profile WHERE profile_id = '{$profiles->get_selectedItemKey()}'";
$object = new classListBox($db, "objectProf");
$object->set_query($obSQL, "object", "object");
$object->set_postback(true);
$obProf = $object->display();
$smarty->assign('objects', $obProf);
if ($object->get_selectedItemKey() != '') {
    $smarty->assign('button', 'visible');
    unset($_SESSION['objectProf']);
}
if (!isset($_POST['submit'])) {
    // new form, we (re)set the session data
    SmartyValidate::connect($smarty, true);
    // register our validators
    SmartyValidate::register_validator('prof', 'dbProfiles', 'notEmpty');
    SmartyValidate::register_validator('obj', 'objectProf', 'notEmpty');
    // display form
} else {
    // validate after a POST