/** * viewlist - Shows a list of audit trail records from the current date (by default). * Can browse around records from different dates using the form * at the top of the page. * * @return void **/ function viewlist($parameter) { include_once 'n_date.php'; include_once 'n_quickform.php'; require_once 'HTML/QuickForm/Renderer/Array.php'; $this->_auth = new NAuth(); $this->auto_render = false; // set up the search form $form = new NQuickForm('audit_search', 'get'); if ($date_params = $this->getParam('date')) { $date = $this->dateStartEnd($date_params); } else { $date = $this->dateStartEnd(); } $el =& $form->addElement('date', 'date', 'Date', array('addEmptyOption' => true, 'format' => 'F d Y', 'maxYear' => 2015)); $el->setValue($date['used']); $form->addElement('submit', null, 'Search'); $renderer = new HTML_QuickForm_Renderer_Array(true, true); $form->accept($renderer); $this->set('audit_search', $renderer->toArray()); $model =& $this->getDefaultModel(); if ($model->find(array('conditions' => 'cms_created BETWEEN ' . $model->quote($date['start']) . ' AND ' . $model->quote($date['end']), 'order_by' => 'cms_created DESC'))) { $html = ''; if ($date['month']) { $html .= "<p>Showing Monthly Results for: " . date("F, Y", strtotime($date['used'])); } while ($model->fetch()) { // Actually turn the id's into something readable. $info = $this->humanizeAuditTrailRecord($model); $this->set($info); $html .= $this->render(array('action' => 'audit_trail_record', 'return' => true)); } $this->set('audit_trail', $html); $this->set('result_count', $model->numRows()); } else { $this->set('result_count', 'no'); $this->set('audit_trail', '<p>There were no results found for the specified date.</p>'); } // Exposes an RSS feed link to Admin or higher users. if (defined('RSS_AUDIT_TRAIL') && RSS_AUDIT_TRAIL) { NDebug::debug('We are checking to see if we can display the RSS feed.', N_DEBUGTYPE_INFO); $this->checkRSSFeed(); } $this->set('date', $date['used']); $this->loadSubnav($parameter); $this->render(array('layout' => 'default')); }