1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23:
24: class cApiFrontendGroupMemberCollection extends ItemCollection {
25:
26: 27: 28:
29: public function __construct() {
30: global $cfg;
31: parent::__construct($cfg['tab']['frontendgroupmembers'], 'idfrontendgroupmember');
32: $this->_setItemClass('cApiFrontendGroupMember');
33:
34:
35: $this->_setJoinPartner('cApiFrontendGroupCollection');
36: $this->_setJoinPartner('cApiFrontendUserCollection');
37: }
38:
39: 40: 41: 42: 43: 44: 45:
46: public function create($idfrontendgroup, $idfrontenduser) {
47: $this->select('idfrontendgroup = ' . (int) $idfrontendgroup . ' AND idfrontenduser = ' . (int) $idfrontenduser);
48:
49: if ($this->next()) {
50: return false;
51: }
52:
53: $item = $this->createNewItem();
54:
55: $item->set('idfrontenduser', $idfrontenduser);
56: $item->set('idfrontendgroup', $idfrontendgroup);
57: $item->store();
58:
59: return $item;
60: }
61:
62: 63: 64: 65: 66: 67:
68: public function remove($idfrontendgroup, $idfrontenduser) {
69: $this->select('idfrontendgroup = ' . (int) $idfrontendgroup . ' AND idfrontenduser = ' . (int) $idfrontenduser);
70:
71: if (($item = $this->next()) !== false) {
72: $this->delete($item->get('idfrontendgroupmember'));
73: }
74: }
75:
76: 77: 78: 79: 80: 81: 82:
83: public function getUsersInGroup($idfrontendgroup, $asObjects = true) {
84: $this->select('idfrontendgroup = ' . (int) $idfrontendgroup);
85:
86: $objects = array();
87:
88: while (($item = $this->next()) !== false) {
89: if ($asObjects) {
90: $user = new cApiFrontendUser();
91: $user->loadByPrimaryKey($item->get('idfrontenduser'));
92: $objects[] = $user;
93: } else {
94: $objects[] = $item->get('idfrontenduser');
95: }
96: }
97:
98: return ($objects);
99: }
100: }
101:
102: 103: 104: 105: 106: 107:
108: class cApiFrontendGroupMember extends Item {
109:
110: 111: 112: 113: 114:
115: public function __construct($mId = false) {
116: global $cfg;
117: parent::__construct($cfg['tab']['frontendgroupmembers'], 'idfrontendgroupmember');
118: if ($mId !== false) {
119: $this->loadByPrimaryKey($mId);
120: }
121: }
122: }
123: