Пример #1
0
// please always use this way instead of hard code (e.g. there have been some problems with REGISTER_GLOBALS=OFF with hard code)
$unittest_id = intval(dPgetParam($_GET, "unittest_id", 0));
// check permissions for this record
$canEdit = !getDenyEdit($m, $unittest_id);
if (!$canEdit) {
    $AppUI->redirect("m=public&a=access_denied");
}
// use the object oriented design of dP for loading the quote that should be edited
// therefore create a new instance of the Einstein Class
$obj = new CTesting();
$obj->unittest_lasttested = '2005-07-07';
// format dates
$df = $AppUI->getPref('SHDATEFORMAT');
$lasttested = intval($obj->unittest_lasttested) ? new CDate($obj->unittest_lasttested) : new CDate();
// load the record data in case of that this script is used to edit the quote qith unittest_id (transmitted via GET)
if (!$obj->load($unittest_id, false) && $unittest_id > 0) {
    // show some error messages using the dPFramework if loadOperation failed
    // these error messages are nicely integrated with the frontend of dP
    // use detailed error messages as often as possible
    $AppUI->setMsg('Testing');
    $AppUI->setMsg("invalidID", UI_MSG_ERROR, true);
    $AppUI->redirect();
    // go back to the calling location
}
// check if this record has dependancies to prevent deletion
$msg = '';
$canDelete = $obj->canDelete($msg, $unittest_id);
// this is not relevant for CTesting objects
// this code is shown for demonstration purposes
// setup the title block
// Fill the title block either with 'Edit' or with 'New' depending on if unittest_id has been transmitted via GET or is empty