Changeset 10022


Ignore:
Timestamp:
04/03/11 17:59:35 (8 years ago)
Author:
mistic100
Message:

merge r10017 from trunk to 2.2 (bug:1023)

Location:
branches/2.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/include/ws_functions.inc.php

    r9944 r10022  
    180180  else 
    181181    return new PwgError(403, 'Forbidden'); 
     182} 
     183 
     184/** 
     185 * returns general informations (web service method) 
     186 */ 
     187function ws_getInfos($params, &$service) 
     188{ 
     189  global $conf; 
     190   
     191  if ($conf['show_version'] or is_admin()) 
     192  { 
     193    $infos['version'] = PHPWG_VERSION; 
     194  } 
     195         
     196  $query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.';'; 
     197  list($infos['nb_elements']) = pwg_db_fetch_row(pwg_query($query)); 
     198 
     199  $query = 'SELECT COUNT(*) FROM '.CATEGORIES_TABLE.';'; 
     200  list($infos['nb_categories']) = pwg_db_fetch_row(pwg_query($query)); 
     201 
     202  $query = 'SELECT COUNT(*) FROM '.CATEGORIES_TABLE.' WHERE dir IS NULL;'; 
     203  list($infos['nb_virtual']) = pwg_db_fetch_row(pwg_query($query)); 
     204 
     205  $query = 'SELECT COUNT(*) FROM '.CATEGORIES_TABLE.' WHERE dir IS NOT NULL;'; 
     206  list($infos['nb_physical']) = pwg_db_fetch_row(pwg_query($query)); 
     207 
     208  $query = 'SELECT COUNT(*) FROM '.IMAGE_CATEGORY_TABLE.';'; 
     209  list($infos['nb_image_category']) = pwg_db_fetch_row(pwg_query($query)); 
     210 
     211  $query = 'SELECT COUNT(*) FROM '.TAGS_TABLE.';'; 
     212  list($infos['nb_tags']) = pwg_db_fetch_row(pwg_query($query)); 
     213 
     214  $query = 'SELECT COUNT(*) FROM '.IMAGE_TAG_TABLE.';'; 
     215  list($infos['nb_image_tag']) = pwg_db_fetch_row(pwg_query($query)); 
     216 
     217  $query = 'SELECT COUNT(*) FROM '.USERS_TABLE.';'; 
     218  list($infos['nb_users']) = pwg_db_fetch_row(pwg_query($query)); 
     219 
     220  $query = 'SELECT COUNT(*) FROM '.GROUPS_TABLE.';'; 
     221  list($infos['nb_groups']) = pwg_db_fetch_row(pwg_query($query)); 
     222 
     223  $query = 'SELECT COUNT(*) FROM '.COMMENTS_TABLE.';'; 
     224  list($infos['nb_comments']) = pwg_db_fetch_row(pwg_query($query)); 
     225 
     226  // first element 
     227  if ($infos['nb_elements'] > 0) 
     228  { 
     229    $query = 'SELECT MIN(date_available) FROM '.IMAGES_TABLE.';'; 
     230    list($infos['first_date']) = pwg_db_fetch_row(pwg_query($query)); 
     231  } 
     232 
     233  // unvalidated comments 
     234  if ($infos['nb_comments'] > 0 and is_admin()) 
     235  { 
     236    $query = 'SELECT COUNT(*) FROM '.COMMENTS_TABLE.' WHERE validated=\'false\';'; 
     237    list($infos['nb_unvalidated_comments']) = pwg_db_fetch_row(pwg_query($query)); 
     238  } 
     239 
     240  foreach ($infos as $name => $value) 
     241  { 
     242    $output[] = array( 
     243      'name' => $name, 
     244      'value' => $value, 
     245    ); 
     246  } 
     247 
     248  return array('infos' => new PwgNamedArray($output, 'item')); 
    182249} 
    183250 
  • branches/2.2/ws.php

    r9191 r10022  
    4343  $service->addMethod('pwg.getVersion', 'ws_getVersion', null, 
    4444      'retrieves the PWG version'); 
     45           
     46  $service->addMethod('pwg.getInfos', 'ws_getInfos', null, 
     47      'retrieves general informations'); 
    4548 
    4649  $service->addMethod('pwg.caddie.add', 'ws_caddie_add', 
Note: See TracChangeset for help on using the changeset viewer.