Post-processing activities
When the order returns from the processor, if PDT was successful, this stores the results in order-status-history and logs data for subsequent reference

@return boolean
3291
function after_process() {
    global $insert_id, $db, $order;
    if ($_SESSION['paypal_transaction_PDT_passed'] != true) {
      $_SESSION['order_created'] = '';
      unset($_SESSION['paypal_transaction_PDT_passed']);
      return false;
    } else {
    // PDT found order to be approved, so add a new OSH record for this order's PP details
      unset($_SESSION['paypal_transaction_PDT_passed']);
      $sql_data_array= array(array('fieldName'=>'orders_id', 'value'=>$insert_id, 'type'=>'integer'),
                             array('fieldName'=>'orders_status_id', 'value'=>$this->order_status, 'type'=>'integer'),
                             array('fieldName'=>'date_added', 'value'=>'now()', 'type'=>'noquotestring'),
                             array('fieldName'=>'customer_notified', 'value'=>0, 'type'=>'integer'),
                             array('fieldName'=>'comments', 'value'=>'PayPal status: ' . $this->pdtData['payment_status'] . ' ' . ' @ ' . $this->pdtData['payment_date'] . "\n" . ' Trans ID:' . $this->pdtData['txn_id'] . "\n" . ' Amount: ' . $this->pdtData['mc_gross'] . ' ' . $this->pdtData['mc_currency'] . '.', 'type'=>'string'));
      $db->perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
      ipn_debug_email('PDT NOTICE :: Order added: ' . $insert_id . "\n" . 'PayPal status: ' . $this->pdtData['payment_status'] . ' ' . ' @ ' . $this->pdtData['payment_date'] . "\n" . ' Trans ID:' . $this->pdtData['txn_id'] . "\n" . ' Amount: ' . $this->pdtData['mc_gross'] . ' ' . $this->pdtData['mc_currency']);

      // store the PayPal order meta data -- used for later matching and back-end processing activities
      $sql_data_array = array('order_id' => $insert_id,
                          'txn_type' => $this->pdtData['txn_type'],
                          'module_name' => $this->code . ' ' . $this->codeVersion,
                          'module_mode' => 'PDT',
                          'reason_code' => $this->pdtData['reasoncode'],
                          'payment_type' => $this->pdtData['payment_type'],
                          'payment_status' => $this->pdtData['payment_status'],
                          'pending_reason' => $this->pdtData['pendingreason'],
                          'invoice' => $this->pdtData['invoice'],
                          'first_name' => $this->pdtData['first_name'],
                          'last_name' => $this->pdtData['last_name'],
                          'payer_business_name' => $order->billing['company'],
                          'address_name' => $order->billing['name'],
                          'address_street' => $order->billing['street_address'],
                          'address_city' => $order->billing['city'],
                          'address_state' => $order->billing['state'],
                          'address_zip' => $order->billing['postcode'],
                          'address_country' => $this->pdtData['residence_country'], // $order->billing['country']
                          'address_status' => $this->pdtData['address_status'],
                          'payer_email' => $this->pdtData['payer_email'],
                          'payer_id' => $this->pdtData['payer_id'],
                          'payer_status' => $this->pdtData['payer_status'],
                          'payment_date' => datetime_to_sql_format($this->pdtData['payment_date']),
                          'business' => $this->pdtData['business'],
                          'receiver_email' => $this->pdtData['receiver_email'],
                          'receiver_id' => $this->pdtData['receiver_id'],
                          'txn_id' => $this->pdtData['txn_id'],
                          'parent_txn_id' => $this->pdtData['parent_txn_id'],
                          'num_cart_items' => (float)$this->pdtData['num_cart_items'],
                          'mc_gross' => (float)$this->pdtData['mc_gross'],
                          'mc_fee' => (float)$this->pdtData['mc_fee'],
                          'mc_currency' => $this->pdtData['mc_currency'],
                          'settle_amount' => (float)$this->pdtData['settle_amount'],
                          'settle_currency' => $this->pdtData['settle_currency'],
                          'exchange_rate' => ($this->pdtData['exchange_rate'] > 0 ? $this->pdtData['exchange_rate'] : 1.0),
                          'notify_version' => (float)$this->pdtData['notify_version'],
                          'verify_sign' => $this->pdtData['verify_sign'],
                          'date_added' => 'now()',
                          'memo' => '{Successful PDT Confirmation - Record auto-generated by payment module}'
                         );
//TODO: $db->perform vs zen_db_perform
      zen_db_perform(TABLE_PAYPAL, $sql_data_array);
      ipn_debug_email('PDT NOTICE :: paypal table updated: ' . print_r($sql_data_array, true));
    }
  }
