aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/dblayer/functions_mysql.inc.php2
-rw-r--r--include/dblayer/functions_mysqli.inc.php6
-rw-r--r--include/functions_url.inc.php4
-rw-r--r--include/ws_functions/pwg.categories.php92
-rw-r--r--include/ws_functions/pwg.php2
5 files changed, 101 insertions, 5 deletions
diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php
index a1853b223..9cf25e76f 100644
--- a/include/dblayer/functions_mysql.inc.php
+++ b/include/dblayer/functions_mysql.inc.php
@@ -53,7 +53,7 @@ function pwg_db_check_charset()
{
$db_charset = DB_CHARSET;
}
- pwg_query('SET NAMES "'.$db_charset.'"');
+ mysql_set_charset($db_charset);
}
function pwg_db_check_version()
diff --git a/include/dblayer/functions_mysqli.inc.php b/include/dblayer/functions_mysqli.inc.php
index 390cf2e06..f9590c1d1 100644
--- a/include/dblayer/functions_mysqli.inc.php
+++ b/include/dblayer/functions_mysqli.inc.php
@@ -80,12 +80,14 @@ function pwg_db_connect($host, $user, $password, $database)
*/
function pwg_db_check_charset()
{
+ global $mysqli;
+
$db_charset = 'utf8';
if (defined('DB_CHARSET') and DB_CHARSET != '')
{
$db_charset = DB_CHARSET;
}
- pwg_query('SET NAMES "'.$db_charset.'"');
+ $mysqli->set_charset($db_charset);
}
/**
@@ -901,4 +903,4 @@ function query2array($query, $key_name=null, $value_name=null)
return $data;
}
-?> \ No newline at end of file
+?>
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index 138a895e1..e0f09a28c 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -379,7 +379,7 @@ function make_section_in_url($params)
$section_string.= '/'.$tag['id'];
break;
case 'tag':
- if (isset($tag['url_name']) and !is_numeric($tag['url_name']) )
+ if (isset($tag['url_name']))
{
$section_string.= '/'.$tag['url_name'];
break;
@@ -824,4 +824,4 @@ function url_is_remote($url)
return false;
}
-?> \ No newline at end of file
+?>
diff --git a/include/ws_functions/pwg.categories.php b/include/ws_functions/pwg.categories.php
index b2cfc2dd4..07e64c803 100644
--- a/include/ws_functions/pwg.categories.php
+++ b/include/ws_functions/pwg.categories.php
@@ -663,6 +663,98 @@ UPDATE '. USER_CACHE_CATEGORIES_TABLE .'
/**
* API method
+ *
+ * Deletes the album thumbnail. Only possible if
+ * $conf['allow_random_representative']
+ *
+ * @param mixed[] $params
+ * @option int category_id
+ */
+function ws_categories_deleteRepresentative($params, &$service)
+{
+ global $conf;
+
+ // does the category really exist?
+ $query = '
+SELECT id
+ FROM '. CATEGORIES_TABLE .'
+ WHERE id = '. $params['category_id'] .'
+;';
+ $result = pwg_query($query);
+ if (pwg_db_num_rows($result) == 0)
+ {
+ return new PwgError(404, 'category_id not found');
+ }
+
+ if (!$conf['allow_random_representative'])
+ {
+ return new PwgError(401, 'not permitted');
+ }
+
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET representative_picture_id = NULL
+ WHERE id = '.$params['category_id'].'
+;';
+ pwg_query($query);
+}
+
+/**
+ * API method
+ *
+ * Find a new album thumbnail.
+ *
+ * @param mixed[] $params
+ * @option int category_id
+ */
+function ws_categories_refreshRepresentative($params, &$service)
+{
+ global $conf;
+
+ // does the category really exist?
+ $query = '
+SELECT id
+ FROM '. CATEGORIES_TABLE .'
+ WHERE id = '. $params['category_id'] .'
+;';
+ $result = pwg_query($query);
+ if (pwg_db_num_rows($result) == 0)
+ {
+ return new PwgError(404, 'category_id not found');
+ }
+
+ $query = '
+SELECT
+ DISTINCT category_id
+ FROM '.IMAGE_CATEGORY_TABLE.'
+ WHERE category_id = '.$params['category_id'].'
+ LIMIT 1
+;';
+ $result = pwg_query($query);
+ $has_images = pwg_db_num_rows($result) > 0 ? true : false;
+
+ if (!$has_images)
+ {
+ return new PwgError(401, 'not permitted');
+ }
+
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+
+ set_random_representant(array($params['category_id']));
+
+ // return url of the new representative
+ $query = '
+SELECT *
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id = '.$params['category_id'].'
+;';
+ $category = pwg_db_fetch_assoc(pwg_query($query));
+
+ return get_category_representant_properties($category['representative_picture_id']);
+}
+
+/**
+ * API method
* Deletes a category
* @param mixed[] $params
* @option string|int[] category_id
diff --git a/include/ws_functions/pwg.php b/include/ws_functions/pwg.php
index b96338eaf..6d9d49fcc 100644
--- a/include/ws_functions/pwg.php
+++ b/include/ws_functions/pwg.php
@@ -339,6 +339,8 @@ function ws_session_getStatus($params, &$service)
)
)
);
+
+ $res['upload_form_chunk_size'] = $conf['upload_form_chunk_size'];
}
return $res;