<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class HiddenAction extends MemberAction
{
    public function run()
    {
        if (!Members::isHiddenLogin($this->uid()))
        {
            if (!isset($_GET['confirm']))
            {
                $message[] = '确定要隐身吗？这将收取你100'.setting('creditname');
                $message[] = ilink('确定', url('system', array('s'=>'member','a'=>'hidden','confirm'=>1))).'.'.memberLink('还是算了');
                $this->showMessage($message);
            }
            else
            {
                try
                {
                    Members::single()->hasMoney($this->uid(), 100);
                }
                catch (NotEnoughMoneyException $exce)
                {
                    $this->showMessage($exce->getMessage());
                }
                iCredits::single($this->uid(), $this->userName())->consume(100);
                Members::hiddenLogin($this->uid());
            }
        }
        else
        {
            Members::deleteHidden($this->uid());
        }

        iforward(url('system', array('s'=>'member')));
    }
}
