diff --git a/plugins/admin/systems/class_servService.inc b/plugins/admin/systems/class_servService.inc
index 6cace375b388c0cb07d80cf4c2bfc94bef5ffedb..627cb5a95d82761ebcf50177a666ad19dcb18892 100644 (file)
var $cli_description= "Some longer text\nfor help";
var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- var $goExportEntry = array();
- var $goTimeSource = array();
- var $goLdapBase= "";
- var $goXdmcpIsEnabled ="";
- var $goFontPath= "";
- var $goNTPServer="";
- var $goLdapServer="";
- var $goTerminalServer="";
- var $goSyslogServer="";
- var $goCupsServer="";
-
+ var $goExportEntry = array();
+ var $goTimeSource = array();
+ var $goLdapBase = "";
+ var $goXdmcpIsEnabled = "";
+ var $goFontPath = "";
+ var $goNTPServer = "";
+ var $goShareServer = false;
+ var $goLdapServer = "";
+ var $goTerminalServer = "";
+ var $goSyslogServer = "";
+ var $goCupsServer = "";
+ var $goMailServer = "";
+ var $o_subWindow = NULL;
/* attribute list for save action */
- var $attributes = array("goExportEntry","goTimeSource","goLdapBase","goXdmcpIsEnabled","goFontPath" );
- var $objectclasses = array("top","goServer");
- var $additionaloc = array(
-
- "goNfsServer" => array("goExportEntry"),
- "goNtpServer" => array("goTimeSource"),
- "goLdapServer" => array("goLdapBase"),
- "goTerminalServer"=> array("goXdmcpIsEnabled", "goFontPath"),
- "goSyslogServer" => array(),
- "goCupsServer" => array()
- );
-
-
-
-
-
-
-
-
+ var $ignore_account= TRUE;
+ var $attributes = array("goLdapBase","goXdmcpIsEnabled","goFontPath");
+ var $possible_objectclasses= array( "goShareServer", "goNtpServer", "goServer", "goLdapServer",
+ "goTerminalServer", "goSyslogServer", "goCupsServer","goMailServer");
+ var $objectclasses = array( "top","goServer");
+ var $additionaloc = array( "goShareServer" => array("goExportEntry"),
+ "goNtpServer" => array("goTimeSource"),
+ "goLdapServer" => array("goLdapBase"),
+ "goTerminalServer"=> array("goXdmcpIsEnabled", "goFontPath"),
+ "goSyslogServer" => array(),
+ "goMailServer" => array(),
+ "goCupsServer" => array());
function servservice ($config, $dn= NULL)
{
plugin::plugin ($config, $dn);
-
+
+ /* Assemble final object class list */
foreach ($this->additionaloc as $oc => $dummy){
if (isset($this->attrs['objectClass']) && in_array($oc, $this->attrs['objectClass'])){
$this->objectclasses[$oc]= $oc;
}
}
+
+ /* Load arrays */
+ foreach (array("goTimeSource") as $name){
+ $tmp= array();
+ if (isset($this->attrs[$name])){
+ for ($i= 0; $i<$this->attrs[$name]['count']; $i++){
+ $tmp[$this->attrs[$name][$i]]= $this->attrs[$name][$i];
+ }
+ }
+ $this->$name= $tmp;
+ }
+
+ $tmp =array();
+ $tmp2=array();
+ if(isset($this->attrs['goExportEntry'])){
+ unset($this->attrs['goExportEntry']['count']);
+ if((isset($this->attrs['goExportEntry']))&&(isset($this->attrs['goExportEntry']))){
+ foreach($this->attrs['goExportEntry'] as $entry){
+ $tmp2= split("\|",$entry);
+ $tmp[$tmp2[0]]= $entry;
+ }
+ }
+ }
+ $this->goExportEntry = $tmp;
+
/* Always is account... */
$this->is_account= TRUE;
+
+ /* Check if goShareServer is defined */
+ if((isset($this->attrs['objectClass']))&&(is_array($this->attrs['objectClass']))){
+ if(in_array("goShareServer",$this->attrs['objectClass'])){
+ $this->goShareServer = true;
+ }
+ }
+ }
+
+ function addToList($entry){
+ $key = key($entry);
+ $this->goExportEntry[$key]=$entry[$key];
}
+ function deleteFromList($id){
+ unset($this->goExportEntry[$id]);
+ }
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty= get_smarty();
-
- /*
- Handling for Nfs Export Entries
- */
+ $smarty->assign("staticAddress", "");
- /* Here we add a new entry */
- if(isset($_POST['NewNfsAdd']))
- {
- $this->attrs['goExportEntry'][]=$_POST['NewNfsExport'];
- }
-
- /* Deleting an Entry, is a bit more complicated than adding one*/
- if(isset($_POST['DelNfsEnt']))
- {
- /* Go through all entries an skip the selected (The one we want to delete)*/
- foreach($this->attrs['goExportEntry'] as $key => $val)
- {
- /* Add all entries in an new Array, because when deleting one entry, the could be broken*/
- if(($val != $_POST['goExportEntry'] ))
- {
- /* Skip the entry that we want to delete*/
- $new_arr[]=$val;
- }
- }
- /* Deleting complete so add result to the attrs */
- $this->attrs['goExportEntry']=$new_arr;
- }
+ if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntry']))){
+ $this->deleteFromList($_POST['goExportEntry']);
+ }
- /* Set the entry which we want to show in the frontend */
- if(isset($this->attrs['goExportEntry']))
- {
- $this->goExportEntry = ($this->attrs['goExportEntry']);
- unset($this->goExportEntry['count']);
- }
+ if(isset($_POST['NewNfsAdd'])){
+ $this->o_subWindow = new servnfs($this->config, $this->dn);
+ $this->dialog = true;
+ }
+ if((isset($_POST['NewNfsEdit']))&&(isset($_POST['goExportEntry']))){
+ $entry = $this->goExportEntry[$_POST['goExportEntry']];
+ $this->o_subWindow = new servnfs($this->config, $this->dn,$entry);
+ $this->dialog = true;
+ }
- /*
- Handling for NTP Export Entries
- */
+ if(isset($this->o_subWindow)){
+ $this->o_subWindow->save_object(TRUE);
+ }
- /* Here we add a new entry */
- if(isset($_POST['NewNTPAdd']))
- {
- $this->attrs['goTimeSource'][]=$_POST['NewNTPExport'];
- }
-
- /*Deleting an Entry, is a bit more complicated than adding one*/
- if(isset($_POST['DelNTPEnt']))
- {
- /* Go through all entries an skip the selected (The one we want to delete)*/
- foreach($this->attrs['goTimeSource'] as $key => $val)
- {
- /* Add all entries in an new Array, because wehn deleting one entry, the could be broken*/
- if($val != $_POST['goTimeSource'] )
- {
- /* Skip the entry that we want to delete*/
- $new_arr[]=$val;
- }
+ /* Save NFS setup */
+ if(isset($_POST['NFSsave'])){
+ if(count($this->o_subWindow->check())>0){
+ foreach($this->o_subWindow->check() as $msg) {
+ print_red($msg);
}
- /* Deleting complete so add result to the attrs */
- $this->attrs['goTimeSource']=$new_arr;
- }
-
- /* Set the entry which we want to show in the frontend */
- if(isset($this->attrs['goTimeSource']))
- {
- $this->goTimeSource = ($this->attrs['goTimeSource']);
- unset($this->goTimeSource['count']);
+ }else{
+ $this->o_subWindow->save_object();
+ $newone = $this->o_subWindow->save();
+ $this->addToList($newone) ;
+ unset($this->o_subWindow);
+ $this->dialog = false;
}
+ }
+
+ /* Cancel NFS setup */
+ if(isset($_POST['NFScancel'])){
+ unset($this->o_subWindow);
+ $this->dialog = false;
+ }
+
+ /* Execute NFS setup dialog*/
+ if(isset($this->o_subWindow)){
+ return $this->o_subWindow->execute();
+ }
+ /* Here we add a new entry */
+ if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "") {
+ $this->goTimeSource[$_POST['NewNTPExport']]= $_POST['NewNTPExport'];
+ asort($this->goTimeSource);
+ }
+ /* Deleting an Entry, is a bit more complicated than adding one*/
+ if(isset($_POST['DelNTPEnt'])) {
+ foreach ($_POST['goTimeSource'] as $entry){
+ if (isset($this->goTimeSource[$entry])){
+ unset($this->goTimeSource[$entry]);
+ }
+ }
+ }
-
- /* Attributes... */
+ /* Attributes */
foreach ($this->attributes as $attr){
$smarty->assign("$attr", $this->$attr);
$smarty->assign("$attr"."ACL", chkacl($this->acl, $attr));
+ $smarty->assign($attr."State","");
}
+
+ $tellSmarty=array();
+ foreach($this->goExportEntry as $name=>$values){
+ $tmp = split("\|",$values);
+ $tellSmarty[$name] = $tmp[0]." ".$tmp[4];
+ }
+ $smarty->assign("goExportEntry",array_keys($tellSmarty));
+ $smarty->assign("goExportEntryKeys",($tellSmarty));
+ $smarty->assign("goExportEntryACL", chkacl($this->acl, "goExportEntry"));
+ $smarty->assign("goTimeSource", $this->goTimeSource);
+ $smarty->assign("goTimeSourceACL", chkacl($this->acl, "goTimeSource"));
+ $smarty->assign("goTimeSourceState","");
+
/* Classes... */
foreach ($this->additionaloc as $oc => $dummy){
if (isset($this->objectclasses[$oc])){
$smarty->assign("$oc", "checked");
+ $smarty->assign("$oc"."State", "");
$smarty->assign("$oc"."ACL", chkacl($this->acl, $oc));
+
} else {
+ $smarty->assign("$oc", "");
+ $smarty->assign("$oc"."ACL", chkacl($this->acl, $oc));
$smarty->assign("$oc"."State", "disabled");
}
}
- return($smarty->fetch (get_template_path('servservice.tpl', TRUE)));
+ if(!$this->goShareServer){
+ $smarty->assign("goShareServerState", " disabled ");
+ $smarty->assign("goExportEntryACL", " disabled ");
+ }else{
+ $smarty->assign("goShareServerState", " ");
+ $smarty->assign("goExportEntryACL", " ");
+ }
+
+ /* Different handling for checkbox */
+ if($this->goXdmcpIsEnabled == "true"){
+ $smarty->assign("goXdmcpIsEnabled","checked");
+ } else {
+ $smarty->assign("goXdmcpIsEnabled","");
+ }
+
+ return($smarty->fetch (get_template_path('servservice.tpl', TRUE)));
}
+
function remove_from_parent()
{
/* This cannot be removed... */
/* Save data to object */
function save_object()
{
- plugin::save_object();
+ if (isset($_POST['servicetab'])){
+ plugin::save_object();
+
+ /* Save checkbox state */
+ foreach ($this->additionaloc as $oc => $dummy){
+ if (chkacl($this->acl, $oc) == ""){
+ if (isset($_POST[$oc]) && $_POST[$oc] == '1'){
+ $this->objectclasses[$oc]= $oc;
+ } else {
+ unset($this->objectclasses[$oc]);
+ }
+ }
+ }
- /* Save checkbox state */
- foreach ($this->additionaloc as $oc => $dummy){
- if (isset($_POST[$oc]) && $_POST[$oc] == '1'){
- $this->objectclasses[$oc]= $oc;
+ /* Save xdmcp is enabled flag */
+ if (isset($_POST['goXdmcpIsEnabled'])){
+ $this->goXdmcpIsEnabled= "true";
+ } else {
+ $this->goXdmcpIsEnabled= "false";
+ }
+
+ /* Save xdmcp is enabled flag */
+ if (isset($_POST['goShareServer'])){
+ $this->goShareServer = true;
} else {
- unset($this->objectclasses[$oc]);
+ $this->goShareServer = false;
}
}
-
}
function check()
{
$message= array();
+
+ if((isset($_POST['goTerminalServer']))&&(empty($this->goFontPath))){
+ $message[]=_("Terminal server, must have fontpath specified.");
+ }
return ($message);
}
/* Save to LDAP */
function save()
{
- /* Normalize lazy objectclass arrays */
- $objectclasses= array();
- foreach($this->objectclasses as $oc){
- $objectclasses[]= $oc;
- }
-
- $this->objectclasses= $objectclasses;
plugin::save();
- /* Remove objectclasses */
- foreach(array_merge($this->objectclasses, $this->additionaloc) as $oc){
- foreach ($this->attrs['objectClass'] as $key => $value){
- if ($value == $oc){
- unset ($this->attrs['objectClass'][$key]);
- }
+ $tmp= array();
+
+ /* Remove all from this plugin */
+ foreach($this->attrs['objectClass'] as $oc){
+ if (!in_array_ics($oc, $this->possible_objectclasses)){
+ $tmp[]= $oc;
}
}
- $this->attrs['objectClass']=array();
+
+ /* Merge our current objectclasses */
foreach($this->objectclasses as $oc){
- $this->attrs['objectClass'][]= $oc;
+ if (!in_array_ics($oc, $tmp)){
+ $tmp[]= $oc;
+ }
}
+ /* Reassign cleaned value */
+ $this->attrs['objectClass']= $tmp;
- /* Adapt sieve server if needed */
- if (in_array('goImapServer', $this->objectclasses)){
- $this->attrs['goImapSieveServer']= preg_replace('/:.*$/', '',
- preg_replace('/^{([^}]+)}$/', '\\1',
- $this->attrs['goImapConnect']));
+ /* Arrays */
+ foreach (array("goTimeSource", "goExportEntry") as $name){
+ $this->attrs[$name]= array();
+ foreach ($this->$name as $element){
+ $this->attrs[$name][]= $element;
+ }
}
-
- /* Remove unneeded attributes */
+
+ /* Remove illegal attributes */
foreach ($this->additionaloc as $oc => $attrs){
if (!in_array($oc, $this->objectclasses)){
foreach ($attrs as $attr){
}
}
}
-
- print_a($this->attrs);
-
+
/* Write to LDAP */
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
$ldap->modify($this->attrs);
show_ldap_error($ldap->get_error());
-
+
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account){
if ($this->is_modified){
} else {
$this->handle_post_events("add");
}
-
}
}