/** * Find all old entries and delete them. */ public function _on_execute() { if (!$this->_config->get('delete_older')) { return; } debug_add('_on_execute called'); if (!midcom::get('auth')->request_sudo('org.openpsa.directmarketing')) { $msg = "Could not get sudo, aborting operation, see error log for details"; $this->print_error($msg); debug_add($msg, MIDCOM_LOG_ERROR); return; } $cleanup = new org_openpsa_directmarketing_cleanup(); $cleanup->delete(); midcom::get('auth')->drop_sudo(); debug_add('Done'); return; }
<?php midcom::get('auth')->require_admin_user(); ?> <h1>Clean up old contents</h1> <?php $cleanup = new org_openpsa_directmarketing_cleanup(); if (midcom_baseclasses_components_configuration::get('org.openpsa.directmarketing', 'config')->get('delete_older')) { if (isset($_POST['erase_older'])) { $cleanup->delete(); } echo "<form method=\"post\" action=\"\">\n"; echo " <input type=\"submit\" name=\"erase_older\" value=\"Clean up old entries\" />\n"; echo "</form>\n"; } else { echo "<p>Automatic cleanup disabled by configuration.</p>\n"; } // Show count $cleanups = $cleanup->count(); $cleanups_kept = $cleanup->count(true); echo "<table>\n"; echo " <thead>\n"; echo " <tr>\n"; echo " <th>Type</th>\n"; echo " <th>To clean</th>\n"; echo " <th>To keep</th>\n"; echo " </tr>\n"; echo " </thead>\n"; echo " <tbody>\n"; foreach ($cleanups as $type => $count) { echo " <tr>\n";