public function read() { if (!isset($this->params['type'])) { $this->error(ECode::$REFER_NONE); } if (!isset($this->params['url']['index'])) { $this->error(ECode::$REFER_NONE); } $type = $this->params['type']; try { $refer = new Refer(User::getInstance(), $type); } catch (ReferNullException $e) { $this->error(ECode::$REFER_NONE); } if ('all' == $this->params['url']['index']) { $refer->setRead(); $this->redirect($this->_mbase . "/refer/" . $type); } else { $index = intval($this->params['url']['index']); $r = $refer->getRefer($index); if (null !== $r) { $refer->setRead($index); $this->redirect("{$this->_mbase}/article/{$r['BOARD']}/single/{$r['ID']}/0"); } else { $this->redirect($this->_mbase . "/single/" . $type); } } }
public function ajax_read() { if (!$this->RequestHandler->isPost()) { $this->error(ECode::$SYS_REQUESTERROR); } if (!isset($this->params['type'])) { $this->error(ECode::$REFER_NONE); } if (!isset($this->params['form']['index'])) { $this->error(ECode::$REFER_NONE); } $type = $this->params['type']; try { $refer = new Refer(User::getInstance(), $type); } catch (ReferNullException $e) { $this->error(ECode::$REFER_NONE); } if ('all' == $this->params['form']['index']) { $refer->setRead(); } else { $refer->setRead(intval($this->params['form']['index'])); } }
public function setRead() { if (!$this->RequestHandler->isPost()) { $this->error(ECode::$SYS_REQUESTERROR); } if (!isset($this->params['type'])) { $this->error(ECode::$REFER_NONE); } $type = $this->params['type']; try { $refer = new Refer(User::getInstance(), $type); } catch (ReferNullException $e) { $this->error(ECode::$REFER_NONE); } if (!isset($this->params['index'])) { $refer->setRead(); $this->set('data', array('status' => true)); } else { $wrapper = Wrapper::getInstance(); $index = intval($this->params['index']); $refer->setRead($index); $this->set('data', $wrapper->refer($refer->getRefer($index))); } }