<?php

include_once "./classes/classListbox.php";
#include_once('./classes/main/security.class.php');
#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 {
<?php

include_once "./classes/classListbox.php";
$SQL = "SELECT value,id FROM sionapros_categories ORDER BY id";
$con = new classListBox($db, "con");
$con->set_query($SQL, "id", "value");
#$userMods->set_postback(true);
$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();
<?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

require_once "./classes/classListbox.php";
$SQL = "SELECT value,id FROM sionapros_categories ORDER BY id";
$cat = new classListBox($db, "cats");
$cat->set_query($SQL, "id", "value");
#$userMods->set_postback(true);
$groups = $cat->display();
$smarty->assign('cat', $groups);
#check that new name doesnt match an already existing name
function check()
{
    global $_POST, $db;
    $chkSQL = "SELECT * FROM sionapros_categories WHERE value = '{$_POST['newname']}'";
    $chkSQL .= " AND id != {$_POST['cats']}";
    if (count($db->execute($chkSQL)) == 0) {
        return true;
    } else {
        return false;
    }
}
if (empty($_POST)) {
    // 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('grp', 'cats', 'notEmpty');
    SmartyValidate::register_validator('newgrp', 'newname', 'notEmpty');
    // display form
    #$content = $smarty->fetch('./main/allergy/tm0.allergy.chg_allergy_group.tpl.html');