aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2007-10-03 23:36:21 +0000
committerrvelices <rv-github@modusoptimus.com>2007-10-03 23:36:21 +0000
commitfb9abe8fea6bf40c5628467158edf2fc6881a8dd (patch)
tree978ba2948e6ddfe82be3982590b7d0a83b8638fd
parent2889cbc4eb06ce32caf3d5f8d592120830c4b676 (diff)
- bug 755: admin permalinks page - fix category field sort
- web service functions: 1 fix and 3 optimizations git-svn-id: http://piwigo.org/svn/trunk@2119 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/permalinks.php26
-rw-r--r--include/ws_functions.inc.php54
2 files changed, 44 insertions, 36 deletions
diff --git a/admin/permalinks.php b/admin/permalinks.php
index cbbbbc4e5..77becf76f 100644
--- a/admin/permalinks.php
+++ b/admin/permalinks.php
@@ -30,11 +30,11 @@ function parse_sort_variables(
$anchor = '' )
{
global $template;
-
+
$url_components = parse_url( $_SERVER['REQUEST_URI'] );
$base_url = $url_components['path'];
-
+
parse_str($url_components['query'], $vars);
$is_first = true;
foreach ($vars as $key => $value)
@@ -51,18 +51,24 @@ function parse_sort_variables(
foreach( $sortable_by as $field)
{
$url = $base_url;
+ $disp = '&dArr;'; // TODO: an small image is better
+
if ( $field !== @$_GET[$get_param] )
{
if ( !isset($default_field) or $default_field!=$field )
{ // the first should be the default
$url = add_url_params($url, array($get_param=>$field) );
}
- $disp = '&dArr;'; // TODO: an small image is better
+ elseif (isset($default_field) and !isset($_GET[$get_param]) )
+ {
+ array_push($ret, $field);
+ $disp = '<em>'.$disp.'</em>';
+ }
}
else
{
array_push($ret, $field);
- $disp = '<em>&dArr;</em>'; // TODO: an small image is better
+ $disp = '<em>'.$disp.'</em>';
}
if ( isset($template_var) )
{
@@ -103,10 +109,10 @@ DELETE FROM '.OLD_PERMALINKS_TABLE.'
$template->set_filename('permalinks', 'admin/permalinks.tpl' );
$query = '
-SELECT
- id,
+SELECT
+ id,
CONCAT(id, " - ", name, IF(permalink IS NULL, "", " &radic;") ) AS name,
- uppercats, global_rank
+ uppercats, global_rank
FROM '.CATEGORIES_TABLE;
display_select_cat_wrapper( $query, $selected_cat, 'categories', false );
@@ -124,9 +130,7 @@ SELECT id, permalink, uppercats, global_rank
FROM '.CATEGORIES_TABLE.'
WHERE permalink IS NOT NULL
';
-if ( count($sort_by) and
- ($sort_by[0]=='id' or $sort_by[0]=='permalink')
- )
+if ( $sort_by[0]=='id' or $sort_by[0]=='permalink' )
{
$query .= ' ORDER BY '.$sort_by[0];
}
@@ -138,7 +142,7 @@ while ( $row=mysql_fetch_assoc($result) )
$categories[] = $row;
}
-if ( !count($sort_by) or $sort_by[0]=='name')
+if ( $sort_by[0]=='name')
{
usort($categories, 'global_rank_compare');
}
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 151296de0..c0b3585db 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -32,18 +32,18 @@
function ws_isInvokeAllowed($res, $methodName, $params)
{
global $conf, $calling_partner_id;
-
+
if ( strpos($methodName,'reflection.')===0 )
{ // OK for reflection
return $res;
}
-
+
if ( !is_autorize_status(ACCESS_GUEST) and
strpos($methodName,'pwg.session.')!==0 )
{
return new PwgError(401, 'Access denied');
}
-
+
if ( !$conf['ws_access_control'] )
{
return $res; // No controls are requested
@@ -316,7 +316,10 @@ function ws_categories_getImages($params, &$service)
OR ', $where_clauses) . ')'
);
}
- $where_clauses[] = 'id NOT IN ('.$user['forbidden_categories'].')';
+ $where_clauses[] = get_sql_condition_FandF(
+ array('forbidden_categories' => 'id'),
+ NULL, true
+ );
$query = '
SELECT id, name, permalink, image_order
@@ -460,7 +463,6 @@ function ws_categories_getList($params, &$service)
}
else
{
- $where[] = 'id NOT IN ('.$user['forbidden_categories'].')';
$where[]= 'user_id='.$user['id'];
}
@@ -472,8 +474,6 @@ SELECT id, name, permalink, uppercats, global_rank,
INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id=cat_id
WHERE '. implode('
AND ', $where);
- $query .= '
-ORDER BY global_rank';
$result = pwg_query($query);
@@ -512,9 +512,9 @@ function ws_images_addComment($params, &$service)
}
$params['image_id'] = (int)$params['image_id'];
$query = '
-SELECT DISTINCT image_id
+SELECT DISTINCT image_id
FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.CATEGORIES_TABLE.' ON category_id=id
- WHERE commentable="true"
+ WHERE commentable="true"
AND image_id='.$params['image_id'].
get_sql_condition_FandF(
array(
@@ -528,9 +528,9 @@ SELECT DISTINCT image_id
{
return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id");
}
-
+
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
-
+
$comm = array(
'author' => trim( stripslashes($params['author']) ),
'content' => trim( stripslashes($params['content']) ),
@@ -538,8 +538,8 @@ SELECT DISTINCT image_id
);
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
-
- $comment_action = insert_user_comment(
+
+ $comment_action = insert_user_comment(
$comm, $params['key'], $infos
);
@@ -550,14 +550,14 @@ SELECT DISTINCT image_id
return new PwgError(403, implode("\n", $infos) );
case 'validate':
case 'moderate':
- $ret = array(
+ $ret = array(
'id' => $comm['id'],
'validation' => $comment_action=='validate',
);
return new PwgNamedStruct(
'comment',
- $ret,
- null, array()
+ $ret,
+ null, array()
);
default:
return new PwgError(500, "Unknown comment action ".$comment_action );
@@ -599,8 +599,11 @@ LIMIT 1;';
SELECT id, name, permalink, uppercats, global_rank, commentable
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
- WHERE image_id = '.$image_row['id'].'
- AND category_id NOT IN ('.$user['forbidden_categories'].')
+ WHERE image_id = '.$image_row['id'].
+ get_sql_condition_FandF(
+ array( 'forbidden_categories' => 'category_id' ),
+ ' AND'
+ ).'
;';
$result = pwg_query($query);
$is_commentable = false;
@@ -667,7 +670,7 @@ SELECT COUNT(rate) AS count
//---------------------------------------------------------- related comments
$related_comments = array();
-
+
$where_comments = 'image_id = '.$image_row['id'];
if ( !is_admin() )
{
@@ -699,16 +702,16 @@ SELECT id, date, author, content
array_push($related_comments, $row);
}
}
-
+
$comment_post_data = null;
- if ($is_commentable and
+ if ($is_commentable and
(!is_a_guest()
or (is_a_guest() and $conf['comments_forall'] )
)
)
{
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
- $comment_post_data['author'] = $user['username'];
+ $comment_post_data['author'] = $user['username'];
$comment_post_data['key'] = get_comment_post_key($params['image_id']);
}
@@ -733,7 +736,7 @@ SELECT id, date, author, content
$ret['comment_post'] = array( WS_XML_ATTRIBUTES => $comment_post_data );
}
$ret['comments'] = array(
- WS_XML_ATTRIBUTES =>
+ WS_XML_ATTRIBUTES =>
array(
'page' => $params['comments_page'],
'per_page' => $params['comments_per_page'],
@@ -805,7 +808,7 @@ SELECT DISTINCT id FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON
{
$image_ids = $search_result['items'];
}
-
+
$image_ids = array_slice($image_ids,
$params['page']*$params['per_page'],
$params['per_page'] );
@@ -951,7 +954,7 @@ function ws_tags_getImages($params, &$service)
{
@include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
global $conf;
-
+
// first build all the tag_ids we are interested in
$params['tag_id'] = array_map( 'intval',$params['tag_id'] );
$tags = find_tags($params['tag_id'], $params['tag_url_name'], $params['tag_name']);
@@ -1028,6 +1031,7 @@ LIMIT '.$params['per_page']*$params['page'].','.$params['per_page'];
$result = pwg_query($query);
while ($row = mysql_fetch_assoc($result))
{
+ $image = array();
foreach ( array('id', 'width', 'height', 'hit') as $k )
{
if (isset($row[$k]))