/** * This is what Datamanager calls to actually create a query */ function &dm2_create_callback(&$controller) { $query = new org_openpsa_reports_query_dba(); $query->component = $this->_component; if (!$query->create()) { debug_print_r('We operated on this object:', $query); throw new midcom_error("Failed to create a new project. Error: " . midcom_connection::get_error_string()); } $this->_request_data['query'] = $query; return $query; }
/** * Find all old temporary reports and clear them. */ public function _on_execute() { //Disable limits, TODO: think if this could be done in smaller chunks to save memory. midcom::get()->disable_limits(); debug_add('_on_execute called'); $days = $this->_config->get('temporary_report_max_age'); if ($days == 0) { debug_add('temporary_report_max_age evaluates to zero, aborting'); return; } $th = time() - $days * 3600 * 24; $qb = org_openpsa_reports_query_dba::new_query_builder(); $qb->add_constraint('metadata.created', '<', $th); $qb->add_constraint('orgOpenpsaObtype', '=', ORG_OPENPSA_OBTYPE_REPORT_TEMPORARY); $ret = $qb->execute_unchecked(); if ($ret === false || !is_array($ret)) { //TODO: display some error ? return false; } if (empty($ret)) { debug_add('No results, returning early.'); return; } foreach ($ret as $query) { debug_add("removing temporary query #{$query->id}"); $stat = $query->delete(); if (!$stat) { debug_add("FAILED to delete query #{$query->id}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_WARN); } } debug_add('Done'); return; }
public function testCRUD() { midcom::get('auth')->request_sudo('org.openpsa.reports'); $query = new org_openpsa_reports_query_dba(); $stat = $query->create(); $this->assertTrue($stat); $this->register_object($query); $query = new org_openpsa_reports_query_dba($query->guid); $this->assertEquals('.html', $query->extension); $this->assertEquals(ORG_OPENPSA_OBTYPE_REPORT_TEMPORARY, $query->orgOpenpsaObtype); $this->assertEquals('text/html', $query->mimetype); $this->assertEquals('unnamed', $query->title); $query->title = 'TEST'; $stat = $query->update(); $this->assertTrue($stat); $query->refresh(); $this->assertEquals('TEST', $query->title); $stat = $query->delete(); $this->assertTrue($stat); midcom::get('auth')->drop_sudo(); }
<?php $saved_reports = org_openpsa_reports_query_dba::get_saved('org.openpsa.invoices'); ?> <ul> <li> <a href="&(data['report_prefix']);"> <?php echo $data['l10n']->get('define custom report'); ?> </a> </li> <?php foreach ($saved_reports as $report) { ?> <li> <a href="&(data['report_prefix']);&(report.guid);/" target="_blank"> &(report.title); </a> <a class="actions" href="delete/&(report.guid);/"><img style="border:0px" src="<?php echo MIDCOM_STATIC_URL . '/stock-icons/16x16/trash.png'; ?> " title="<?php echo $data['l10n_midcom']->get('delete'); ?> " alt="<?php echo $data['l10n_midcom']->get('delete'); ?> "/></a> <a class="actions" href="&(data['report_prefix']);edit/&(report.guid);/"><img style="border:0px" src="<?php echo MIDCOM_STATIC_URL . '/stock-icons/16x16/edit.png';
/** * Delete the given report and redirect to front page * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete_report($handler_id, array $args, array &$data) { $report = new org_openpsa_reports_query_dba($args[0]); $report->delete(); return new midcom_response_relocate(''); }