summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 15afcd7)
raw | patch | inline | side by side (parent: 15afcd7)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 24 Apr 2007 06:47:35 +0000 (06:47 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 24 Apr 2007 06:47:35 +0000 (06:47 +0000) |
aclRole inherits functions from class acl now.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6178 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6178 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/acl/class_aclRole.inc | patch | blob | history |
index ef54ec83f73fdb2f9fd7ac025d36325be673fad0..03cc4562321a77b556b46f6620ebd9e325661976 100644 (file)
<?php
-class aclrole extends plugin
+class aclrole extends acl
{
/* Definitions */
var $plHeadline= "Access control list templates";
return($ret);
}
- function buildAclSelector($list)
- {
- $display= "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
- $cols= 3;
- $tmp= get_global('plist');
- $plist= $tmp->info;
- asort($plist);
-
- /* Add select all/none buttons */
- $style = "style='width:100px;'";
-
- $display .= "<input ".$style." type='button' name='toggle_all_create' onClick=\"acl_toggle_all('_0_c$');\" value='Toggle C'>";
- $display .= "<input ".$style." type='button' name='toggle_all_move' onClick=\"acl_toggle_all('_0_m$');\" value='Toggle M'>";
- $display .= "<input ".$style." type='button' name='toggle_all_remove' onClick=\"acl_toggle_all('_0_d$');\" value='Toggle D'> - ";
- $display .= "<input ".$style." type='button' name='toggle_all_read' onClick=\"acl_toggle_all('_0_r$');\" value='Toggle R'>";
- $display .= "<input ".$style." type='button' name='toggle_all_write' onClick=\"acl_toggle_all('_0_w$');\" value='Toggle W'> - ";
-
- $display .= "<input ".$style." type='button' name='toggle_all_sub_read' onClick=\"acl_toggle_all('[^0]_r$');\" value='R+'>";
- $display .= "<input ".$style." type='button' name='toggle_all_sub_write' onClick=\"acl_toggle_all('[^0]_w$');\" value='W+'>";
-
- $display .= "<br>";
-
- $style = "style='width:50px;'";
- $display .= "<input ".$style." type='button' name='set_true_all_create' onClick=\"acl_set_all('_0_c$',true);\" value='C+'>";
- $display .= "<input ".$style." type='button' name='set_false_all_create' onClick=\"acl_set_all('_0_c$',false);\" value='C-'>";
- $display .= "<input ".$style." type='button' name='set_true_all_move' onClick=\"acl_set_all('_0_m$',true);\" value='M+'>";
- $display .= "<input ".$style." type='button' name='set_false_all_move' onClick=\"acl_set_all('_0_m$',false);\" value='M-'>";
- $display .= "<input ".$style." type='button' name='set_true_all_remove' onClick=\"acl_set_all('_0_d$',true);\" value='D+'>";
- $display .= "<input ".$style." type='button' name='set_false_all_remove' onClick=\"acl_set_all('_0_d$',false);\" value='D-'> - ";
- $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('_0_r$',true);\" value='R+'>";
- $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('_0_r$',false);\" value='R-'>";
- $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('_0_w$',true);\" value='W+'>";
- $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('_0_w$',false);\" value='W-'> - ";
-
- $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('[^0]_r$',true);\" value='R+'>";
- $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('[^0]_r$',false);\" value='R-'>";
- $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('[^0]_w$',true);\" value='W+'>";
- $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('[^0]_w$',false);\" value='W-'>";
-
- /* Build general objects */
- $list =$this->sort_by_priority($list);
- foreach ($list as $key => $name){
-
- /* Create sub acl if it does not exist */
- if (!isset($this->aclContents[$key])){
- $this->aclContents[$key]= array();
- $this->aclContents[$key][0]= '';
- }
- $currentAcl= $this->aclContents[$key];
-
- /* Object header */
- if($_SESSION['js']) {
- if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) {
- $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
- "\n <tr>".
- "\n <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
- "\n <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
- "\n <input type='button' onclick='divtoggle(\"".preg_replace("/[^a-z0-9]/i","_",$name)."\");' value='"._("Show/Hide Advanced Settings")."' /></td>".
- "\n </tr>";
- } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
- $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
- "\n <tr>".
- "\n <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
- "\n <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
- "\n <input type='button' onclick='divtoggle(\"".preg_replace("/[^a-z0-9]/i","_",$name)."\");' value='"._("Show/Hide Advanced Settings")."' /></td>".
- "\n </tr>";
- } else {
- $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
- "\n <tr>".
- "\n <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
- "\n </tr>";
- }
- } else {
- $display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
- "\n <tr>".
- "\n <td style='background-color:#C8C8C8;height:1.8em;' colspan=$cols><b>"._("Object").": $name</b></td>".
- "\n </tr>";
- }
-
- /* Generate options */
- $spc= " ";
- if ($this->isContainer && $this->aclType != 'base'){
- $options= $this->mkchkbx($key."_0_c", _("Create objects"), preg_match('/c/', $currentAcl[0])).$spc;
- $options.= $this->mkchkbx($key."_0_m", _("Move objects"), preg_match('/m/', $currentAcl[0])).$spc;
- $options.= $this->mkchkbx($key."_0_d", _("Remove objects"), preg_match('/d/', $currentAcl[0])).$spc;
- if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
- $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $currentAcl[0])).$spc;
- }
- } else {
- $options= $this->mkchkbx($key."_0_m", _("Move object"), preg_match('/m/', $currentAcl[0])).$spc;
- $options.= $this->mkchkbx($key."_0_d", _("Remove object"), preg_match('/d/', $currentAcl[0])).$spc;
- if ($plist[preg_replace('%^.*/%', '', $key)]['plSelfModify']){
- $options.= $this->mkchkbx($key."_0_s", _("Modifyable by owner"), preg_match('/s/', $currentAcl[0])).$spc;
- }
- }
-
- /* Global options */
- $more_options= $this->mkchkbx($key."_0_r", _("read"), preg_match('/r/', $currentAcl[0])).$spc;
- $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $currentAcl[0]));
-
- $display.= "\n <tr>".
- "\n <td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>".
- "\n <td style='background-color:#D4D4D4'> "._("Complete object").": $more_options</td>".
- "\n </tr>";
-
- /* Walk through the list of attributes */
- $cnt= 1;
- $splist= $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls'];
- asort($splist);
- if($_SESSION['js']) {
- if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) {
- $display.= "\n <tr id='tr_".preg_replace("/[^a-z0-9]/i","_",$name)."' style='vertical-align:top;height:0px;'>".
- "\n <td colspan=".$cols.">".
- "\n <div id='".preg_replace("/[^a-z0-9]/i","_",$name)."' style='overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
- "\n <table style='width:100%;'>";
- } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) {
- $display.= "\n <tr id='tr_".preg_replace("/[^a-z0-9]/i","_",$name)."' style='vertical-align:top;height:0px;'>".
- "\n <td colspan=".$cols.">".
- "\n <div id='".preg_replace("/[^a-z0-9]/i","_",$name)."' style='position:absolute;overflow:hidden;visibility:hidden;height:0px;vertical-align:top;width:100%;'>".
- "\n <table style='width:100%;'>";
- }
- }
- foreach($splist as $attr => $dsc){
-
- /* Skip pl* attributes, they are internal... */
- if (preg_match('/^pl[A-Z]+.*$/', $attr)){
- continue;
- }
-
- /* Open table row */
- if ($cnt == 1){
- $display.= "\n <tr>";
- }
-
- /* Close table row */
- if ($cnt == $cols){
- $cnt= 1;
- $rb= "";
- $end= "\n </tr>";
- } else {
- $cnt++;
- $rb= "border-right:1px solid #A0A0A0;";
- $end= "";
- }
-
- /* Collect list of attributes */
- $state= "";
- if (isset($currentAcl[$attr])){
- $state= $currentAcl[$attr];
- }
- $display.= "\n <td style='border-top:1px solid #A0A0A0;${rb}width:".(int)(100/$cols)."%'>".
- "\n <b>$dsc</b> ($attr)<br>".$this->mkrwbx($key."_".$attr, $state)."</td>$end";
- }
-
- /* Fill missing td's if needed */
- if (--$cnt != $cols && $cnt != 0){
- $display.= str_repeat("\n <td style='border-top:1px solid #A0A0A0; width:".(int)(100/$cols)."%'> </td>", $cols-$cnt);
- }
-
- if($_SESSION['js']) {
- if(isset($_SERVER['HTTP_USER_AGENT']) && (preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) || (preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT']))) {
- $display.= "\n </table>".
- "\n </div>".
- "\n </td>".
- "\n </tr>";
- }
- }
-
- $display.= "\n</table><br />\n";
- }
-
- return ($display);
- }
-
-
- function mkchkbx($name, $text, $state= FALSE)
- {
- $state= $state?"checked":"";
- return "\n <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."' type=checkbox name='acl_$name' $state>".
- "\n <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."'>$text</label>";
- }
-
-
- function mkrwbx($name, $state= "")
- {
- $rstate= preg_match('/r/', $state)?'checked':'';
- $wstate= preg_match('/w/', $state)?'checked':'';
- return ("\n <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_r' type=checkbox name='acl_${name}_r' $rstate>".
- "\n <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_r'>"._("read")."</label>".
- "\n <input id='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_w' type=checkbox name='acl_${name}_w' $wstate>".
- "\n <label for='acl_".preg_replace("/[^a-z0-9]/i","_",$name)."_w'>"._("write")."</label>");
- }
-
-
- function explodeACL($acl)
- {
- list($index, $type)= split(':', $acl);
- $a= array( $index => array("type" => $type,
- "members" => $this->extractMembers($acl)));
-
- /* Handle different types */
- switch ($type){
-
- case 'psub':
- case 'sub':
- case 'one':
- case 'base':
- $a[$index]['acl']= $this->extractACL($acl);
- break;
-
- case 'role':
- echo "Role";
- break;
-
- case 'reset':
- break;
-
- default:
- print_red(sprintf(_("Unkown ACL type '%s'. Don't know how to handle it."), $type));
- $a= array();
- }
-
- return ($a);
- }
-
-
- function extractMembers($acl)
- {
- global $config;
- $a= array();
-
- /* Rip acl off the string, seperate by ',' and place it in an array */
- $ms= preg_replace('/^[^:]+:[^:]+:([^:]+).*$/', '\1', $acl);
- if ($ms == $acl){
- return $a;
- }
- $ma= split(',', $ms);
-
- /* Decode dn's, fill with informations from LDAP */
- $ldap= $config->get_ldap_link();
- foreach ($ma as $memberdn){
- $dn= base64_decode($memberdn);
- $ldap->cat($dn, array('cn', 'objectClass', 'description', 'uid'));
-
- /* Found entry... */
- if ($ldap->count()){
- $attrs= $ldap->fetch();
- if (in_array_ics('gosaAccount', $attrs['objectClass'])){
- $a['U:'.$dn]= $attrs['cn'][0]." [".$attrs['uid'][0]."]";
- } else {
- $a['G:'.$dn]= $attrs['cn'][0];
- if (isset($attrs['description'][0])){
- $a['G:'.$dn].= " [".$attrs['description'][0]."]";
- }
- }
-
- /* ... or not */
- } else {
- $a['U:'.$dn]= sprintf(_("Unknown entry '%s'!"), $dn);
- }
- }
-
- return ($a);
- }
-
-
- function extractACL($acl)
- {
- /* Rip acl off the string, seperate by ',' and place it in an array */
- $as= preg_replace('/^[^:]+:[^:]+:[^:]*:(.*)$/', '\1', $acl);
- $aa= split(',', $as);
- $a= array();
-
- /* Dis-assemble single ACLs */
- foreach($aa as $sacl){
-
- /* Dis-assemble field ACLs */
- $ao= split('#', $sacl);
- $gobject= "";
- foreach($ao as $idx => $ssacl){
-
- /* First is department with global acl */
- $object= preg_replace('/^([^;]+);.*$/', '\1', $ssacl);
- $gacl= preg_replace('/^[^;]+;(.*)$/', '\1', $ssacl);
- if ($idx == 0){
- /* Create hash for this object */
- $gobject= $object;
- $a[$gobject]= array();
-
- /* Append ACL if set */
- if ($gacl != ""){
- $a[$gobject]= array($gacl);
- }
- } else {
-
- /* All other entries get appended... */
- list($field, $facl)= split(';', $ssacl);
- $a[$gobject][$field]= $facl;
- }
-
- }
- }
-
- return ($a);
- }
-
-
- function assembleAclSummary($entry)
- {
- $summary= "";
-
- /* Summarize ACL */
- if (isset($entry['acl'])){
- $acl= "";
- foreach ($entry['acl'] as $name => $object){
- if (count($object)){
- $acl.= "$name, ";
- }
- }
- $summary.= sprintf(_("Contains settings for these objects: %s"), preg_replace('/, $/', '', $acl));
- }
-
- /* Summarize members */
- if ($summary != ""){
- $summary.= ", ";
- }
- if (count($entry['members'])){
- $summary.= _("Members:")." ";
- foreach ($entry['members'] as $cn){
- $cn= preg_replace('/ \[.*$/', '', $cn);
- $summary.= $cn.", ";
- }
- } else {
- $summary.= _("ACL is valid for all users");
- }
-
- return (preg_replace('/, $/', '', $summary));
- }
-
-
function loadAclEntry($new= FALSE)
{
/* New entry gets presets... */