<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class EditAction extends ForumAction
{
    public function run()
    {
        $this->isManager();
        
        if (isset($_POST['forumname']))
     	{
     		$forumname = S::gp('forumname','P');
     		if (mb_strlen($forumname, 'utf-8') < 3 || mb_strlen($forumname,'utf-8') > 20)
     		{
     			throw new iSystemException('书会名长度不能小于3或者大于20个字');
     		}
     		$this->db()->update(BookForum::table())->value(array('forumname'=>$forumname))->where(array('bookid'=>$this->id()))->q();
     		updateBookForum($this->id());
     		
            $logData = array(
                'uid' => 0,
                'ouid' => $this->uid(),
                'bookid' => $this->id(),
                'type' => 'EditName',
                'message' => '[uid='.$this->uid().']将书会改名成《'.$forumname.'》',
            );
            BookManageLog::single()->create($logData);
            
     		$message[] = '书会名称更新成功';
     		$message[] = '返回'.ilink('管理',url('system',array('s'=>'forum','c'=>'manage','id'=>$this->id()))).'.'.forumLink($this->id());
     		$this->showMessage($message);
     	}
        $this->getController()->render('edit', array(
                'bookid' => $this->id(),
                'forumInfo' => $this->forumInfo()
            )
        );
    }
}