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