<?php
require_once 'Zend/Controller/Action.php';

class Manage_UninstallController extends Zend_Controller_Action
{
    public function preDispatch()
    {
        global $Me;
        if ($Me->isAdmin() == false) {
            $this->_redirect('/Manage/Login/');
        }
    }
    
    public function indexAction()
    {
        $this->uninstallAction();
    }
    
    /**
     * アンインストール
     */
    public function uninstallAction()
    {
        global $db;
        
        $sql[] = 'DROP TABLE Platy_Config';
        $sql[] = 'DROP TABLE Platy_ContentType';
        $sql[] = 'DROP TABLE Platy_Content_Node';
        $sql[] = 'DROP TABLE Platy_Content_Base';
        $sql[] = 'DROP TABLE Platy_Content_Base_Rev';
        $sql[] = 'DROP TABLE Platy_Module';
        $sql[] = 'DROP TABLE Platy_CVar';
        $sql[] = 'DROP TABLE Platy_CExt';
        $sql[] = 'DROP TABLE Platy_Widget';
        $sql[] = 'DROP TABLE Platy_Sidebar';
        $sql[] = 'DROP TABLE Platy_Member';
        $sql[] = 'DROP TABLE Platy_Member_Profile';
        $sql[] = 'DROP TABLE Platy_ACL_Role';
        $sql[] = 'DROP TABLE Platy_ACL_Member_to_Role';
        $sql[] = 'DROP TABLE Platy_ACL_Privilege';
        $sql[] = 'DROP TABLE Platy_ACL_Role_to_Privilege';
        $sql[] = 'DROP TABLE Platy_Menu';
        for ($i = 0; $i < count($sql); $i++) {
            $result = $db->query($sql[$i]);
        }
    }
    
    public function noRouteAction()
    {
        //$this->_redirect('/');
        echo "noRouteAction";
    }
}
?>