private function cleaner()
    {
        if (!$this->done && in_array('--run-cleaner', $this->params)) {
            $this->done = true;

            $testTaker = $this->getResourceFromParameter('--clean-user=');
            if (!$testTaker) {
                $this->report->add(\common_report_Report::createFailure('--clean-user=[userId] is required and need to be a Resource'));
                return false;
            }

            $delivery = $this->getResourceFromParameter('--clean-delivery=');
            if ($delivery) {
                $this->report->add(\common_report_Report::createInfo('Deleting of the delivery data [' . $delivery->getUri() . ']'));
            } elseif ($delivery === null) {
                $this->report->add(\common_report_Report::createFailure('Delivery does not found'));
                return false;
            } else {
                $this->report->add(\common_report_Report::createInfo('Deleting of the TestTaker data [' . $testTaker->getUri() . ']'));
            }

            $ttData = $this->getDataByTestTaker($testTaker, false);
            if (!count($ttData)) {
                $this->report->add(\common_report_Report::createFailure('TestTaker with id [' . $testTaker->getUri() . '] has not been found'));
                return false;
            } elseif($delivery) {
                $hasDelivery = false;
                foreach ($ttData as $row) {
                    if ($row[1] == $delivery->getUri()) {
                        $hasDelivery = true;
                        break;
                    }
                }

                if (!$hasDelivery) {
                    $this->report->add(\common_report_Report::createFailure('Delivery with id [' . $testTaker->getUri() . '] has not been found'));
                    return false;
                }
            }

            if ($delivery) {
                $this->deleteDelivery($delivery);
            } else {
                $this->deleteTestTaker($testTaker, $ttData);
            }
        }
        return true;
    }
private function cleaner()
    {
        if (!$this->done && in_array('--run-cleaner', $this->params)) {
            $this->done = true;

            $testTaker = $this->getResourceFromParameter('--clean-user=');
            if (!$testTaker) {
                $this->report->add(\common_report_Report::createFailure('--clean-user=[userId] is required and need to be a Resource'));
                return false;
            }

            $delivery = $this->getResourceFromParameter('--clean-delivery=');
            if ($delivery) {
                $this->report->add(\common_report_Report::createInfo('Deleting of the delivery data [' . $delivery->getUri() . ']'));
            } elseif ($delivery === null) {
                $this->report->add(\common_report_Report::createFailure('Delivery does not found'));
                return false;
            } else {
                $this->report->add(\common_report_Report::createInfo('Deleting of the TestTaker data [' . $testTaker->getUri() . ']'));
            }

            $ttData = $this->getDataByTestTaker($testTaker, false);
            if (!count($ttData)) {
                $this->report->add(\common_report_Report::createFailure('TestTaker with id [' . $testTaker->getUri() . '] has not been found'));
                return false;
            } elseif($delivery) {
                $hasDelivery = false;
                foreach ($ttData as $row) {
                    if ($row[1] == $delivery->getUri()) {
                        $hasDelivery = true;
                        break;
                    }
                }

                if (!$hasDelivery) {
                    $this->report->add(\common_report_Report::createFailure('Delivery with id [' . $testTaker->getUri() . '] has not been found'));
                    return false;
                }
            }

            if ($delivery) {
                $this->deleteDelivery($delivery);
            } else {
                $this->deleteTestTaker($testTaker, $ttData);
            }
        }
        return true;
    }
private function cleaner ( ) { if ( ! $ this -> done && in_array ( '--run-cleaner' , $ this -> params ) ) { $ this -> done = true ; $ testTaker = $ this -> getResourceFromParameter ( '--clean-user=' ) ; if ( ! $ testTaker ) { $ this -> report -> add ( \ common_report_Report :: createFailure ( '--clean-user=[userId] is required and need to be a Resource' ) ) ; return false ; } $ delivery = $ this -> getResourceFromParameter ( '--clean-delivery=' ) ; if ( $ delivery ) { $ this -> report -> add ( \ common_report_Report :: createInfo ( 'Deleting of the delivery data [' . $ delivery -> getUri ( ) . ']' ) ) ; } elseif ( $ delivery === null ) { $ this -> report -> add ( \ common_report_Report :: createFailure ( 'Delivery does not found' ) ) ; return false ; } else { $ this -> report -> add ( \ common_report_Report :: createInfo ( 'Deleting of the TestTaker data [' . $ testTaker -> getUri ( ) . ']' ) ) ; } $ ttData = $ this -> getDataByTestTaker ( $ testTaker , false ) ; if ( ! count ( $ ttData ) ) { $ this -> report -> add ( \ common_report_Report :: createFailure ( 'TestTaker with id [' . $ testTaker -> getUri ( ) . '] has not been found' ) ) ; return false ; } elseif ( $ delivery ) { $ hasDelivery = false ; foreach ( $ ttData as $ row ) { if ( $ row [ 1 ] == $ delivery -> getUri ( ) ) { $ hasDelivery = true ; break ; } } if ( ! $ hasDelivery ) { $ this -> report -> add ( \ common_report_Report :: createFailure ( 'Delivery with id [' . $ testTaker -> getUri ( ) . '] has not been found' ) ) ; return false ; } } if ( $ delivery ) { $ this -> deleteDelivery ( $ delivery ) ; } else { $ this -> deleteTestTaker ( $ testTaker , $ ttData ) ; } } return true ; }
The most dangerous of the sections which will affect on the stored data
The most dangerous of the sections which will affect on the stored data