<?php
// ÊÕ²ØÄ£¿é¿ØÖÆÆ÷
class CollectAction extends Action {
	protected function _initialize() {
		$this -> obj = M('collect');
	}
	public function defaults() {
		$this -> display('member_collect');
	}
	public function add() {
		if (M('member') -> isLogin()) {
			$favorite = $this -> obj -> save();
			$response = $favorite?array('1', iconv(C('APP_CHARSET', 1), 'utf-8', L('OPERATE_SUCCESS')), $favorite):array('0', iconv(C('APP_CHARSET', 1), 'utf-8', $this -> obj -> error), '');
		} else $response = array('0', iconv(C('APP_CHARSET', 1), 'utf-8', L('LOGIN_FIRST')), Url :: getUrl('member', 'login', urlencode($this -> referer)));
		exit(json_encode($response));
	}
	public function del() {
		if ($this -> obj -> del()) $this -> showMsg(L('OPERATE_SUCCESS'), $this -> referer);
		else $this -> showMsg($this -> error);
	}
}