Esempio n. 1
0
 public function set()
 {
     $module = $_REQUEST['module'];
     $privRoleObj = AdminPriv::getInstance();
     if ($this->isPost()) {
         if (C('TOKEN_ON') && !checkFormToken($_REQUEST)) {
             die('hack attemp.');
         }
         if ($privRoleObj->_update('module', $module, $_REQUEST['priv_roleid'])) {
             $this->assign('jumpUrl', $this->_refererUrl);
             $this->success('修改成功');
         } else {
             $this->assign('jumpUrl', $this->_refererUrl);
             $this->success('修改失败');
         }
     }
     $privs_conf = C('_privs_.Admin');
     $module_privs = $privs_conf[$module];
     $this->assign('module_privs', $module_privs);
     $this->assign('privs', $privRoleObj->getPrivs($module));
     $this->assign('module', $module);
     $sysRoles = null;
     $roleModule = D('AdminRole');
     $sysRoles = $roleModule->getAll();
     $this->assign('sysRoles', $sysRoles);
     $this->assign('ur_href', '权限管理');
     $this->assign('_hash_', buildFormToken());
     $this->display();
 }
Esempio n. 2
0
 public static function getInstance()
 {
     if (self::$_instance !== null) {
         return self::$_instance;
     }
     self::$_instance = new self();
     return self::$_instance;
 }
 public function toggleStatus()
 {
     $action = '';
     if (empty($_REQUEST['model'])) {
         $action = strtolower(trim($_REQUEST['field']));
     } else {
         $action = $_REQUEST['model'] . '_' . strtolower(trim($_REQUEST['field']));
     }
     if (!AdminPriv::checkPrive(MODULE_NAME, $action)) {
         $this->ajaxReturn('', '您没有权限进行此操作', 0);
     }
     $id = intval($_REQUEST['id']);
     if ($id == 0) {
         exit;
     }
     $val = intval($_REQUEST['val']) == 0 ? 1 : 0;
     $field = trim($_REQUEST['field']);
     if (empty($field)) {
         exit;
     }
     $name = $_REQUEST['model'] ? $_REQUEST['model'] : $this->getActionName();
     if (empty($name)) {
         exit;
     }
     $model = D($name);
     if (!$model instanceof Model) {
         $model = M($name);
         if (!$model instanceof Model) {
             exit;
         }
     }
     $pk = $_REQUEST['pk'] ? $_REQUEST['pk'] : $model->getPk();
     if (false !== $model->where($pk . ' = ' . $id)->setField($field, $val)) {
         //清空数据缓存
         clear_all_caches();
         $this->ajaxReturn('', $val, 1);
     } else {
         $this->ajaxReturn('', '操作失败', 0);
     }
 }