<?php
/**
 * プライバシーポリシー モジュールの管理
 */
require_once 'Zend/Controller/Action.php';

class Manage_PrivacyController extends Zend_Controller_Action
{
    public function preDispatch()
    {
        global $Me;
        if ($Me->isAdmin() == false) {
            $this->_redirect('/Manage/Login/');
        }
    }
    
    public function indexAction()
    {
        $this->configAction();
    }
    
    public function configAction()
    {
        global $db, $config;
        
        ob_start();
        
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $main = h($_POST['main']);
            $sql = "UPDATE Platy_Config SET value='{$main}' WHERE name='M_PRIVACY_MAIN'";
            echo $sql;
            $db->query($sql);
        }
        else {
            $main = $config['M_PRIVACY_MAIN'];
        }
        
        echo '<form method="post" action="">' . "\n";
        echo '<textarea name="main" cols="60" rows="12">' . "\n";
        echo $main;
        echo '</textarea>' . "<br />\n";
        echo '<input type="submit" />' . "\n";
        echo '</form>' . "\n";
        
        $contents = ob_get_contents();
        ob_end_clean();
        
        Zend_Loader::loadClass('Zend_View');
        $view = new Zend_View();
        $view->setScriptPath(APP_PATH . 'Manage/views');
        $view->contents = $contents;
        echo $view->render('page.php');
    }
    
    public function noRouteAction()
    {
        //$this->_redirect('/');
        echo "noRouteAction";
    }
    
    /**
     * インストール
     */
    public function installAction()
    {
        global $db;
        
        $sql[] = "INSERT INTO Platy_Config(name,value) VALUES('CONTACT_HEADER', '');";
        $sql[] = "INSERT INTO Platy_Config(name,value) VALUES('CONTACT_ADMIN_EMAIL', '');";
        for ($i = 0; $i < count($sql); $i++) {
        }
        return TRUE;
    }
    
    /**
     * アンインストール
     */
    public function uninstallAction()
    {
        global $db;
        
        $sql[] = "DELETE FROM Platy_Config WHERE name='CONTACT_HEADER';";
        $sql[] = "DELETE FROM Platy_Config WHERE name='CONTACT_ADMIN_EMAIL';";
        for ($i = 0; $i < count($sql); $i++) {
        }
        return TRUE;
    }
}
?>