<?php
/**
 * Created by JetBrains PhpStorm.
 * User: yzxh24
 * Date: 12-2-5
 * Time: 下午11:17
 * To change this template use File | Settings | File Templates.
 */
class AddMedalAction extends BaseAction
{
    public function run()
    {
        $uid = Yii::app()->request->getQuery('uid');
        $field = MemberData::model()->findByPk($uid);
        if (isset($_POST['medal']) && Yii::app()->request->isAjaxRequest)
        {
            $expire = strtotime(Yii::app()->request->getPost('expire'));
            $id = Yii::app()->request->getPost('medal');
            $field->medals = ($field->medals ? $field->medals . "\t" : '') . $id . '|' . $expire;
            $field->save();
            echo CJSON::encode(1);
            Yii::app()->end();
        }

        $this->getController()->renderPartial('addmedal', array(
                'fields' => $field,
            ),
            false,
            true
        );
    }
}
