@@ -55,22 +55,41 @@ function plugin_flowview_upgrade() {
5555}
5656
5757function plugin_flowview_check_upgrade () {
58- $ current = plugin_flowview_version ();
59- $ current = $ current ['version ' ];
60- $ old = read_config_option ('plugin_flowview_version ' );
61- if ($ current != $ old ) {
62- flowview_setup_table ();
63- }else {
58+ $ files = array ('plugins.php ' , 'flowview.php ' , 'index.php ' );
59+ if (isset ($ _SERVER ['PHP_SELF ' ]) && !in_array (basename ($ _SERVER ['PHP_SELF ' ]), $ files )) {
6460 return ;
6561 }
6662
67- /* update titles for those that don't have them */
68- db_execute ("UPDATE plugin_flowview_schedules SET title='Ugraded Schedule' WHERE title='' " );
63+ $ info = plugin_flowview_version ();
64+ $ current = $ info ['version ' ];
65+ $ old = read_config_option ('plugin_flowview_version ' );
66+
67+ if ($ current != $ old ) {
68+ $ bad_titles = db_fetch_cell ('SELECT COUNT(*)
69+ FROM plugin_flowview_schedules
70+ WHERE title="" ' );
71+
72+ if ($ bad_titles ) {
73+ /* update titles for those that don't have them */
74+ db_execute ("UPDATE plugin_flowview_schedules SET title='Ugraded Schedule' WHERE title='' " );
75+
76+ /* Set the new version */
77+ db_execute_prepared ("REPLACE INTO settings (name, value) VALUES ('plugin_flowview_version', ?) " , array ($ current ));
6978
70- /* Set the new version */
71- db_execute_prepared ("REPLACE INTO settings (name, value) VALUES ('plugin_flowview_version', ?) " , array ($ current ));
79+ db_execute ('ALTER TABLE plugin_flowview_devices ENGINE=InnoDB ' );
80+ }
81+
82+ db_execute ("UPDATE plugin_config
83+ SET version=' $ current'
84+ WHERE directory='flowview' " );
7285
73- db_execute ('ALTER TABLE plugin_flowview_devices ENGINE=InnoDB ' );
86+ db_execute ("UPDATE plugin_config SET
87+ version=' " . $ info ['version ' ] . "',
88+ name=' " . $ info ['longname ' ] . "',
89+ author=' " . $ info ['author ' ] . "',
90+ webpage=' " . $ info ['homepage ' ] . "'
91+ WHERE directory=' " . $ info ['name ' ] . "' " );
92+ }
7493}
7594
7695function plugin_flowview_version () {
@@ -84,6 +103,8 @@ function flowview_config_arrays() {
84103
85104 $ messages ['flow_deleted ' ] = array ('message ' => __ ('The Filter has been Deleted ' , 'flowview ' ), 'type ' => 'info ' );
86105 $ messages ['flow_updated ' ] = array ('message ' => __ ('The Filter has been Updated ' , 'flowview ' ), 'type ' => 'info ' );
106+
107+ plugin_flowview_check_upgrade ();
87108}
88109
89110function flowview_draw_navigation_text ($ nav ) {
0 commit comments