From 59a8bc9e0f806c70a6df5dcdbab7f77a516a9b49 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 23 Jan 2007 08:13:13 +0000 Subject: [PATCH] Added notification acls git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5588 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../addons/notifications/class_msgplug.inc | 65 ++++++++++++------- plugins/addons/notifications/contents.tpl | 6 +- plugins/addons/notifications/main.inc | 20 +++--- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/plugins/addons/notifications/class_msgplug.inc b/plugins/addons/notifications/class_msgplug.inc index 08a239568..3aea28353 100644 --- a/plugins/addons/notifications/class_msgplug.inc +++ b/plugins/addons/notifications/class_msgplug.inc @@ -22,7 +22,7 @@ class msgplug extends plugin var $templates= array(); var $template= ""; var $finalized= false; - + var $module = "msgplug"; function msgplug ($config, $dn= NULL) { @@ -35,34 +35,23 @@ class msgplug extends plugin $this->targets= array("user" => _("Users"), "group" => _("Groups")); asort($this->targets); - /* Users */ - $ldap= $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - if ($tag == ""){ - $ldap->search('(objectClass=gosaAccount)', array('uid', 'cn')); - } else { - $ldap->search('(&(objectClass=gosaAccount)(gosaUnitTag='.$tag.'))', array('uid', 'cn')); - } - while ($attrs= $ldap->fetch()){ + $res = get_list("(objectClass=gosaAccount)", "users", $this->config->current['BASE'],array('uid', 'cn'),GL_SUBSEARCH); + foreach($res as $key => $attrs){ $this->users['U:'.$attrs['uid'][0]]= $attrs['cn'][0].' ['.$attrs['uid'][0].']'; } ksort($this->users); + print_a($this->users); - /* Groups */ - $ldap->cd($config->current['BASE']); - if ($tag == ""){ - $ldap->search('(objectClass=posixGroup)', array('cn', 'description')); - } else { - $ldap->search('(&(objectClass=posixGroup)(gosaUnitTag='.$tag.'))', array('cn', 'description')); - } - while ($attrs= $ldap->fetch()){ + $res = get_list("(objectClass=posixGroup)", "groups", $this->config->current['BASE'],array('cn','description')); + foreach($res as $key => $attrs){ $dsc= ""; if (isset($attrs['description'][0])){ $dsc= $attrs['description'][0]; } $this->groups['G:'.$attrs['cn'][0]]= $attrs['cn'][0].' ['.$dsc.']'; } - ksort($this->groups); + ksort($this->users); + /* Load templates */ if (isset($this->config->current['NOTIFYDIR'])){ @@ -94,13 +83,13 @@ class msgplug extends plugin plugin::execute(); /* Send message? */ - if (isset($_POST['send'])){ + if (isset($_POST['send']) && $this->acl_is_writeable("notify")){ /* Do we have recipients? */ if (count($this->recipients)){ /*Permissions ok? */ - if (chkacl($this->acl, 'notify') != ""){ + if (!$this->acl_is_writeable('notify')){ print_red(_("You have no permissions to send a message!")); } else { $cmd= search_config($this->config->data['MENU'], "msgplug", "NOTIFY_COMMAND"); @@ -129,7 +118,7 @@ class msgplug extends plugin } /* Add to list? */ - if (isset($_POST['add']) && isset($_POST['source'])){ + if (isset($_POST['add']) && isset($_POST['source']) && $this->acl_is_writeable("notify")){ foreach ($_POST['source'] as $key){ if ($this->target == 'user'){ $this->recipients[$key]= $this->users[$key]; @@ -189,7 +178,7 @@ class msgplug extends plugin $smarty->assign('recipients', $this->recipients); /* Assign ACL */ - $smarty->assign('nmessageACL', chkacl($this->acl, "notify")); + $smarty->assign('nmessageACL', $this->getacl("notify")); /* Handle templates */ $smarty->assign('show_templates', $this->show_templates?"true":"false"); @@ -222,6 +211,36 @@ class msgplug extends plugin return $desc; } + + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + + /* Return plugin informations for acl handling */ + function plInfo() + { + return (array( + "plShortName" => _("Notification"), + "plDescription" => _("Notification plugin"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 89, + "plSection" => array("addon"), + "plCategory" => array("msgplug" => array("objectClass" => "none", "description" => _("Notification plugin"))), + + "plProvidedAcls" => array( + "notify" => _("Allow sending notifications") + ) + )); + } + } diff --git a/plugins/addons/notifications/contents.tpl b/plugins/addons/notifications/contents.tpl index a7abd2cf4..689869613 100644 --- a/plugins/addons/notifications/contents.tpl +++ b/plugins/addons/notifications/contents.tpl @@ -42,8 +42,10 @@

 

{t}Message{/t}

+{render acl=$nmessageACL} + +{/render} - {if $show_templates eq "true"} +{/render} diff --git a/plugins/addons/notifications/main.inc b/plugins/addons/notifications/main.inc index fe806b8b2..c73698541 100644 --- a/plugins/addons/notifications/main.inc +++ b/plugins/addons/notifications/main.inc @@ -19,16 +19,20 @@ */ if (!$remove_lock){ - /* Create message object on demand */ - if (!isset($_SESSION['msgplug']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['msgplug']= new msgplug ($config); - } + /* Create msgplug object on demand */ + if (!isset($_SESSION['msgplug']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $ui = get_userinfo(); + $_SESSION['msgplug']= new msgplug ($config); + $_SESSION['msgplug']->set_acl_category("msgplug"); + + /* Check root dn and user dn for acl informations */ + $_SESSION['msgplug']->set_acl_base($config->current['BASE']); + if($_SESSION['msgplug']->getacl("") == ""){ + $_SESSION['msgplug']->set_acl_base($ui->dn); + } + } $msgplug= $_SESSION['msgplug']; - /* Set permissions */ - $acl= get_permissions ($ui->dn, $ui->subtreeACL); - $msgplug->acl= get_module_permission($acl, "msgplug", $ui->dn); - /* save changes back to object */ if (isset ($_POST['target'])){ $msgplug->save_object (); -- 2.30.2