* 当前用户 * * @var unknown */ protected $aCurrUser = null; /** * 当前城市 * * @var unknown */ protected $iCurrCityID = null; protected $aCurrCity = null; /** * 执行Action前执行 * * @see Yaf_Controller::actionBefore() */ public function actionBefore() { $this->_frame = 'admin.phtml';
/** * 更换城市 */ public function changeAction() { // 当前用户 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); if (empty($aCookie)) { return $this->redirect('/admin/login'); } $this->aCurrUser = $aCookie; $iCityID = $this->getParam('id'); $aCity = Model_City::getDetail($iCityID); if (empty($aCity) || $aCity['iBackendShow'] == 0 || $aCity['iStatus'] == 0) { return $this->showMsg('城市不存在或未开放!', false); } $aUser = Model_Admin::getDetail($this->aCurrUser['iAdminID']); $aCityID = explode(',', $aUser['sCityID']); if ($aUser['sCityID'] != '-1' && !in_array($iCityID, $aCityID)) { return $this->showMsg('您没有访问该城市的权限,请联系管理员!', false); } Util_Cookie::set('city', $iCityID); return $this->showMsg('城市切换成功!', true); }
/** * 城市修改 */ public function editAction() { if ($this->_request->isPost()) { //修改密码验证 $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie')); $iAdminID = $aCookie['iAdminID']; $aUser = Model_Admin::getDetail($iAdminID); $pwd = $this->getParam('pwd'); if (!isset($pwd) || $pwd == '') { return $this->showMsg('修改密码不可以为空', false); } if ($aUser['sEditPassword'] != md5($pwd)) { return $this->showMsg('修改密码不正确', false); } $aCity = $this->_checkData('update'); if (empty($aCity)) { return null; } $aCity['iCityID'] = intval($this->getParam('iCityID')); $aOldCity = Model_City::getDetail($aCity['iCityID']); if (empty($aOldCity)) { return $this->showMsg('城市不存在!', false); } if ($aOldCity['sCityName'] != $aCity['sCityName']) { if (Model_City::getCityByName($aCity['sCityName'])) { return $this->showMsg('城市已经存在!', false); } } if (1 == Model_City::updData($aCity)) { return $this->showMsg('城市信息更新成功!', true); } else { return $this->showMsg('城市信息更新失败!', false); } } else { $iCityID = intval($this->getParam('id')); $aCity = Model_City::getDetail($iCityID); $this->assign('aCity', $aCity); } }