manqod-server 1.257.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,356 @@
1
+
2
+
3
+ DROP TABLE IF EXISTS `buttons`;
4
+ CREATE TABLE `buttons` (
5
+ `id` int(11) NOT NULL auto_increment,
6
+ `moditemid` int(11) NOT NULL default '0',
7
+ `target_moditemid` int(11) NOT NULL default '0',
8
+ `btfunct` varchar(10) NOT NULL default '',
9
+ `moditem_render_mode` varchar(10) NOT NULL default '',
10
+ `oid` char(1) NOT NULL default '',
11
+ `display` text NOT NULL,
12
+ `grp_id` mediumint(9) NOT NULL,
13
+ PRIMARY KEY (`id`),
14
+ KEY `moditemid` (`moditemid`),
15
+ KEY `target_moditemid` (`target_moditemid`),
16
+ KEY `btfunct` (`btfunct`),
17
+ KEY `moditem_render_mode` (`moditem_render_mode`),
18
+ KEY `oid` (`oid`),
19
+ KEY `grp_id` (`grp_id`)
20
+ ) ENGINE=MyISAM AUTO_INCREMENT=129 DEFAULT CHARSET=utf8;
21
+ DROP TABLE IF EXISTS `conf`;
22
+ CREATE TABLE `conf` (
23
+ `id` int(11) NOT NULL auto_increment,
24
+ `nick` varchar(10) NOT NULL default '',
25
+ `moditemid` int(11) NOT NULL default '0',
26
+ `itemid` int(11) NOT NULL default '0',
27
+ `Variable` varchar(20) NOT NULL,
28
+ `Value` text NOT NULL,
29
+ PRIMARY KEY (`id`),
30
+ UNIQUE KEY `nick` (`nick`,`moditemid`,`itemid`,`Variable`),
31
+ KEY `moditemid` (`moditemid`),
32
+ KEY `itemid` (`itemid`)
33
+ ) ENGINE=MyISAM AUTO_INCREMENT=14119 DEFAULT CHARSET=utf8;
34
+ DROP TABLE IF EXISTS `cronjobs`;
35
+ CREATE TABLE `cronjobs` (
36
+ `id` int(11) NOT NULL auto_increment,
37
+ `moditems_id` int(11) NOT NULL,
38
+ `cron` varchar(32) NOT NULL,
39
+ `command` text NOT NULL,
40
+ PRIMARY KEY (`id`)
41
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
42
+ DROP TABLE IF EXISTS `db_version`;
43
+ CREATE TABLE `db_version` (
44
+ `version` float default NULL,
45
+ `utime` timestamp NOT NULL default CURRENT_TIMESTAMP
46
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
47
+ DROP TABLE IF EXISTS `events`;
48
+ CREATE TABLE `events` (
49
+ `id` int(11) NOT NULL auto_increment,
50
+ `gtkobjectid` int(11) NOT NULL default '0',
51
+ `event` text NOT NULL,
52
+ `command` text NOT NULL,
53
+ PRIMARY KEY (`id`),
54
+ KEY `gtkobjectid` (`gtkobjectid`)
55
+ ) ENGINE=MyISAM AUTO_INCREMENT=78 DEFAULT CHARSET=utf8;
56
+ DROP TABLE IF EXISTS `groups`;
57
+ CREATE TABLE `groups` (
58
+ `id` int(11) NOT NULL auto_increment,
59
+ `parent_id` int(11) NOT NULL,
60
+ `name` varchar(200) NOT NULL default '',
61
+ PRIMARY KEY (`id`)
62
+ ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
63
+ DROP TABLE IF EXISTS `gtkattributes`;
64
+ CREATE TABLE `gtkattributes` (
65
+ `id` bigint(20) NOT NULL auto_increment,
66
+ `gtkobjectid` bigint(20) NOT NULL,
67
+ `gtkobjecttype` char(16) NOT NULL,
68
+ `attribute` char(32) NOT NULL,
69
+ `data` text NOT NULL,
70
+ PRIMARY KEY (`id`),
71
+ UNIQUE KEY `gtkobjectid` (`gtkobjectid`,`gtkobjecttype`,`attribute`)
72
+ ) ENGINE=MyISAM AUTO_INCREMENT=229 DEFAULT CHARSET=utf8;
73
+ DROP TABLE IF EXISTS `gtkattributes_schema`;
74
+ CREATE TABLE `gtkattributes_schema` (
75
+ `id` int(11) NOT NULL auto_increment,
76
+ `gtkobjecttype` char(16) NOT NULL,
77
+ `attribute` char(32) NOT NULL,
78
+ `attributetype` char(5) NOT NULL,
79
+ `valid_values` text NOT NULL,
80
+ `description` text NOT NULL,
81
+ `can_default` tinyint(4) NOT NULL default '0',
82
+ PRIMARY KEY (`id`)
83
+ ) ENGINE=MyISAM AUTO_INCREMENT=104 DEFAULT CHARSET=utf8;
84
+ DROP TABLE IF EXISTS `gtkformitems`;
85
+ CREATE TABLE `gtkformitems` (
86
+ `id` int(11) NOT NULL auto_increment,
87
+ `data` varchar(50) NOT NULL,
88
+ `updatedata` varchar(30) NOT NULL default '',
89
+ `formid` int(11) NOT NULL default '0',
90
+ `gtktype` varchar(20) NOT NULL default 'gtk_text',
91
+ `editable` varchar(5) NOT NULL default '0',
92
+ `required` varchar(5) NOT NULL default '',
93
+ `description` varchar(30) NOT NULL default '',
94
+ `x` char(2) NOT NULL default '0',
95
+ `xspan` char(2) NOT NULL default '1',
96
+ `y` char(2) NOT NULL default '0',
97
+ `yspan` char(2) NOT NULL default '1',
98
+ `querysql` text NOT NULL,
99
+ `to_call` int(11) NOT NULL default '0',
100
+ `hint` text NOT NULL,
101
+ `hrequest` int(11) NOT NULL default '-1',
102
+ `wrequest` int(11) NOT NULL default '-1',
103
+ `type_def` text NOT NULL,
104
+ PRIMARY KEY (`id`),
105
+ KEY `formid` (`formid`),
106
+ KEY `to_call` (`to_call`)
107
+ ) ENGINE=MyISAM AUTO_INCREMENT=110 DEFAULT CHARSET=utf8;
108
+ DROP TABLE IF EXISTS `gtkheaders`;
109
+ CREATE TABLE `gtkheaders` (
110
+ `listing` varchar(10) NOT NULL default '',
111
+ `oid` float NOT NULL default '0',
112
+ `header` varchar(40) NOT NULL,
113
+ `printable` char(5) NOT NULL default 'true',
114
+ `data` varchar(50) NOT NULL default '',
115
+ `id` int(11) NOT NULL auto_increment,
116
+ `align` varchar(10) NOT NULL default '',
117
+ `type` varchar(20) NOT NULL default '',
118
+ `editable` varchar(5) NOT NULL default '',
119
+ `querySQL` text NOT NULL,
120
+ `rgrp_id` smallint(6) NOT NULL,
121
+ `wgrp_id` smallint(6) NOT NULL,
122
+ PRIMARY KEY (`id`),
123
+ KEY `oid` (`oid`),
124
+ KEY `listing` (`listing`),
125
+ KEY `rgrp_id` (`rgrp_id`),
126
+ KEY `wgrp_id` (`wgrp_id`)
127
+ ) ENGINE=MyISAM AUTO_INCREMENT=253 DEFAULT CHARSET=utf8;
128
+ DROP TABLE IF EXISTS `gtkmenu`;
129
+ CREATE TABLE `gtkmenu` (
130
+ `id` int(11) NOT NULL auto_increment,
131
+ `oid` varchar(11) NOT NULL default '0',
132
+ `hint` varchar(100) NOT NULL default '',
133
+ `display` varchar(50) NOT NULL default '',
134
+ `parent` int(11) NOT NULL default '0',
135
+ `module` tinyint(4) NOT NULL default '0',
136
+ `groupid` tinyint(4) NOT NULL default '0',
137
+ `target` int(11) default NULL,
138
+ `imageid` int(11) NOT NULL,
139
+ PRIMARY KEY (`id`),
140
+ KEY `oid` (`oid`),
141
+ KEY `parent` (`parent`),
142
+ KEY `module` (`module`),
143
+ KEY `groupid` (`groupid`),
144
+ KEY `target` (`target`),
145
+ KEY `imageid` (`imageid`)
146
+ ) ENGINE=MyISAM AUTO_INCREMENT=67 DEFAULT CHARSET=utf8;
147
+ DROP TABLE IF EXISTS `gtkprintitems`;
148
+ CREATE TABLE `gtkprintitems` (
149
+ `id` int(11) NOT NULL auto_increment,
150
+ `printid` int(11) NOT NULL default '0',
151
+ `gtktype` varchar(20) NOT NULL default '',
152
+ `page_number` tinyint(4) NOT NULL,
153
+ `x` int(11) NOT NULL default '0',
154
+ `y` int(11) NOT NULL default '0',
155
+ `txt` text NOT NULL,
156
+ `font` varchar(64) NOT NULL,
157
+ `width` int(100) NOT NULL,
158
+ `height` int(100) NOT NULL,
159
+ `text_alignment` varchar(6) NOT NULL default 'left',
160
+ PRIMARY KEY (`id`),
161
+ KEY `printid` (`printid`)
162
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
163
+ DROP TABLE IF EXISTS `gtkprintpages`;
164
+ CREATE TABLE `gtkprintpages` (
165
+ `moditem_id` int(11) NOT NULL,
166
+ `paper_size_name` varchar(16) NOT NULL,
167
+ `orientation` varchar(32) NOT NULL,
168
+ `bottom_margin` float NOT NULL,
169
+ `top_margin` float NOT NULL,
170
+ `left_margin` float NOT NULL,
171
+ `right_margin` float NOT NULL,
172
+ UNIQUE KEY `moditem_id` (`moditem_id`)
173
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
174
+ DROP TABLE IF EXISTS `help_formats`;
175
+ CREATE TABLE `help_formats` (
176
+ `name` varchar(100) NOT NULL,
177
+ `format_dump` text NOT NULL,
178
+ PRIMARY KEY (`name`)
179
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
180
+ DROP TABLE IF EXISTS `help_items`;
181
+ CREATE TABLE `help_items` (
182
+ `index` varchar(100) NOT NULL,
183
+ `description` text NOT NULL,
184
+ PRIMARY KEY (`index`)
185
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
186
+ DROP TABLE IF EXISTS `history`;
187
+ CREATE TABLE `history` (
188
+ `id` bigint(20) NOT NULL auto_increment,
189
+ `ctime` datetime NOT NULL,
190
+ `nick` varchar(10) NOT NULL,
191
+ `base` varchar(100) NOT NULL,
192
+ `row_id` bigint(20) NOT NULL,
193
+ `operation` char(1) NOT NULL,
194
+ `header_id` int(11) NOT NULL,
195
+ `data` text NOT NULL,
196
+ PRIMARY KEY (`id`)
197
+ ) ENGINE=MyISAM AUTO_INCREMENT=1846 DEFAULT CHARSET=utf8;
198
+ DROP TABLE IF EXISTS `images`;
199
+ CREATE TABLE `images` (
200
+ `id` int(11) NOT NULL auto_increment,
201
+ `filename` text NOT NULL,
202
+ `filedata` longblob NOT NULL,
203
+ PRIMARY KEY (`id`)
204
+ ) ENGINE=MyISAM AUTO_INCREMENT=48 DEFAULT CHARSET=utf8;
205
+ DROP TABLE IF EXISTS `messages`;
206
+ CREATE TABLE `messages` (
207
+ `id` bigint(20) NOT NULL auto_increment,
208
+ `date` datetime default NULL,
209
+ `sender` char(12) NOT NULL,
210
+ `recipient` char(12) NOT NULL,
211
+ `subject` text NOT NULL,
212
+ `body` text NOT NULL,
213
+ `state` char(1) NOT NULL,
214
+ PRIMARY KEY (`id`)
215
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
216
+ DROP TABLE IF EXISTS `moditems`;
217
+ CREATE TABLE `moditems` (
218
+ `id` int(11) NOT NULL auto_increment,
219
+ `querysql` text NOT NULL,
220
+ `query_sql_id` int(11) NOT NULL,
221
+ `comment` text NOT NULL,
222
+ `additional_on_update` text NOT NULL,
223
+ `additional_on_insert` text NOT NULL,
224
+ `display` text NOT NULL,
225
+ `name` varchar(20) NOT NULL default '',
226
+ `modid` int(11) NOT NULL default '0',
227
+ `oid` char(2) NOT NULL default '0',
228
+ `parent` int(11) NOT NULL default '0',
229
+ `on_embed` text NOT NULL,
230
+ PRIMARY KEY (`id`),
231
+ KEY `modid` (`modid`),
232
+ KEY `oid` (`oid`),
233
+ KEY `parent` (`parent`)
234
+ ) ENGINE=MyISAM AUTO_INCREMENT=102 DEFAULT CHARSET=utf8;
235
+ DROP TABLE IF EXISTS `modules`;
236
+ CREATE TABLE `modules` (
237
+ `id` tinyint(4) NOT NULL auto_increment,
238
+ `modname` text NOT NULL,
239
+ PRIMARY KEY (`id`)
240
+ ) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
241
+ DROP TABLE IF EXISTS `qobjects`;
242
+ CREATE TABLE `qobjects` (
243
+ `id` int(11) NOT NULL auto_increment,
244
+ `query_id` int(11) NOT NULL,
245
+ `obj_type` char(1) NOT NULL,
246
+ `obj_id` int(11) NOT NULL,
247
+ `field` text,
248
+ `custom` char(5) NOT NULL default 'false',
249
+ PRIMARY KEY (`id`)
250
+ ) ENGINE=MyISAM AUTO_INCREMENT=69 DEFAULT CHARSET=utf8;
251
+ DROP TABLE IF EXISTS `queries`;
252
+ CREATE TABLE `queries` (
253
+ `id` int(11) NOT NULL auto_increment,
254
+ `name` varchar(50) NOT NULL,
255
+ `base` int(11) NOT NULL,
256
+ `comment` text NOT NULL,
257
+ `sql` text NOT NULL,
258
+ `where_clause` text NOT NULL,
259
+ `order_by_qobject_id` int(11) NOT NULL,
260
+ `order_by_dir` tinyint(4) NOT NULL,
261
+ `group_by` text NOT NULL,
262
+ PRIMARY KEY (`id`)
263
+ ) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
264
+ DROP TABLE IF EXISTS `relations`;
265
+ CREATE TABLE `relations` (
266
+ `id` int(11) NOT NULL auto_increment,
267
+ `src_table` char(32) NOT NULL,
268
+ `src_field` char(64) NOT NULL,
269
+ `dst_table` char(32) NOT NULL,
270
+ `dst_field` char(64) NOT NULL,
271
+ `rel_type` char(1) NOT NULL,
272
+ `rbx` float NOT NULL default '0',
273
+ `rby` float NOT NULL default '0',
274
+ `rel_name` varchar(30) NOT NULL,
275
+ `rel_custom` text NOT NULL,
276
+ PRIMARY KEY (`id`),
277
+ KEY `src_table` (`src_table`),
278
+ KEY `src_field` (`src_field`),
279
+ KEY `dst_table` (`dst_table`),
280
+ KEY `joint_type` (`rel_type`),
281
+ KEY `dst_field` (`dst_field`)
282
+ ) ENGINE=MyISAM AUTO_INCREMENT=38 DEFAULT CHARSET=utf8;
283
+ DROP TABLE IF EXISTS `scv`;
284
+ CREATE TABLE `scv` (
285
+ `id` int(11) NOT NULL auto_increment,
286
+ `cdisplay` text NOT NULL,
287
+ `cdata` varchar(32) NOT NULL,
288
+ `combo` varchar(64) NOT NULL default '0',
289
+ `description` text NOT NULL,
290
+ PRIMARY KEY (`id`),
291
+ KEY `cdata` (`cdata`),
292
+ KEY `combo` (`combo`)
293
+ ) ENGINE=MyISAM AUTO_INCREMENT=132 DEFAULT CHARSET=utf8;
294
+ DROP TABLE IF EXISTS `tables`;
295
+ CREATE TABLE `tables` (
296
+ `id` int(11) NOT NULL auto_increment,
297
+ `name` char(128) NOT NULL,
298
+ `rbx` float NOT NULL default '0',
299
+ `rby` float NOT NULL default '0',
300
+ PRIMARY KEY (`id`),
301
+ KEY `name` (`name`)
302
+ ) ENGINE=MyISAM AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
303
+ DROP TABLE IF EXISTS `todo`;
304
+ CREATE TABLE `todo` (
305
+ `id` bigint(20) NOT NULL auto_increment,
306
+ `moditems_id` bigint(20) NOT NULL,
307
+ `cdate` date NOT NULL,
308
+ `todo` text NOT NULL,
309
+ `comment` text NOT NULL,
310
+ `done` char(5) NOT NULL default 'false',
311
+ PRIMARY KEY (`id`)
312
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
313
+ DROP TABLE IF EXISTS `usergroups`;
314
+ CREATE TABLE `usergroups` (
315
+ `id` int(11) NOT NULL auto_increment,
316
+ `groupid` int(11) NOT NULL default '0',
317
+ `userid` int(11) NOT NULL default '0',
318
+ PRIMARY KEY (`id`),
319
+ KEY `groupid` (`groupid`),
320
+ KEY `userid` (`userid`)
321
+ ) ENGINE=MyISAM AUTO_INCREMENT=59 DEFAULT CHARSET=utf8;
322
+ DROP TABLE IF EXISTS `users`;
323
+ CREATE TABLE `users` (
324
+ `id` int(11) NOT NULL auto_increment,
325
+ `nick` varchar(10) NOT NULL default '',
326
+ `passwd` varchar(32) NOT NULL default '',
327
+ `name` varchar(200) NOT NULL default '',
328
+ `email` text NOT NULL,
329
+ PRIMARY KEY (`id`),
330
+ KEY `nick` (`nick`)
331
+ ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
332
+
333
+
334
+
335
+
336
+ DROP TABLE IF EXISTS `modules`;
337
+ CREATE TABLE `modules` (
338
+ `id` tinyint(4) NOT NULL auto_increment,
339
+ `modname` text NOT NULL,
340
+ PRIMARY KEY (`id`)
341
+ ) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
342
+
343
+ LOCK TABLES `modules` WRITE;
344
+ INSERT INTO `modules` (`id`, `modname`) VALUES (1,'listing'),(2,'form'),(5,'about'),(9,'print'),(10,'info'),(11,'print_wysiwyg'),(12,'quit'),(13,'config'),(14,'relation_builder'),(17,'help');
345
+ UNLOCK TABLES;
346
+ DROP TABLE IF EXISTS `db_version`;
347
+ CREATE TABLE `db_version` (
348
+ `version` float default NULL,
349
+ `utime` timestamp NOT NULL default CURRENT_TIMESTAMP
350
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
351
+
352
+ LOCK TABLES `db_version` WRITE;
353
+ INSERT INTO `db_version` (`version`, `utime`) VALUES (1,'2009-07-23 08:55:01'),(2,'2009-12-17 11:18:48'),(3,'2010-01-31 09:05:48'),(4,'2010-03-11 09:13:27'),(5,'2010-06-15 17:56:57'),(6,'2010-07-13 10:30:04'),(7,'2010-08-10 18:59:54'),(8,'2010-08-11 07:06:12'),(9,'2010-08-11 07:06:12'),(12,'2010-09-07 16:49:20'),(10,'2010-08-11 18:45:44'),(11,'2010-09-07 16:49:20'),(14,'2011-01-17 07:38:10');
354
+ UNLOCK TABLES;
355
+
356
+
@@ -0,0 +1,19 @@
1
+ # manqod-server server.conf
2
+ # this is the main server uri (this usually matches with your client's server.conf)
3
+ #
4
+ # for the host part you can use a fqdn or an ip or nothing
5
+ # if fqdn is set, it will be resolved to a local ip
6
+ # if ip is set, the server will listen only on that interface
7
+ # if nothing is set, than the server will bind to all interfaces
8
+ #
9
+ # the port for the main manqod server thread is usually 5549, but can be changed
10
+ #server_uri = "druby://:5549"
11
+
12
+ #the filename to log to, defaults to path-to-manqod-server/log/manqod-server.log
13
+ #log="/tmp/manqod-server.log"
14
+
15
+ #debug level, defaults to ERROR
16
+ #debug="ERROR"
17
+
18
+ #e-mail address, where automatic server errors and user reports are sent, no default
19
+ #report=root
data/etc/update.sql ADDED
@@ -0,0 +1,35 @@
1
+ -- pre auto-update queries can be found At revision 169.
2
+ -- this file is parsed by manqod-server on startup, queries will be auto applied on the databases
3
+ -- format: comments start with --, one query per version
4
+ -- query; -- version_number
5
+ -- version_number will be inserted automatically into db_version by manqod_server
6
+
7
+ -- adding the database version table, apply i by hand
8
+ create table if not exists db_version (`version` float, `utime` timestamp default current_timestamp);
9
+
10
+ -- first database version, apply it by hand
11
+ insert into db_version set version=1; --1
12
+
13
+ ALTER TABLE `gtkprintitems` ADD `text_alignment` VARCHAR( 6 ) NOT NULL DEFAULT 'left'; --2
14
+
15
+ ALTER TABLE `users` drop `autologin`; --3
16
+
17
+ ALTER TABLE `tables` CHANGE `name` `name` CHAR( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; -- 4
18
+
19
+ ALTER TABLE `history` CHANGE `list_id` `base` VARCHAR( 100 ) NOT NULL; --5
20
+
21
+ ALTER TABLE `users` ADD `email` TEXT NOT NULL ; --6
22
+
23
+ INSERT INTO `modules` (`id` ,`modname`)VALUES (NULL , 'help'); --7
24
+
25
+ DROP TABLE IF EXISTS `help`; --8
26
+
27
+ CREATE TABLE `help_items` (`index` VARCHAR( 100 ) NOT NULL ,`description` TEXT NOT NULL ,PRIMARY KEY ( `index` )) ENGINE = MYISAM; --9
28
+ CREATE TABLE `help_formats` (`name` VARCHAR( 100 ) NOT NULL ,`format_dump` TEXT NOT NULL ,PRIMARY KEY ( `name` )) ENGINE = MYISAM; --10
29
+
30
+ DROP TABLE IF EXISTS `messages`; --11
31
+ CREATE TABLE `messages` (`id` BIGINT NOT NULL AUTO_INCREMENT,`date` datetime, `sender` CHAR( 12 ) NOT NULL ,`recipient` CHAR( 12 ) NOT NULL ,`subject` TEXT NOT NULL ,`body` TEXT NOT NULL ,`state` CHAR( 1 ) NOT NULL ,PRIMARY KEY ( `id` )) ENGINE = MYISAM; --12
32
+ ALTER TABLE `todo` ADD `comment` TEXT NOT NULL AFTER `todo`; --13
33
+
34
+ CREATE TABLE `cronjobs` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,`moditems_id` INT NOT NULL ,`cron` VARCHAR( 32 ) NOT NULL , `command` TEXT NOT NULL ) ENGINE = MYISAM; --14
35
+
data/lib/DBSetup.rb ADDED
@@ -0,0 +1,98 @@
1
+ #this file is part of manqod
2
+ #manqod is distributed under the CDDL licence
3
+ #the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
4
+
5
+ module DBSetup
6
+ def load_conns
7
+ einfo("loading server connections")
8
+ begin
9
+ f=File.new(@connections_conf)
10
+ @conns=Marshal.load(f.read)
11
+ f.close
12
+ rescue =>err
13
+ ewarn("can't load config: #{@connections_conf}\n#{err}")
14
+ end
15
+ end
16
+ def save_conns
17
+ einfo("saving server connections")
18
+ begin
19
+ f=File.new(@connections_conf,"w+")
20
+ f.write(Marshal.dump(@conns))
21
+ rescue =>err
22
+ ewarn("can't write config: #{@connections_conf}\n{err}")
23
+ ensure
24
+ f.close
25
+ end
26
+ end
27
+
28
+ def create_conn(conn_name)
29
+ @conns[conn_name]=Hash.new
30
+ save_conns
31
+ end
32
+
33
+ def remove_conn(conn_name)
34
+ free_conn(conn_name)
35
+ @conns.delete(conn_name)
36
+ save_conns
37
+ end
38
+
39
+ def set_conn_variables(conn_name,conn_vars)
40
+ conn_vars.each_pair{|var,val|
41
+ @conns[conn_name][var]=val
42
+ }
43
+ save_conns
44
+ end
45
+
46
+ def check_sql_db(conn_name)
47
+ begin
48
+ conn=@conns[conn_name]
49
+ require 'DrbDB/MyMultiSQL/mysql-ruby.rb'
50
+ sql=MySQL.new(conn['sql_host'],conn['sql_user'],conn['sql_password'],conn['sql_db'])
51
+ sql.close
52
+ rescue => err
53
+ eerror("#{err} #{err.backtrace.join("\n\t")}")
54
+ raise "#{err}"
55
+ end
56
+ end
57
+
58
+ def create_sql_db_and_perms(conn_name,su,sup)
59
+ begin
60
+ conn=@conns[conn_name]
61
+ require 'DrbDB/MyMultiSQL/mysql-ruby.rb'
62
+ sql=MySQL.new(conn['sql_host'],su,sup,nil)
63
+ sql.query("drop database if exists `#{conn['sql_db']}`")
64
+ sql.query("create database `#{conn['sql_db']}`")
65
+ begin
66
+ sql.query("create user '#{conn['sql_user']}' identified by '#{conn['sql_password']}'")
67
+ rescue =>e
68
+ einfo("failed to create user '#{conn['sql_user']}'")
69
+ end
70
+ sql.query("grant all privileges on #{conn['sql_db']}.* to '#{conn['sql_user']}'")
71
+ sql.query("flush privileges")
72
+ # conn['sql_user'],conn['sql_password'],conn['sql_db'])
73
+ sql.close
74
+ rescue => err
75
+ eerror("#{err} #{err.backtrace.join("\n\t")}")
76
+ raise "#{err}"
77
+ end
78
+ end
79
+
80
+ def populate_manqod_db(conn_name,structure_only=false)
81
+ begin
82
+ conn=@conns[conn_name]
83
+ require 'DrbDB/MyMultiSQL/mysql-ruby.rb'
84
+ sql=MySQL.new(conn['sql_host'],conn['sql_user'],conn['sql_password'],conn['sql_db'])
85
+ filename=structure_only ? "manqod_structure.sql" : "manqod.sql"
86
+ file=File.open(File::expand_path(File.join(File.join(@path,"doc"),filename)))
87
+ while q=file.gets(";\n")
88
+ qq=q.gsub("\n","")
89
+ sql.query(qq) if q.length>5
90
+ end
91
+ file.close
92
+ sql.close
93
+ rescue =>err
94
+ eerror("#{err} #{err.backtrace.join("\n\t")}")
95
+ raise "#{err}"
96
+ end
97
+ end
98
+ end
data/lib/DrbDB/Cron.rb ADDED
@@ -0,0 +1,66 @@
1
+ #this file is part of manqod
2
+ #manqod is distributed under the CDDL licence
3
+ #the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
4
+
5
+ module Cron
6
+ class CronJob
7
+ def initialize(cron_id,cron,moditems_id,command,drbdb)
8
+ @cron_id=cron_id
9
+ @cron=cron
10
+ @moditems_id=moditems_id
11
+ @command=command
12
+ @drbdb=drbdb
13
+ @scheduler=@drbdb.scheduler
14
+ @job=nil
15
+
16
+ end
17
+ def register
18
+ @job=@scheduler.cron(@cron) {|job|
19
+ if @drbdb.moditem(@moditems_id) and b=@drbdb.moditem(@moditems_id).getBinding then
20
+ @drbdb.einfo("running ##{@cron_id} @#{@cron} on #{@drbdb.moditem(@moditems_id)}")
21
+ ret=eval(@command, b)
22
+ end
23
+ }
24
+ self
25
+ end
26
+ def unregister
27
+ @job.unschedule if @job
28
+ end
29
+ def to_s
30
+ "CronJob ##{@cron_id}"
31
+ end
32
+ end
33
+
34
+ def start_cron
35
+ einfo("starting Cron")
36
+ @scheduler = Rufus::Scheduler.start_new
37
+ @crons=Hash.new
38
+ admin.rows("select * from cronjobs").each{|row|
39
+ @crons[row["id"].to_i]=CronJob.new(row["id"].to_i,row["cron"],row["moditems_id"].to_i,row["command"],self).register;
40
+ }
41
+ end
42
+ attr_reader :scheduler
43
+
44
+ def stop_cron
45
+ einfo("stopping Cron")
46
+ @scheduler.stop
47
+ end
48
+ def remove_cron(cron_id)
49
+ edebug("removing cronjob ##{cron_id}")
50
+ if @crons.has_key?(cron_id)
51
+ @crons[cron_id].unregister
52
+ @crons.delete(cron_id)
53
+ end
54
+ end
55
+ def add_cron(cron_id)
56
+ admin.rows("select * from cronjobs where id='#{cron_id}'").each{|row|
57
+ edebug("adding cronjob ##{cron_id} for #{moditem(row["moditems_id"].to_i)}")
58
+ @crons[row["id"].to_i]=CronJob.new(row["id"].to_i,row["cron"],row["moditems_id"].to_i,row["command"],self).register;
59
+ }
60
+ end
61
+ def reset_cron(cron_id)
62
+ remove_cron(cron_id)
63
+ add_cron(cron_id)
64
+ end
65
+ end
66
+
@@ -0,0 +1,79 @@
1
+ #this file is part of manqod
2
+ #manqod is distributed under the CDDL licence
3
+ #the owner of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
4
+
5
+
6
+ class DrbForm
7
+ include Eprint
8
+ include DRbUndumped
9
+ def initialize(drbdb,my_id)
10
+ @my_id=my_id.to_i
11
+ @drbdb=drbdb
12
+ @title="not loaded"
13
+ end
14
+ attr_reader :moditem, :tabs
15
+
16
+ def create_skeleton
17
+ @moditem=@drbdb.admin.qrow("select * from moditems where id='#{@my_id}'")
18
+ @title=@moditem["display"]
19
+ if @table=gtk_attribute("table")
20
+ @querySQL="select * from `#{@table}` where id='\#{@parentselected}'"
21
+ edebug("table(from attribute): #{@table.inspect}") unless @drbdb.main_server.starting_up
22
+ else
23
+ @querySQL=@moditem["querysql"]
24
+ @table=@drbdb.admin.guess_base(@querySQL)
25
+ edebug("table(guessed): #{@table.inspect}") unless @drbdb.main_server.starting_up
26
+ end
27
+
28
+ @batch=false
29
+ @tabs=Hash.new
30
+ items=Array.new
31
+ @drbdb.admin.rows("select gtkformitems.*,modules.modname from gtkformitems left join moditems on gtkformitems.to_call = moditems.id left join modules on modules.id=moditems.modid where formid='#{@my_id}' order by y,x").each{|itemp|
32
+ #Form suppots batch if at least one item supports it
33
+ @batch=true if (@drbdb.gtk_attribute_of_object("batch",itemp["id"],"form-item") || "false").upcase == "TRUE"
34
+ itemp["tab"]=@drbdb.gtk_attribute_of_object("tab",itemp["id"],"form-item") || "default"
35
+ #add the missing tab item requires
36
+ unless tabs.has_key?(itemp["tab"])
37
+ tabs[itemp["tab"]]=Hash.new
38
+ tabs[itemp["tab"]]["title"]=(itemp["tab"] == "default" ? "" : itemp["tab"])
39
+ end
40
+ tabs[itemp["tab"]]["minX"]=itemp["x"].to_i if !tabs[itemp["tab"]].has_key?("minX") || tabs[itemp["tab"]]["minX"]>itemp["x"].to_i
41
+ tabs[itemp["tab"]]["minY"]=itemp["y"].to_i if !tabs[itemp["tab"]].has_key?("minY") || tabs[itemp["tab"]]["minY"]>itemp["y"].to_i
42
+ tabs[itemp["tab"]]["maxX"]=itemp["x"].to_i if !tabs[itemp["tab"]].has_key?("maxX") || tabs[itemp["tab"]]["maxX"]<itemp["x"].to_i
43
+ tabs[itemp["tab"]]["maxY"]=itemp["y"].to_i if !tabs[itemp["tab"]].has_key?("maxY") || tabs[itemp["tab"]]["maxY"]<itemp["y"].to_i
44
+ items.push(itemp)
45
+ }
46
+
47
+ cache.set("#{@my_id}moditem",@moditem)
48
+ cache.set("#{@my_id}attributes",{
49
+ :querySQL=>@querySQL,
50
+ :title=>@title,
51
+ :table=>@table,
52
+ :tabs=>tabs,
53
+ :batch=>@batch
54
+ })
55
+ cache.set("#{@my_id}items",items)
56
+
57
+ self
58
+ end
59
+
60
+ def cache
61
+ @drbdb.cache
62
+ end
63
+
64
+
65
+ def get_id
66
+ @my_id
67
+ end
68
+ def gtk_attribute(gattr)
69
+ @drbdb.gtk_attribute(gattr,self)
70
+ end
71
+ def mod_type
72
+ "form"
73
+ end
74
+ def to_s
75
+ "DrbForm{#{@drbdb.name}:#{@title}(#{@my_id})}"
76
+ end
77
+
78
+ end
79
+
@@ -0,0 +1,39 @@
1
+ #this file is part of manqod
2
+ #manqod is distributed under the CDDL licence
3
+ #the owner of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
4
+
5
+ class DrbImages
6
+ include Eprint
7
+ include DRbUndumped
8
+ def initialize(drbdb)
9
+ @drbdb=drbdb
10
+ @images=Hash.new
11
+ end
12
+ attr_reader :drbdb, :images
13
+
14
+
15
+ def load_all
16
+ @keys=Hash.new
17
+ begin
18
+ drbdb.admin.rows("select * from images").each{|row|
19
+ @images[row["id"].to_i]=row
20
+ @drbdb.cache.set("im[#{row["id"]}]",row)
21
+ @keys[row["id"].to_i]="im[#{row["id"]}]"
22
+ }
23
+ rescue => err
24
+ end
25
+ @drbdb.cache.set("imkeys",@keys)
26
+ einfo("#{@images.size} images")
27
+ self
28
+ end
29
+ def get_image(image_id)
30
+ @images[image_id.to_i]
31
+ end
32
+ def keys
33
+ @images.keys
34
+ end
35
+ def to_s
36
+ "Images of #{drbdb}"
37
+ end
38
+ end
39
+