/** * 删除配置 */ public function del() { $ids = array_unique((array) Util::getSafeText(I('id', 0))); $configModel = D('Config'); $res = $configModel->delConfig($ids); $this->logWriter = $this->logWriter->action(LogsModel::ACT_DELETE)->called(ltrim(__CLASS__, __NAMESPACE__) . '::' . __FUNCTION__)->exec($configModel->_sql()); if ($res) { $this->logWriter->ok(); exit(Util::response(self::__OK__, "删除成功!")); } else { $this->logWriter->fail(); exit(Util::response(self::__ERROR__3, "删除配置失败!")); } }
/** * 删除菜单分组 */ public function del() { $ids = array_unique((array) Util::getSafeText(I('id', 0))); $menuGroupModel = D('MenuGroup'); //TODO:菜单分组被使用的情况下不能删除 foreach ($ids as $id) { } $res = $menuGroupModel->delRowsInIds($ids); $this->logWriter = $this->logWriter->action(LogsModel::ACT_DELETE)->called(ltrim(__CLASS__, __NAMESPACE__) . '::' . __FUNCTION__)->exec($menuGroupModel->_sql()); if ($res) { $this->logWriter->ok(); exit(Util::response(self::__OK__, "删除成功!")); } else { $this->logWriter->fail(); exit(Util::response(self::__ERROR__3, "删除菜单分组失败!")); } }
public function picUploadHandler() { if (IS_POST) { $keys = array_keys($_FILES); $configName = $keys['0']; $upload = new Upload(); //设置附件上传大小 $upload->maxSize = 3145728; //设置附件上传类型 $upload->exts = array('jpg', 'gif', 'png', 'jpeg'); //设置附件上传根目录 $upload->rootPath = './uploads/'; $info = $upload->upload(); $logs = D('Logs')->action(LogsModel::ACT_UPDATE)->called(ltrim(__CLASS__, __NAMESPACE__) . '::' . __FUNCTION__); //上传错误提示错误信息 if (!$info) { $logs->exec(json_encode($info))->fail(); exit(Util::response(self::__ERROR__2, "上传失败!")); } else { $filePath = ltrim($upload->rootPath, '.') . $info[$configName]['savepath'] . $info[$configName]['savename']; $configModel = D('Config'); $res = $configModel->getConfigByName($configName); $res['value'] = $filePath; if ($res) { $updateRes = $configModel->saveConfig($res); if ($updateRes) { $logs->exec($configModel->_sql())->ok(); exit(Util::response(self::__OK__, "上传成功!")); } else { $logs->exec($configModel->_sql())->fail(); exit(Util::response(self::__ERROR__2, "上传失败!")); } } } } }
/** * 写入组权限 */ public function writeGroup() { if (isset($_POST['rules'])) { sort($_POST['rules']); $_POST['rules'] = implode(',', array_unique($_POST['rules'])); } $_POST['module'] = 'admin'; $_POST['type'] = AuthGroupModel::TYPE_ADMIN; $authGroupModel = M('AuthGroup'); $data = $authGroupModel->create(); if ($data) { if (empty($data['id'])) { $r = $authGroupModel->add(); } else { $r = $authGroupModel->save(); } $this->logWriter = $this->logWriter->action(LogsModel::ACT_UPDATE)->called(ltrim(__CLASS__, __NAMESPACE__) . '::' . __FUNCTION__)->exec($authGroupModel->_sql()); if ($r === false) { $this->logWriter->fail(); exit(Util::response(self::__ERROR__4, "操作失败!")); //$this->error('操作失败'.$authGroupModel->getError()); } else { $this->logWriter->ok(); exit(Util::response(self::__OK__, "操作成功!")); } } else { exit(Util::response(self::__ERROR__5, "操作失败!")); } }
/** * 删除菜单 */ public function del() { $ids = array_unique((array) Util::getSafeText(I('id', 0))); $menuModel = D('Menu'); //检查是否存在子菜单,存在子菜单则不允许删除 $hasChild = $menuModel->hasChild($ids); if ($hasChild) { exit(Util::response(self::__ERROR__4, "该菜单包含子菜单,不允许删除!")); } $res = $menuModel->delMenus($ids); $this->logWriter = $this->logWriter->action(LogsModel::ACT_DELETE)->called(ltrim(__CLASS__, __NAMESPACE__) . '::' . __FUNCTION__)->exec($menuModel->_sql()); if ($res) { $this->logWriter->ok(); exit(Util::response(self::__OK__, "删除菜单成功!")); } else { $this->logWriter->fail(); exit(Util::response(self::__ERROR__3, "删除菜单失败!")); } }
public function del() { $ids = array_unique((array) Util::getSafeText(I('id', 0))); $userAdminModel = D('Useradmin'); $res = $userAdminModel->delRowsInIds($ids); $this->logWriter = $this->logWriter->action(LogsModel::ACT_DELETE)->called(ltrim(__CLASS__, __NAMESPACE__) . '::' . __FUNCTION__)->exec($userAdminModel->_sql()); if ($res) { $this->logWriter->ok(); //$this->success('删除用户成功!'); exit(Util::response(self::__OK__, "删除用户成功!")); } else { $this->logWriter->fail(); exit(Util::response(self::__ERROR__3, "删除用户失败!")); } }
public function regedit() { if (IS_POST) { $uname = Util::getSafeText(trim(I('post.uname'))); $userpwd = Util::getSafeText(I('post.passwd')); $userrepwd = Util::getSafeText(I('post.repwd')); $group = Util::getSafeText(I('post.group')); $blocked = Util::getSafeText(I('post.blocked')) ? Util::getSafeText(I('post.blocked')) : 1; //$expirtime = Util::getSafeText(trim(I('post.expirtime'))); //$nickname = Util::getSafeText(trim(I('post.nickname'))); if (empty($uname) || empty($userpwd) || empty($userrepwd) || $userpwd !== $userrepwd) { exit(Util::response(self::__ERROR__0, "参数错误!")); } $data = array('uname' => $uname, 'passwd' => Util::genMd5Pwd($userpwd), 'blocked' => $blocked, 'createtime' => time(), 'expirtime' => time() + 100 * 12 * 30 * 24 * 3600); $userModel = D('Useradmin'); if ($userModel->where(array('uname' => $uname))->find()) { exit(Util::response(self::__ERROR__2, "用户名已存在!")); } $res = $userModel->addRow($data); if ($res) { $authGroupAccessModel = D('AuthGroupAccess'); $authGroupAccessModel->addRow(array('uid' => $res, 'group_id' => $group)); exit(Util::response(self::__OK__, "注册成功,等待管理员审核!")); } else { exit(Util::response(self::__ERROR__1, "注册失败!")); } } else { $authGroupModel = D('AuthGroup'); $groups = $authGroupModel->getAll(); $this->assign('groups', $groups); $this->assign('isEdit', false); $this->assign('addAction', U('regedit')); $this->display(); } }
/** * 提供修改用户资料功能 */ public function userinfo() { $id = $this->userId; $userModel = D('Useradmin'); if (IS_POST) { $uname = Util::getSafeText(trim(I('post.uname'))); $data = array('uname' => $uname, 'createtime' => time(), 'expirtime' => time() + 100 * 12 * 30 * 24 * 3600); $res = $userModel->updateRows($data, intval($id)); $this->logWriter = $this->logWriter->action(LogsModel::ACT_UPDATE)->called(ltrim(__CLASS__, __NAMESPACE__) . '::' . __FUNCTION__)->exec($userModel->_sql()); if ($res) { $authGroupAccessModel = D('AuthGroupAccess'); $authGroupAccessModel->updateRows(array(), array("uid" => intval($id))); $this->logWriter->ok(); exit(Util::response(self::__OK__, "修改用户信息成功!")); } else { $this->logWriter->fail(); exit(Util::response(self::__ERROR__2, "修改用户信息失败!")); } } else { $authGroupModel = D('AuthGroup'); $groups = $authGroupModel->getAll(); $this->assign('groups', $groups); $authGroupAccessModel = D('AuthGroupAccess'); $row = $authGroupAccessModel->getRow(array("uid={$id}")); $group_id = $row['group_id']; $this->assign('groupId', $group_id); $map = array("id={$id}"); $user = $userModel->getRow($map); $this->assign('user', $user); $this->assign('isEdit', true); $this->pageTitle("修改用户信息"); $this->display(); } }