Exemplo n.º 1
0
function savePerms()
{
    global $db, $row;
    $apppageuripermDAO = new ApppageuripermDAO($db);
    $apppermDAO = new ApppermDAO($db);
    $perms = array();
    foreach ($apppermDAO->findAll('perm_name') as $perm) {
        $valname = 'perm_nameSelected_' . $perm->perm_name;
        if (isset($_POST[$valname]) && (int) $_POST[$valname] != 0) {
            $obj = new stdClass();
            $obj->page_uri = $row->page_uri;
            $obj->perm_name = $perm->perm_name;
            $perms[] = $obj;
        }
    }
    ChildRowUpdater::updateChildRows($db, 'Apppageuriperm', $perms, array('page_uri' => $row->page_uri), array('page_uri', 'perm_name'));
}
Exemplo n.º 2
0
function deleteCheckHook()
{
    global $db, $id, $result, $RESERVED_PERM_NAMES;
    $apppermDAO = new ApppermDAO($db);
    if (!($perm = $apppermDAO->load($id))) {
        $result->errorMsg .= "This Permission cannot be deleted because it does not exist.\n";
        return;
    }
    if (in_array($perm->perm_name, $RESERVED_PERM_NAMES)) {
        $result->errorMsg .= "This is a reserved Permission, and cannot be deleted.\n";
        return;
    }
    $ps = new PreparedStatement('select * from apppageuriperm where perm_name = ?', 0, 1);
    $ps->setString($perm->perm_name);
    if ($db->fetchObject($db->executeQuery($ps), true)) {
        $result->errorMsg .= "This Permission cannot be deleted because it is referenced by one or more Page URIs.\n";
    }
    $ps = new PreparedStatement('select * from approleperm where perm_name = ?', 0, 1);
    $ps->setString($perm->perm_name);
    if ($db->fetchObject($db->executeQuery($ps), true)) {
        $result->errorMsg .= "This Permission cannot be deleted because it is referenced by one or more Roles.\n";
    }
}
Exemplo n.º 3
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);