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:
25: class PimPluginCollection extends ItemCollection {
26:
27: 28: 29: 30: 31:
32: public function __construct() {
33: global $cfg;
34: parent::__construct($cfg['tab']['plugins'], 'idplugin');
35: $this->_setItemClass('PimPlugin');
36: }
37:
38: 39: 40: 41: 42:
43: public function create($name, $description, $author, $copyright, $mail, $website, $version, $foldername, $uuId, $active) {
44: global $client;
45:
46: $nextId = $this->_getNextId();
47:
48:
49: $client = cSecurity::toInteger($client);
50: $name = cSecurity::escapeString($name);
51: $description = cSecurity::escapeString($description);
52: $author = cSecurity::escapeString($author);
53: $copyright = cSecurity::escapeString($copyright);
54: $mail = cSecurity::escapeString($mail);
55: $website = cSecurity::escapeString($website);
56: $version = cSecurity::escapeString($version);
57: $foldername = cSecurity::escapeString($foldername);
58: $uuId = cSecurity::escapeString($uuId);
59: $active = cSecurity::toInteger($active);
60:
61:
62: $item = parent::createNewItem($nextId);
63: $item->set('idclient', $client);
64: $item->set('name', $name);
65: $item->set('description', $description);
66: $item->set('author', $author);
67: $item->set('copyright', $copyright);
68: $item->set('mail', $mail);
69: $item->set('website', $website);
70: $item->set('version', $version);
71: $item->set('folder', $foldername);
72: $item->set('uuid', $uuId);
73: $item->set('installed', date("Y-m-d H:i:s"), false);
74: $item->set('active', $active);
75:
76: $item->store();
77:
78: return $item;
79: }
80:
81: 82: 83: 84: 85: 86:
87: protected function _getNextId() {
88: global $cfg;
89:
90: $sql = 'SELECT MAX(idplugin) AS id FROM ' . $cfg['tab']['plugins'];
91: $this->db->query($sql);
92:
93: if ($this->db->nextRecord()) {
94:
95: $result = $this->db->f('id');
96:
97:
98: if ($result < 10000) {
99: $result = 10000;
100: }
101:
102:
103: $result = $result + 10;
104:
105:
106: $result = substr($result, 0, strlen($result) - 1);
107:
108:
109: return cSecurity::toInteger($result . 0);
110: }
111: }
112:
113: }
114:
115: 116: 117:
118: class PimPlugin extends Item {
119:
120: 121: 122: 123: 124:
125: protected $_error;
126:
127: 128: 129: 130: 131:
132: public function __construct($id = false) {
133: global $cfg;
134: parent::__construct($cfg['tab']['plugins'], 'idplugin');
135: $this->_error = '';
136: if ($id !== false) {
137: $this->loadByPrimaryKey($id);
138: }
139: }
140:
141: }
142: