diff options
author | mistic100 <mistic@piwigo.org> | 2011-04-03 12:36:32 +0000 |
---|---|---|
committer | mistic100 <mistic@piwigo.org> | 2011-04-03 12:36:32 +0000 |
commit | 53dc1f54601b3d537c92272c179cb857fab70a57 (patch) | |
tree | 59392c2872d18e2499c748fdfa3739232f71a01a | |
parent | dba1f4950f18dd96483fca7125f423cf5f063d81 (diff) |
add pwg.getInfos method in PWG API
git-svn-id: http://piwigo.org/svn/trunk@10017 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | include/ws_functions.inc.php | 67 | ||||
-rw-r--r-- | ws.php | 3 |
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()) @@ -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( |