Index: /extensions/linked_pages/include/functions.inc.php
===================================================================
--- /extensions/linked_pages/include/functions.inc.php	(revision 17924)
+++ /extensions/linked_pages/include/functions.inc.php	(revision 17925)
@@ -23,9 +23,35 @@
 function linked_pages_loc_end_index()
 {
-  global $page, $user, $template;
+  global $page, $user, $template, $conf;
   
-
   if ( isset($page['section']) and $page['section']=='categories' and isset($page['category']) )
   {
+    $where_clauses = array('category_id = '.$page['category']['id']);
+    
+    if (!is_admin())
+    {
+      if ($conf['AP']['language_perm'])
+      {
+        $where_clauses[] = '(ap.lang = NULL OR ap.lang = "'.$user['language'].'")';
+      }
+      if ($conf['AP']['level_perm'])
+      {
+        $where_clauses[] = 'ap.level <= '.$user['level'];
+      }
+      if ($conf['AP']['user_perm'])
+      {
+        $where_clauses[] = 'ap.users LIKE "%'.$user['status'].'%"';
+      }
+      if ($conf['AP']['group_perm'])
+      {
+        $query = '
+SELECT group_id
+  FROM '.USER_GROUP_TABLE.'
+  WHERE user_id = '.$user['id'].'
+;';
+        $user_groups = array_from_query($query, 'group_id');
+      }
+    }
+    
     $query = '
 SELECT
@@ -34,9 +60,11 @@
     ap.title,
     ap.standalone,
-    ap.permalink
+    ap.permalink,
+    ap.groups
   FROM '.LINKEDPAGES_TABLE.' AS lp
     INNER JOIN '.ADD_PAGES_TABLE.' AS ap
     ON lp.page_id = ap.id
-  WHERE category_id = '.$page['category']['id'].'
+  WHERE
+    '.implode("\n    AND ", $where_clauses).'
   ORDER BY lp.pos
 ;';
@@ -50,5 +78,19 @@
     while ($row = pwg_db_fetch_assoc($result))
     {
-      if ( isset($row['lang']) and $row['lang'] != $user['language'] ) return;
+      if ( !is_admin() and $conf['AP']['group_perm'] and !empty($row['groups']) )
+      {
+        $authorized = false;
+        foreach (explode(',',$row['groups']) as $group_id)
+        {
+          if (in_array($group_id, $user_groups))
+          {
+            $authorized = true;
+            break;
+          }
+        }
+        if (!$authorized) continue;
+      }
+        
+      
       $row['U_PAGE'] = make_index_url(array('section'=>'page')).'/'.(isset($row['permalink']) ? $row['permalink'] : $row['page_id']);
       $row['TITLE'] = trigger_event('AP_render_title', $row['title']);
@@ -62,4 +104,11 @@
   else if ( isset($page['section']) and $page['section']=='additional_page' and isset($page['additional_page']) )
   {
+    $where_clauses = array('page_id = '.$page['additional_page']['id']);
+    
+    if (!is_admin())
+    {
+      $where_clauses[] = 'lp.category_id NOT IN('.$user['forbidden_categories'].')';
+    }
+    
     $query = '
 SELECT
@@ -70,5 +119,6 @@
     INNER JOIN '.CATEGORIES_TABLE.' AS cat
     ON lp.category_id = cat.id
-  WHERE page_id = '.$page['additional_page']['id'].'
+  WHERE
+    '.implode("\n    AND ", $where_clauses).'
   ORDER BY lp.pos
 ;';
Index: /extensions/linked_pages/main.inc.php
===================================================================
--- /extensions/linked_pages/main.inc.php	(revision 17924)
+++ /extensions/linked_pages/main.inc.php	(revision 17925)
@@ -16,7 +16,8 @@
 // | Define plugin constants                                               |
 // +-----------------------------------------------------------------------+
-define('LINKEDPAGES_PATH' ,   PHPWG_PLUGINS_PATH . 'linked_pages/');
+defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__)));
+define('LINKEDPAGES_PATH' ,   PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/');
 define('LINKEDPAGES_TABLE',   $prefixeTable . 'linked_pages');
-define('LINKEDPAGES_ADMIN',   get_root_url() . 'admin.php?page=plugin-linked_pages');
+define('LINKEDPAGES_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . LINKEDPAGES_ID);
 define('LINKEDPAGES_VERSION', '1.0.0');
 
@@ -51,6 +52,6 @@
   
   if (
-    $pwg_loaded_plugins['linked_pages']['version'] == 'auto' or
-    version_compare($pwg_loaded_plugins['linked_pages']['version'], LINKEDPAGES_VERSION, '<')
+    $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] == 'auto' or
+    version_compare($pwg_loaded_plugins[LINKEDPAGES_ID]['version'], LINKEDPAGES_VERSION, '<')
   )
   {
@@ -58,17 +59,17 @@
     linked_pages_install();
     
-    if ($pwg_loaded_plugins['linked_pages']['version'] != 'auto')
+    if ($pwg_loaded_plugins[LINKEDPAGES_ID]['version'] != 'auto')
     {
       $query = '
 UPDATE '. PLUGINS_TABLE .'
 SET version = "'. LINKEDPAGES_VERSION .'"
-WHERE id = "linked_pages"';
+WHERE id = "'. LINKEDPAGES_ID .'"';
       pwg_query($query);
       
-      $pwg_loaded_plugins['linked_pages']['version'] = LINKEDPAGES_VERSION;
+      $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] = LINKEDPAGES_VERSION;
       
       if (defined('IN_ADMIN'))
       {
-        $_SESSION['page_infos'][] = 'Skeleton updated to version '. LINKEDPAGES_VERSION;
+        $_SESSION['page_infos'][] = 'Linked Pages updated to version '. LINKEDPAGES_VERSION;
       }
     }
Index: /extensions/linked_pages/maintain.inc.php
===================================================================
--- /extensions/linked_pages/maintain.inc.php	(revision 17924)
+++ /extensions/linked_pages/maintain.inc.php	(revision 17925)
@@ -2,5 +2,6 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-include_once(PHPWG_PLUGINS_PATH . 'linked_pages/include/install.inc.php');
+defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__)));
+include_once(PHPWG_PLUGINS_PATH . LINKEDPAGES_ID '/include/install.inc.php');
 
 
