<?php
/**
 * 链接管理模块
 * @copyright reginx.com
 * $Id$
 */
class link_mod extends admin_mod{

    /**
     * 列表页
     */
    public function listAct(){
        if($this->has('link', 'P')){
            $obj = core::getobj('link_tab');
            if($obj->load('link')){
                $ret = $obj->save();
                if(intval($ret['code']) === 0){
                    $this->showmsg('操作成功', NULL, 1, 1);
                }
            }
            $this->showmsg($obj->geterr(), -1, 1, 1);
        }
        $this->assign('list', core::getobj('link_tab')->order("id desc")->getall());
        $this->assign('atitle', '链接列表');
        $this->display('misc/link.html');
    }

    /**
     * 删除
     */
    public function delAct(){
        $id = intval($this->get('id'));
        if($id > 0){
            $row = core::getobj('link_tab')->where("id = $id ")->get();
            if(!empty($row)){
                if(file_exists(UPLOAD_PATH . $row['logo'])){
                    unlink(UPLOAD_PATH . $row['logo']);
                }
                $thumb = core::thumburl($row['logo']);
                if(file_exists(UPLOAD_PATH . $thumb)){
                    unlink(UPLOAD_PATH . $thumb);
                }
                core::getobj('link_tab')->where("id = $id ")->del();
                $this->showmsg('删除成功', null, 1, 1);
            }
        }
    }
}
?>