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 cApiContainerCollection extends ItemCollection {
25:
26: public function __construct($select = false) {
27: global $cfg;
28: parent::__construct($cfg['tab']['container'], 'idcontainer');
29: $this->_setItemClass('cApiContainer');
30:
31:
32: $this->_setJoinPartner('cApiTemplateCollection');
33:
34: if ($select !== false) {
35: $this->select($select);
36: }
37: }
38:
39: public function clearAssignments($idtpl) {
40: $this->select('idtpl = ' . (int) $idtpl);
41: while (($item = $this->next()) !== false) {
42: $this->delete($item->get('idcontainer'));
43: }
44: }
45:
46: public function assignModul($idtpl, $number, $idmod) {
47: $this->select('idtpl = ' . (int) $idtpl . ' AND number = ' . (int) $number);
48: if (($item = $this->next()) !== false) {
49: $item->set('idmod', (int) $idmod);
50: $item->store();
51: } else {
52: $this->create($idtpl, $number, $idmod);
53: }
54: }
55:
56: public function create($idtpl, $number, $idmod) {
57: $item = parent::createNewItem();
58: $item->set('idtpl', (int) $idtpl);
59: $item->set('number', (int) $number);
60: $item->set('idmod', (int) $idmod);
61: $item->store();
62: }
63:
64: }
65:
66: 67: 68: 69: 70: 71:
72: class cApiContainer extends Item {
73:
74: 75: 76: 77: 78:
79: public function __construct($mId = false) {
80: global $cfg;
81: parent::__construct($cfg['tab']['container'], 'idcontainer');
82: $this->setFilters(array(), array());
83: if ($mId !== false) {
84: $this->loadByPrimaryKey($mId);
85: }
86: }
87: }
88: