| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- // +----------------------------------------------------------------------
- // | Fanwe 方维直播系统
- // +----------------------------------------------------------------------
- // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Author: 云淡风轻(1956838968@qq.com)
- // +----------------------------------------------------------------------
- class RoleTrashAction extends CommonAction{
- public function trash()
- {
- if(intval($_REQUEST['action_id'])!='')
- {
- $action_id= intval($_REQUEST['action_id']);
- }
- $this->assign('action_id',$action_id);
- $condition['is_delete'] = 1;
- $this->assign("default_map",$condition);
- $map = $this->_search ();
- //追加默认参数
- if($this->get("default_map"))
- $map = array_merge($map,$this->get("default_map"));
- if (method_exists ( $this, '_filter' )) {
- $this->_filter ( $map );
- }
- $name="Role";
- $model = D ($name);
- if (! empty ( $model )) {
- $this->_list ( $model, $map );
- }
- $this->display ();
- return;
- }
- //相关操作
- public function set_effect()
- {
- $id = intval($_REQUEST['id']);
- $ajax = intval($_REQUEST['ajax']);
- $info = M("Role")->where("id=".$id)->getField("name");
- $c_is_effect = M("Role")->where("id=".$id)->getField("is_effect"); //当前状态
- $n_is_effect = $c_is_effect == 0 ? 1 : 0; //需设置的状态
- M("Role")->where("id=".$id)->setField("is_effect",$n_is_effect);
- save_log($info.l("SET_EFFECT_".$n_is_effect),1);
- $this->ajaxReturn($n_is_effect,l("SET_EFFECT_".$n_is_effect),1) ;
- }
- public function delete() {
- //删除指定记录
- $ajax = intval($_REQUEST['ajax']);
- $id = $_REQUEST ['id'];
- if (isset ( $id )) {
- $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
- $rel_data = M("Role")->where($condition)->findAll();
- foreach($rel_data as $data)
- {
- $info[] = $data['name'];
- //开始验证分组下是否存在管理员
- if(M("Admin")->where("is_effect = 1 and is_delete = 0 and role_id=".$data['id'])->count()>0)
- {
- $this->error ($data['name'].l("EXIST_ADMIN"),$ajax);
- }
- }
- if($info) $info = implode(",",$info);
- $list = M("Role")->where ( $condition )->setField ( 'is_delete', 1 );
- if ($list!==false) {
- save_log($info.l("DELETE_SUCCESS"),1);
- $this->success (l("DELETE_SUCCESS"),$ajax);
- } else {
- save_log($info.l("DELETE_FAILED"),0);
- $this->error (l("DELETE_FAILED"),$ajax);
- }
- } else {
- $this->error (l("INVALID_OPERATION"),$ajax);
- }
- }
- public function restore() {
- //删除指定记录
- $ajax = intval($_REQUEST['ajax']);
- $id = $_REQUEST ['id'];
- if (isset ( $id )) {
- $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
- $rel_data = M("Role")->where($condition)->findAll();
- foreach($rel_data as $data)
- {
- $info[] = $data['name'];
- }
- if($info) $info = implode(",",$info);
- $list = M("Role")->where ( $condition )->setField ( 'is_delete', 0 );
- if ($list!==false) {
- save_log($info.l("RESTORE_SUCCESS"),1);
- $this->success (l("RESTORE_SUCCESS"),$ajax);
- } else {
- save_log($info.l("RESTORE_FAILED"),0);
- $this->error (l("RESTORE_FAILED"),$ajax);
- }
- } else {
- $this->error (l("INVALID_OPERATION"),$ajax);
- }
- }
- public function foreverdelete() {
- //彻底删除指定记录
- $ajax = intval($_REQUEST['ajax']);
- $id = $_REQUEST ['id'];
- if (isset ( $id )) {
- $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
- $role_access_condition = array ('role_id' => array ('in', explode ( ',', $id ) ) );
- $rel_data = M("Role")->where($condition)->findAll();
- foreach($rel_data as $data)
- {
- $info[] = $data['name'];
- //开始验证分组下是否存在管理员
- if(M("Admin")->where("is_effect = 1 and is_delete = 0 and role_id=".$data['id'])->count()>0)
- {
- $this->error ($data['name'].l("EXIST_ADMIN"),$ajax);
- }
- }
- if($info) $info = implode(",",$info);
- $list = M("Role")->where ( $condition )->delete();
- M("RoleAccess")->where($role_access_condition)->delete();
- M("Admin")->where($role_access_condition)->delete();
- if ($list!==false) {
- save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
- $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
- } else {
- save_log($info.l("FOREVER_DELETE_FAILED"),0);
- $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
- }
- } else {
- $this->error (l("INVALID_OPERATION"),$ajax);
- }
- }
- }
- ?>
|