/** * 检查用户是否登录,如果没有登录,跳转到登录页面 * @return void */ protected function _isLogin() { if (!$this->_validLogin) { return; } if (Identity::isLogin()) { return; } $this->display(array('err_no' => ErrorNo::ERROR_NO_LOGIN, 'err_msg' => libapp\Lang::_('ERROR_MSG_ERROR_NO_LOGIN'))); }
/** * 检查用户身份授权,如果没有授权,跳转到403页面 * @return void */ protected function _isAuth() { if (!$this->_validAuth) { return; } if (!$this->_validLogin) { return; } $authoriz = Identity::getAuthoriz(); if ($authoriz->isAllowed(APP_NAME, Mvc::$module, Mvc::$controller, $this->_power)) { return; } $this->display(array('err_no' => ErrorNo::ERROR_NO_POWER, 'err_msg' => libapp\Lang::_('ERROR_MSG_ERROR_NO_POWER'))); }
/** * 调用从回收站还原数据类方法 * @param \libsrv\AbstractService $object * @param string $method * @param integer|array $id * @return array */ public function callRestoreMethod(AbstractService $object, $method, $id) { $rowCount = $object->{$method}($id); if ($rowCount === false) { $errNo = ErrorNo::ERROR_ARGS_RESTORE; $errMsg = Lang::_('ERROR_MSG_ERROR_DB_RESTORE'); Log::warning(sprintf('%s callRestoreMethod, service "%s", method "%s", id "%s"', $errMsg, get_class($object), $method, is_array($id) ? serialize($id) : $id), $errNo, __METHOD__); return array('err_no' => $errNo, 'err_msg' => $errMsg, 'id' => $id); } $errNo = ErrorNo::SUCCESS_NUM; $errMsg = $rowCount > 0 ? Lang::_('ERROR_MSG_SUCCESS_RESTORE') : Lang::_('ERROR_MSG_ERROR_DB_AFFECTS_ZERO'); Log::debug(sprintf('%s callRestoreMethod, service "%s", method "%s", id "%s", rowCount "%d"', $errMsg, get_class($object), $method, is_array($id) ? serialize($id) : $id, $rowCount), $errNo, __METHOD__); return array('err_no' => $errNo, 'err_msg' => $errMsg, 'id' => $id, 'row_count' => $rowCount); }
/** * 操作会员账户 * @param string $columnName * @param string $opType * @param integer $memberId * @param integer|float $value */ public function opAccount($columnName, $opType, $memberId, $value) { $funcName = 'op' . ucfirst(strtolower($columnName)); $ret = $this->getService()->{$funcName}($opType, $memberId, $value, DataMembers::SOURCE_ADMINOP, '', Identity::getUserId()); if ($ret) { $errNo = ErrorNo::SUCCESS_NUM; $errMsg = Lang::_('ERROR_MSG_SUCCESS_UPDATE'); } else { $errNo = ErrorNo::ERROR_DB_UPDATE; $errMsg = Lang::_('ERROR_MSG_ERROR_DB_UPDATE'); } return array('err_no' => $errNo, 'err_msg' => $errMsg); }
/** * 批量编辑排序 * @param array $params * @return integer */ public function batchModifySort(array $params = array()) { $rowCount = $this->getService()->batchModifySort($params); $errNo = ErrorNo::SUCCESS_NUM; $errMsg = $rowCount > 0 ? Lang::_('ERROR_MSG_SUCCESS_UPDATE') : Lang::_('ERROR_MSG_ERROR_DB_AFFECTS_ZERO'); Log::debug(sprintf('%s callModifyMethod, service "%s", method "%s", rowCount "%d", params "%s"', $errMsg, get_class($this), 'batchModifySort', $rowCount, serialize($params)), $errNo, __METHOD__); return array('err_no' => $errNo, 'err_msg' => $errMsg, 'row_count' => $rowCount); }