<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 高级评论列表处操作链接
 *
 * @author yzxh24
 */
Yii::import('zii.widgets.grid.CButtonColumn');
class BookReplyList extends CButtonColumn
{
    public $header;

    public $buttons = array(
        'delete' => array(
            'label' => '删除',
            'url' => 'Yii::app()->controller->createUrl("/admin/bookpostreply/delete",array("id"=>$data->id))',
            'type' => 'raw',
        ),
        'punish' => array(
            'label' => '处罚',
            'url' => 'Yii::app()->controller->createUrl("/admin/bookpostreply/punish",array("id"=>$data->id))',
            'type' => 'raw',
            'visible' => '$data->ispunish == 0',
        ),
    );

    protected function initDefaultButtons()
    {
        // nothing to do
        $confirmation="if(!confirm(".CJavaScript::encode(Yii::t('zii','确定要处罚?')).")) return false;";
        $this->buttons['punish']['click']=<<<EOD
function() {
	$confirmation
	$.fn.yiiGridView.update('{$this->grid->id}', {
		type:'POST',
		url:$(this).attr('href'),
		success:function() {
			$.fn.yiiGridView.update('{$this->grid->id}');
		}
	});
	return false;
}
EOD;

        $confirmation="if(!confirm(".CJavaScript::encode(Yii::t('zii','确定要删除?')).")) return false;";
        $this->buttons['delete']['click']=<<<EOD
function() {
	$confirmation
	$.fn.yiiGridView.update('{$this->grid->id}', {
		type:'POST',
		url:$(this).attr('href'),$csrf
		success:function() {
			$.fn.yiiGridView.update('{$this->grid->id}');
		}
	});
	return false;
}
EOD;
    }
}