From 3c13387dfd965afe5c3b2d9bd0e31303599d8784 Mon Sep 17 00:00:00 2001 From: rvelices Date: Wed, 18 Jun 2014 19:51:42 +0000 Subject: since number of accepted args not required for add_event_handler, simplify calls git-svn-id: http://piwigo.org/svn/trunk@28714 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/include/add_core_tabs.inc.php | 32 ++++++++++++++++---------------- admin/include/functions_history.inc.php | 18 +++++++++--------- admin/include/functions_upload.inc.php | 20 ++++++++++---------- include/common.inc.php | 4 ++-- include/functions_comment.inc.php | 31 +++++++++++++++---------------- include/functions_user.inc.php | 12 ++++++------ picture.php | 7 +------ 7 files changed, 59 insertions(+), 65 deletions(-) diff --git a/admin/include/add_core_tabs.inc.php b/admin/include/add_core_tabs.inc.php index efc9cd0db..3b0c70118 100644 --- a/admin/include/add_core_tabs.inc.php +++ b/admin/include/add_core_tabs.inc.php @@ -21,7 +21,7 @@ // | USA. | // +-----------------------------------------------------------------------+ -add_event_handler('tabsheet_before_select', 'add_core_tabs', 0, 2); +add_event_handler('tabsheet_before_select', 'add_core_tabs', 0); function add_core_tabs($sheets, $tab_id) { @@ -34,20 +34,20 @@ function add_core_tabs($sheets, $tab_id) $sheets['permissions'] = array('caption' => ''.l10n('Permissions'), 'url' => $admin_album_base_url.'-permissions'); $sheets['notification'] = array('caption' => ''.l10n('Notification'), 'url' => $admin_album_base_url.'-notification'); break; - + case 'albums': global $my_base_url; $sheets['list'] = array('caption' => ''.l10n('List'), 'url' => $my_base_url.'cat_list'); $sheets['move'] = array('caption' => ''.l10n('Move'), 'url' => $my_base_url.'cat_move'); $sheets['permalinks'] = array('caption' => ''.l10n('Permalinks'), 'url' => $my_base_url.'permalinks'); break; - + case 'batch_manager': global $manager_link; $sheets['global'] = array('caption' => l10n('global mode'), 'url' => $manager_link.'global'); $sheets['unit'] = array('caption' => l10n('unit mode'), 'url' => $manager_link.'unit'); break; - + case 'cat_options': global $link_start, $conf; $sheets['status'] = array('caption' => ''.l10n('Public / Private'), 'url' => $link_start.'cat_options&section=status'); @@ -57,7 +57,7 @@ function add_core_tabs($sheets, $tab_id) if ($conf['allow_random_representative']) $sheets['representative'] = array('caption' => l10n('Representative'), 'url' => $link_start.'cat_options&section=representative'); break; - + case 'comments': $sheets[''] = array('caption' => l10n('User comments'), 'url' => ''); break; @@ -79,7 +79,7 @@ function add_core_tabs($sheets, $tab_id) $sheets['comments'] = array('caption' => l10n('Comments'), 'url' => $conf_link.'comments'); $sheets['default'] = array('caption' => l10n('Guest Settings'), 'url' => $conf_link.'default'); break; - + case 'help': global $help_link; $sheets['add_photos'] = array('caption' => l10n('Add Photos'), 'url' => $help_link.'add_photos'); @@ -88,33 +88,33 @@ function add_core_tabs($sheets, $tab_id) $sheets['virtual_links'] = array('caption' => l10n('Virtual Links'), 'url' => $help_link.'virtual_links'); $sheets['misc'] = array('caption' => l10n('Miscellaneous'), 'url' => $help_link.'misc'); break; - + case 'history': global $link_start; $sheets['stats'] = array('caption' => ''.l10n('Statistics'), 'url' => $link_start.'stats'); $sheets['history'] = array('caption' => ''.l10n('Search'), 'url' => $link_start.'history'); break; - + case 'languages': global $my_base_url; $sheets['installed'] = array('caption' => ''.l10n('Installed Languages'), 'url' => $my_base_url.'&tab=installed'); $sheets['update'] = array('caption' => ''.l10n('Check for updates'), 'url' => $my_base_url.'&tab=update'); $sheets['new'] = array('caption' => ''.l10n('Add New Language'), 'url' => $my_base_url.'&tab=new'); break; - + case 'nbm': global $base_url; $sheets['param'] = array('caption' => l10n('Parameter'), 'url' => $base_url.'?page=notification_by_mail&mode=param'); $sheets['subscribe'] = array('caption' => l10n('Subscribe'), 'url' => $base_url.'?page=notification_by_mail&mode=subscribe'); $sheets['send'] = array('caption' => l10n('Send'), 'url' => $base_url.'?page=notification_by_mail&mode=send'); break; - + case 'photo': global $admin_photo_base_url; $sheets['properties'] = array('caption' => l10n('Properties'), 'url' => $admin_photo_base_url.'-properties'); $sheets['coi'] = array('caption' => ''.l10n('Center of interest'), 'url' => $admin_photo_base_url.'-coi'); break; - + case 'photos_add': global $conf; $sheets['direct'] = array('caption' => ''.l10n('Web Form'), 'url' => PHOTOS_ADD_BASE_URL.'&section=direct'); @@ -122,33 +122,33 @@ function add_core_tabs($sheets, $tab_id) if ($conf['enable_synchronization']) $sheets['ftp'] = array('caption' => ''.l10n('FTP + Synchronization'), 'url' => PHOTOS_ADD_BASE_URL.'&section=ftp'); break; - + case 'plugins': global $my_base_url; $sheets['installed'] = array('caption' => ''.l10n('Plugin list'), 'url' => $my_base_url.'&tab=installed'); $sheets['update'] = array('caption' => ''.l10n('Check for updates'), 'url' => $my_base_url.'&tab=update'); $sheets['new'] = array('caption' => ''.l10n('Other plugins'), 'url' => $my_base_url.'&tab=new'); break; - + case 'rating': $sheets['rating'] = array('caption' => l10n('Photos'), 'url' => get_root_url().'admin.php?page=rating'); $sheets['rating_user'] = array('caption' => l10n('Users'), 'url' => get_root_url().'admin.php?page=rating_user'); break; - + case 'themes': global $my_base_url; $sheets['installed'] = array('caption' => ''.l10n('Installed Themes'), 'url' => $my_base_url.'&tab=installed'); $sheets['update'] = array('caption' => ''.l10n('Check for updates'), 'url' => $my_base_url.'&tab=update'); $sheets['new'] = array('caption' => ''.l10n('Add New Theme'), 'url' => $my_base_url.'&tab=new'); break; - + case 'updates': global $my_base_url; $sheets['pwg'] = array('caption' => l10n('Piwigo Update'), 'url' => $my_base_url); $sheets['ext'] = array('caption' => l10n('Extensions Update'), 'url' => $my_base_url.'&tab=ext'); break; } - + return $sheets; } diff --git a/admin/include/functions_history.inc.php b/admin/include/functions_history.inc.php index 6c6bddef7..e2bcc4d62 100644 --- a/admin/include/functions_history.inc.php +++ b/admin/include/functions_history.inc.php @@ -71,9 +71,9 @@ SELECT ;'; $search['image_ids'] = array_from_query($query, 'id'); } - + // echo '
'; print_r($search); echo '
'; - + $clauses = array(); if (isset($search['fields']['date-after'])) @@ -89,7 +89,7 @@ SELECT if (isset($search['fields']['types'])) { $local_clauses = array(); - + foreach ($types as $type) { if (in_array($type, $search['fields']['types'])) { $clause = 'image_type '; @@ -101,11 +101,11 @@ SELECT { $clause.= "= '".$type."'"; } - + $local_clauses[] = $clause; } } - + if (count($local_clauses) > 0) { $clauses[] = implode(' OR ', $local_clauses); @@ -122,7 +122,7 @@ SELECT { $clauses[] = 'image_id = '.$search['fields']['image_id']; } - + if (isset($search['fields']['filename'])) { if (count($search['image_ids']) == 0) @@ -140,7 +140,7 @@ SELECT { $clauses[] = 'IP LIKE "'.$search['fields']['ip'].'"'; } - + $clauses = prepend_append_array_items($clauses, '(', ')'); $where_separator = @@ -148,7 +148,7 @@ SELECT "\n AND ", $clauses ); - + $query = ' SELECT date, @@ -176,7 +176,7 @@ SELECT return $data; } -add_event_handler('get_history', 'get_history', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); +add_event_handler('get_history', 'get_history'); trigger_notify('functions_history_included'); ?> \ No newline at end of file diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php index 40a53adf9..2eefd09b5 100644 --- a/admin/include/functions_upload.inc.php +++ b/admin/include/functions_upload.inc.php @@ -25,8 +25,8 @@ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php'); // add default event handler for image and thumbnail resize -add_event_handler('upload_image_resize', 'pwg_image_resize', EVENT_HANDLER_PRIORITY_NEUTRAL, 7); -add_event_handler('upload_thumbnail_resize', 'pwg_image_resize', EVENT_HANDLER_PRIORITY_NEUTRAL, 9); +add_event_handler('upload_image_resize', 'pwg_image_resize'); +add_event_handler('upload_thumbnail_resize', 'pwg_image_resize'); function get_upload_form_config() { @@ -126,7 +126,7 @@ function save_upload_form_config($data, &$errors=array(), &$form_errors=array()) $upload_form_config[$field]['error_message'], $min, $max ); - + $form_errors[$field] = '['.$min.' .. '.$max.']'; } } @@ -260,19 +260,19 @@ SELECT $representative_file_path.= $representative_ext; prepare_directory(dirname($representative_file_path)); - + $exec = $conf['ext_imagick_dir'].'convert'; if ('jpg' == $conf['tiff_representative_ext']) { $exec .= ' -quality 98'; } - + $exec .= ' "'.realpath($file_path).'"'; $dest = pathinfo($representative_file_path); $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"'; - + $exec .= ' 2>&1'; @exec($exec, $returnarray); @@ -286,7 +286,7 @@ SELECT '-0.'.$representative_ext, $representative_file_abspath ); - + if (file_exists($first_file_abspath)) { rename($first_file_abspath, $representative_file_abspath); @@ -322,7 +322,7 @@ SELECT // width/height of "multisizes" $rotation_angle = pwg_image::get_rotation_angle($file_path); $rotation = pwg_image::get_rotation_code_from_angle($rotation_angle); - + $file_infos = pwg_image_infos($file_path); if (isset($image_id)) @@ -411,9 +411,9 @@ SELECT // in case we are on uploadify.php, we have to replace the false path $thumb_url = preg_replace('#admin/include/i#', 'i', DerivativeImage::thumb_url($image_infos)); unset_make_full_url(); - + fetchRemote($thumb_url, $dest); - + return $image_id; } diff --git a/include/common.inc.php b/include/common.inc.php index e6a1d5877..d282da5a1 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -269,8 +269,8 @@ add_event_handler('render_tag_url', 'str2url'); add_event_handler('blockmanager_register_blocks', 'register_default_menubar_blocks', EVENT_HANDLER_PRIORITY_NEUTRAL-1); if ( !empty($conf['original_url_protection']) ) { - add_event_handler('get_element_url', 'get_element_url_protection_handler', EVENT_HANDLER_PRIORITY_NEUTRAL, 2 ); - add_event_handler('get_src_image_url', 'get_src_image_url_protection_handler', EVENT_HANDLER_PRIORITY_NEUTRAL, 2 ); + add_event_handler('get_element_url', 'get_element_url_protection_handler'); + add_event_handler('get_src_image_url', 'get_src_image_url_protection_handler'); } trigger_notify('init'); ?> diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php index 5807fc12f..3cb0f79c7 100644 --- a/include/functions_comment.inc.php +++ b/include/functions_comment.inc.php @@ -24,10 +24,9 @@ /** * @package functions\comment */ - -add_event_handler('user_comment_check', 'user_comment_check', - EVENT_HANDLER_PRIORITY_NEUTRAL, 2); + +add_event_handler('user_comment_check', 'user_comment_check'); /** * Does basic check on comment and returns action to perform. @@ -143,7 +142,7 @@ SELECT COUNT(*) AS user_exists $comment_action='reject'; $_POST['cr'][] = 'key'; // rvelices: I use this outside to see how spam robots work } - + // website if (!empty($comm['website_url'])) { @@ -158,7 +157,7 @@ SELECT COUNT(*) AS user_exists $comment_action='reject'; } } - + // email if (empty($comm['email'])) { @@ -177,7 +176,7 @@ SELECT COUNT(*) AS user_exists $infos[] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); $comment_action='reject'; } - + // anonymous id = ip address $ip_components = explode('.', $comm['ip']); if (count($ip_components) > 3) @@ -283,23 +282,23 @@ function delete_user_comment($comment_id) { $user_where_clause = ' AND author_id = \''.$GLOBALS['user']['id'].'\''; } - + if (is_array($comment_id)) $where_clause = 'id IN('.implode(',', $comment_id).')'; else $where_clause = 'id = '.$comment_id; - + $query = ' DELETE FROM '.COMMENTS_TABLE.' WHERE '.$where_clause. $user_where_clause.' ;'; - + if ( pwg_db_changes(pwg_query($query)) ) { invalidate_user_cache_nb_comments(); - email_admin('delete', + email_admin('delete', array('author' => $GLOBALS['user']['username'], 'comment_id' => $comment_id )); @@ -383,9 +382,9 @@ UPDATE '.COMMENTS_TABLE.' $user_where_clause.' ;'; $result = pwg_query($query); - + // mail admin and ask to validate the comment - if ($result and $conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action) + if ($result and $conf['email_admin_on_comment_validation'] and 'moderate' == $comment_action) { include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); @@ -411,7 +410,7 @@ $user_where_clause.' 'content' => stripslashes($comment['content'])) ); } } - + return $comment_action; } @@ -482,7 +481,7 @@ SELECT return false; } } - + list($author_id) = pwg_db_fetch_row($result); return $author_id; @@ -499,7 +498,7 @@ function validate_user_comment($comment_id) $where_clause = 'id IN('.implode(',', $comment_id).')'; else $where_clause = 'id = '.$comment_id; - + $query = ' UPDATE '.COMMENTS_TABLE.' SET validated = \'true\' @@ -507,7 +506,7 @@ UPDATE '.COMMENTS_TABLE.' WHERE '.$where_clause.' ;'; pwg_query($query); - + invalidate_user_cache_nb_comments(); trigger_notify('user_comment_validation', $comment_id); } diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 5ee56f0f2..54bbc1b35 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -250,7 +250,7 @@ SELECT id if ($notify_user and email_check_format($mail_address)) { include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); - + $keyargs_content = array( get_l10n_args('Hello %s,', stripslashes($login)), get_l10n_args('Thank you for registering at %s!', $conf['gallery_title']), @@ -262,7 +262,7 @@ SELECT id get_l10n_args('', ''), get_l10n_args('If you think you\'ve received this email in error, please contact us at %s', get_webmaster_mail_address()), ); - + pwg_mail( $mail_address, array( @@ -281,7 +281,7 @@ SELECT id 'email'=>$mail_address, ) ); - + return $user_id; } else @@ -1050,7 +1050,7 @@ function pwg_password_verify($password, $hash, $user_id=null) { return true; } - + // Rehash using new hash. $hash = pwg_password_hash($password); @@ -1088,7 +1088,7 @@ function try_log_user($username, $password, $remember_me) return trigger_change('try_log_user', false, $username, $password, $remember_me); } -add_event_handler('try_log_user', 'pwg_login', EVENT_HANDLER_PRIORITY_NEUTRAL, 4); +add_event_handler('try_log_user', 'pwg_login'); /** * Default method for user login, can be overwritten with 'try_log_user' trigger. @@ -1447,7 +1447,7 @@ function get_sql_condition_FandF( return $sql; } -/** +/** * Returns sql WHERE condition for recent photos/albums for current user. * * @param string $db_field diff --git a/picture.php b/picture.php index abca13f48..aaefcaa3e 100644 --- a/picture.php +++ b/picture.php @@ -135,12 +135,7 @@ if ( isset($_GET['metadata']) ) } // add default event handler for rendering element content -add_event_handler( - 'render_element_content', - 'default_picture_content', - EVENT_HANDLER_PRIORITY_NEUTRAL, - 2 - ); +add_event_handler('render_element_content', 'default_picture_content'); // add default event handler for rendering element description add_event_handler('render_element_description', 'nl2br'); -- cgit v1.2.3