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 cApiTemplateConfigurationCollection extends ItemCollection {
25:
26: 27: 28: 29: 30: 31:
32: public function __construct($select = false) {
33: global $cfg;
34: parent::__construct($cfg['tab']['tpl_conf'], 'idtplcfg');
35: $this->_setItemClass('cApiTemplateConfiguration');
36:
37:
38: $this->_setJoinPartner('cApiTemplateCollection');
39:
40: if ($select !== false) {
41: $this->select($select);
42: }
43: }
44:
45: 46: 47: 48: 49: 50: 51:
52: public function delete($idtplcfg) {
53: $result = parent::delete($idtplcfg);
54:
55:
56: $oContainerConfColl = new cApiContainerConfigurationCollection('idtplcfg = ' . (int) $idtplcfg);
57: $oContainerConfColl->deleteByWhereClause('idtplcfg = ' . (int) $idtplcfg);
58:
59: return $result;
60: }
61:
62: 63: 64: 65: 66: 67: 68: 69: 70: 71:
72: public function create($idtpl, $status = 0, $author = '', $created = '', $lastmodified = '') {
73: global $auth;
74:
75: if (empty($author)) {
76: $author = $auth->auth['uname'];
77: }
78: if (empty($created)) {
79: $created = date('Y-m-d H:i:s');
80: }
81: if (empty($lastmodified)) {
82: $lastmodified = '0000-00-00 00:00:00';
83: }
84:
85: $item = $this->createNewItem();
86: $item->set('idtpl', $idtpl);
87: $item->set('author', $author);
88: $item->set('status', $status);
89: $item->set('created', $created);
90: $item->set('lastmodified', $lastmodified);
91: $item->store();
92:
93: return $item;
94: }
95:
96: 97: 98: 99: 100: 101: 102:
103: public function copyTemplatePreconfiguration($idtpl, $idtplcfg) {
104: $oTemplateColl = new cApiTemplateCollection('idtpl = ' . (int) $idtpl);
105:
106: if (($oTemplate = $oTemplateColl->next()) !== false) {
107: if ($oTemplate->get('idtplcfg') > 0) {
108: $oContainerConfColl = new cApiContainerConfigurationCollection('idtplcfg = ' . $oTemplate->get('idtplcfg'));
109: $aStandardconfig = array();
110: while (($oContainerConf = $oContainerConfColl->next()) !== false) {
111: $aStandardconfig[$oContainerConf->get('number')] = $oContainerConf->get('container');
112: }
113:
114: foreach ($aStandardconfig as $number => $container) {
115: $oContainerConfColl->create($idtplcfg, $number, $container);
116: }
117: }
118: }
119: }
120: }
121:
122: 123: 124: 125: 126: 127:
128: class cApiTemplateConfiguration extends Item {
129:
130: 131: 132: 133: 134:
135: public function __construct($mId = false) {
136: global $cfg;
137: parent::__construct($cfg['tab']['tpl_conf'], 'idtplcfg');
138: $this->setFilters(array(), array());
139: if ($mId !== false) {
140: $this->loadByPrimaryKey($mId);
141: }
142: }
143:
144: 145: 146: 147: 148: 149: 150: 151:
152: public function setField($name, $value, $bSafe = true) {
153: switch ($name) {
154: case 'idtpl':
155: case 'status':
156: $value = (int) $value;
157: break;
158: }
159:
160: parent::setField($name, $value, $bSafe);
161: }
162: }
163: