<?php

class Inbox_CountsController extends Inbox_Controller_Base
{
    public function init()
    {
        parent::init();
    }

    public function getAction()
    {
        $id = $this->_getParam('id', 0);

        if($id == 0)
        {
            $this->preconditionFailed();
            return;
        }

        try
        {
            $sql = "SELECT accountName as name, unreadMail as unseen_count from ui_account where userId=:id";
            $stmt = $this->_dbAdapter->prepare($sql);
            $stmt->bindParam("id", $id);
            $stmt->execute();
            $result = $stmt->fetchAll();
            $this->renderJson($result);
        }
        catch (Exception $e)
        {
            $this->renderJson(array('error' => array('text' => $e->getMessage())));
        }
    }

    public function indexAction()
    {
        $this->methodNotAllowed();
    }

    public function postAction()
    {
        $this->methodNotAllowed();
    }

    public function putAction()
    {
        $this->methodNotAllowed();
    }

    public function deleteAction()
    {
        $this->methodNotAllowed();
    }
}
