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 cApiFrontendGroupCollection extends ItemCollection {
25:
26: 27: 28:
29: public function __construct() {
30: global $cfg;
31: parent::__construct($cfg['tab']['frontendgroups'], 'idfrontendgroup');
32: $this->_setItemClass('cApiFrontendGroup');
33:
34:
35: $this->_setJoinPartner('cApiClientCollection');
36: }
37:
38: 39: 40: 41: 42: 43:
44: public function create($groupname) {
45: global $client;
46:
47: $group = new cApiFrontendGroup();
48:
49:
50:
51: $mangledGroupName = $group->_inFilter($groupname);
52: $this->select("idclient = " . cSecurity::toInteger($client) . " AND groupname = '" . $mangledGroupName . "'");
53:
54: if (($obj = $this->next()) !== false) {
55: $groupname = $groupname . md5(rand());
56: }
57:
58: $item = $this->createNewItem();
59: $item->set('idclient', $client);
60: $item->set('groupname', $groupname);
61: $item->store();
62:
63: return $item;
64: }
65:
66: 67: 68: 69: 70: 71: 72:
73: public function delete($itemID) {
74: $associations = new cApiFrontendGroupMemberCollection();
75: $associations->select('idfrontendgroup = ' . (int) $itemID);
76:
77: while (($item = $associations->next()) !== false) {
78: $associations->delete($item->get('idfrontendgroupmember'));
79: }
80: parent::delete($itemID);
81: }
82: }
83:
84: 85: 86: 87: 88: 89:
90: class cApiFrontendGroup extends Item {
91:
92: 93: 94: 95: 96:
97: public function __construct($mId = false) {
98: global $cfg;
99: parent::__construct($cfg['tab']['frontendgroups'], 'idfrontendgroup');
100: if ($mId !== false) {
101: $this->loadByPrimaryKey($mId);
102: }
103: }
104: }
105: