Contents of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk.control.class.in
Parent Directory | Revision Log
Revision 2874 -
(show annotations)
(download)
Fri Aug 14 08:43:55 2020 UTC (3 years, 8 months ago) by niro
File size: 3087 byte(s)
Fri Aug 14 08:43:55 2020 UTC (3 years, 8 months ago) by niro
File size: 3087 byte(s)
-fixed broken table evaluation
1 | # $Id$ |
2 | |
3 | push_config 80_idesk_icon |
4 | |
5 | help_idesk_icon() |
6 | { |
7 | local serial="${CLASS_ARGV[0]}" |
8 | control_client "${serial}" help idesk.icon |
9 | } |
10 | |
11 | set_idesk_icon() |
12 | { |
13 | local serial="${CLASS_ARGV[0]}" |
14 | local action="${CLASS_ARGV[1]}" |
15 | local name="${CLASS_ARGV[2]}" |
16 | local command="${CLASS_ARGV[3]}" |
17 | local icon="${CLASS_ARGV[4]}" |
18 | local filename="${CLASS_ARGV[5]}" |
19 | local xypos="${CLASS_ARGV[6]}" |
20 | local widthheight="${CLASS_ARGV[7]}" |
21 | local default_icon="${CLASS_ARGV[8]}" |
22 | local xpos |
23 | local ypos |
24 | local width |
25 | local height |
26 | local id |
27 | local enabled |
28 | |
29 | [[ -z ${action} ]] && help_idesk_icon && return 1 |
30 | |
31 | if [[ -n ${xypos} ]] |
32 | then |
33 | xpos="${xypos%,*}" |
34 | ypos="${xypos#*,}" |
35 | fi |
36 | |
37 | if [[ -n ${widthheight} ]] |
38 | then |
39 | width="${widthheight%,*}" |
40 | height="${widthheight#*,}" |
41 | fi |
42 | |
43 | case "${action}" in |
44 | add) enabled=1 ;; |
45 | del) enabled=0 ;; |
46 | *) |
47 | eecho "Unknown action '${action}'" |
48 | return 1 |
49 | ;; |
50 | esac |
51 | |
52 | if [[ -z ${name} ]] |
53 | then |
54 | eecho "No name given" |
55 | return 1 |
56 | fi |
57 | |
58 | id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';") |
59 | if [[ -n ${id} ]] |
60 | then |
61 | mysqldo "update cfg_idesk_icon set name='${name}', command='${command}', icon='${icon}', filename='${filename}', xpos='${xpos}', ypos='${ypos}', width='${width}', height='${height}', default_icon='${default_icon}', enabled='${enabled}' where id=${id};" |
62 | else |
63 | mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled) |
64 | values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');" |
65 | fi |
66 | } |
67 | |
68 | control_idesk_icon() |
69 | { |
70 | local serial="${CLASS_ARGV[0]}" |
71 | push_config_80_idesk_icon "${serial}" |
72 | } |
73 | |
74 | push_config_80_idesk_icon() |
75 | { |
76 | local serial="$1" |
77 | local values |
78 | local id |
79 | local xypos |
80 | local widthheight |
81 | |
82 | values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';") |
83 | for id in ${values} |
84 | do |
85 | evaluate_table_xml cfg_idesk_icon "where id='${id}'" |
86 | if [[ -z ${cfg_idesk_icon_name} ]] |
87 | then |
88 | eecho "Name must not be empty id->'${id}'" |
89 | continue |
90 | fi |
91 | if [[ -z ${cfg_idesk_icon_enabled} ]] |
92 | then |
93 | eecho "Enabled must not be empty id->'${id}'" |
94 | continue |
95 | fi |
96 | if [[ ${cfg_idesk_icon_enabled} = 1 ]] |
97 | then |
98 | if [[ -n ${cfg_idesk_icon_xpos} ]] && [[ -n ${cfg_idesk_icon_ypos} ]] |
99 | then |
100 | xypos="${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}" |
101 | fi |
102 | if [[ -n ${width} ]] && [[ -n ${height} ]] |
103 | then |
104 | widthheight="${cfg_idesk_icon_width},${cfg_idesk_icon_height}" |
105 | fi |
106 | control_client "${serial}" set idesk.icon add "${cfg_idesk_icon_name}" "${cfg_idesk_icon_command}" "${cfg_idesk_icon_icon}" "${cfg_idesk_icon_filename}" "${xypos}" "${widthheight}" "${cfg_idesk_icon_default_icon}" |
107 | elif [[ ${cfg_idesk_icon_enabled} = 0 ]] |
108 | then |
109 | control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}" |
110 | # remove from database too |
111 | mysqldo "delete from cfg_idesk_icon where id='${id}';" |
112 | else |
113 | eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'" |
114 | return 1 |
115 | fi |
116 | done |
117 | } |