<?php
class UpdateAction extends BaseAction
{
    public function run()
    {
        $chapter = Chapters::model()->findByPk(Yii::app()->request->getQuery('id'));
        $chapter->content = $chapter->getContent();
        $this->getController()->performAjaxValidation($chapter);
        
        if (isset($_POST['Chapters']) && Yii::app()->request->isAjaxRequest)
        {
            $chapter->oldIsImage = $chapter->isimage;
            $chapter->attributes = $_POST['Chapters'];
            if ($chapter->save())
            {
                echo CJSON::encode(array('status'=>1));
                exit(0);
            }
        }
        
        $this->getController()->renderPartial('_ajaxupdate', array('chapter' => $chapter), false, true);
    }
}