Нема описа
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.

UsersParameter.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 陈风任 <491085389@qq.com>
  11. * Date: 2019-3-11
  12. */
  13. namespace app\admin\model;
  14. use think\Db;
  15. use think\Model;
  16. /**
  17. * 会员属性
  18. */
  19. class UsersParameter extends Model
  20. {
  21. private $admin_lang = 'cn';
  22. //初始化
  23. protected function initialize()
  24. {
  25. // 需要调用`Model`的`initialize`方法
  26. parent::initialize();
  27. $this->admin_lang = get_admin_lang();
  28. }
  29. /**
  30. * 校验是否允许非必填
  31. */
  32. public function isRequired($id_name='',$id_value='',$field='',$value='')
  33. {
  34. $return = true;
  35. $value = trim($value);
  36. if (($value == '0' && $field == 'is_required') || ($value == '1' && $field == 'is_hidden')) {
  37. $where = [
  38. $id_name => $id_value,
  39. 'lang' => $this->admin_lang,
  40. ];
  41. $paraData = Db::name('users_parameter')->where($where)->field('dtype')->find();
  42. if ($paraData['dtype'] == 'email') {
  43. $usersData = getUsersConfigData('users.users_verification');
  44. if ($usersData == '2') {
  45. if ($value == '0') {
  46. $return = [
  47. 'msg' => '您已选择:会员功能设置-注册验证-邮件验证,因此邮箱地址必须为必填!',
  48. ];
  49. }
  50. if ($value == '1') {
  51. $return = [
  52. 'msg' => '您已选择:会员功能设置-注册验证-邮件验证,因此邮箱地址不可隐藏!',
  53. ];
  54. }
  55. }
  56. }
  57. } else if ($value == 1 && $field == 'is_reg') {
  58. $where = [
  59. $id_name => $id_value,
  60. 'lang' => $this->admin_lang,
  61. ];
  62. $paraData = Db::name('users_parameter')->where($where)->field('is_hidden')->find();
  63. if (1 == $paraData['is_hidden']) {
  64. $return = [
  65. 'msg' => '该属性已被禁用!',
  66. 'time' => 2,
  67. ];
  68. }
  69. }
  70. return $return;
  71. }
  72. }