diff --git a/include/class_acl.inc b/include/class_acl.inc index b71fd3731f0d2149afaa8568a2a6c735f1589c00..962c0c79dbd10bc3646b0111c67493992106a2a0 100644 --- a/include/class_acl.inc +++ b/include/class_acl.inc @@ -26,75 +26,24 @@ /*! * \brief This class contains all the function needed to manage acl - * \see class_plugin */ -class acl extends plugin +class acl { - /* attribute list for save action */ - var $attributes = array('gosaAclEntry'); - var $objectclasses = array('gosaAcl'); - - /* Helpers */ - var $dialogState = "head"; - var $gosaAclEntry = array(); - var $aclType = ""; - var $aclObject = ""; - var $aclContents = array(); - var $aclFilter = ""; - var $aclMyObjects = array(); - var $roles = array(); - var $recipients = array(); - var $currentIndex = 0; - var $wasNewEntry = FALSE; - var $savedAclContents = array(); - var $acl_category = "acl/"; - - /*! - * \brief Acl contructor - * - * \param String $config Configuration file for ACL - * - * \param String $parent - * - * \param String $dn The DN - */ - function acl (&$config, $dn = NULL, $baseobject = NULL) + static function plInfo() { - /* Include config object */ - parent::__construct($config, $dn, $baseobject); - - /* Load ACL's */ - $this->gosaAclEntry = array(); - if (isset($this->attrs['gosaAclEntry'])) { - for ($i = 0; $i < $this->attrs['gosaAclEntry']['count']; $i++) { - $acl = $this->attrs['gosaAclEntry'][$i]; - $this->gosaAclEntry = array_merge($this->gosaAclEntry, acl::explodeACL($acl)); - } - } - ksort($this->gosaAclEntry); - - /* Save parent - we've to know more about it than other plugins... */ - if (($baseobject !== NULL) && isset($baseobject->parent)) { - $this->parent =& $baseobject->parent; - } - - $ldap = $config->get_ldap_link(); - - /* Roles TODO - use objects::ls?*/ - $ldap->cd($config->current['BASE']); - $ldap->search('(objectClass=gosaRole)', array('cn', 'description','gosaAclTemplate','dn')); - while ($attrs = $ldap->fetch()) { - $role_id = $attrs['dn']; - - $this->roles[$role_id]['acls'] = acl::explodeRole($attrs['gosaAclTemplate']); - $this->roles[$role_id]['cn'] = $attrs['cn'][0]; - if (isset($attrs['description'][0])) { - $this->roles[$role_id]['description'] = $attrs['description'][0]; - } - } + return array( + 'plShortName' => _('ACL'), + 'plDescription' => _('Manage access control lists'), + 'plCategory' => array( + 'acl' => array( + 'description' => _('ACL').' & '._('ACL roles'), + 'objectClass' => array('gosaAcl','gosaRole') + ) + ), + 'plObjectType' => array(), - /* Finally - we want to get saved... */ - $this->is_account = TRUE; + 'plProvidedAcls' => array() + ); } /*! @@ -102,7 +51,7 @@ class acl extends plugin * * \param Array $list Array to be sorted */ - function sort_by_priority($list) + static function sort_by_priority($list) { uksort($list, function ($a, $b) @@ -266,44 +215,5 @@ class acl extends plugin return $a; } - - /*! - * \brief Removes object from parent - */ - function remove_from_parent() - { - parent::remove_from_parent(); - - /* include global link_info */ - $ldap = $this->config->get_ldap_link(); - - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify($this->attrs); - - new log('remove', 'acls/'.get_class($this), $this->dn, array_keys($this->attrs), $ldap->get_error()); - - /* Optionally execute a command after we're done */ - $this->handle_post_events('remove'); - } - - /* - * \brief Return plugin informations for acl handling - */ - static function plInfo() - { - return array( - 'plShortName' => _('ACL'), - 'plDescription' => _('Manage access control lists'), - 'plSelfModify' => FALSE, - 'plPriority' => 0, - 'plCategory' => array('acl' => array('description' => _('ACL').' & '._('ACL roles'), - 'objectClass' => array('gosaAcl','gosaRole'))), - 'plObjectType' => array(), - - 'plProvidedAcls' => array() - ); - } } - ?> diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 99291058b26f26cf1caf9d3b3a1330fb245482d5..92894ab2e9904d51b631146f2313452c89ef1a5c 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -330,9 +330,6 @@ class plugin */ function execute() { - /* This one is empty currently. Fabian - please fill in the docu code */ - session::global_set('current_class_for_help', get_class($this)); - /* Reset Lock message POST/GET check array, to prevent perg_match errors*/ session::set('LOCK_VARS_TO_USE', array()); session::set('LOCK_VARS_USED_GET', array()); diff --git a/plugins/admin/aclrole/acl_role.tpl b/plugins/admin/aclrole/acl_role.tpl index 62315accc074931ce32cf29f9ae1b41315d958c2..42cbf9677af44a77641c1804c8f47024e18d7bdc 100644 --- a/plugins/admin/aclrole/acl_role.tpl +++ b/plugins/admin/aclrole/acl_role.tpl @@ -4,7 +4,7 @@ <hr/> <div style="text-align:right;margin-top:5px"> - {render acl=$gosaAclEntryACL} + {render acl=$gosaAclTemplateACL} <input type="submit" name="submit_new_acl" value="{msgPool type=applyButton}"/> {/render} @@ -15,13 +15,13 @@ {if $dialogState eq 'edit'} <h1>{$headline}</h1> - {render acl=$gosaAclEntryACL} + {render acl=$gosaAclTemplateACL} {$aclSelector} {/render} <hr/> <div style="text-align:right;margin-top:5px"> - {render acl=$gosaAclEntryACL} + {render acl=$gosaAclTemplateACL} <input type="submit" name="submit_edit_acl" value="{msgPool type=applyButton}"/> {/render} diff --git a/plugins/admin/aclrole/class_aclRole.inc b/plugins/admin/aclrole/class_aclRole.inc index a995c7f933f9dc61a0830e23593fbb98e08f0d40..bc61b2764186baf205701bcc6c0cdf4fab36cfd1 100644 --- a/plugins/admin/aclrole/class_aclRole.inc +++ b/plugins/admin/aclrole/class_aclRole.inc @@ -32,6 +32,12 @@ class ACLDialog extends GenericDialog $this->initialAclValue = $acl; } + function dialog_execute () + { + $this->dialog->save_object(); + return $this->dialog->execute(); + } + function handle_finish () { $this->attribute->addValue($this->dialog->getAclEntry()); @@ -50,8 +56,8 @@ class ACLDialog extends GenericDialog /* complicated stuff */ class ACLsAttribute extends DialogOrderedArrayAttribute { - protected $order = TRUE; - protected $dialogClass = 'ACLDialog'; + protected $order = TRUE; + protected $dialogClass = 'ACLDialog'; protected function getAttributeArrayValue($key, $value) { @@ -157,34 +163,41 @@ class aclRole extends simplePlugin } } -class acl_createedit extends acl +class acl_createedit extends simplePlugin { + var $objectclasses = array('gosaAcl'); + /* Helpers */ - var $dialogState = "create"; - var $aclType = ""; - var $aclObject = ""; + var $dialogState = 'create'; + var $aclObject = ''; var $aclContents = array(); - var $recipients = array(); var $savedAclContents = array(); static function plInfo() { } + static function getAttributesInfo() + { + return array(); + } + function __construct (&$config, $acl = NULL) { /* Include config object */ - plugin::__construct($config, $config->current['BASE']); + parent::__construct($config, $config->current['BASE']); - $this->loadAclEntry($acl); + /* New entry gets presets... */ + if ($acl === NULL) { + $this->aclContents = array(); + } else { + $this->aclContents = $acl; + } } - function execute() + function save_object() { - /* Call parent execute */ - plugin::execute(); - - $new_acl = array(); + $new_acl = array(); foreach ($_POST as $name => $post) { /* Actions... */ @@ -195,12 +208,11 @@ class acl_createedit extends acl if (isset($this->aclContents[$oc])) { $this->savedAclContents[$oc] = $this->aclContents[$oc]; } + if (isset($this->aclContents[$this->aclObject.'/'.$oc])) { + $this->savedAclContents[$this->aclObject.'/'.$oc] = $this->aclContents[$this->aclObject.'/'.$oc]; + } } - continue; - } - - if (!$this->acl_is_writeable("gosaAclEntry")) { - continue; + break; } if (preg_match('/^cat_del_.*_x/', $name)) { @@ -208,10 +220,10 @@ class acl_createedit extends acl foreach ($this->config->data['CATEGORIES'][$idx]['classes'] as $key) { unset($this->aclContents["$idx/$key"]); } - continue; + break; } - /* ACL saving... */ + /* ACL checkbox saving... */ if (preg_match('/^acl_([^_]+)_(.*)_([^_yx])$/', $name, $matches)) { $object = $matches[1]; $attribute = $matches[2]; @@ -235,7 +247,7 @@ class acl_createedit extends acl } /* Only be interested in new acl's, if we're in the right _POST place */ - if (isset($_POST['acl_dummy_0_0_0']) && ($this->aclObject != "") && is_array($this->config->data['CATEGORIES'][$this->aclObject])) { + if (isset($_POST['acl_dummy_0_0_0']) && ($this->aclObject != '') && is_array($this->config->data['CATEGORIES'][$this->aclObject])) { foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $oc) { unset($this->aclContents[$oc]); unset($this->aclContents[$this->aclObject.'/'.$oc]); @@ -255,40 +267,44 @@ class acl_createedit extends acl if (isset($this->savedAclContents[$oc])) { $this->aclContents[$oc] = $this->savedAclContents[$oc]; } + if (isset($this->savedAclContents[$this->aclObject.'/'.$oc])) { + $this->aclContents[$this->aclObject.'/'.$oc] = $this->savedAclContents[$this->aclObject.'/'.$oc]; + } } } - if ($this->acl_is_writeable("gosaAclEntry")) { - /* Save edit acl? */ - if (isset($_POST['submit_edit_acl'])) { - $this->dialogState = 'create'; - } - - /* Save common values */ - foreach (array("aclObject") as $key) { - if (isset($_POST[$key])) { - $this->$key = validate($_POST[$key]); - } - } + /* Save edit acl? */ + if (isset($_POST['submit_edit_acl'])) { + $this->dialogState = 'create'; } + } + + function execute() + { + /* Call parent execute */ + parent::execute(); /* Create templating instance */ $smarty = get_smarty(); - $smarty->assign("usePrototype", "true"); + $smarty->assign('usePrototype', 'true'); - $smarty->assign("gosaAclEntryACL", $this->getacl('gosaAclEntry')); + $smarty->assign('gosaAclTemplateACL', $this->getacl('gosaAclTemplate')); if ($this->dialogState == 'create') { /* Draw list */ - $aclList = new divSelectBox("aclList"); - $aclList->SetHeight(450); + $aclList = new divSelectBox('aclList'); + $aclList->setHeight('auto'); /* Add settings for all categories to the (permanent) list */ foreach ($this->config->data['CATEGORIES'] as $section => $infos) { - $summary = ""; + if (($section != 'all') && (count($infos['classes']) == 1)) { + /* Hide empty categories */ + continue; + } + $summary = ''; foreach ($infos['classes'] as $oc) { if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) && - $this->aclContents[$oc][0] != "") { + $this->aclContents[$oc][0] != '') { $summary .= "$oc, "; continue; @@ -310,14 +326,10 @@ class acl_createedit extends acl } $action = ""; - if ($this->acl_is_readable("gosaAclEntry")) { - $action .= "<input class='center' type='image' src='geticon.php?context=actions&icon=document-edit&size=16' - alt='"._("Edit")."' name='cat_edit_$section' title='"._("Edit category ACL")."'>"; - } - if ($this->acl_is_writeable("gosaAclEntry")) { - $action .= "<input class='center' type='image' src='geticon.php?context=actions&icon=edit-delete&size=16' - alt='"._("Delete")."' name='cat_del_$section' title='"._("Reset category ACL")."'>"; - } + $action .= "<input class='center' type='image' src='geticon.php?context=actions&icon=document-edit&size=16' + alt='"._("Edit")."' name='cat_edit_$section' title='"._("Edit category ACL")."'>"; + $action .= "<input class='center' type='image' src='geticon.php?context=actions&icon=edit-delete&size=16' + alt='"._("Delete")."' name='cat_del_$section' title='"._("Reset category ACL")."'>"; $field1 = array("html" => $infos['description'], "attach" => "style='width:140px'"); $field2 = array("html" => $summary); @@ -325,11 +337,12 @@ class acl_createedit extends acl $aclList->AddEntry(array($field1, $field2, $field3)); } - $smarty->assign("aclList", $aclList->DrawList()); + $smarty->assign('aclList', $aclList->DrawList()); } elseif ($this->dialogState == 'edit') { $smarty->assign('headline', sprintf(_("Edit ACL for '%s'"), $this->config->data['CATEGORIES'][$this->aclObject]['description'])); /* Collect objects for selected category */ + $aclObjects = array(); foreach ($this->config->data['CATEGORIES'][$this->aclObject]['classes'] as $idx => $class) { if ($idx == 0) { continue; @@ -338,13 +351,13 @@ class acl_createedit extends acl $aclObjects[$this->aclObject.'/'.$class] = $pInfos['plShortName']; } if ($this->aclObject == 'all') { - $aclObjects['all'] = _("All objects in current subtree"); + $aclObjects['all'] = _('All objects in current subtree'); } $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects)); } /* Show main page */ - $smarty->assign("dialogState", $this->dialogState); + $smarty->assign('dialogState', $this->dialogState); return $smarty->fetch(get_template_path('acl_role.tpl', dirname(__FILE__))); } @@ -362,14 +375,9 @@ class acl_createedit extends acl */ function mkchkbx($name, $text, $state = FALSE) { - $state = ($state?"checked":""); - if ($this->acl_is_writeable("")) { - $tname = preg_replace("/[^a-z0-9]/i", "_", $name); - return "\n <input id='acl_$tname' type=checkbox name='acl_$name' $state>". - "\n <label for='acl_$tname'>$text</label>"; - } else { - return "\n <input type='checkbox' disabled name='dummy_".microtime(1)."' $state>$text"; - } + $tname = preg_replace('/[^a-z0-9]/i', '_', $name); + return '<input id="acl_'.$tname.'" type="checkbox" name="acl_'.$name.'"'.($state ? ' checked="checked"' : '').'/>'."\n". + '<label for="acl_'.$tname.'">'.$text.'</label>'."\n"; } /*! @@ -381,21 +389,16 @@ class acl_createedit extends acl * * \return String containing checkbox */ - function mkrwbx($name, $state = "") + function mkrwbx($name, $state = '') { - $rstate = (preg_match('/r/', $state)?'checked':''); - $wstate = (preg_match('/w/', $state)?'checked':''); + $rstate = (preg_match('/r/', $state) ? 'checked' : ''); + $wstate = (preg_match('/w/', $state) ? 'checked' : ''); $tname = preg_replace("/[^a-z0-9]/i", "_", $name); - if ($this->acl_is_writeable("")) { - return "\n <input id='acl_".$tname."_r' type=checkbox name='acl_${name}_r' $rstate>". - "\n <label for='acl_".$tname."_r'>"._("read")."</label>". - "\n <input id='acl_".$tname."_w' type=checkbox name='acl_${name}_w' $wstate>". - "\n <label for='acl_".$tname."_w'>"._("write")."</label>"; - } else { - return "\n <input disabled type=checkbox name='dummy_".microtime(1)."' $rstate>"._("read"). - "\n <input disabled type=checkbox name='dummy_".microtime(1)."' $wstate>"._("write"); - } + return "\n <input id='acl_".$tname."_r' type=checkbox name='acl_${name}_r' $rstate>". + "\n <label for='acl_".$tname."_r'>"._("read")."</label>". + "\n <input id='acl_".$tname."_w' type=checkbox name='acl_${name}_w' $wstate>". + "\n <label for='acl_".$tname."_w'>"._("write")."</label>"; } /*! @@ -447,7 +450,7 @@ class acl_createedit extends acl } /* Build general objects */ - $list = $this->sort_by_priority($list); + $list = acl::sort_by_priority($list); foreach ($list as $key => $name) { /* Create sub acl if it does not exist */ if (!isset($this->aclContents[$key])) { @@ -556,24 +559,9 @@ class acl_createedit extends acl return $display; } - function loadAclEntry($acl = NULL) - { - /* New entry gets presets... */ - if ($acl === NULL) { - $this->aclContents = array(); - } else { - $this->aclContents = $acl; - } - } - function getAclEntry() { return $this->aclContents; } - - function save_object() - { - plugin::save_object(); - } } ?>