X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_pluglist.inc;h=114ab5ddd21fe3cbf8b58558f1fcbee4e1c429ee;hb=888516587f0cda06601ab943d2851bfaf5b23578;hp=6fdf9b32026a722405bcfd5181d5bc09e70bd917;hpb=894aa86d1d4d57416d43052ea7b781ff680f03c9;p=gosa.git
diff --git a/gosa-core/include/class_pluglist.inc b/gosa-core/include/class_pluglist.inc
index 6fdf9b320..114ab5ddd 100644
--- a/gosa-core/include/class_pluglist.inc
+++ b/gosa-core/include/class_pluglist.inc
@@ -1,24 +1,25 @@
config= &$config;
/* Create dirlist for all plugins */
- $this->dirlist= $this->get_plugins ($this->dirlist, $this->config->data);
+ $this->dirlist= $this->get_plugins ($this->dirlist, $this->config->data['MENU']);
/* Fill info part of pluglist */
$classes= get_declared_classes();
@@ -58,65 +60,79 @@ class pluglist {
function get_plugins($list, &$config)
{
+ global $class_mapping;
+
/* Error reporting, because I'm getting strange messages in PHP 4.2.x */
- if (!isset($config['PATH']) && !isset($config['CLASS'])){
+ if (!isset($config['CLASS'])){
if (is_array($config)){
foreach ($config as $val){
$list= $this->get_plugins($list, $val);
}
}
} else {
- if (isset ($config['PATH']) && is_array($config)){
- $list[$this->index++]= $config['PATH'];
- if (isset($config['CLASS'])){
- $class= $config['CLASS'];
- }
+ if (is_array($config) && isset($class_mapping[$config['CLASS']])){
+ $list[$this->index++]= dirname($class_mapping[$config['CLASS']]);
+ } else {
+ $list[$this->index++]= "";
}
}
return ($list);
}
+
+ /*! \brief Check whether we are allowed to modify the given acl or nit..
+ This function is used to check which plugins are visible.
+
+ @param The acl tag to test, eg. "users/user:self", "systems", ...
+ @return Boolean TRUE on success else FALSE
+ */
function check_access($aclname)
{
- $deps= $this->ui->get_module_departments($aclname);
-
+ /* Split given acl string into an array.
+ e.g. "user,systems" => array("users","systems");
+ */
$acls_to_check = array();
if(preg_match("/,/",$aclname)){
$acls_to_check = split(",",$aclname);
}else{
$acls_to_check = array($aclname);
}
-
- if(preg_match("/\//",$aclname)){
- foreach($deps as $dep){
- foreach($acls_to_check as $acl_to_check){
- if($this->ui->get_permissions($dep,$acl_to_check) != ""){
- return(TRUE);
- }
- }
- }
- }else{
- foreach($deps as $dep){
- foreach($acls_to_check as $acl_to_check){
- if($this->ui->get_category_permissions($dep,$acl_to_check) != ""){
- return(TRUE);
- }
+
+ foreach($acls_to_check as $acl_to_check){
+
+ /* Check if the given acl tag is only valid for self acl entries
+ ui->get_permissions($this->ui->dn,$acl_to_check,"") != ""){
+ return(TRUE);
}
+ return(FALSE);
+ }else{
+
+ /* No self acls. Check if we have any acls for the given ACL type
+ */
+ $deps = $this->ui->get_module_departments($acl_to_check,TRUE);
+ if(count($deps)) return TRUE;
}
}
return (FALSE);
}
+
function gen_headlines()
{
$ret = array();
if(count($this->headlines) == 0){
foreach($this->config->data['MENU'] as $headline => $plugins){
foreach( $plugins as $id => $plug){
- $attrs = (get_class_vars($plug['CLASS']));
- $ret[$id]['HEADLINE'] = $headline;
- $ret[$id]['NAME'] = $attrs['plHeadline'];
+ if (plugin_available($plug['CLASS'])){
+ $attrs = (get_class_vars($plug['CLASS']));
+ $ret[$id]['HEADLINE'] = $headline;
+ $ret[$id]['NAME'] = $attrs['plHeadline'];
+ }
}
}
$this->headlines = $ret;
@@ -126,6 +142,19 @@ class pluglist {
function gen_menu()
{
+ /* Check if class_location.inc has changed, this is the case
+ if we have installed or removed plugins.
+ */
+ if(!session::is_set("class_location.inc:timestamp")){
+ $tmp = stat("../include/class_location.inc");
+ session::set("class_location.inc:timestamp",$tmp['mtime']);
+ }else{
+ $tmp = stat("../include/class_location.inc");
+ if($tmp['mtime'] != session::get("class_location.inc:timestamp")){
+ $this->menu = "";
+ }
+ }
+
if ($this->menu == ""){
$first= TRUE;
$cfg= $this->config->data['MENU'];
@@ -147,17 +176,20 @@ class pluglist {
/* Read information from class variable */
if (!isset($info['CLASS'])){
- print_red(_("Your gosa.conf format has changed. Please re-run setup!"));
- echo $_SESSION['errors'];
- exit;
+ msg_dialog::display(
+ _("Configuration error"),
+ _("The configuration format has changed. Please re-run setup!"),
+ FATAL_ERROR_DIALOG);
+ exit();
+ }
+ if (!plugin_available($info['CLASS'])){
+ continue;
}
$vars= get_class_vars($info['CLASS']);
$plHeadline= $vars['plHeadline'];
$plDescription= $vars['plDescription'];
-
- $index= $this->get_index($info['PATH'],$info['CLASS']);
- $image= get_template_path('images/'.$info['ICON']);
+ $index= $this->get_index($info['CLASS']);
$href= "main.php?plug=$index&reset=1";
if(!$vars){
@@ -168,9 +200,11 @@ class pluglist {
if ($this->check_access($info['ACL'])){
+ $this->allowed_plugins[$index] = $index;
+
$entries= $entries."\n";
} else {
$entries.= "
\n";
}
- /* Generate icon entry with description */
- $current= '';
- $this->menuparts[_($headline)][]= $current;
- if(!isset($_SESSION['maxC'])){
- $_SESSION['maxC'] = "RO0K9CzEYCSAAOtOICCFhEDBKGSKANyHMKDHAEwFLNTJILwEMODJYPgMRA0F9IOPSPUKNEVCUKyDBAHNbIWFJOIP";
+ if(!session::is_set('maxC')){
+ session::set('maxC',"RO0K9CzEYCSAAOtOICCFhEDBKGSKANyHMKDHAEwFLNTJILwEMODJYPgMRA0F9IOPSPUKNEVCUKyDBAHNbIWFJOIP");
}
}
}
@@ -240,6 +265,21 @@ class pluglist {
function show_iconmenu()
{
+ global $class_mapping;
+
+ /* Check if class_location.inc has changed, this is the case
+ if we have installed or removed plugins.
+ */
+ if(!session::is_set("class_location.inc:timestamp")){
+ $tmp = stat("../include/class_location.inc");
+ session::set("class_location.inc:timestamp",$tmp['mtime']);
+ }else{
+ $tmp = stat("../include/class_location.inc");
+ if($tmp['mtime'] != session::get("class_location.inc:timestamp")){
+ $this->iconmenu = "";
+ }
+ }
+
if ($this->iconmenu == ""){
$cfg= $this->config->data['MENU'];
@@ -260,12 +300,21 @@ class pluglist {
foreach ($plug as $info){
+ if (!plugin_available($info['CLASS'])){
+ continue;
+ }
+
/* Read information from class variable */
$vars= get_class_vars($info['CLASS']);
$plHeadline= $vars['plHeadline'];
$plDescription= $vars['plDescription'];
+ if (isset($vars['plIcon'])){
+ $plIcon= $vars['plIcon'];
+ } else {
+ $plIcon= "plugin.png";
+ }
- $index= $this->get_index($info['PATH'],$info['CLASS']);
+ $index= $this->get_index($info['CLASS']);
$href = "main.php?plug=".$index."&reset=1";
@@ -280,15 +329,19 @@ class pluglist {
if ($this->check_access($info['ACL'])){
- /* Hm this looks doubled */
- $image= get_template_path('images/'.$info['ICON']);
+ /* Load icon */
+ if (isset($info['ICON'])){
+ $image= get_template_path('images/'.$info['ICON']);
+ } else {
+ $image= get_template_path("plugins/".preg_replace('%^.*/([^/]+)/[^/]+$%', '\1', $class_mapping[$info['CLASS']])."/images/$plIcon");
+ }
if ($col > 5){
$entries= $entries."";
$col = 1;
}
$entries= $entries."