Changeset 9516


Ignore:
Timestamp:
03/04/11 11:26:08 (9 years ago)
Author:
plg
Message:

display the number of pending photos outside the dedicated admin screen (on the admin homepage, in the admin menubar, in the tab name)

Location:
extensions/community
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/community/admin.php

    r9372 r9516  
    3030include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
    3131 
    32 load_language('plugin.lang', COMMUNITY_PATH); 
    33  
    3432define('COMMUNITY_BASE_URL', get_root_url().'admin.php?page=plugin-community'); 
    3533 
     
    4442// +-----------------------------------------------------------------------+ 
    4543 
     44$pendings_label = l10n('Pending Photos'); 
     45if ($page['community_nb_pendings'] > 0) 
     46{ 
     47  $pendings_label.= ' ('.$page['community_nb_pendings'].')'; 
     48} 
     49 
    4650$tabs = array( 
    4751  array( 
     
    5155  array( 
    5256    'code' => 'pendings', 
    53     'label' => l10n('Pending Photos'), 
     57    'label' => $pendings_label, 
    5458    ), 
    5559  ); 
  • extensions/community/language/en_UK/plugin.lang.php

    r9510 r9516  
    5656$lang['Permission updated'] = 'Permission updated'; 
    5757$lang['Delete permission'] = 'Delete permission'; 
     58$lang['%u pending photos'] = '%u pending photos'; 
    5859?> 
  • extensions/community/language/fr_FR/plugin.lang.php

    r9510 r9516  
    5757$lang['Permission updated'] = 'Permission mise à jour'; 
    5858$lang['Delete permission'] = 'Supprimer la permission'; 
     59$lang['%u pending photos'] = '%u photos en attente'; 
    5960?> 
  • extensions/community/main.inc.php

    r9452 r9516  
    2121 
    2222include_once(COMMUNITY_PATH.'include/functions_community.inc.php'); 
     23load_language('plugin.lang', COMMUNITY_PATH); 
    2324 
    2425/* Plugin admin */ 
    2526add_event_handler('get_admin_plugin_menu_links', 'community_admin_menu'); 
    26  
    2727function community_admin_menu($menu) 
    2828{ 
     29  global $page; 
     30   
     31  $query = ' 
     32SELECT 
     33    COUNT(*) 
     34  FROM '.COMMUNITY_PENDINGS_TABLE.' 
     35  WHERE state = \'moderation_pending\' 
     36;'; 
     37  $result = pwg_query($query); 
     38  list($page['community_nb_pendings']) = pwg_db_fetch_row($result); 
     39 
     40  $name = 'Community'; 
     41  if ($page['community_nb_pendings'] > 0) 
     42  { 
     43    $style = 'background-color:#666;'; 
     44    $style.= 'color:white;'; 
     45    $style.= 'padding:1px 5px;'; 
     46    $style.= '-moz-border-radius:10px;'; 
     47    $style.= '-webkit-border-radius:10px;'; 
     48    $style.= '-border-radius:10px;'; 
     49    $style.= 'margin-left:5px;'; 
     50     
     51    $name.= '<span style="'.$style.'">'.$page['community_nb_pendings'].'</span>'; 
     52 
     53    if (defined('IN_ADMIN') and IN_ADMIN and $page['page'] == 'intro') 
     54    { 
     55      global $template; 
     56       
     57      $template->set_prefilter('intro', 'community_pendings_on_intro'); 
     58      $template->assign( 
     59        array( 
     60          'COMMUNITY_PENDINGS' => sprintf( 
     61            '<a href="%s">'.l10n('%u pending photos').'</a>', 
     62            get_root_url().'admin.php?page=plugin-community-pendings', 
     63            $page['community_nb_pendings'] 
     64            ), 
     65          ) 
     66        ); 
     67    } 
     68  } 
     69 
    2970  array_push( 
    3071    $menu, 
    3172    array( 
    32       'NAME' => 'Community', 
     73      'NAME' => $name, 
    3374      'URL'  => get_root_url().'admin.php?page=plugin-community' 
    3475      ) 
     
    3677 
    3778  return $menu; 
     79} 
     80 
     81function community_pendings_on_intro($content, &$smarty) 
     82{ 
     83  $pattern = '#<li>\s*{\$DB_ELEMENTS\}#ms'; 
     84  $replacement = '<li>{$COMMUNITY_PENDINGS}</li><li>{$DB_ELEMENTS}'; 
     85  return preg_replace($pattern, $replacement, $content); 
    3886} 
    3987 
     
    154202  community_reject_user_pendings($user_id); 
    155203} 
    156  
    157204?> 
Note: See TracChangeset for help on using the changeset viewer.