index 2e17bb2d02d87937839665b1a7c0b9df9ee006d2..49aa77226df402ff31922b0a83f03d3ac42d7d97 100644 (file)
var $dialog = NULL; // a dialog, e.g. new disk dialog
var $SubObjects = array(); // All leafobjects of this object
+ var $FAIstate = "";
+
function faiVariable ($config, $dn= NULL)
{
/* Load Attributes */
plugin::plugin ($config, $dn);
+ $this->acl ="#all#";
+
/* If "dn==new" we try to create a new entry
* Else we must read all objects from ldap which belong to this entry.
* First read SubObjects from ldap ... and then the partition definitions for the SubObjects.
*/
+
if($dn != "new"){
$this->dn =$dn;
+ /* Set acls
+ */
+ $ui = get_userinfo();
+ $acl = get_permissions ($this->dn, $ui->subtreeACL);
+ $acli = get_module_permission($acl, "FAIclass", $this->dn);
+ $this->acl=$acli;
+
+ /* Get FAIstate
+ */
+ if(isset($this->attrs['FAIstate'][0])){
+ $this->FAIstate = $this->attrs['FAIstate'][0];
+ }
+
/* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry)
*/
$ldap = $this->config->get_ldap_link();
$this->SubObjects[$object['cn'][0]]['status'] = "edited";
$this->SubObjects[$object['cn'][0]]['dn'] = $object['dn'];
}
- ksort($this->SubObjects);
}
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
/* Add new sub object */
if(isset($_POST['AddSubObject'])){
$this->dialog= new $this->subClassName($this->config,"new");
+ $this->dialog->acl = $this->acl;
$this->is_dialog=true;
}
- $_SESSION['objectinfo'] = $this->dn;
+ if($this->dn != "new"){
+ $_SESSION['objectinfo']= $this->dn;
+ }
+
+
/* Edit selected Sub Object */
if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){
- $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$_POST['SubObject']]);
- $_SESSION['objectinfo'] = $this->SubObjects[$_POST['SubObject']]['dn'];
+
+ $var = $_POST['SubObject'][0];
+ $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$var]);
+ $this->dialog->acl = $this->acl;
+ $_SESSION['objectinfo'] = $this->SubObjects[$var]['dn'];
$this->is_dialog=true;
}
/* Remove Sub object */
if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){
- if($this->SubObjects[$_POST['SubObject']]['status'] == "edited"){
- $this->SubObjects[$_POST['SubObject']]['status']= "delete";
- }else{
- unset($this->SubObjects[$_POST['SubObject']]);
+ foreach($_POST['SubObject'] as $var){
+ if($this->SubObjects[$var]['status'] == "edited"){
+ $this->SubObjects[$var]['status']= "delete";
+ }else{
+ unset($this->SubObjects[$var]);
+ }
}
}
$this->is_dialog=false;
unset($this->dialog);
$this->dialog=NULL;
- ksort($this->SubObjects);
}
}
+ /* Sort entries */
+ $tmp = $keys = array();
+ foreach($this->SubObjects as $key => $entry){
+ $keys[$key]=$key;
+ }
+ natcasesort($keys);
+ foreach($keys as $key){
+ $tmp[$key]=$this->SubObjects[$key];
+ }
+ $this->SubObjects = $tmp;
+
/* Cancel Dialog */
if(isset($_POST['CancelSubObject'])){
$this->is_dialog=false;
}
$smarty->assign("SubObjects",$this->getList());
- $smarty->assign("SubObjectKeys",array_flip($this->getList()));
/* Magic quotes GPC, escapes every ' " \, to solve some security risks
* If we post the escaped strings they will be escaped again
*/
+
foreach($this->attributes as $attrs){
if(get_magic_quotes_gpc()){
- $smarty->assign($attrs,stripslashes($this->$attrs));
+ $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs))));
}else{
- $smarty->assign($attrs,($this->$attrs));
+ $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs)));
}
}
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
+ }
+
$display.= $smarty->fetch(get_template_path('faiVariable.tpl', TRUE));
return($display);
*/
function save_object()
{
- if(isset($_POST['FAIvariable_posted'])){
+ if((isset($_POST['FAIvariable_posted'])) && ($this->FAIstate != "freeze") ){
plugin::save_object();
foreach($this->attributes as $attrs){
if(isset($_POST[$attrs])){
/* Check supplied data */
function check()
{
- $message= array();
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
return ($message);
}
$ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn);
+ $ldap->cat($this->dn,array("objectClass"));
if($ldap->count()!=0){
/* Write FAIscript to ldap*/
$ldap->cd($this->dn);
- $ldap->modify($this->attrs);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
}else{
/* Write FAIscript to ldap*/
$ldap->cd(preg_replace('/^[^,]+,[^,]+,/', '', $this->dn));
$ldap->cd($this->dn);
$ldap->add($this->attrs);
}
- show_ldap_error($ldap->get_error());
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/variable with dn '%s' failed."),$this->dn));
+
+ /* Do object tagging */
+ $this->handle_object_tagging();
/* Prepare FAIscriptEntry to write it to ldap
* First sort array.
$sub_dn = "cn=".$obj['cn'].",".$this->dn;
if($obj['status']=="new"){
- $ldap->cat($sub_dn);
+ $ldap->cat($sub_dn,array("objectClass"));
if($ldap->count()){
- $obj['status']="modify";
+ $obj['status']="edited";
+ }
+ }
+
+ /* Check if gosaAdministrativeUnitTag is required as object class */
+ if($obj['status'] == "edited"){
+ $ldap->cat($sub_dn,array("objectClass"));
+ $attrs = $ldap->fetch();
+ if(isset($attrs['objectClass'])){
+ if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
+ $tmp['objectClass'][] = "gosaAdministrativeUnitTag";
+ }
}
}
$ldap->cd($sub_dn);
$ldap->rmdir_recursive($sub_dn);
$this->handle_post_events("remove");
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing of FAI/variable with dn '%s' failed."),$sub_dn));
}elseif($obj['status'] == "edited"){
$ldap->cd($sub_dn);
- $ldap->modify($tmp);
+ $this->cleanup();
+ $ldap->modify ($tmp);
+
$this->handle_post_events("modify");
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/variable with dn '%s' failed."),$sub_dn));
}elseif($obj['status']=="new"){
if($tmp['description'] == array()){
$ldap->cd($sub_dn);
$ldap->add($tmp);
$this->handle_post_events("add");
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/variable with dn '%s' failed."),$sub_dn));
}
- show_ldap_error($ldap->get_error());
+
+ $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
}
}
}