Exemplo n.º 1
0
<?php

require_once $AppUI->getModuleClass('projects');
// one site for both adding and editing einstein's quote items
// besides the following lines show the possiblities of the dPframework
// retrieve GET-Parameters via dPframework
// 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();
// 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
Exemplo n.º 2
0
<?php

require_once $AppUI->getModuleClass('projects');
// one site for both adding and editing einstein's quote items
// besides the following lines show the possiblities of the dPframework
// retrieve GET-Parameters via dPframework
// 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
Exemplo n.º 3
0
<?php

// this doSQL script is called from the addedit.php script
// its purpose is to use the CTest class to interoperate with the database (store, edit, delete)
/* the following variables can be retreived via POST from testing/addedit.php:
** int unittest_id	is '0' if a new database object has to be stored or the id of an existing quote that should be overwritten or deleted in the db
** str test_description	the text of the quote that should be stored
** int del		bool flag, in case of presence the row with the given unittest_id has to be dropped from db
*/
// create a new instance of the test class
$obj = new CTesting();
$msg = '';
// reset the message string
// bind the informations (variables) retrieved via post to the test object
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
// detect if a deleete operation has to be processed
$del = dPgetParam($_POST, 'del', 0);
if ($del) {
    // check if there are dependencies on this object (not relevant for test, left here for show-purposes)
    //	if (!$obj->canDelete( $msg )) {
    //		$AppUI->setMsg( $msg, UI_MSG_ERROR );
    //		$AppUI->redirect();
    //	}
    // see how easy it is to run database commands with the object oriented architecture !
    // simply delete a quote from db and have detailed error or success report
    if ($msg = $obj->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        // message with error flag