aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php67
-rw-r--r--ws.php3
2 files changed, 70 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())
diff --git a/ws.php b/ws.php
index c2d2115d7..7bc4dc21c 100644
--- a/ws.php
+++ b/ws.php
@@ -42,6 +42,9 @@ function ws_addDefaultMethods( $arr )
$service = &$arr[0];
$service->addMethod('pwg.getVersion', 'ws_getVersion', null,
'retrieves the PWG version');
+
+ $service->addMethod('pwg.getInfos', 'ws_getInfos', null,
+ 'retrieves general informations');
$service->addMethod('pwg.caddie.add', 'ws_caddie_add',
array(