NodeAction.class.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. *
  4. * Node (权限管理)
  5. *
  6. */
  7. if(!defined("Ainaphp")) exit("Access Denied");
  8. class NodeAction extends AdminbaseAction {
  9. protected $dao,$groups;
  10. function _initialize()
  11. {
  12. parent::_initialize();
  13. $this->dao=D('node');
  14. $this->groups[0]=array('id'=>0,'name'=>L('ACCESS_PUBLIC'));
  15. foreach($this->menudata as $key=>$r){ if($r['parentid']==0)$this->groups[$r[id]]=$r;}
  16. $this->assign('groups', $this->groups);
  17. }
  18. function index(){
  19. $data[]=array('name'=>'index','title'=>'列表','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  20. $data[]=array('name'=>'add','title'=>'添加','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  21. $data[]=array('name'=>'edit','title'=>'修改','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  22. $data[]=array('name'=>'insert','title'=>'插入','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  23. $data[]=array('name'=>'update','title'=>'更新','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  24. $data[]=array('name'=>'delete','title'=>'删除','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  25. $data[]=array('name'=>'status','title'=>'状态','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  26. $data[]=array('name'=>'listorder','title'=>'排序','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  27. //$data[]=array('name'=>'deleteall','title'=>'批量删除','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  28. //$data[]=array('name'=>'statusallok','title'=>'批量审核','pid'=>90,'status'=>1,'listorder'=>0,'level'=>3,'groupid'=>3);
  29. foreach($data as $sql){
  30. //$this->dao->add($sql);
  31. }
  32. $str = "<tr>
  33. <td align='center'><input name='listorders[\$id]' type='text' size='2' value='\$listorder' class='input-text-c'></td>
  34. <td >\$spacer\$title</td>
  35. <td >\$name</td>
  36. <td align='center'>\$status</td>
  37. <td align='center'>\$str_manage</td>
  38. </tr>";
  39. import ( '@.ORG.Tree' );
  40. foreach($this->groups as $key=>$res){
  41. $result=$this->dao->where("groupid=$res[id]")->select();
  42. $array=array();
  43. foreach($result as $r) {
  44. $r['str_manage'] = '<a href="'.U('Node/add',array( 'pid' => $r['id'],'groupid'=>$r['groupid'])).'">'.L('add').'</a> | <a href="'.U('Node/edit',array( 'id' => $r['id'])).'">'.L('edit').'</a> | <a href="javascript:confirm_delete(\''.U('Node/delete',array( 'id' => $r['id'])).'\',\''.L('confirm',array('message'=>$r['cname'])).'\')">'.L('delete').'</a> ';
  45. $r['parentid']=$r['pid'];
  46. $r['status']==1 ? $r['status']=L('enable') : $r['status']=L('disable') ;
  47. $array[] = $r;
  48. }
  49. $tree = new Tree ($array);
  50. $tree->icon = array('&nbsp;&nbsp;&nbsp;'.L('tree_1'),'&nbsp;&nbsp;&nbsp;'.L('tree_2'),'&nbsp;&nbsp;&nbsp;'.L('tree_3'));
  51. $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
  52. $data = $tree->get_tree(1, $str);
  53. $nodes[$res['id']]['data'] = $data;
  54. $nodes[$res['id']]['groupinfo']=$res;
  55. }
  56. $this->assign('nodes', $nodes);
  57. $this->display();
  58. }
  59. function _before_insert(){
  60. if($_POST['pid']){
  61. $level =$this->dao->getById($_POST['pid']);
  62. $_POST['level']=$level['level']+1;
  63. }else{
  64. $_POST['level']=1;
  65. }
  66. }
  67. function _before_update(){
  68. if($_POST['pid']){
  69. $level =$this->dao->getById($_POST['pid']);
  70. $_POST['level']=$level['level']+1;
  71. }else{
  72. $_POST['level']=1;
  73. }
  74. }
  75. function _before_add(){
  76. $groupid= intval($_GET['groupid']);
  77. $pid = intval($_GET['pid']);
  78. import ( '@.ORG.Tree' );
  79. $result = $this->dao->select();
  80. foreach($result as $r) {
  81. if($r['status']!=1 || $r['level']==3) continue;
  82. $r['selected'] = $r['id'] == $pid ? 'selected' : '';
  83. $r['parentid']=$r['pid'];
  84. $array[] = $r;
  85. }
  86. $str = "<option value='\$id' \$selected>\$spacer \$title</option>";
  87. $tree = new Tree ($array);
  88. $nodes = $tree->get_tree(0, $str,$pid);
  89. $this->assign('nodes', $nodes);
  90. $this->assign('groupid', $groupid);
  91. }
  92. function edit(){
  93. $id = intval($_GET['id']);;
  94. $vo = $this->dao->getById($id);
  95. $this->assign('groupid', $vo['groupid']);
  96. $pid = intval($vo['pid']);
  97. import ( '@.ORG.Tree' );
  98. $result = $this->dao->select();
  99. foreach($result as $r) {
  100. if($r['status']!=1) continue;
  101. $r['selected'] = $r['id'] == $pid ? 'selected' : '';
  102. $r['parentid']=$r['pid'];
  103. $array[] = $r;
  104. }
  105. $str = "<option value='\$id' \$selected>\$spacer \$title</option>";
  106. $tree = new Tree ($array);
  107. $nodes = $tree->get_tree(0, $str,$pid);
  108. $this->assign('nodes', $nodes);
  109. $this->assign ( 'udate', $vo );
  110. $this->display ();
  111. }
  112. }
  113. ?>