<?php
/**
 * Testモジュール
 */
require_once 'Zend/Controller/Action.php';

class Manage_TestController extends Zend_Controller_Action
{
    public function preDispatch()
    {
        global $Me;
        if ($Me->isAdmin() == false) {
            $this->_redirect('/Manage/Login/');
        }
    }
    
    public function indexAction()
    {
        $this->dateAction();
    }
    
    public function noRouteAction()
    {
        //$this->_redirect('/');
        echo "noRouteAction";
    }
    
    public function dateAction()
    {
        global $db, $config;
        
        ob_start();
        
        echo '<form name="f" method="post" action="">' . "\n";
        echo 'startDate:<input type="text" name="startDate" size="30" value="" />';
        echo '<input type="button" value="..." onclick="dateinput(this.form.startDate)" /><br />';
        
        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('test.php');
    }
    
    public function quoteTestAction()
    {
        global $db;
        
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            echo "raw=" . $_POST['t1'] . "<br />\n";
            echo "h=" . h($_POST['t1']) . "<br />\n";
            echo "zf:quote=" . $db->quote($_POST['t1']) . "<br />\n";
            echo "zf:quote= h" . $db->quote(h($_POST['t1'])) . "<br />\n";
            echo "zf:quote^2=" . $db->quote($db->quote($_POST['t1'])) . "<br />\n";
        }
        else {
        }
        echo '<form method="post">' . "\n";
        echo '<input type="text" name="t1" value="" size="60" />' . "<br />\n";
        echo '<input type="submit" />' . "<br />\n";
        echo '</form>' . "\n";
    }
    
    public function roleTestAction()
    {
        global $db, $Me;
        
        if ($Me->isAllowed('Access_Backend')) {
        }
        //var_dump($Me);
        var_dump($Me->privilege);
        $sql = "SELECT memberId, roleId FROM Platy_ACL_Member_to_Role";
        $rows = $db->fetchAll($sql);
        echo "<br />---<br />\n";
        var_dump($rows);
    }
    
    /**
     * OpenID Test
     */
    public function OpenIDTestAction()
    {
    }
}
?>