コード例 #1
0
// handle submits
if (isset($_POST['cancel'])) {
    $msg->addFeedback('CANCELLED');
    header('Location: user_group.php');
    exit;
} else {
    if (isset($_POST['save'])) {
        $title = trim($_POST['title']);
        if ($title == '') {
            $msg->addError(array('EMPTY_FIELDS', _AC('title')));
        }
        if (!$msg->containsErrors()) {
            if (isset($id)) {
                $userGroupsDAO->update($id, $title, trim($_POST['description']));
            } else {
                $id = $userGroupsDAO->Create($title, trim($_POST['description']));
            }
            if (!$msg->containsErrors()) {
                // add checks
                if (is_array($_POST['add_privileges_id'])) {
                    $userGroupPrivilegeDAO = new UserGroupPrivilegeDAO();
                    foreach ($_POST['add_privileges_id'] as $add_priv_id) {
                        $userGroupPrivilegeDAO->Create($id, $add_priv_id);
                    }
                }
                $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
                header('Location: user_group.php');
                exit;
            }
        }
    } else {
コード例 #2
0
// handle submits
if (isset($_POST['cancel'])) {
    $msg->addFeedback('CANCELLED');
    header('Location: user_group.php');
    exit;
} else {
    if (isset($_POST['save'])) {
        $title = $addslashes(trim($_POST['title']));
        if ($title == '') {
            $msg->addError(array('EMPTY_FIELDS', _AT('title')));
        }
        if (!$msg->containsErrors()) {
            if (isset($id)) {
                $userGroupsDAO->update($id, $title, $addslashes(trim($_POST['description'])));
            } else {
                $id = $userGroupsDAO->Create($title, $addslashes(trim($_POST['description'])));
            }
            if (!$msg->containsErrors()) {
                $userGroupPrivilegeDAO = new UserGroupPrivilegeDAO();
                // add checks
                if (is_array($_POST['add_privileges_id'])) {
                    foreach ($_POST['add_privileges_id'] as $add_priv_id) {
                        $userGroupPrivilegeDAO->Create($id, $add_priv_id);
                    }
                }
                if (is_array($_POST['user_requirement'])) {
                    foreach ($_POST['user_requirement'] as $priv_id => $user_requirement) {
                        $user_group_priv_row = $userGroupPrivilegeDAO->Get($id, $priv_id);
                        if ($user_group_priv_row && $user_group_priv_row['user_requirement'] != $user_requirement) {
                            $userGroupPrivilegeDAO->UpdateField($id, $priv_id, 'user_requirement', $user_requirement);
                        }