From 3b46143435b528684d52772039540273bbcea52b Mon Sep 17 00:00:00 2001 From: plegall Date: Tue, 20 Feb 2007 23:40:02 +0000 Subject: New: non picture files are now logged in history when downloaded. The history filter was redesigned: #history.is_high replaced by #history.image_type = high. The filter is simpler. git-svn-id: http://piwigo.org/svn/trunk@1844 68402e56-0260-453c-a942-63ccdbb3a9ee --- action.php | 7 ++- admin/history.php | 114 ++++++++++++++---------------------- include/functions.inc.php | 6 +- install/db/52-database.php | 73 +++++++++++++++++++++++ install/phpwebgallery_structure.sql | 2 +- picture.php | 2 +- template/yoga/admin/history.tpl | 45 +++----------- 7 files changed, 136 insertions(+), 113 deletions(-) create mode 100644 install/db/52-database.php diff --git a/action.php b/action.php index 73ac6d72b..29f9fac38 100644 --- a/action.php +++ b/action.php @@ -127,8 +127,11 @@ if ( empty($file) ) } if ($_GET['part'] == 'h') { - $is_high = true; - pwg_log($_GET['id'], $is_high); + pwg_log($_GET['id'], 'high'); +} +else if ($_GET['part'] == 'e') +{ + pwg_log($_GET['id'], 'other'); } $http_headers = array(); diff --git a/admin/history.php b/admin/history.php index a4e2fddaa..146737f7d 100644 --- a/admin/history.php +++ b/admin/history.php @@ -58,6 +58,8 @@ else $page['start'] = 0; } +$types = array('none', 'picture', 'high', 'other'); + // +-----------------------------------------------------------------------+ // | Check Access and exit when user status is not ok | // +-----------------------------------------------------------------------+ @@ -94,8 +96,7 @@ if (isset($_POST['submit'])) ); } - $search['fields']['pictures'] = $_POST['pictures']; - $search['fields']['high'] = $_POST['high']; + $search['fields']['types'] = $_POST['types']; // echo '
'; print_r($search); echo '
'; @@ -184,43 +185,32 @@ SELECT rules ); } - if (isset($page['search']['fields']['pictures'])) + if (isset($page['search']['fields']['types'])) { - $clause = null; + $local_clauses = array(); - if ($page['search']['fields']['pictures'] == 'no') - { - $clause = 'image_id IS NULL'; - } - - if ($page['search']['fields']['pictures'] == 'only') - { - $clause = 'image_id IS NOT NULL'; - } - - if (isset($clause)) - { - array_push($clauses, $clause); + foreach ($types as $type) { + if (in_array($type, $page['search']['fields']['types'])) { + $clause = 'image_type '; + if ($type == 'none') + { + $clause.= 'IS NULL'; + } + else + { + $clause.= "= '".$type."'"; + } + + array_push($local_clauses, $clause); + } } - } - - if (isset($page['search']['fields']['high'])) - { - $clause = null; - if ($page['search']['fields']['high'] == 'no') - { - $clause = "is_high IS NULL or is_high = 'false'"; - } - - if ($page['search']['fields']['high'] == 'only') + if (count($local_clauses) > 0) { - $clause = "is_high = 'true'"; - } - - if (isset($clause)) - { - array_push($clauses, $clause); + array_push( + $clauses, + implode(' OR ', $local_clauses) + ); } } @@ -236,8 +226,10 @@ SELECT rules SELECT COUNT(*) FROM '.HISTORY_TABLE.' WHERE '.$where_separator.' -'; +;'; + // echo '
'.$query.'
'; + list($page['nb_lines']) = mysql_fetch_row(pwg_query($query)); $query = ' @@ -250,7 +242,7 @@ SELECT category_id, tag_ids, image_id, - is_high + image_type FROM '.HISTORY_TABLE.' WHERE '.$where_separator.' LIMIT '.$page['start'].', '.$conf['nb_logs_page'].' @@ -344,6 +336,7 @@ SELECT id, IF(name IS NULL, file, name) AS label ? $label_of_image[$line['image_id']] : 'deleted '.$line['image_id']) : $line['image_id'], + 'TYPE' => $line['image_type'], 'SECTION' => $line['section'], 'CATEGORY' => isset($line['category_id']) ? ( isset($name_of_category[$line['category_id']]) @@ -354,18 +347,6 @@ SELECT id, IF(name IS NULL, file, name) AS label 'T_CLASS' => ($i++ % 2) ? 'row1' : 'row2', ) ); - - if (isset($line['image_id'])) - { - if ($line['is_high'] == 'true') - { - $template->assign_block_vars('detail.high', array()); - } - else - { - $template->assign_block_vars('detail.no_high', array()); - } - } } } @@ -425,8 +406,7 @@ if (isset($page['search'])) $form['end_day'] = (int)$tokens[2]; } - $form['pictures'] = $page['search']['fields']['pictures']; - $form['high'] = $page['search']['fields']['high']; + $form['types'] = $page['search']['fields']['types']; } else { @@ -435,8 +415,7 @@ else $form['start_year'] = $form['end_year'] = date('Y'); $form['start_month'] = $form['end_month'] = date('n'); $form['start_day'] = $form['end_day'] = date('j'); - $form['pictures'] = 'yes'; - $form['high'] = 'yes'; + $form['types'] = $types; } // start date @@ -453,26 +432,23 @@ $template->assign_vars( ) ); -foreach (array('pictures', 'high') as $block) +foreach ($types as $option) { - foreach (array('yes', 'no', 'only') as $item) + $selected = ''; + + if (in_array($option, $form['types'])) { - $selected = ''; - - if ($item == $form[$block]) - { - $selected = 'selected="selected"'; - } - - $template->assign_block_vars( - $block.'_option', - array( - 'VALUE' => $item, - 'CONTENT' => l10n($item), - 'SELECTED' => $selected, - ) - ); + $selected = 'selected="selected"'; } + + $template->assign_block_vars( + 'types_option', + array( + 'VALUE' => $option, + 'CONTENT' => l10n($option), + 'SELECTED' => $selected, + ) + ); } // +-----------------------------------------------------------------------+ diff --git a/include/functions.inc.php b/include/functions.inc.php index c52fa5457..e09339982 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -410,7 +410,7 @@ function replace_search( $string, $search ) return $string; } -function pwg_log($image_id = null, $is_high = false) +function pwg_log($image_id = null, $image_type = null) { global $conf, $user, $page; @@ -468,7 +468,7 @@ INSERT INTO '.HISTORY_TABLE.' section, category_id, image_id, - is_high, + image_type, tag_ids ) VALUES @@ -484,7 +484,7 @@ INSERT INTO '.HISTORY_TABLE.' '.(isset($page['section']) ? "'".$page['section']."'" : 'NULL').', '.(isset($page['category']) ? $page['category'] : 'NULL').', '.(isset($image_id) ? $image_id : 'NULL').', - '.(isset($image_id) ? "'".boolean_to_string($is_high)."'" : 'NULL').', + '.(isset($image_id) ? "'".$image_type."'" : 'NULL').', '.(isset($tags_string) ? "'".$tags_string."'" : 'NULL').' ) ;'; diff --git a/install/db/52-database.php b/install/db/52-database.php new file mode 100644 index 000000000..ad38d6984 --- /dev/null +++ b/install/db/52-database.php @@ -0,0 +1,73 @@ + diff --git a/install/phpwebgallery_structure.sql b/install/phpwebgallery_structure.sql index 0b39c9018..bc229dc6a 100644 --- a/install/phpwebgallery_structure.sql +++ b/install/phpwebgallery_structure.sql @@ -126,7 +126,7 @@ CREATE TABLE `phpwebgallery_history` ( `tag_ids` varchar(50) default NULL, `image_id` mediumint(8) default NULL, `summarized` enum('true','false') default 'false', - `is_high` enum('true','false') default NULL, + `image_type` enum('picture','high','other') default NULL, PRIMARY KEY (`id`), KEY `history_i1` (`summarized`) ) TYPE=MyISAM; diff --git a/picture.php b/picture.php index 6b5775560..a917d0888 100644 --- a/picture.php +++ b/picture.php @@ -812,7 +812,7 @@ if ($metadata_showable and isset($_GET['metadata'])) include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php'); } //------------------------------------------------------------ log informations -pwg_log($picture['current']['id']); +pwg_log($picture['current']['id'], 'picture'); include(PHPWG_ROOT_PATH.'include/page_header.php'); trigger_action('loc_end_picture'); diff --git a/template/yoga/admin/history.tpl b/template/yoga/admin/history.tpl index 697c37df5..43b1440ae 100644 --- a/template/yoga/admin/history.tpl +++ b/template/yoga/admin/history.tpl @@ -49,36 +49,14 @@ - - - - @@ -101,7 +79,7 @@ {lang:user} {lang:IP} {lang:image} - {lang:high quality} + {lang:Element type} {lang:section} {lang:category} {lang:tags} @@ -113,14 +91,7 @@ {detail.USER} {detail.IP} {detail.IMAGE} - - - {lang:yes} - - - {lang:no} - - + {detail.TYPE} {detail.SECTION} {detail.CATEGORY} {detail.TAGS} -- cgit v1.2.3