Exemplo n.º 1
0
 function onProcessList(&$resultArray)
 {
     parent::onProcessList($resultArray);
     // Don't process an empty list
     if (empty($resultArray)) {
         return;
     }
     // Get the scan_id's and initialise the special fields
     $scanids = array();
     $map = array();
     foreach ($resultArray as $index => &$row) {
         $scanids[] = $row->id;
         $map[$row->id] = $index;
         $row->files_new = 0;
         $row->files_modified = 0;
     }
     // Fetch the stats for the IDs at hand
     $ids = implode(',', $scanids);
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select(array($db->quoteName('scan_id'), '(' . $db->quoteName('diff') . ' = ' . $db->quote('') . ') AS ' . $db->quoteName('newfile'), 'COUNT(*) AS ' . $db->quoteName('count')))->from($db->quoteName('#__admintools_scanalerts'))->where($db->quoteName('scan_id') . ' IN (' . $ids . ')')->group(array($db->quoteName('scan_id'), $db->quoteName('newfile')));
     $db->setQuery($query);
     $alertstats = $db->loadObjectList();
     $query = $db->getQuery(true)->select(array($db->quoteName('scan_id'), 'COUNT(*) AS ' . $db->quoteName('count')))->from($db->quoteName('#__admintools_scanalerts'))->where($db->quoteName('scan_id') . ' IN (' . $ids . ')')->where('(' . $db->quoteName('threat_score') . ' > ' . $db->quote('0') . ')')->group(array($db->quoteName('scan_id')));
     $db->setQuery($query);
     $suspiciousstats = $db->loadObjectList();
     // Update the $resultArray with the loaded stats
     if (!empty($alertstats)) {
         foreach ($alertstats as $stat) {
             $idx = $map[$stat->scan_id];
             if ($stat->newfile) {
                 $resultArray[$idx]->files_new = $stat->count;
             } else {
                 $resultArray[$idx]->files_modified = $stat->count;
             }
         }
     }
     if (!empty($suspiciousstats)) {
         foreach ($suspiciousstats as $stat) {
             $idx = $map[$stat->scan_id];
             $resultArray[$idx]->files_suspicious = $stat->count;
         }
     }
 }