예제 #1
0
    /**
     * Delete module
     *
     * @param int|string $id Module ID of the acp_portal module
     * @param string $mode Mode of the acp_portal module
     * @param string $action Current action of the acp_portal module
     * @param int $module_id ID of the module that should be deleted
     */
    public function module_delete($id, $mode, $action, $module_id)
    {
        $module_data = $this->get_move_module_data($module_id);
        if ($module_data !== false) {
            $module_classname = $this->request->variable('module_classname', '');
            $this->get_module($module_data['module_classname']);
            if (confirm_box(true)) {
                $this->module->uninstall($module_data['module_id'], $this->db);
                $sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE . '
					WHERE module_id = ' . (int) $module_id;
                $this->db->sql_query($sql);
                $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
					SET module_order = module_order - 1
					WHERE module_column = ' . (int) $module_data['module_column'] . '
						AND module_order > ' . (int) $module_data['module_order'];
                $this->db->sql_query($sql);
                $this->cache->purge();
                // make sure we don't get errors after re-adding a module
                // Handle ajax request
                $this->handle_ajax_request(array('success' => true, 'MESSAGE_TITLE' => $this->user->lang['INFORMATION'], 'MESSAGE_TEXT' => $this->user->lang['SUCCESS_DELETE']));
                trigger_error($this->user->lang['SUCCESS_DELETE'] . adm_back_link($this->u_action));
            } else {
                if ($this->module->get_language()) {
                    $this->controller_helper->load_module_language($this->module);
                }
                $confirm_text = isset($this->user->lang[$module_data['module_name']]) ? sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], $this->user->lang[$module_data['module_name']]) : sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], utf8_normalize_nfc($module_data['module_name']));
                confirm_box(false, $confirm_text, build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action, 'module_id' => $module_id, 'module_classname' => $module_classname)));
            }
        }
        $this->cache->destroy('sql', PORTAL_MODULES_TABLE);
    }