Ejemplo n.º 1
0
<?php

// DO NOT EDIT THIS FILE.
// This file was generated by searchgen.
// If you need to customize this file, please edit the corresponding
// yaml file in the gencfg directory, and then re-generate this file
// by running searchgen, passing in the table name.
if (isset($command) && $command == 'loadAppuser') {
    header('Content-Type: application/json');
    $db = ConnectionFactory::getConnection();
    $appuserDAO = new AppuserDAO($db);
    $approleDAO = new ApproleDAO($db);
    $id = isset($params['id']) ? (int) trim($params['id']) : 0;
    if ($id <= 0) {
        $rows = array(Appuser::createDefault());
    } else {
        $sql = <<<EOF
select * from appuser pri where pri.id = ?
EOF;
        $ps = new PreparedStatement($sql, 0, 1);
        $ps->setInt($id);
        $rows = $appuserDAO->findWithPreparedStatement($ps);
    }
    $ps1 = new PreparedStatement(<<<EOF
select distinct r.* from appuserrole u_r inner join approle r on r.role_name = u_r.role_name where u_r.user_id = ? order by r.sort_order, r.role_name
EOF
, 0, 0);
    foreach ($rows as &$row) {
        $ps1->clearParams();
        $ps1->setInt($row->id);
        $row->roles = $id <= 0 ? array() : $approleDAO->findWithPreparedStatement($ps1);
Ejemplo n.º 2
0
	}
}
if (returnToSearchMode) {
	parent.setMode(parent.SEARCH_MODE, false);
}
<?php 
            }
            ?>
</script></body></html>
<?php 
            exit;
        case 'deleteApprole':
            $db = ConnectionFactory::getConnection();
            $db->beginTransaction();
            $committed = false;
            $approleDAO = new ApproleDAO($db);
            $result = createMsgResultObj();
            $id = isset($_POST['id']) ? (int) trim($_POST['id']) : 0;
            if ($approleDAO->load($id) === false) {
                $result->errorMsg .= sprintf(_t('crud.idNotFoundRowNotDeleted'), _t('crud.approle.tableDescription', 'Role'), $id) . "\n";
            } else {
                if (function_exists('deleteCheckHook')) {
                    deleteCheckHook();
                }
                if ($result->errorMsg == '' && empty($result->fieldErrors)) {
                    if (function_exists('preDeleteHook')) {
                        preDeleteHook();
                    }
                    try {
                        $success = $approleDAO->delete($id);
                    } catch (Exception $ex) {
Ejemplo n.º 3
0
function deleteUserRoles()
{
    global $db, $id;
    $approleDAO = new ApproleDAO($db);
    if ($role = $approleDAO->load($id)) {
        $appuserroleDAO = new AppuserroleDAO($db);
        foreach ($appuserroleDAO->findByRole_name($role->role_name) as $permrow) {
            $appuserroleDAO->delete($permrow->id);
        }
    }
}
Ejemplo n.º 4
0
<?php

// DO NOT EDIT THIS FILE.
// This file was generated by searchgen.
// If you need to customize this file, please edit the corresponding
// yaml file in the gencfg directory, and then re-generate this file
// by running searchgen, passing in the table name.
if (isset($command) && $command == 'loadApprole') {
    header('Content-Type: application/json');
    $db = ConnectionFactory::getConnection();
    $approleDAO = new ApproleDAO($db);
    $apppermDAO = new ApppermDAO($db);
    $id = isset($params['id']) ? (int) trim($params['id']) : 0;
    if ($id <= 0) {
        $rows = array(Approle::createDefault());
    } else {
        $sql = <<<EOF
select * from approle pri where pri.id = ?
EOF;
        $ps = new PreparedStatement($sql, 0, 1);
        $ps->setInt($id);
        $rows = $approleDAO->findWithPreparedStatement($ps);
    }
    $ps1 = new PreparedStatement(<<<EOF
select distinct p.* from approleperm r_p inner join appperm p on p.perm_name = r_p.perm_name where r_p.role_name = ? order by p.perm_name
EOF
, 0, 0);
    foreach ($rows as &$row) {
        $ps1->clearParams();
        $ps1->setString($row->role_name);
        $row->perms = $id <= 0 ? array() : $apppermDAO->findWithPreparedStatement($ps1);
Ejemplo n.º 5
0
function saveRoles($user_id)
{
    global $db, $row, $MAX_RESERVED_ID;
    if ($row->id > 0 && $row->id <= $MAX_RESERVED_ID) {
        return;
    }
    $appuserroleDAO = new AppuserroleDAO($db);
    $approleDAO = new ApproleDAO($db);
    $roles = array();
    foreach ($approleDAO->findAll('sort_order, role_name') as $role) {
        $valname = 'role_nameSelected_' . $role->role_name;
        if (isset($_POST[$valname]) && (int) $_POST[$valname] != 0) {
            $obj = new stdClass();
            $obj->user_id = $user_id;
            $obj->role_name = $role->role_name;
            $roles[] = $obj;
        }
    }
    ChildRowUpdater::updateChildRows($db, 'Appuserrole', $roles, array('user_id' => $user_id), array('user_id', 'role_name'));
}