aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/cat_modify.php26
-rw-r--r--admin/include/functions.php19
-rw-r--r--admin/picture_modify.php9
-rw-r--r--admin/tags.php42
4 files changed, 31 insertions, 65 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index 7edda9fe3..0ecfef4fb 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -114,27 +114,23 @@ if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
//--------------------------------------------------------- form criteria check
if (isset($_POST['submit']))
{
- $data =
- array(
- 'id' => $_GET['cat_id'],
- 'name' => @$_POST['name'],
- 'comment' =>
- $conf['allow_html_descriptions'] ?
- @$_POST['comment'] : strip_tags(@$_POST['comment']),
- );
+ $data = array(
+ 'id' => $_GET['cat_id'],
+ 'name' => @$_POST['name'],
+ 'comment' =>
+ $conf['allow_html_descriptions'] ?
+ @$_POST['comment'] : strip_tags(@$_POST['comment']),
+ );
if ($conf['activate_comments'])
{
$data['commentable'] = isset($_POST['commentable'])?$_POST['commentable']:'false';
}
-
- mass_updates(
+
+ single_update(
CATEGORIES_TABLE,
- array(
- 'primary' => array('id'),
- 'update' => array_diff(array_keys($data), array('id'))
- ),
- array($data)
+ $data,
+ array('id' => $data['id'])
);
// retrieve cat infos before continuing (following updates are expensive)
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 39d8f85ee..0142bd023 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1816,34 +1816,25 @@ SELECT id
if (count($existing_tags) == 0)
{
- mass_inserts(
+ single_insert(
TAGS_TABLE,
- array('name', 'url_name'),
array(
- array(
- 'name' => $tag_name,
- 'url_name' => trigger_event('render_tag_url', $tag_name),
- )
+ 'name' => $tag_name,
+ 'url_name' => trigger_event('render_tag_url', $tag_name),
)
);
$inserted_id = pwg_db_insert_id(TAGS_TABLE);
return array(
- 'info' => sprintf(
- l10n('Tag "%s" was added'),
- stripslashes($tag_name)
- ),
+ 'info' => l10n('Tag "%s" was added', stripslashes($tag_name)),
'id' => $inserted_id,
);
}
else
{
return array(
- 'error' => sprintf(
- l10n('Tag "%s" already exists'),
- stripslashes($tag_name)
- )
+ 'error' => l10n('Tag "%s" already exists', stripslashes($tag_name))
);
}
}
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index 91e992407..814ec27d8 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -154,13 +154,10 @@ if (isset($_POST['submit']) and count($page['errors']) == 0)
$data{'date_creation'} = null;
}
- mass_updates(
+ single_update(
IMAGES_TABLE,
- array(
- 'primary' => array('id'),
- 'update' => array_diff(array_keys($data), array('id'))
- ),
- array($data)
+ $data,
+ array('id' => $data['id'])
);
// time to deal with tags
diff --git a/admin/tags.php b/admin/tags.php
index 02ab03b1c..794514b28 100644
--- a/admin/tags.php
+++ b/admin/tags.php
@@ -129,16 +129,14 @@ SELECT id, name
}
else if (!empty($tag_name))
{
- mass_inserts(
+ single_insert(
TAGS_TABLE,
- array('name', 'url_name'),
array(
- array(
- 'name' => $tag_name,
- 'url_name' => trigger_event('render_tag_url', $tag_name),
- )
+ 'name' => $tag_name,
+ 'url_name' => trigger_event('render_tag_url', $tag_name),
)
);
+
$query = '
SELECT id
FROM '.TAGS_TABLE.'
@@ -146,6 +144,7 @@ SELECT id, name
;';
$destination_tag = array_from_query($query, 'id');
$destination_tag_id = $destination_tag[0];
+
$query = '
SELECT
image_id
@@ -153,6 +152,7 @@ SELECT id, name
WHERE tag_id = '.$tag_id.'
;';
$destination_tag_image_ids = array_from_query($query, 'image_id');
+
$inserts = array();
foreach ($destination_tag_image_ids as $image_id)
{
@@ -179,6 +179,7 @@ SELECT id, name
}
}
}
+
mass_updates(
TAGS_TABLE,
array(
@@ -323,34 +324,15 @@ if (isset($_GET['action']) and 'delete_orphans' == $_GET['action'])
if (isset($_POST['add']) and !empty($_POST['add_tag']))
{
- $tag_name = $_POST['add_tag'];
-
- // does the tag already exists?
- $query = '
-SELECT id
- FROM '.TAGS_TABLE.'
- WHERE name = \''.$tag_name.'\'
-;';
- $existing_tags = array_from_query($query, 'id');
-
- if (count($existing_tags) == 0)
+ $ret = create_tag($_POST['add_tag']);
+
+ if (isset($ret['error']))
{
- mass_inserts(
- TAGS_TABLE,
- array('name', 'url_name'),
- array(
- array(
- 'name' => $tag_name,
- 'url_name' => trigger_event('render_tag_url', $tag_name),
- )
- )
- );
-
- $page['infos'][] = l10n('Tag "%s" was added', stripslashes($tag_name));
+ $page['errors'][] = $ret['error'];
}
else
{
- $page['errors'][] = l10n('Tag "%s" already exists', stripslashes($tag_name));
+ $page['infos'][] = $ret['info'];
}
}