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 cApiGroupMemberCollection extends ItemCollection {
25:
26: 27: 28:
29: public function __construct() {
30: global $cfg;
31: parent::__construct($cfg['tab']['groupmembers'], 'idgroupuser');
32: $this->_setItemClass('cApiGroupMember');
33:
34:
35: $this->_setJoinPartner('cApiGroupCollection');
36: $this->_setJoinPartner('cApiUserCollection');
37: }
38:
39: 40: 41: 42: 43: 44: 45:
46: public function create($userId, $groupId) {
47: $oItem = $this->createNewItem();
48:
49: $oItem->set('user_id', $userId);
50: $oItem->set('group_id', $groupId);
51:
52: $oItem->store();
53:
54: return $oItem;
55: }
56:
57: 58: 59: 60: 61: 62:
63: public function deleteByUserId($userId) {
64: $result = $this->deleteBy('user_id', $userId);
65: return ($result > 0) ? true : false;
66: }
67:
68: 69: 70: 71: 72: 73: 74:
75: public function fetchByUserIdAndGroupId($userId, $groupId) {
76: $where = "user_id = '" . $this->escape($userId) . "' AND group_id = '" . $this->escape($groupId) . "'";
77: if ($this->select($where)) {
78: return $this->next();
79: } else {
80: return NULL;
81: }
82: }
83:
84: }
85:
86: 87: 88: 89: 90: 91:
92: class cApiGroupMember extends Item {
93:
94: 95: 96: 97: 98:
99: public function __construct($mId = false) {
100: global $cfg;
101: parent::__construct($cfg['tab']['groupmembers'], 'idgroupuser');
102: $this->setFilters(array(), array());
103: if ($mId !== false) {
104: $this->loadByPrimaryKey($mId);
105: }
106: }
107:
108: }
109: