Exemplo n.º 1
0
/**
 * @param int $errorCode
 * @param string $previousURL
 * @return string
 */
function build_error_path($errorCode, $previousURL)
{
    $path = EDIT_DEFAULT_FILE_NAME;
    $args = http_build_str(array(REPORT_CODE => $errorCode, PREVIOUS_URL => $previousURL));
    $path = $path . '?' . $args;
    return $path;
}
$identifier = HttpEntityParamBuilder::retrieveFilter(array(Result::PROP_EXAM_ID, Result::PROP_STUDENT_ID));
$currentResultInstance = Result::getBuilder()->getByIdentifier($identifier);
$params = HttpEntityParamBuilder::buildParams();
$resultInstance = new Result($params);
$listURL = $_GET[PREVIOUS_URL];
$listURL = urldecode($listURL);
try {
    if ($currentResultInstance) {
        $resultInstance->update();
    } else {
        $resultInstance->save();
    }
    header("Location: {$listURL}");
} catch (InvalidArgumentException $e) {
    $path = build_error_path($e->getCode(), $listURL);
    header("Location: {$path}");
} catch (MySQLException $e) {
    $path = build_error_path($e->getCode(), $listURL);
    header("Location: {$path}");
Exemplo n.º 2
0
<?php

/**
 * Created by PhpStorm.
 * User: Marin Kaçaj
 * Date: 6/14/2015
 * Time: 4:49 PM
 */
use fti\adv_db\entity\Result;
use fti\adv_db\http\HttpEntityParamBuilder;
use fti\adv_db\nav\ActionNavigator;
require_once dirname(dirname(__FILE__)) . '/includes/session.php';
require_once dirname(dirname(__FILE__)) . '/auth/security.php';
require_once dirname(dirname(dirname(__FILE__))) . '/src/fti/adv_db/functions/auto_loader.php';
spl_autoload_register('class_auto_loader');
redirectIfNotProfessor();
$id = HttpEntityParamBuilder::retrieveFilter(array(Result::PROP_EXAM_ID, Result::PROP_STUDENT_ID));
$resultInstance = Result::getBuilder()->getByIdentifier($id);
$actionNavigator = new ActionNavigator($resultInstance);
$actionNavigator->deleteAndRedirect();
Exemplo n.º 3
0
 * User: Marin Kaçaj
 * Date: 6/14/2015
 * Time: 2:05 PM
 */
use fti\adv_db\aggregator\FormViewAggregator;
use fti\adv_db\entity\Exam;
use fti\adv_db\entity\Result;
use fti\adv_db\entity\Student;
use fti\adv_db\http\HttpEntityParamBuilder;
require_once dirname(dirname(__FILE__)) . '/includes/loader.php';
require_once dirname(dirname(__FILE__)) . '/pages/editHelper.php';
redirectIfNotProfessor();
$previousURL = $_GET[PREVIOUS_URL];
$previousURLArg = http_build_str(array(PREVIOUS_URL => $previousURL));
$identifier = HttpEntityParamBuilder::retrieveFilter(array(Result::PROP_EXAM_ID, Result::PROP_STUDENT_ID));
$entityBuilder = Result::getBuilder();
$entityInstance = $entityBuilder->getByIdentifier($identifier);
if (!$entityInstance) {
    $entityInstance = $entityBuilder->createEmpty();
}
$entityInstance->setProperty(Result::PROP_EXAM_ID, $identifier[Result::PROP_EXAM_ID]);
$entityInstance->setProperty(Result::PROP_STUDENT_ID, $identifier[Result::PROP_STUDENT_ID]);
$examInstance = Exam::getBuilder()->getByIdentifier(array(Exam::PROP_ID => $identifier[Result::PROP_EXAM_ID]));
$studentInstance = Student::getBuilder()->getByIdentifier(array(Student::PROP_ID => $identifier[Result::PROP_STUDENT_ID]));
$entityInstance->getProperty(Result::PROP_EXAM_ID)->setEntityInstances(array($examInstance));
$entityInstance->getProperty(Result::PROP_STUDENT_ID)->setEntityInstances(array($studentInstance));
$formViewAggregator = new FormViewAggregator($entityInstance, $previousURLArg);
$contentHeader = $entityBuilder->getLabel();
$contentAction = 'P&euml;rdit&euml;so';
$contentHTML = $formViewAggregator->buildEntityFormHTML();
$GLOBALS[CONTENT_HEADER] = $contentHeader;