700601
public function completedAssessmentsData()
    {
        $timePeriod = $this->getRequestParameter('interval');

        $eventLog = $this->getServiceLocator()->get(\oat\taoEventLog\model\eventLog\LoggerService::SERVICE_ID);

        $tz = new \DateTimeZone(\common_session_SessionManager::getSession()->getTimeZone());
        $timeKeys = $this->getTimeKeys($timePeriod);
        $interval = $this->getInterval($timePeriod);

        foreach ($timeKeys as $timeKey) {
            $to = clone($timeKey);
            $from = clone($to);
            $from->sub($interval);
            $countEvents = $eventLog->count([
                ['occurred', 'between', $from->format('Y-m-d H:i:s'), $to->format('Y-m-d H:i:s')],
                ['event_name', '=', DeliveryExecutionFinished::class],
            ]);
            $result['time'][] = $to->setTimezone($tz)->format('Y-m-d H:i:s');
            $result['amount'][] = $countEvents;
        }

        $this->returnJson($result, 200);
    }
262586
public function afterDelete ()
		{
			$parent = parent::afterDelete();

			if ($this->hasAttribute('order'))
			{
				$query = self::find()->where([ '>', 'order', $this->order ]);

				$condition = $this->orderCondition();
				if ($condition !== null)
				{
					$query->andWhere($condition);
				}

				$objects = $query->all();
				foreach ($objects as $object)
				{
					$object->order -= 1;
					$object->save();
				}
			}

			return $parent;
		}
746759
public function isSuccessful()
    {
        if (null === $this->data) {
            $this->initializeReport();
        }

        return isset($this->data['report']['state']) && 'successful' === $this->data['report']['state'];
    }
565036
public function postFlush()
    {
        if (!$this->enabled || $this->isHandling) {
            return;
        }

        $this->isHandling = true;

        $aliaser = $this->container->get($this->aliaserServiceId);

        while (list($record, $action) = array_shift($this->records)) {
            $aliaser->createAlias($record, $action);
        }

        $this->isHandling = false;
    }
238163
protected function afterCreate()
    {
        parent::afterCreate();

        ProductListStore::instance()->sorting->clear(ProductListStore::SORT_NEW);
        ProductListStore::instance()->sorting->clear(ProductListStore::SORT_NO);
    }
1071607
public function process()
    {
        // Skip blank queues
        if (empty($this->batches)) {
            return true;
        }

        // Don't re-process completed queue
        if ($this->currentBatch >= count($this->batches)) {
            return true;
        }

        // Send current patch to indexes
        $this->prepareIndexes();

        // Advance to next batch if successful
        $this->setBatch($this->currentBatch + 1);
        return true;
    }
1243583
public function isSuccessful()
    {
        return $this->data->getStatus() === InvoiceInterface::STATUS_CONFIRMED || $this->data->getStatus() === InvoiceInterface::STATUS_COMPLETE;
    }
33574
public function onAfterInit()
    {
        // Suppress errors if dev/build necessary
        if (!Security::database_is_ready()) {
            return false;
        }
        $currentMember = Security::getCurrentUser();
        if (!$currentMember || !$currentMember->exists()) {
            return false;
        }

        $statusCode = $this->owner->getResponse()->getStatusCode();

        if (substr($statusCode, 0, 1) == '4') {
            $this->logPermissionDenied($statusCode, $currentMember);
        }
    }
