diff options
author | rvelices <rv-github@modusoptimus.com> | 2012-02-09 21:11:34 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2012-02-09 21:11:34 +0000 |
commit | f6825cfb33d16796951ce29f28e2e99f61e3d903 (patch) | |
tree | a16d8fffbacb57ef35281e84410d9c7bff0cea6e /include | |
parent | 40280db9d81c299044533c4331af2c2854e4f959 (diff) |
- remove square/thumb from choices on picture
- fix content margin on password register
- purge derivative cache by type of derivative
- session saved infos/messages are not given to the page on html redirections
- shorter/faster code in functions_xxx
git-svn-id: http://piwigo.org/svn/trunk@13074 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/functions_category.inc.php | 28 | ||||
-rw-r--r-- | include/functions_user.inc.php | 71 | ||||
-rw-r--r-- | include/page_header.php | 33 | ||||
-rw-r--r-- | include/ws_functions.inc.php | 36 |
4 files changed, 73 insertions, 95 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index c37a9c266..5d66e75c5 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -485,33 +485,5 @@ SELECT image_id return $image_id; } -/** - * create a tree from a flat list of categories, no recursivity for high speed - */ -function categories_flatlist_to_tree($categories) -{ - $tree = array(); - $key_of_cat = array(); - - foreach ($categories as $key => &$node) - { - $key_of_cat[$node['id']] = $key; - - if (!isset($node['id_uppercat'])) - { - $tree[$key] = &$node; - } - else - { - if (!isset($categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'])) - { - $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array(); - } - $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node; - } - } - - return $tree; -} ?>
\ No newline at end of file diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 47fa9ab8f..9c25ed1d4 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -73,7 +73,7 @@ where upper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\') function validate_login_case($login) { global $conf; - + if (defined("PHPWG_INSTALLED")) { $query = " @@ -105,7 +105,7 @@ function search_case_username($username) $username_lo = strtolower($username); $SCU_users = array(); - + $q = pwg_query(" SELECT ".$conf['user_fields']['username']." AS username FROM `".USERS_TABLE."`; @@ -114,7 +114,7 @@ function search_case_username($username) $SCU_users[$r['username']] = strtolower($r['username']); // $SCU_users is now an associative table where the key is the account as // registered in the DB, and the value is this same account, in lower case - + $users_found = array_keys($SCU_users, $username_lo); // $users_found is now a table of which the values are all the accounts // which can be written in lowercase the same way as $username @@ -130,28 +130,28 @@ function register_user($login, $password, $mail_address, if ($login == '') { - array_push($errors, l10n('Please, enter a login')); + $errors[] = l10n('Please, enter a login'); } if (preg_match('/^.* $/', $login)) { - array_push($errors, l10n('login mustn\'t end with a space character')); + $errors[] = l10n('login mustn\'t end with a space character'); } if (preg_match('/^ .*$/', $login)) { - array_push($errors, l10n('login mustn\'t start with a space character')); + $errors[] = l10n('login mustn\'t start with a space character'); } if (get_userid($login)) { - array_push($errors, l10n('this login is already used')); + $errors[] = l10n('this login is already used'); } if ($login != strip_tags($login)) { - array_push($errors, l10n('html tags are not allowed in login')); + $errors[] = l10n('html tags are not allowed in login'); } $mail_error = validate_mail_address(null, $mail_address); if ('' != $mail_error) { - array_push($errors, $mail_error); + $errors[] = $mail_error; } if ($conf['insensitive_case_logon'] == true) @@ -159,7 +159,7 @@ function register_user($login, $password, $mail_address, $login_error = validate_login_case($login); if ($login_error != '') { - array_push($errors, $login_error); + $errors[] = $login_error; } } @@ -205,15 +205,10 @@ SELECT id $inserts = array(); while ($row = pwg_db_fetch_assoc($result)) { - array_push - ( - $inserts, - array - ( + $inserts[] = array( 'user_id' => $next_id, 'group_id' => $row['id'] - ) - ); + ); } } @@ -400,7 +395,7 @@ SELECT DISTINCT(id) if ( empty($forbidden_ids) ) { - array_push( $forbidden_ids, 0 ); + $forbidden_ids[] = 0; } $userdata['image_access_type'] = 'NOT IN'; //TODO maybe later $userdata['image_access_list'] = implode(',',$forbidden_ids); @@ -423,7 +418,7 @@ SELECT COUNT(DISTINCT(image_id)) as total { if ($cat['count_images']==0) { - array_push($forbidden_ids, $cat['cat_id']); + $forbidden_ids[] = $cat['cat_id']; unset( $user_cache_cats[$cat['cat_id']] ); } } @@ -518,27 +513,16 @@ SELECT DISTINCT f.image_id 'AND' ).' ;'; - $result = pwg_query($query); - $authorizeds = array(); - while ($row = pwg_db_fetch_assoc($result)) - { - array_push($authorizeds, $row['image_id']); - } + $authorizeds = array_from_query($query, 'image_id'); $query = ' SELECT image_id FROM '.FAVORITES_TABLE.' WHERE user_id = '.$user['id'].' ;'; - $result = pwg_query($query); - $favorites = array(); - while ($row = pwg_db_fetch_assoc($result)) - { - array_push($favorites, $row['image_id']); - } + $favorites = array_from_query($query, 'image_id'); $to_deletes = array_diff($favorites, $authorizeds); - if (count($to_deletes) > 0) { $query = ' @@ -564,19 +548,12 @@ DELETE FROM '.FAVORITES_TABLE.' */ function calculate_permissions($user_id, $user_status) { - $private_array = array(); - $authorized_array = array(); - $query = ' SELECT id FROM '.CATEGORIES_TABLE.' WHERE status = \'private\' ;'; - $result = pwg_query($query); - while ($row = pwg_db_fetch_assoc($result)) - { - array_push($private_array, $row['id']); - } + $private_array = array_from_query($query, 'id'); // retrieve category ids directly authorized to the user $query = ' @@ -617,7 +594,7 @@ SELECT id $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { - array_push($forbidden_array, $row['id']); + $forbidden_array[] = $row['id']; } $forbidden_array = array_unique($forbidden_array); } @@ -626,7 +603,7 @@ SELECT id {// at least, the list contains 0 value. This category does not exists so // where clauses such as "WHERE category_id NOT IN(0)" will always be // true. - array_push($forbidden_array, 0); + $forbidden_array[] = 0; } return implode(',', $forbidden_array); @@ -809,7 +786,7 @@ function get_userid_by_email($email) global $conf; $email = pwg_db_real_escape_string($email); - + $query = ' SELECT '.$conf['user_fields']['id'].' @@ -931,7 +908,7 @@ function get_default_theme() { return $theme; } - + // let's find the first available theme $active_themes = get_pwg_themes(); foreach (array_keys(get_pwg_themes()) as $theme_id) @@ -1158,7 +1135,7 @@ function try_log_user($username, $password, $remember_me) { // we force the session table to be clean pwg_session_gc(); - + global $conf; // retrieving the encrypted password of the login submitted $query = ' @@ -1351,12 +1328,12 @@ function is_adviser() function can_manage_comment($action, $comment_author_id) { global $user, $conf; - + if (is_a_guest()) { return false; } - + if (!in_array($action, array('delete','edit', 'validate'))) { return false; diff --git a/include/page_header.php b/include/page_header.php index 3ed10fe47..e48740a01 100644 --- a/include/page_header.php +++ b/include/page_header.php @@ -66,7 +66,7 @@ if ( !empty($header_notes) ) } // No referencing is required -if ( !$conf['meta_ref'] ) +if ( !$conf['meta_ref'] ) { $page['meta_robots']['noindex'] = 1; $page['meta_robots']['nofollow'] = 1; @@ -81,8 +81,8 @@ if ( !empty($page['meta_robots']) ) ); } if ( !isset($page['meta_robots']['noindex']) ) -{ - $template->assign('meta_ref',1); +{ + $template->assign('meta_ref',1); } // refresh @@ -97,23 +97,22 @@ if ( isset( $refresh ) and intval($refresh) >= 0 ) )); } - - -// messages -foreach (array('errors','infos') as $mode) -{ - if (isset($_SESSION['page_'.$mode])) +else +{// messages only if no redirection + foreach (array('errors','infos') as $mode) { - $page[$mode] = array_merge($page[$mode], $_SESSION['page_'.$mode]); - unset($_SESSION['page_'.$mode]); - } - - if (count($page[$mode]) != 0) - { - $template->assign($mode, $page[$mode]); + if (isset($_SESSION['page_'.$mode])) + { + $page[$mode] = array_merge($page[$mode], $_SESSION['page_'.$mode]); + unset($_SESSION['page_'.$mode]); + } + + if (count($page[$mode]) != 0) + { + $template->assign($mode, $page[$mode]); + } } } - trigger_action('loc_end_page_header'); header('Content-Type: text/html; charset='.get_pwg_charset()); diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 908eb6118..fa4fd5fb0 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -522,6 +522,36 @@ LIMIT '.(int)$params['per_page'].' OFFSET '.(int)($params['per_page']*$params['p /** + * create a tree from a flat list of categories, no recursivity for high speed + */ +function categories_flatlist_to_tree($categories) +{ + $tree = array(); + $key_of_cat = array(); + + foreach ($categories as $key => &$node) + { + $key_of_cat[$node['id']] = $key; + + if (!isset($node['id_uppercat'])) + { + $tree[$key] = &$node; + } + else + { + if (!isset($categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'])) + { + $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array(); + } + + $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node; + } + } + + return $tree; +} + +/** * returns a list of categories (web service method) */ function ws_categories_getList($params, &$service) @@ -1669,9 +1699,9 @@ SELECT if ('file' == $params['type']) { $do_update = false; - + $infos = pwg_image_infos($file_path); - + foreach (array('width', 'height', 'filesize') as $image_info) { if ($infos[$image_info] > $image[$image_info]) @@ -1744,7 +1774,7 @@ SELECT // pwg.images.addChunk. If "high" is available we use it as "original" // else we use "file". remove_chunks($params['original_sum'], 'thumb'); - + if (isset($params['high_sum'])) { $original_type = 'high'; |