Code

Added first test for get_module_permissions
[gosa.git] / include / functions.inc
index cae474cb80a6e95ba647eb7f2747d790b1400ac9..19e897ea87153d3487e02e76694a2eff534b3055 100644 (file)
@@ -39,6 +39,7 @@ require_once ("class_ldap.inc");
 require_once ("class_config.inc");
 require_once ("class_userinfo.inc");
 require_once ("class_plugin.inc");
+require_once ("class_dhcpPlugin.inc");
 require_once ("class_pluglist.inc");
 require_once ("class_tabs.inc");
 require_once ("class_mail-methods.inc");
@@ -754,9 +755,27 @@ function get_permissions ($dn, $subtreeACL)
 }
 
 
-function get_module_permission($acl_array, $module, $dn)
-{
-  global $ui;
+function get_module_permission($acl_array, $module, $dn, $checkTag= TRUE)
+  global $ui, $config;
+
+  /* Check for strict tagging */
+  if ($checkTag && isset($config->current['STRICT_UNITS']) &&
+      preg_match('/^(yes|true)$/i', $config->current['STRICT_UNITS']) &&
+      $ui->gosaUnitTag != ""){
+    $size= 0;
+    foreach ($config->tdepartments as $tdn => $tag){
+      if (preg_match("/$tdn$/", $dn)){
+        if (strlen($tdn) > $size){
+          $ttag= $tag;
+        }
+      }
+    }
+
+    /* We have no permission for areas that don't carry our tag */
+    if ($ttag != $ui->gosaUnitTag){
+      return ("#none#");
+    }
+  }
 
   $final= "";
   foreach($acl_array as $acl){
@@ -2522,17 +2541,30 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA
         "sv_SE" => "Swedish",
         "zh_CN" => "Chinese",
         "ru_RU" => "Russian");
+  
+  $tmp2= array(
+        "de_DE" => _("German"),
+        "fr_FR" => _("French"),
+        "it_IT" => _("Italian"),
+        "es_ES" => _("Spanish"),
+        "en_US" => _("English"),
+        "nl_NL" => _("Dutch"),
+        "pl_PL" => _("Polish"),
+        "sv_SE" => _("Swedish"),
+        "zh_CN" => _("Chinese"),
+        "ru_RU" => _("Russian"));
 
   $ret = array();
   if($languages_in_own_language){
+
     $old_lang = setlocale(LC_ALL, 0);
     foreach($tmp as $key => $name){
       $lang = $key.".UTF-8";
       setlocale(LC_ALL, $lang);
       if($strip_region_tag){
-        $ret[preg_replace("/^([^_]*).*$/","\\1",$key)] = _($name)." (".$name.")";
+        $ret[preg_replace("/^([^_]*).*$/","\\1",$key)] = _($name)." (".$tmp2[$key].")";
       }else{
-        $ret[$key] = _($name)."  (".$name.")";
+        $ret[$key] = _($name)."  (".$tmp2[$key].")";
       }
     }
     setlocale(LC_ALL, $old_lang);