631787
public function check()
    {
        $this->loadDatabase();

        $current = $this->getCurrentUptime();

        $this->persist($current);

        $rebooted =
            ($cs = $this->uptimeInSeconds($current)) <
            ($ss = $this->uptimeInSeconds($this->database));

        return $this->makeResult(
            ! $rebooted,
            $this->makeMessage($current, $this->database)
        );
    }
518051
public function isSuccessful()
    {
        $isHttpSuccess = parent::isSuccessful();
        $isPurchaseSuccess = false;

        if (isset($this->data['paymentStatus']) && $this->data['paymentStatus'] == $this->successfulPaymentStatus) {
            $isPurchaseSuccess = true;
        }

        return ($isHttpSuccess && $isPurchaseSuccess);
    }
5406
protected function success()
    {
        $this->cleanup();

        if (empty($this->incidents)) {
            Log::warning(
                'The collector ' . config("{$this->configBase}.collector.name") . ' did not return any incidents ' .
                'which should be investigated for collector and/or configuration errors'
            );
        }

        Log::info(
            get_class($this) . ': ' .
            'Collector run completed for collector : ' . config("{$this->configBase}.collector.name")
        );

        return [
            'errorStatus'   => false,
            'errorMessage'  => 'Data successfully collected',
            'warningCount'  => $this->warningCount,
            'data'          => $this->incidents,
        ];
    }
115495
public function check()
    {
        $this->state = self::STATE_UNCHECKED;
        
        // check all conditions
        /* @var $processor \Sokil\FraudDetector\ProcessorInterface */
        foreach($this->processorDeclarationList->getKeys() as $processorName) {
            $processor = $this->getProcessor($processorName);

            if($processor->isPassed()) {
                $processor->afterCheckPassed();
                $this->trigger(self::STATE_PASSED . ':' . $processorName);
                
                // check passed if all processors passes their cheks
                if ($this->state === self::STATE_UNCHECKED) {
                    $this->state = self::STATE_PASSED;
                }
            } else {
                $processor->afterCheckFailed();
                $this->trigger(self::STATE_FAILED . ':' . $processorName);
                // if any processor failed - all check failed
                $this->state = self::STATE_FAILED;
            }
        }

        $this->trigger($this->state);
    }
215659
protected function _afterWalk() {
        // return the pointer of a Rowset to 0
        if ($this->_result instanceof Garp_Db_Table_Rowset) {
            $this->_result->rewind();
        } else {
            // also, return results to the original format if it was no Rowset to begin with.
            $this->_result = $this->_result[0];
        }
    }
799200
public function logSuccess()
  {
    $this->_lastSuccess = true;
    if ($this->_debug) {
      printf("[LoadBalancer] Success for %s<br />\n", $this->_connectionStrings[$this->_lastReturnedIndex] . (isset($this->_storageNames[$this->_lastReturnedIndex]) ? '|' . $this->_storageNames[$this->_lastReturnedIndex] : ''));
    }
    $hash = md5($this->_connectionStrings[$this->_lastReturnedIndex] . (isset($this->_storageNames[$this->_lastReturnedIndex]) ? '|' . $this->_storageNames[$this->_lastReturnedIndex] : ''));
    if (file_exists($this->_statusFilePrefix . $hash)) {
      unlink($this->_statusFilePrefix . $hash);
    }
  }
947017
public function process()
    {
        // Generate and commit all instances
        $indexes = $this->prepareIndexes();
        foreach ($indexes as $index) {
            if (!$this->commitIndex($index)) {
                return false;
            }
        }
        return true;
    }
1123581
public function getOrderTotalAmount(){
        if (isset($this->data['OrderTotal']) && isset($this->data['OrderTotal']['Amount'])){
            return $this->data['OrderTotal']['Amount'];
        } else {
            return false;
        }
    }