From 60d0cc2cc9c5f1f5cba5eca7204736a2fa133e09 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 11 Jan 2011 13:42:59 +0000 Subject: [PATCH] Moved check_clock_src to portal/includes/functions.php and renamed it to check_file_src; Edited includes/acp/acp_portal.php to we can use functions outside of the module class upon submitting; Added possibility to move blocks i.e. from left to right column --- root/includes/acp/acp_portal.php | 60 +++++++++++++++++++++++++++- root/portal/includes/functions.php | 34 +++++++++++++++- root/portal/modules/portal_clock.php | 32 +-------------- 3 files changed, 93 insertions(+), 33 deletions(-) diff --git a/root/includes/acp/acp_portal.php b/root/includes/acp/acp_portal.php index 74ad5860..6af2e8e5 100644 --- a/root/includes/acp/acp_portal.php +++ b/root/includes/acp/acp_portal.php @@ -160,7 +160,15 @@ class acp_portal { $func = array($c_class, $null['submit']); $args = ($module_id != 0) ? array($cfg_array[$config_name], $config_name, $module_id) : $config_name; - call_user_func_array($func, $args); + + if(method_exists($c_class, $null['submit'])) + { + call_user_func_array($func, $args); + } + else + { + call_user_func_array($null['submit'], $args); + } } @@ -400,6 +408,31 @@ class acp_portal } } } + elseif($c_class->columns & column_string_const(column_num_string($module_data['module_column'] + 2))) + { + if ($module_data !== false) + { + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order + 1 + WHERE module_order >= ' . $module_data['module_order'] . ' + AND module_column = ' . ($module_data['module_column'] + 2); + $db->sql_query($sql); + $updated = $db->sql_affectedrows(); + if ($updated) + { + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_column = module_column + 2 + WHERE module_id = ' . $module_id; + $db->sql_query($sql); + + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order - 1 + WHERE module_order >= ' . $module_data['module_order'] . ' + AND module_column = ' . $module_data['module_column']; + $db->sql_query($sql); + } + } + } else { trigger_error($user->lang['UNABLE_TO_MOVE'] . adm_back_link($this->u_action)); @@ -450,6 +483,31 @@ class acp_portal } } } + elseif($c_class->columns & column_string_const(column_num_string($module_data['module_column'] - 2))) + { + if ($module_data !== false) + { + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order + 1 + WHERE module_order >= ' . $module_data['module_order'] . ' + AND module_column = ' . ($module_data['module_column'] - 2); + $db->sql_query($sql); + $updated = $db->sql_affectedrows(); + if ($updated) + { + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_column = module_column - 2 + WHERE module_id = ' . $module_id; + $db->sql_query($sql); + + $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' + SET module_order = module_order - 1 + WHERE module_order >= ' . $module_data['module_order'] . ' + AND module_column = ' . $module_data['module_column']; + $db->sql_query($sql); + } + } + } else { trigger_error($user->lang['UNABLE_TO_MOVE'] . adm_back_link($this->u_action)); diff --git a/root/portal/includes/functions.php b/root/portal/includes/functions.php index 411c551f..22b91548 100644 --- a/root/portal/includes/functions.php +++ b/root/portal/includes/functions.php @@ -918,6 +918,38 @@ function board3_basic_install($mode = 'install', $purge_modules = true, $u_actio return $user->lang['PORTAL_BASIC_UNINSTALL']; } -} +} + + +/* +* check if the entered source file actually exists +*/ +function check_file_src($value, $key, $module_id) +{ + global $db, $phpbb_root_path, $phpEx, $user; + + $error = ''; + + $sql = 'SELECT st.theme_path + FROM ' . STYLES_THEME_TABLE . ' st + LEFT JOIN ' . STYLES_TABLE . ' s + ON (st.theme_id = s.style_id) + WHERE s.style_active = 1'; + + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + if(!file_exists($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/images/portal/' . $value)) + { + $error .= $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/' . $row['theme_path'] . '/theme/images/portal/' . $value . '
'; + } + } + $db->sql_freeresult($result); + + if(!empty($error)) + { + trigger_error($error . adm_back_link(append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&mode=config&module_id=' . $module_id))); + } +} ?> \ No newline at end of file diff --git a/root/portal/modules/portal_clock.php b/root/portal/modules/portal_clock.php index 8542f0b2..ef01fa92 100644 --- a/root/portal/modules/portal_clock.php +++ b/root/portal/modules/portal_clock.php @@ -63,7 +63,7 @@ class portal_clock_module 'title' => 'ACP_PORTAL_CLOCK_SETTINGS', 'vars' => array( 'legend1' => 'ACP_PORTAL_CLOCK_SETTINGS', - 'board3_clock_src_' . $module_id => array('lang' => 'ACP_PORTAL_CLOCK_SRC', 'validate' => 'string', 'type' => 'text:50:200', 'explain' => true, 'submit_type' => 'custom', 'submit' => 'check_clock_src'), + 'board3_clock_src_' . $module_id => array('lang' => 'ACP_PORTAL_CLOCK_SRC', 'validate' => 'string', 'type' => 'text:50:200', 'explain' => true, 'submit_type' => 'custom', 'submit' => 'check_file_src'), ), ); } @@ -88,36 +88,6 @@ class portal_clock_module WHERE ' . $db->sql_in_set('config_name', $del_config); return $db->sql_query($sql); } - - - /* - * check if the entered clock src file actually exists - */ - function check_clock_src($value, $key, $module_id) - { - global $db, $phpbb_root_path, $phpEx, $user; - - $sql = 'SELECT st.theme_path - FROM ' . STYLES_THEME_TABLE . ' st - LEFT JOIN ' . STYLES_TABLE . ' s - ON (st.theme_id = s.style_id) - WHERE s.style_active = 1'; - - $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) - { - if(!file_exists($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/images/portal/' . $value)) - { - $error = $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/' . $row['theme_path'] . '/theme/images/portal/' . $value . '
'; - } - } - $db->sql_freeresult($result); - - if(isset($error)) - { - trigger_error($error . adm_back_link(append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&mode=config&module_id=' . $module_id))); - } - } } ?> \ No newline at end of file