<?php
/**
 * Created by JetBrains PhpStorm.
 * User: yzxh24
 * Date: 12-2-3
 * Time: 下午4:36
 * To change this template use File | Settings | File Templates.
 */
class PasswordAction extends BaseAction
{
    public function run()
    {
        $uid = Yii::app()->request->getQuery('uid');
        $member = Member::model()->findByPk($uid);

        $this->performAjaxValidation($member, 'upassword');

        if (isset($_POST['Member']) && Yii::app()->request->isAjaxRequest)
        {
            $member->password = md5($_POST['Member']['password']);
            if ($member->save())
            {
                $iorange = Front::getNewIorange();
                $member->iorange = $iorange;
                $member->save();
                echo CJSON::encode(1);
            }
            Yii::app()->end();
        }

        $this->getController()->renderPartial('password', array('member'=>$member), false, true);
    }
}