1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12:
13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
14:
15: 16: 17: 18: 19: 20:
21: class SIWECOSCollection extends ItemCollection
22: {
23: 24: 25: 26: 27: 28: 29: 30:
31: public function __construct($where = false)
32: {
33: parent::__construct('con_pi_siwecos', 'idsiwecos');
34: $this->_setItemClass('SIWECOS');
35: if (false !== $where) {
36: $this->select($where);
37: }
38: }
39:
40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50:
51: public static function getByClientAndLang($client, $lang)
52: {
53: if (0 >= cSecurity::toInteger($client)) {
54: $msg = i18n('ERR_MISSING_CLIENT', 'siwecos');
55: throw new SIWECOSException($msg);
56: }
57:
58: if (0 >= cSecurity::toInteger($lang)) {
59: $msg = i18n('ERR_MISSING_LANG', 'siwecos');
60: throw new SIWECOSException($msg);
61: }
62:
63: return self::_getBy($client, $lang);
64: }
65:
66: 67: 68: 69: 70: 71: 72: 73: 74:
75: private static function _getBy($client, $lang)
76: {
77: global $idsiwecos;
78:
79: if ($idsiwecos) {
80: $str = "AND idsiwecos = " . cSecurity::toInteger($idsiwecos);
81: } else {
82: $str = '';
83: }
84:
85: $db = cRegistry::getDb();
86: $db->query(
87: "SELECT *
88: FROM `con_pi_siwecos`
89: WHERE
90: idclient = " . cSecurity::toInteger($client) . "
91: AND idlang = " . cSecurity::toInteger($lang) . "
92: " . $str . "
93: ;"
94: );
95:
96: $forms = [];
97: while ($db->nextRecord()) {
98: $forms[$db->f('idsiwecos')]['idsiwecos'] = $db->f('idsiwecos');
99: $forms[$db->f('idsiwecos')]['domain'] = $db->f('domain');
100: $forms[$db->f('idsiwecos')]['email'] = $db->f('email');
101: $forms[$db->f('idsiwecos')]['userToken'] = $db->f('userToken');
102: $forms[$db->f('idsiwecos')]['domainToken'] = $db->f('domainToken');
103: $forms[$db->f('idsiwecos')]['dangerLevel'] = $db->f('dangerLevel');
104: $forms[$db->f('idsiwecos')]['author'] = $db->f('author');
105: $forms[$db->f('idsiwecos')]['created'] = $db->f('created');
106: }
107:
108: return $forms;
109: }
110: }
111:
112: 113: 114:
115: class SIWECOS extends Item
116: {
117: 118: 119: 120: 121:
122: private static $_name = 'siwecos';
123:
124: 125: 126: 127: 128: 129: 130: 131:
132: public function __construct($id = false)
133: {
134: parent::__construct('con_pi_siwecos', 'idsiwecos');
135: $this->setFilters([], []);
136: if (false !== $id) {
137: $this->loadByPrimaryKey($id);
138: }
139: }
140:
141: 142: 143: 144: 145:
146: public static function getName()
147: {
148: return self::$_name;
149: }
150:
151: 152: 153: 154: 155: 156: 157:
158: public static function logException(Exception $e)
159: {
160: if (getSystemProperty('debug', 'debug_for_plugins') == 'true') {
161: $cfg = cRegistry::getConfig();
162: $destination = $cfg['path']['contenido_logs'] . 'errorlog.txt';
163: $writer = cLogWriter::factory('file', ['destination' => $destination]);
164: $log = new cLog($writer);
165: $log->err($e->getMessage());
166: $log->err($e->getTraceAsString());
167: }
168: }
169:
170: 171: 172: 173: 174: 175: 176: 177:
178: public static function notifyException(Exception $e)
179: {
180: $cGuiNotification = new cGuiNotification();
181: $level = cGuiNotification::LEVEL_ERROR;
182: $message = $e->getMessage();
183:
184: return $cGuiNotification->returnNotification($level, $message);
185: }
186:
187: 188: 189: 190: 191: 192: 193: 194:
195: public function delete()
196: {
197: global $idsiwecos;
198: $db = cRegistry::getDb();
199:
200:
201: $succ = $db->query(
202: "
203: DELETE
204: FROM con_pi_siwecos
205: WHERE
206: idsiwecos = " . cSecurity::toInteger($idsiwecos) . "
207: ;"
208: );
209:
210: if (false === $succ) {
211: $msg = i18n('ERR_DELETE_ENTITY', 'siwecos');
212: throw new SIWECOSException($msg);
213: }
214: }
215: }
216:
217: 218: 219: 220: 221:
222: class SIWECOSException extends cException
223: {
224: }
225: