aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/history.php101
-rw-r--r--admin/include/functions.php101
2 files changed, 193 insertions, 9 deletions
diff --git a/admin/history.php b/admin/history.php
index ea7add177..516e940cf 100644
--- a/admin/history.php
+++ b/admin/history.php
@@ -94,6 +94,9 @@ if (isset($_POST['submit']))
);
}
+ $search['fields']['pictures'] = $_POST['pictures'];
+ $search['fields']['high'] = $_POST['high'];
+
// echo '<pre>'; print_r($search); echo '</pre>';
if (!empty($search))
@@ -181,6 +184,46 @@ SELECT rules
);
}
+ if (isset($page['search']['fields']['pictures']))
+ {
+ $clause = null;
+
+ 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);
+ }
+ }
+
+ 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')
+ {
+ $clause = "is_high = 'true'";
+ }
+
+ if (isset($clause))
+ {
+ array_push($clauses, $clause);
+ }
+ }
+
$clauses = prepend_append_array_items($clauses, '(', ')');
$where_separator =
@@ -198,7 +241,16 @@ SELECT COUNT(*)
list($page['nb_lines']) = mysql_fetch_row(pwg_query($query));
$query = '
-SELECT date, time, user_id, IP, section, category_id, tag_ids, image_id
+SELECT
+ date,
+ time,
+ user_id,
+ IP,
+ section,
+ category_id,
+ tag_ids,
+ image_id,
+ is_high
FROM '.HISTORY_TABLE.'
WHERE '.$where_separator.'
LIMIT '.$page['start'].', '.$conf['nb_logs_page'].'
@@ -298,6 +350,18 @@ 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());
+ }
+ }
}
}
@@ -351,11 +415,14 @@ if (isset($page['search']))
if (isset($page['search']['fields']['date-before']))
{
$tokens = explode('-', $page['search']['fields']['date-before']);
-
- (int)$tokens[0];
- (int)$tokens[1];
- (int)$tokens[2];
+
+ $form['end_year'] = (int)$tokens[0];
+ $form['end_month'] = (int)$tokens[1];
+ $form['end_day'] = (int)$tokens[2];
}
+
+ $form['pictures'] = $page['search']['fields']['pictures'];
+ $form['high'] = $page['search']['fields']['high'];
}
else
{
@@ -364,6 +431,8 @@ 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';
}
// start date
@@ -379,6 +448,28 @@ $template->assign_vars(
'END_YEAR' => @$form['end_year'],
)
);
+
+foreach (array('pictures', 'high') as $block)
+{
+ foreach (array('yes', 'no', 'only') as $item)
+ {
+ $selected = '';
+
+ if ($item == $form[$block])
+ {
+ $selected = 'selected="selected"';
+ }
+
+ $template->assign_block_vars(
+ $block.'_option',
+ array(
+ 'VALUE' => $item,
+ 'CONTENT' => l10n($item),
+ 'SELECTED' => $selected,
+ )
+ );
+ }
+}
// +-----------------------------------------------------------------------+
// | html code display |
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 4c56dc20f..ad493f877 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -606,7 +606,7 @@ function mass_updates($tablename, $dbfields, $datas)
UPDATE '.$tablename.'
SET ';
$is_first = true;
- foreach ($dbfields['update'] as $num => $key)
+ foreach ($dbfields['update'] as $key)
{
if (!$is_first)
{
@@ -625,13 +625,16 @@ function mass_updates($tablename, $dbfields, $datas)
}
$query.= '
WHERE ';
- foreach ($dbfields['primary'] as $num => $key)
+
+ $is_first = true;
+ foreach ($dbfields['primary'] as $key)
{
- if ($num > 1)
+ if (!$is_first)
{
$query.= ' AND ';
}
$query.= $key.' = \''.$data[$key].'\'';
+ $is_first = false;
}
$query.= '
;';
@@ -1902,6 +1905,97 @@ SELECT image_id
}
/**
+ * Create an XML file with PhpWebGallery informations about a list of
+ * pictures.
+ *
+ * The goal of the export feature is to make easier the reading of
+ * informations related to pictures outside of PhpWebGallery.
+ *
+ * @param array image_ids
+ */
+function export_pwg_data($image_ids)
+{
+ global $conf;
+
+ if (count($image_ids) == 0)
+ {
+ return;
+ }
+
+ $fp = fopen($conf['export_file'], 'w');
+ $xml_string = '<export>'."\n";
+
+ $query = '
+SELECT tag_id,
+ image_id
+ FROM '.IMAGE_TAG_TABLE.'
+ WHERE image_id IN ('.implode(',', $image_ids).')
+;';
+ $result = pwg_query($query);
+ $tags_of = array();
+ $all_tag_ids = array();
+ $tag_name_of = array();
+
+ if (mysql_num_rows($result))
+ {
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($all_tag_ids, $row['tag_id']);
+
+ if (!isset($tags_of[ $row['image_id'] ])) {
+ $tags_of[ $row['image_id'] ] = array();
+ }
+
+ array_push(
+ $tags_of[ $row['image_id'] ],
+ $row['tag_id']
+ );
+ }
+
+ $all_tag_ids = array_unique($all_tag_ids);
+
+ $query = '
+SELECT id,
+ name
+ FROM '.TAGS_TABLE.'
+ WHERE id IN ('.implode(',', $all_tag_ids).')
+;';
+ $result = pwg_query($query);
+
+ while ($row = mysql_fetch_array($result))
+ {
+ $tag_name_of[ $row['id'] ] = $row['name'];
+ }
+ }
+
+ $query = '
+SELECT id,
+ path
+ FROM '.IMAGES_TABLE.'
+ WHERE id IN ('.implode(',', $image_ids).')
+;';
+ $result = pwg_query($query);
+
+ while ($row = mysql_fetch_array($result))
+ {
+ $xml_string.= " <photo>\n";
+ $xml_string.= " <id>".$row['id']."</id>\n";
+ $xml_string.= " <path>".$row['path']."</path>\n";
+
+ foreach ($tags_of[ $row['id'] ] as $tag_id)
+ {
+ $xml_string.= " <tag>".$tag_name_of[$tag_id]."</tag>\n";
+ }
+
+ $xml_string.= " </photo>\n";
+ }
+
+ $xml_string.= '</export>';
+ fwrite($fp, $xml_string);
+ fclose($fp);
+}
+
+/**
* Check configuration and add notes on problem
*
* @param void
@@ -1937,7 +2031,6 @@ function check_conf()
);
}
}
-
/**
* Refer main PhpWebGallery URLs (currently PHPWG_DOMAIN domain)
*