ZAuth.php 806 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * summary: 权限组件
  4. * author: justin
  5. * date: 2014.03.04
  6. */
  7. class ZAuth extends ZComponent
  8. {
  9. /**
  10. * 返回操作对应的权限名称
  11. */
  12. public function getAuthItem($controller, $action = ''){
  13. $del = "-";
  14. $mod = $controller->module !== null ? $controller->module->id . $del: '';
  15. $act = $action;
  16. if ($action == ''){
  17. if ($controller->action !== null){
  18. $act = $controller->action->id;
  19. } else {
  20. $act = $controller->defaultAction;
  21. }
  22. }
  23. $contrArr = explode($del, $controller->id);
  24. $contrArr[sizeof($contrArr) - 1] = ucfirst($contrArr[sizeof($contrArr) - 1]);
  25. $con = implode(".", $contrArr);
  26. $auth_item = $mod . $con . ucfirst($act);
  27. return $auth_item;
  28. }
  29. }