/** * remove_modules */ function remove_modules($mode, $sub) { global $db, $user, $phpbb_root_path, $phpEx; if (!class_exists('acp_modules')) { require $phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx; } $_module = new acp_modules(); // Set the module class $module_classes = array_keys($this->module_categories); $_module->u_action = "phpbb_seo_install.{$phpEx}"; $cat_module_data = array(); $module_data = array(); $delete_module_data = array(); foreach ($module_classes as $module_class) { $_module->module_class = $module_class; foreach ($this->module_categories[$module_class] as $cat_name => $subs) { // If the cat is already uninstalled break for now if ($this->get_module_id($cat_name) < 1) { $url_mod = !empty($this->sub) ? '?mode=' . $this->mode : ''; $this->p_master->error(sprintf($user->lang['SEO_ERROR_UNINSTALLED'], $user->lang[$cat_name]) . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->p_master->module_url . $url_mod . '">', '</a>'), '', '', false, $user->lang['SEO_ERROR_INFO']); } $cat_module_data[$cat_name] = array('module_id' => $this->check_module_id($cat_name), 'module_basename' => '', 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => 0, 'module_class' => $module_class, 'module_langname' => $cat_name, 'module_mode' => '', 'module_auth' => ''); if (is_array($subs)) { foreach ($subs as $sub_cat) { $sub_cat_module_data[$sub_cat] = array('module_id' => $this->check_module_id($sub_cat), 'module_basename' => '', 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => (int) $cat_module_data[$cat_name]['module_id'], 'module_class' => $module_class, 'module_langname' => $sub_cat, 'module_mode' => '', 'module_auth' => ''); $branch = $_module->get_module_branch($sub_cat_module_data[$sub_cat]['module_id'], 'children', 'descending', false); if (sizeof($branch)) { foreach ($branch as $module) { $error = $_module->delete_module($module['module_id']); if (!sizeof($error)) { $_module->remove_cache_file(); $delete_module_data[$module['module_id']] = $module['module_langname'] . ' - id : ' . $module['module_id']; } else { $this->errors[] = implode(' ', $error); } } // End modules } if (!sizeof($this->errors)) { $error = $_module->delete_module($sub_cat_module_data[$sub_cat]['module_id']); if (!sizeof($error)) { $_module->remove_cache_file(); $delete_module_data[$sub_cat_module_data[$sub_cat]['module_id']] = $sub_cat_module_data[$sub_cat]['module_langname'] . ' - id : ' . $sub_cat_module_data[$sub_cat]['module_id']; } else { $this->errors[] = implode(' ', $error); } } } } // End sub categories if (!sizeof($this->errors)) { $branch = $_module->get_module_branch($cat_module_data[$cat_name]['module_id'], 'children', 'descending', false); if (empty($branch)) { $error = $_module->delete_module($cat_module_data[$cat_name]['module_id']); } if (!sizeof($error)) { $_module->remove_cache_file(); $delete_module_data[$cat_module_data[$cat_name]['module_id']] = $cat_module_data[$cat_name]['module_langname'] . ' - id : ' . $cat_module_data[$cat_name]['module_id']; } else { $this->errors[] = implode(' ', $error); } } } // End categories } // End classes return; }
/** * Delete ALL phpBB Garage Data */ function delete_garage_data($mode, $sub) { global $cache, $db, $phpbb_root_path, $phpEx, $table_prefix, $lang, $template; $this->page_title = $lang['STAGE_OPTIONAL']; //Setup $auth_admin class so we can remove permission options include $phpbb_root_path . '/includes/acp/auth.' . $phpEx; include $phpbb_root_path . '/includes/acp/acp_modules.' . $phpEx; $auth_admin = new auth_admin(); $module_admin = new acp_modules(); // lets get rid of phpBB Garage internal data first foreach ($this->garage_tables as $table) { $db->sql_query('DROP TABLE ' . $table_prefix . $table); } // lets get rid of phpBB Garage internal data first if ($db->sql_layer == 'postgres') { foreach ($this->garage_postgres_sequences as $sequence) { $db->sql_query('DROP SEQUENCE ' . $table_prefix . $sequence); } } // next for the chop is permisions we added foreach ($this->garage_permissions as $permission) { // get auth option id so we can remove it from any user, group or role $sql = $db->sql_build_query('SELECT', array('SELECT' => 'acl.auth_option_id', 'FROM' => array(ACL_OPTIONS_TABLE => 'acl'), 'WHERE' => "acl.auth_option = '{$permission}'")); $result = $db->sql_query($sql); $auth_option_id = (int) $db->sql_fetchfield('auth_option_id'); $db->sql_freeresult($result); // remove option from user $db->sql_query('DELETE FROM ' . ACL_USERS_TABLE . " WHERE auth_option_id = " . $auth_option_id); // remove option from group $db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . " WHERE auth_option_id = " . $auth_option_id); // remove option from role $db->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . " WHERE auth_option_id = " . $auth_option_id); // remove option itself now $db->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . " WHERE auth_option_id = " . $auth_option_id); } // next for the chop is imageset data we added foreach ($this->garage_imageset as $image_name) { $db->sql_query('DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_name = '" . $image_name . "'"); } // clear permissions cache now we have handled them all $cache->destroy('_acl_options'); $auth_admin->acl_clear_prefetch(); // next into the slaughter house is modules we added foreach ($this->garage_modules as $module_name => $module_class) { // get module id so we can remove it $sql = $db->sql_build_query('SELECT', array('SELECT' => 'm.*', 'FROM' => array(MODULES_TABLE => 'm'), 'WHERE' => "m.module_langname = '{$module_name}'\n\t\t\t\t\t\t\tAND m.module_class = '{$module_class}'")); // module may have been installed in multiple places per class ... delete them all $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $module_id = (int) $row['module_id']; $branch = $module_admin->get_module_branch($module_id, 'children', 'descending', false); if (sizeof($branch)) { return array($user->lang['CANNOT_REMOVE_MODULE']); } // If not move $diff = 2; $sql = 'DELETE FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\t\tAND module_id = {$module_id}"; $db->sql_query($sql); $row['right_id'] = (int) $row['right_id']; $row['left_id'] = (int) $row['left_id']; // Resync tree $sql = 'UPDATE ' . MODULES_TABLE . "\n\t\t\t\t\tSET right_id = right_id - {$diff}\n\t\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\t\tAND left_id < {$row['right_id']} AND right_id > {$row['right_id']}"; $db->sql_query($sql); $sql = 'UPDATE ' . MODULES_TABLE . "\n\t\t\t\t\tSET left_id = left_id - {$diff}, right_id = right_id - {$diff}\n\t\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\t\tAND left_id > {$row['right_id']}"; $db->sql_query($sql); } $db->sql_freeresult($result); } // module categories ... be no more foreach ($this->garage_module_categories as $module_category => $module_class) { // get module id so we can remove it $sql = $db->sql_build_query('SELECT', array('SELECT' => 'm.*', 'FROM' => array(MODULES_TABLE => 'm'), 'WHERE' => "m.module_langname = '{$module_category}'\n\t\t\t\t\t\t\tAND m.module_class = '{$module_class}'")); // we can only delete the categories we created... $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $module_id = (int) $row['module_id']; $branch = $module_admin->get_module_branch($module_id, 'children', 'descending', false); if (sizeof($branch)) { return array($user->lang['CANNOT_REMOVE_MODULE']); } // If not move $diff = 2; $sql = 'DELETE FROM ' . MODULES_TABLE . "\n\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\tAND module_id = {$module_id}"; $db->sql_query($sql); $row['right_id'] = (int) $row['right_id']; $row['left_id'] = (int) $row['left_id']; // Resync tree $sql = 'UPDATE ' . MODULES_TABLE . "\n\t\t\t\tSET right_id = right_id - {$diff}\n\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\tAND left_id < {$row['right_id']} AND right_id > {$row['right_id']}"; $db->sql_query($sql); $sql = 'UPDATE ' . MODULES_TABLE . "\n\t\t\t\tSET left_id = left_id - {$diff}, right_id = right_id - {$diff}\n\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\tAND left_id > {$row['right_id']}"; $db->sql_query($sql); } // clear module cache now we have handled them all $module_admin->remove_cache_file(); // and finally step forward data in $config foreach ($this->config_data as $config_data) { $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = '{$config_data}'"); } $submit = $lang['NEXT_STEP']; $url = $this->p_master->module_url . "?mode={$mode}&sub=file_check"; $template->assign_vars(array('BODY' => $lang['STAGE_DATA_EXPLAIN'], 'L_SUBMIT' => $submit, 'U_ACTION' => $url)); }