控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CategoryPriv.php 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 栏目权限模型
  13. // +----------------------------------------------------------------------
  14. namespace app\admin\model\cms;
  15. use think\Model;
  16. class CategoryPriv extends Model
  17. {
  18. /**
  19. * 更新权限
  20. * @param $catid 栏目ID
  21. * @param $priv_datas
  22. * @param $is_admin 1为管理员
  23. */
  24. public static function update_priv($catid, $priv_datas, $is_admin = 1)
  25. {
  26. //删除旧的
  27. self::where(['catid' => $catid, 'is_admin' => $is_admin])->delete();
  28. if (is_array($priv_datas) && !empty($priv_datas)) {
  29. foreach ($priv_datas as $r) {
  30. $r = explode(',', $r);
  31. //动作
  32. $action = $r[0];
  33. //角色或者会员用户组
  34. $roleid = $r[1];
  35. self::create(['catid' => $catid, 'roleid' => $roleid, 'is_admin' => $is_admin, 'action' => $action]);
  36. }
  37. }
  38. }
  39. /**
  40. * 检查栏目权限
  41. * @param $privs 权限数据
  42. * @param $action 动作
  43. * @param $roleid 角色
  44. * @param $is_admin 是否为管理组
  45. */
  46. public function check_category_priv($privs, $action, $roleid, $is_admin = 1)
  47. {
  48. $checked = '';
  49. foreach ($privs as $priv) {
  50. if ($priv['is_admin'] == $is_admin && $priv['roleid'] == $roleid && $priv['action'] == $action) {
  51. $checked = 'checked';
  52. }
  53. }
  54. return $checked;
  55. }
  56. }