protected function action_uninstall_confirmed($ids, $delete_files)
{
global $user, $phpbb_log;
$default = $this->default_style;
$uninstalled = array();
$messages = array();
// Check styles list
foreach ($ids as $id) {
if (!$id) {
trigger_error($this->user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($id == $default) {
trigger_error($this->user->lang['UNINSTALL_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$uninstalled[$id] = false;
}
// Order by reversed style_id, so parent styles would be removed after child styles
// This way parent and child styles can be removed in same function call
$sql = 'SELECT *
FROM ' . STYLES_TABLE . '
WHERE style_id IN (' . implode(', ', $ids) . ')
ORDER BY style_id DESC';
$result = $this->db->sql_query($sql);
$rows = $this->db->sql_fetchrowset($result);
$this->db->sql_freeresult($result);
// Uinstall each style
$uninstalled = array();
foreach ($rows as $style) {
$result = $this->uninstall_style($style, $delete_files);
if (is_string($result)) {
$messages[] = $result;
continue;
}
$messages[] = sprintf($this->user->lang['STYLE_UNINSTALLED'], $style['style_name']);
$uninstalled[] = $style['style_name'];
// Attempt to delete files
if ($delete_files) {
$messages[] = sprintf($this->user->lang[$this->delete_style_files($style['style_path']) ? 'DELETE_STYLE_FILES_SUCCESS' : 'DELETE_STYLE_FILES_FAILED'], $style['style_name']);
}
}
if (empty($messages)) {
// Nothing to uninstall?
trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Log action
if (count($uninstalled)) {
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_STYLE_DELETE', false, array(implode(', ', $uninstalled)));
}
// Clear cache
$this->cache->purge();
// Show message
trigger_error(implode('<br />', $messages) . adm_back_link($this->u_action), E_USER_NOTICE);
}