1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: 18: 19: 20: 21: 22:
23: class cApiTemplateConfigurationCollection extends ItemCollection {
24:
25: 26: 27: 28: 29: 30:
31: public function __construct($select = false) {
32: global $cfg;
33: parent::__construct($cfg['tab']['tpl_conf'], 'idtplcfg');
34: $this->_setItemClass('cApiTemplateConfiguration');
35:
36:
37: $this->_setJoinPartner('cApiTemplateCollection');
38:
39: if ($select !== false) {
40: $this->select($select);
41: }
42: }
43:
44: 45: 46: 47: 48: 49: 50:
51: public function delete($idtplcfg) {
52: $result = parent::delete($idtplcfg);
53:
54:
55: $oContainerConfColl = new cApiContainerConfigurationCollection('idtplcfg = ' . (int) $idtplcfg);
56: $oContainerConfColl->deleteByWhereClause('idtplcfg = ' . (int) $idtplcfg);
57:
58: return $result;
59: }
60:
61: 62: 63: 64: 65: 66: 67: 68: 69: 70:
71: public function create($idtpl, $status = 0, $author = '', $created = '', $lastmodified = '') {
72: global $auth;
73:
74: if (empty($author)) {
75: $author = $auth->auth['uname'];
76: }
77: if (empty($created)) {
78: $created = date('Y-m-d H:i:s');
79: }
80: if (empty($lastmodified)) {
81: $lastmodified = '0000-00-00 00:00:00';
82: }
83:
84: $item = $this->createNewItem();
85: $item->set('idtpl', $idtpl);
86: $item->set('author', $author);
87: $item->set('status', $status);
88: $item->set('created', $created);
89: $item->set('lastmodified', $lastmodified);
90: $item->store();
91:
92: return $item;
93: }
94:
95: 96: 97: 98: 99: 100: 101:
102: public function copyTemplatePreconfiguration($idtpl, $idtplcfg) {
103: $oTemplateColl = new cApiTemplateCollection('idtpl = ' . (int) $idtpl);
104:
105: if (($oTemplate = $oTemplateColl->next()) !== false) {
106: if ($oTemplate->get('idtplcfg') > 0) {
107: $oContainerConfColl = new cApiContainerConfigurationCollection('idtplcfg = ' . $oTemplate->get('idtplcfg'));
108: $aStandardconfig = array();
109: while (($oContainerConf = $oContainerConfColl->next()) !== false) {
110: $aStandardconfig[$oContainerConf->get('number')] = $oContainerConf->get('container');
111: }
112:
113: foreach ($aStandardconfig as $number => $container) {
114: $oContainerConfColl->create($idtplcfg, $number, $container);
115: }
116: }
117: }
118: }
119: }
120:
121: 122: 123: 124: 125: 126:
127: class cApiTemplateConfiguration extends Item {
128:
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:
153: public function setField($name, $value, $bSafe = true) {
154: switch ($name) {
155: case 'idtpl':
156: case 'status':
157: $value = (int) $value;
158: break;
159: }
160:
161: parent::setField($name, $value, $bSafe);
162: }
163: }
164: