aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2007-02-20 23:40:02 +0000
committerplegall <plg@piwigo.org>2007-02-20 23:40:02 +0000
commit3b46143435b528684d52772039540273bbcea52b (patch)
tree69c0319a2dc150ba6a4aabd9178f3eb4c47b4e10
parented97ed33d37db4f1196c48d51c1c7f8cbe8cb9ce (diff)
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
-rw-r--r--action.php7
-rw-r--r--admin/history.php114
-rw-r--r--include/functions.inc.php6
-rw-r--r--install/db/52-database.php73
-rw-r--r--install/phpwebgallery_structure.sql2
-rw-r--r--picture.php2
-rw-r--r--template/yoga/admin/history.tpl45
7 files changed, 136 insertions, 113 deletions
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 '<pre>'; print_r($search); echo '</pre>';
@@ -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 '<pre>'.$query.'</pre>';
+
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 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $Id: 45-database.php 1741 2007-01-22 21:47:03Z vdigital $
+// | last update : $Date: 2007-01-22 22:47:03 +0100 (lun., 22 janv. 2007) $
+// | last modifier : $Author: vdigital $
+// | revision : $Revision: 1741 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die('Hacking attempt!');
+}
+
+$upgrade_description = 'Replace #history.is_high by #history.image_type';
+
+include_once(PHPWG_ROOT_PATH.'include/constants.php');
+
+// +-----------------------------------------------------------------------+
+// | Upgrade content |
+// +-----------------------------------------------------------------------+
+
+$query = "
+ALTER TABLE ".HISTORY_TABLE."
+ ADD COLUMN image_type ENUM('picture', 'high', 'other') DEFAULT NULL
+;";
+pwg_query($query);
+
+$query = "
+UPDATE ".HISTORY_TABLE."
+ SET image_type = 'high'
+ WHERE is_high = 'true'
+;";
+pwg_query($query);
+
+$query = "
+UPDATE ".HISTORY_TABLE."
+ SET image_type = 'picture'
+ WHERE is_high = 'false'
+;";
+pwg_query($query);
+
+$query = "
+ALTER TABLE ".HISTORY_TABLE."
+ DROP COLUMN is_high
+;";
+pwg_query($query);
+
+echo
+"\n"
+.'"'.$upgrade_description.'"'.', ended'
+."\n"
+;
+
+?>
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 @@
</li>
</ul>
- <ul>
- <li><label></label></li>
- <li></li>
- </ul>
-
- <label>
- {lang:Pictures}
- <select name="pictures">
- <!-- BEGIN pictures_option -->
- <option
- value="{pictures_option.VALUE}"
- {pictures_option.SELECTED}
- >
- {pictures_option.CONTENT}
- </option>
- <!-- END pictures_option -->
- </select>
- </label>
-
<label>
- {lang:High quality}
- <select name="high">
- <!-- BEGIN high_option -->
- <option
- value="{high_option.VALUE}"
- {high_option.SELECTED}
- >
- {high_option.CONTENT}
+ {lang:Element type}
+ <select name="types[]" multiple="multiple" size="4">
+ <!-- BEGIN types_option -->
+ <option value="{types_option.VALUE}" {types_option.SELECTED}>
+ {types_option.CONTENT}
</option>
- <!-- END high_option -->
+ <!-- END types_option -->
</select>
</label>
@@ -101,7 +79,7 @@
<th>{lang:user}</th>
<th>{lang:IP}</th>
<th>{lang:image}</th>
- <th>{lang:high quality}</th>
+ <th>{lang:Element type}</th>
<th>{lang:section}</th>
<th>{lang:category}</th>
<th>{lang:tags}</th>
@@ -113,14 +91,7 @@
<td>{detail.USER}</td>
<td>{detail.IP}</td>
<td>{detail.IMAGE}</td>
- <td>
- <!-- BEGIN high -->
- <img src="{themeconf:icon_dir}/check.png" alt="{lang:yes}">
- <!-- END high -->
- <!-- BEGIN no_high -->
- <img src="{themeconf:icon_dir}/uncheck.png" alt="{lang:no}">
- <!-- END no_high -->
- </td>
+ <td>{detail.TYPE}</td>
<td>{detail.SECTION}</td>
<td>{detail.CATEGORY}</td>
<td>{detail.TAGS}</td>