aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2011-04-03 15:59:35 +0000
committermistic100 <mistic@piwigo.org>2011-04-03 15:59:35 +0000
commit91b0ba38abb7f4158ec0cca3a21e85badacd2303 (patch)
treebb12755bf1a640ae891f161e3d6891a0d7936d8a /include/ws_functions.inc.php
parent00ed60887729a445a0bdd26729a362bd2377f052 (diff)
merge r10017 from trunk to 2.2 (bug:1023)
git-svn-id: http://piwigo.org/svn/branches/2.2@10022 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/ws_functions.inc.php')
-rw-r--r--include/ws_functions.inc.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 5807a4cc1..b69da5826 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -181,6 +181,73 @@ function ws_getVersion($params, &$service)
return new PwgError(403, 'Forbidden');
}
+/**
+ * returns general informations (web service method)
+ */
+function ws_getInfos($params, &$service)
+{
+ global $conf;
+
+ if ($conf['show_version'] or is_admin())
+ {
+ $infos['version'] = PHPWG_VERSION;
+ }
+
+ $query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.';';
+ list($infos['nb_elements']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.CATEGORIES_TABLE.';';
+ list($infos['nb_categories']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.CATEGORIES_TABLE.' WHERE dir IS NULL;';
+ list($infos['nb_virtual']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.CATEGORIES_TABLE.' WHERE dir IS NOT NULL;';
+ list($infos['nb_physical']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.IMAGE_CATEGORY_TABLE.';';
+ list($infos['nb_image_category']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.TAGS_TABLE.';';
+ list($infos['nb_tags']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.IMAGE_TAG_TABLE.';';
+ list($infos['nb_image_tag']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.USERS_TABLE.';';
+ list($infos['nb_users']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.GROUPS_TABLE.';';
+ list($infos['nb_groups']) = pwg_db_fetch_row(pwg_query($query));
+
+ $query = 'SELECT COUNT(*) FROM '.COMMENTS_TABLE.';';
+ list($infos['nb_comments']) = pwg_db_fetch_row(pwg_query($query));
+
+ // first element
+ if ($infos['nb_elements'] > 0)
+ {
+ $query = 'SELECT MIN(date_available) FROM '.IMAGES_TABLE.';';
+ list($infos['first_date']) = pwg_db_fetch_row(pwg_query($query));
+ }
+
+ // unvalidated comments
+ if ($infos['nb_comments'] > 0 and is_admin())
+ {
+ $query = 'SELECT COUNT(*) FROM '.COMMENTS_TABLE.' WHERE validated=\'false\';';
+ list($infos['nb_unvalidated_comments']) = pwg_db_fetch_row(pwg_query($query));
+ }
+
+ foreach ($infos as $name => $value)
+ {
+ $output[] = array(
+ 'name' => $name,
+ 'value' => $value,
+ );
+ }
+
+ return array('infos' => new PwgNamedArray($output, 'item'));
+}
+
function ws_caddie_add($params, &$service)
{
if (!is_admin())