1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\Database\Connection;
13: use Xoops\Core\Kernel\XoopsObject;
14: use Xoops\Core\Kernel\XoopsPersistableObjectHandler;
15:
16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
27:
28: class ProfileVisibility extends XoopsObject
29: {
30: 31: 32:
33: public function __construct()
34: {
35: $this->initVar('field_id', XOBJ_DTYPE_INT);
36: $this->initVar('user_group', XOBJ_DTYPE_INT);
37: $this->initVar('profile_group', XOBJ_DTYPE_INT);
38: }
39: }
40:
41: class ProfileVisibilityHandler extends XoopsPersistableObjectHandler
42: {
43: 44: 45:
46: public function __construct(Connection $db = null)
47: {
48: parent::__construct($db, 'profile_visibility', 'profilevisibility', 'field_id');
49: }
50:
51: 52: 53: 54: 55: 56: 57: 58:
59: public function getVisibleFields($profile_groups, $user_groups = null)
60: {
61: $profile_groups[] = 0;
62: array_walk($profile_groups, 'intval');
63: $user_groups[] = 0;
64: array_walk($user_groups, 'intval');
65:
66: $qb = $this->db2->createXoopsQueryBuilder();
67: $eb = $qb->expr();
68: $sql = $qb->select('t1.field_id')
69: ->from($this->table, 't1')
70: ->where($eb->in('t1.profile_group', $profile_groups))
71: ->andWhere($eb->in('t1.user_group', $user_groups));
72:
73: $result = $sql->execute();
74: $field_ids = array();
75: while (list($field_id) = $result->fetch(PDO::FETCH_NUM)) {
76: $field_ids[] = $field_ids;
77: }
78:
79: return $field_ids;
80: }
81: }
82: