dn= $dn; $this->config= &$config; if(!count($data)) { $data[] = array("CLASS" => 'plugin',"NAME" => 'Error'); msg_dialog::display(_("Error"), sprintf(_("No plugin definitions found to initialize '%s', please check your configuration file."),get_class($this)), "ERROR_DIALOG"); } $baseobject= NULL; $this->acl_category = $acl_category; foreach ($data as &$tab){ if (!plugin_available($tab['CLASS'])){ continue; } $this->by_name[$tab['CLASS']]= $tab['NAME']; if ($baseobject === NULL){ $baseobject= new $tab['CLASS']($this->config, $this->dn); $baseobject->enable_CSN_check(); $this->by_object[$tab['CLASS']]= $baseobject; } else { $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject); } $this->read_only |= $this->by_object[$tab['CLASS']]->read_only; $this->by_object[$tab['CLASS']]->parent= &$this; $this->by_object[$tab['CLASS']]->set_acl_category($this->acl_category); /* Initialize current */ if ($this->current == ""){ $this->current= $tab['CLASS']; } } } /*! \brief Reinitializes the tab classes with fresh ldap values. This maybe usefull if for example the apply button was pressed. */ function re_init() { $baseobject= NULL; foreach($this->by_object as $name => $object){ $class = get_class($object); if(in_array($class,array("reference","acl"))) continue; if ($baseobject === NULL){ $baseobject= new $class($this->config, $this->dn); $baseobject->enable_CSN_check(); $this->by_object[$name]= $baseobject; } else { $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject); } $this->by_object[$name]->parent= &$this; $this->by_object[$name]->set_acl_category($this->acl_category); } } function execute() { /* Ensure that the currently selected tab is valid. */ if(!isset($this->by_name[$this->current])) $this->current = key($this->by_name); /* Rotate current to last */ $this->last= $this->current; /* Look for pressed tab button */ foreach ($this->by_object as $class => &$obj){ if (isset($_POST[$class]) || (isset($_POST['arg']) && $_POST['arg'] == "$class")){ $this->current= $class; break; } } /* Save last tab object */ if ($this->last == $this->current){ $this->save_object(TRUE); } else { $this->save_object(FALSE); } /* Show object */ $display = "
\n"; /* If multiple edit is enabled for this tab, we have tho display different templates */ if(!$this->multiple_support_active){ $display.= $this->by_object[$this->current]->execute(); }else{ $display.= $this->by_object[$this->current]->multiple_execute(); } $modal_dialog = $this->by_object[$this->current]->is_modal_dialog(); /* Build tab line */ $modal = TRUE; $tabs= $this->gen_tabs($modal_dialog); /* Footer for tabbed dialog */ $display = $tabs.$display." |
";
/* Shorten string if its too long for the tab headers*/
$title= _($name);
if (mb_strlen($title, 'UTF-8') > 28){
$title= mb_substr($title,0, 25, 'UTF-8')."...";
}
/* nobr causes w3c warnings so we use to keep the tab name in one line */
$title= str_replace(" "," ",$title);
/* Take care about notifications */
$obj = $this->by_object[$class];
if ( $this->by_object[$class]->pl_notify && ($obj->is_account || $obj->ignore_account)){
$notify= "id=\"notify\"";
} else {
$notify= "";
}
if($disabled){
$display.= " ".$title." ";
}elseif (session::get('js')==FALSE){
$display.= " | ";
} else {
$display.= "";
}
}
$display.= "\n";
$display.= " |
"; } } } } return($ret); } function addSpecialTabs() { $this->by_name['acl']= _("ACL"); $this->by_object['acl']= new acl($this->config, $this, $this->dn); $this->by_object['acl']->parent= &$this; $this->by_name['reference']= _("References"); $this->by_object['reference']= new reference($this->config, $this->dn); $this->by_object['reference']->parent= &$this; } function set_acl_base($base= "") { /* Update reference, transfer variables */ $first= ($base == ""); foreach ($this->by_object as &$obj){ if ($first){ $first= FALSE; $base= $obj->acl_base; } else { $obj->set_acl_base($base); } } } /*! \brief Checks if one of the used tab plugins supports multiple edit. @param boolean Returns TRUE if at least one plugins supports multiple edit. */ function multiple_support_available() { foreach($this->by_object as $name => $obj){ if($obj->multiple_support){ return(TRUE); } } return(FALSE); } /*! \brief Enables multiple edit support for the given tab. All unsupported plugins will be disabled. @param boolean Returns TRUE if at least one plugin supports multiple edit */ function enable_multiple_support() { if(!$this->multiple_support_available()){ return(FALSE); }else{ $this->multiple_support_active = TRUE; foreach($this->by_object as $name => $obj){ if($obj->multiple_support){ $this->by_object[$name]->enable_multiple_support(); }else{ unset($this->by_object[$name]); unset($this->by_name[$name]); } } } return(TRUE); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>