Пример #1
0
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
$del = (int) dPgetParam($_POST, 'del', 0);
$obj = new CResource();
$msg = '';
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
$AppUI->setMsg('Resource');
if ($del) {
    if (!$obj->canDelete($msg)) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    }
    if ($msg = $obj->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg('deleted', UI_MSG_ALERT, true);
        $AppUI->redirect('', -1);
    }
} else {
    if ($msg = $obj->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        $AppUI->setMsg($_POST['resource_id'] ? 'updated' : 'added', UI_MSG_OK, true);
    }
    $AppUI->redirect();
}
Пример #2
0
    if (!canAdd('resources')) {
        $AppUI->redirect('m=public&a=access_denied');
    }
}
$obj = new CResource();
$msg = '';
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
$AppUI->setMsg('Resource');
if ($del) {
    if (!$obj->canDelete($msg)) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect('m=resources');
    }
    if ($obj->delete($AppUI)) {
        $AppUI->setMsg('deleted', UI_MSG_ALERT, true);
        $AppUI->redirect('m=resources');
    } else {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect('m=resources');
    }
} else {
    if ($msg = $obj->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        $AppUI->setMsg($resource_id ? 'updated' : 'added', UI_MSG_OK, true);
    }
    $AppUI->redirect('m=resources');
}