<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class UpdateAction extends MemberAction
{
    public function run()
    {
        $id = S::gp('id', 'G', 2);
        $myBookShelfs = $this->getBookShelfs($id);
        $shelfName = $myBookShelfs[$id];
        
        if (isset($_POST['name']))
        {
            $name = S::gp('name','P');
            if (empty($name))
            {
                throw new iSystemException('书架名不能为空');
            }
            if (6 < mb_strlen($name,'utf-8'))
            {
                throw new iSystemException('书架名不能超过6个字');
            }
    
            $myBookShelfs[$id] = $name;
            $this->db()->update(Memberfields::table())->value(array('bookshelfs'=>serialize($myBookShelfs)))->where('uid='.$this->uid())->q();
            $message[] = '书架名修改成功';
            $message[] = '返回'.ilink('进度', url('system',array('s'=>'member','c'=>'my','a'=>'progress'))).'.'.memberLink().'.'.indexLink();
            $this->showMessage($message);
        }
    
        $this->getController()->render('update',array(
                'id' => $id,
                'shelfName' => $shelfName,
            )
        );
    }
}