summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c8d1112)
raw | patch | inline | side by side (parent: c8d1112)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 26 Apr 2006 14:36:47 +0000 (14:36 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 26 Apr 2006 14:36:47 +0000 (14:36 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3127 594d385d-05f5-0310-b6e9-bd551577e9d8
contrib/gosa.conf | patch | blob | history | |
include/class_ldap.inc | patch | blob | history | |
include/functions_setup.inc | patch | blob | history | |
plugins/admin/groups/acl_definition.inc | patch | blob | history | |
plugins/admin/systems/class_servNfs.inc | patch | blob | history | |
plugins/admin/systems/class_servService.inc | patch | blob | history | |
plugins/admin/systems/servnfs.tpl | patch | blob | history | |
plugins/admin/users/class_userManagement.inc | patch | blob | history | |
plugins/personal/netatalk/class_netatalk.inc | [new file with mode: 0644] | patch | blob |
plugins/personal/netatalk/main.inc | [new file with mode: 0644] | patch | blob |
plugins/personal/netatalk/netatalk.tpl | [new file with mode: 0644] | patch | blob |
diff --git a/contrib/gosa.conf b/contrib/gosa.conf
index 00a59493a84d02bc42d5e831ffa88df81b6c6b1e..0ea88fd3bbf190756224a4c74f3e49992eda2ea6 100644 (file)
--- a/contrib/gosa.conf
+++ b/contrib/gosa.conf
path="plugins/personal/mail" />
<plugin acl="default" class="sambaAccount" icon="samba.png"
path="plugins/personal/samba" />
+<!-- <plugin acl="default" class="netatalk" icon="netatalk.png"
+ path="plugins/personal/netatalk" /> -->
<plugin acl="default" class="connectivity" icon="proxy.png"
path="plugins/personal/connectivity" />
<plugin acl="default" class="gofaxAccount" icon="fax.png"
<tab class="environment" name="Environment" />
<tab class="mailAccount" name="Mail" />
<tab class="sambaAccount" name="Samba" />
+<!-- <tab class="netatalk" name="Netatalk" /> -->
<tab class="connectivity" name="Connectivity" />
<tab class="gofaxAccount" name="Fax" />
<tab class="phoneAccount" name="Phone" />
diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index a098b15f5747afd0266c922ed42173805ea34285..677f7f459025e90075dbff282d84a4f2e14e357e 100644 (file)
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
@@ -1039,6 +1039,35 @@ function gen_xls ($dn, $filter= "(objectClass=*)", $attributes= array('*'), $rec
}
}
+
+ function get_objectclasses()
+ {
+ $objectclasses = array();
+
+ # Get base to look for schema
+ $sr = @ldap_read ($this->cid, NULL, "objectClass=*", array("subschemaSubentry"));
+ $attr = @ldap_get_entries($this->cid,$sr);
+ if (!isset($attr[0]['subschemasubentry'][0])){
+ return array();
+ }
+
+ # Get list of objectclasses
+ $nb= $attr[0]['subschemasubentry'][0];
+ $objectclasses= array();
+ $sr= ldap_read ($this->cid, $nb, "objectClass=*", array("objectclasses"));
+ $attrs= ldap_get_entries($this->cid,$sr);
+ if (!isset($attrs[0])){
+ return array();
+ }
+ foreach ($attrs[0]['objectclasses'] as $val){
+ $name= preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val);
+ if ($name != $val){
+ $objectclasses[$name]= $val;
+ }
+ }
+
+ return $objectclasses;
+ }
}
index a558666355cbac4caf995620808917ba5211362b..77ca026fbf9071f1a8b2d6d1df31c1e198a86ca1 100644 (file)
@@ -247,6 +247,16 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false
$affich['nagioscontact']['status']= true;
}
+ if ((!isset($objectclasses['apple-user'])) || (!isset($objectclasses['mount'])) ){
+ $messages['netatalk']['msg']= _("Support for netatalk disabled, no schema seems to be installed");
+ $affich['netatalk']['msg']= $messages['netatalk']['msg']."<td class=\"check\">apple.schema</td>";
+ $messages['netatalk']['status']= FALSE;
+ $affich['netatalk']['status']= FALSE;
+ }else{
+ $affich['netatalk']['msg']= _("Support for netatalk enabled")."<td class=\"check\">apple.schema</td>";
+ $affich['netatalk']['status']= true;
+ }
+
/* Fix for PHP Fehler "Undefined index: ldapconf"
* Ablaufverfolgung[1]: Funktion schema_check Datei: /home/hickert/gosa/include/functions_setup.inc (Zeile 230)
*/
$possible_plugins['pureftp'][] = "'\n.*<tab.*pureftp.*>.*\n'i";
$possible_plugins['webdav'][] = "'\n.*<tab.*webdav.*>.*\n'i";
$possible_plugins['phpgroupware'][]= "'\n.*<tab.*phpgroupware.*>.*\n'i";
+ $possible_plugins['netatalk'][0] = "'\n.*<plugin.*netatalk+.*\n.*>.*\n'i";
+ $possible_plugins['netatalk'][1] = "'\n.*<tab.*netatalk.*>.*\n'i";
/*Header information
Needed to send the generated gosa.conf to the browser */
index f0356021672bf6b90485f58ea2b02946eba9e854..103ce8bea2127a3c4e87824167308b416616f039 100644 (file)
) ;
+$ACLD['netatalk']= array(
+ "netatalkShare",
+ "netatalkUserHomepath");
+
$ACLD['proxyAccount']= array(
"proxyAccount",
"gotoLogonScript",
"gotoKioskProfile",
"gotoProfileQuota",
- "gotoHotplugDevice"
+ "gotoHotplugDevice",
+ "gotoShareAppleMounts"
);
$ACLD['phpgwAccount'] =array("phpgwAccount" );
index 0b96923ca78fd71e90dd2d3f6f343931628f7f2c..4770a78d11c6ff28d6c99af423f8ec0808063efe 100644 (file)
var $description =""; // description
var $type =""; // Type FS/Samba/NCP
var $charset =""; // charset
- var $types =array(); // Array Types NFS/Samba/NCP
+ var $host =""; // hostname
+ var $types =array(); // Array Types NFS/Samba/NCP/netatalk
var $charsets =array(); // Array with charsets
var $path =""; // Path
var $option =""; // Options
var $is_edit =false;
+ var $allow_mounts = false; //do we allow mount entries?
+ var $create_mount_init = false; //mount entry set for this entry (while editing)?
+ var $create_mount = false; //save mount entry
-
- function servnfs ($config, $dn= NULL,$entry = false)
+ function servnfs ($config, $acl, $allow_mounts, $dn= NULL,$entry = false,$mount = false)
{
plugin::plugin ($config, $dn);
- $this->types = array("NFS"=>"NFS","samba"=>"samba","NCP"=>"NCP");
-
+
+ $this->types = array("NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
+ if($dn){
+ $this->host = substr($dn, 3, strpos($dn, ',')-3);
+ }
+
+ $this->acl = $acl;
+ $this->allow_mounts=$allow_mounts;
+
$this->charsets = array();
if(!file_exists("/etc/gosa/encodings")){
$tmp = split("\|",$entry);
$this->name = $tmp[0]; // Name of NFS
$this->description = $tmp[1]; // description
- $this->type = $tmp[2]; // Type NFS/Samba/NCP
+ $this->type = $tmp[2]; // Type NFS/Samba/NCP/netatalk
$this->charset = $tmp[3]; // charset
$this->path = $tmp[4]; // Path
$this->option = $tmp[5]; // Options
$this->is_edit = true;
+
}else{
$this->attributes[] = "name";
}
+
+ $this->create_mount_init = $mount;
}
function execute()
{
- /* Call parent execute */
- plugin::execute();
+ /* Call parent execute */
+ plugin::execute();
/* Fill templating stuff */
$smarty= get_smarty();
if($this->is_edit){
$smarty->assign("nameACL"," disabled ");
}
+
+ $smarty->assign("allow_mounts", $this->allow_mounts);
+ $smarty->assign("mount_checked", "");
+
+
+ $appleMountsACL=chkacl($this->acl,"gotoShareAppleMounts");
+ $appleMountsACLset=strpos($appleMountsACL, "disabled");
+ $smarty->assign("appleMountsACL", $appleMountsACL);
+ $smarty->assign("appleMountsACLset", $appleMountsACLset);
+
+ if (($this->type == "netatalk") || ($this->type == "NFS")) {
+ if ($this->create_mount_init) {
+ $smarty->assign("mount_checked", "checked");
+ } else {
+ $tmp = split(",", $this->dn);
+ $clip = $tmp[0] . ",ou=servers,ou=systems,";
+ $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip));
+ switch ($this->type) {
+ case "netatalk" : {
+ $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn;
+ break;
+ }
+ case "NFS" : {
+ $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn;
+ break;
+ }
+ default : {
+ continue;
+ }
+ }
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($mountdn);
+ $attrs = $ldap->fetch();
+ if (count($attrs) > 0) {
+ $smarty->assign("mount_checked", "checked");
+ }
+ }
+ }
$display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
return($display);
$this->$attr = $_POST[$attr];
}
}
+
+ if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) {
+ $this->create_mount = true;
+ } else {
+ $this->create_mount = false;
+ }
}
$message[]=_("Option contains invalid characters.");
}
+ /* remove a / at the end of the path, we neither need it there nor
+ * do we want to check for it later.
+ */
+ if(substr($this->path, -1, 1) == '/') {
+ $this->path=substr($this->path, 0, -1);
+ }
+
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
$ldap->search("(objectClass=goShareServer)", array("goExportEntry"));
return(array($this->name=>$s_return));
}
+
+ function should_create_mount() {
+ return $this->create_mount;
+ }
}
diff --git a/plugins/admin/systems/class_servService.inc b/plugins/admin/systems/class_servService.inc
index e4984e3dead1910763bc60a64a5bba0fdf7d78d1..8b112da8106a0a436f56d3e85271e313fe8d8ae6 100644 (file)
"goMailServer" => array(),
"goCupsServer" => array());
+ var $allow_mounts = false; //do we allow mount entries?
+ var $mounts_to_add = array();
+ var $mounts_to_remove = array();
+ var $oldone = NULL; //temp dave for old mount entry
+
function servservice ($config, $dn= NULL)
{
+
plugin::plugin ($config, $dn);
+ $ldap = $this->config->get_ldap_link();
+ $avl_objectclasses = @$ldap->get_objectclasses();
+ if (isset($avl_objectclasses["mount"])) {
+ $this->allow_mounts = true;
+ }
+
/* Assemble final object class list */
foreach ($this->additionaloc as $oc => $dummy){
if (isset($this->attrs['objectClass']) && in_array($oc, $this->attrs['objectClass'])){
function deleteFromList($id){
unset($this->goExportEntry[$id]);
}
-
+
+ function addToMountList($entry) {
+ $key = key($entry);
+ $type = $this->get_share_type($entry[$key]);
+ if (($type == "netatalk") || ($type == "NFS")) {
+ $this->mounts_to_add[$entry[$key]] = $entry[$key];
+ unset($this->mounts_to_remove[$entry[$key]]);
+ }
+ }
+
+ function deleteFromMountList($entry) {
+ $type = $this->get_share_type($entry);
+ if (($type == "netatalk") || ($type == "NFS")) {
+ $this->mounts_to_remove[$entry] = $entry;
+ unset($this->mounts_to_add[$entry]);
+ }
+ }
function execute()
{
- /* Call parent execute */
- plugin::execute();
+ /* Call parent execute */
+ plugin::execute();
/* Fill templating stuff */
$smarty= get_smarty();
$smarty->assign("staticAddress", "");
-
+
if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntry']))){
+ if($this->allow_mounts){
+ $this->deleteFromMountList($this->goExportEntry[$_POST['goExportEntry']]);
+ }
$this->deleteFromList($_POST['goExportEntry']);
}
if(isset($_POST['NewNfsAdd'])){
- $this->o_subWindow = new servnfs($this->config, $this->dn);
+ $this->oldone = NULL;
+ $this->o_subWindow = new servnfs($this->config,$this->acl, $this->allow_mounts, $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);
+ $add_mount=isset($this->mounts_to_add[$entry]);
+ $this->oldone=$entry;
+ $this->o_subWindow = new servnfs($this->config,$this->acl,$this->allow_mounts,$this->dn,$entry,$add_mount);
$this->dialog = true;
}
}else{
$this->o_subWindow->save_object();
$newone = $this->o_subWindow->save();
- $this->addToList($newone) ;
+ $this->addToList($newone);
+ if($this->allow_mounts){
+ if($this->oldone) {
+ $this->deleteFromMountList($this->oldone);
+ }
+ if ($this->o_subWindow->should_create_mount()) {
+ $this->addToMountList($newone);
+ }
+ }
unset($this->o_subWindow);
$this->dialog = false;
}
/* Cancel NFS setup */
if(isset($_POST['NFScancel'])){
+ $this->oldone = NULL;
unset($this->o_subWindow);
$this->dialog = false;
}
ksort($this->goExportEntry);
foreach($this->goExportEntry as $name=>$values){
$tmp = split("\|",$values);
- $tellSmarty[$name] = $tmp[0]." ".$tmp[4];
+ $tellSmarty[$name] = $tmp[0]." ".$tmp[4]." (".$tmp[2].")";
}
$smarty->assign("goExportEntry",array_keys($tellSmarty));
$smarty->assign("goExportEntryKeys",($tellSmarty));
$this->attrs[$name][]= $element;
}
}
+
+ /* Process netatalk mounts */
+ if($this->allow_mounts) {
+ $this->process_mounts();
+ }
/* Remove illegal attributes */
foreach ($this->additionaloc as $oc => $attrs){
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
$this->cleanup();
-$ldap->modify ($this->attrs);
+ $ldap->modify ($this->attrs);
show_ldap_error($ldap->get_error());
$this->handle_post_events("add");
}
}
+
+ function process_mounts() {
+
+ $clip = "cn=" . $this->cn . ",ou=servers,ou=systems,";
+ $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip));
+
+ $mounts = array(
+ "objectClass" => "container",
+ "cn" => "mounts"
+ );
+
+ # load data from mounts container
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($mountsdn);
+ $attrs = $ldap->fetch();
+
+ # mounts container not present yet, so we create it
+ if (count($attrs) == 0) {
+ $ldap->cd($mountsdn);
+ $ldap->add($mounts);
+ show_ldap_error($ldap->get_error());
+ gosa_log("Mount container '$mountsdn' has been created");
+ }
-}
+ # remove deleted mounts from the container
+ foreach ($this->mounts_to_remove as $entry) {
+ $mount=$this->returnMountEntry($entry);
+ $mountdn = "cn=".$mount["cn"].","."$mountsdn";
+
+ $ldap->cat($mountdn);
+ $attrs = $ldap->fetch();
+
+ if (count($attrs) != 0) {
+ $ldap->rmdir($mountdn);
+ show_ldap_error($ldap->get_error());
+ gosa_log("Mount object '".$mountdn."' has been removed");
+ }
+ }
+
+ # add new mounts to the container
+ foreach ($this->mounts_to_add as $entry) {
+
+ $mount=$this->returnMountEntry($entry);
+ $mountdn = "cn=".$mount["cn"].","."$mountsdn";
+ $ldap->cd($mountdn);
+ $ldap->add($mount);
+ show_ldap_error($ldap->get_error());
+ gosa_log("Mount object '".$mountdn."' has been added");
+ }
+ }
+
+ function get_share_type($share) {
+ $tmp = split("\|", $share);
+ return $tmp[2];
+ }
+
+ function returnMountEntry($entry) {
+ $item = split("\|", $entry);
+ $name = $item[0];
+ $description = $item[1];
+ $type = $item[2];
+ $charset = $item[3];
+ $path = $item[4];
+ $options = $item[5];
+
+ switch ($type) {
+ case "netatalk" : {
+ $mount = array(
+ "mountDirectory" => "/Network/Servers/",
+ "mountOption" => array(
+ "net",
+ "url==afp://;AUTH=NO%20USER%20AUTHENT@".$this->cn."/$name/"
+ ),
+ "mountType" => "url",
+ "objectClass" => "mount",
+ "cn" => $this->cn .":/".$name
+ );
+ break;
+ }
+ case "NFS" : {
+ $mount = array(
+ "mountDirectory" => "/Network/Servers/",
+ "mountOption" => "net",
+ "mountType" => "nfs",
+ "objectClass" => "mount",
+ "cn" => $this->cn .":".$path
+ );
+ break;
+ }
+ default : {
+ continue;
+ }
+ }
+ return $mount;
+ }
+
+}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
index 095e159d6ce4645fd480e5faafd906ad0d34e1f5..8574dec8205dfd59943ab2f0a9d34b64ebc26421 100644 (file)
<h2><img class="center" alt="" src="images/fai_partitionTable.png" align="middle"> {t}Edit share{/t}</h2>
<table summary="{t}NFS setup{/t}" width="100%">
<tr>
- <td width="45%">
+ <td width="45%" style="vertical-align:top">
<!--Table left-top-->
<table summary="">
<tr>
</tr>
<tr>
<td>
- {t}Path{/t}
+ {t}Path{/t} {$must}
</td>
<td>
<input type="text" size="40" name="path" value="{$path}">
<!--Table right-top-->
<table summary="">
<tr>
- <td>
+ <td style="vertical-align:top">
{t}Type{/t}
</td>
<td>
- <select size="1" name="type">
- {html_options options=$types selected=$type}
- </select>
+ <select size="1" name="type" id="sharetype">
+ {html_options options=$types selected=$type}
+ </select>
+ {if $allow_mounts == TRUE}
+ <br><br><input type="checkbox" name="netatalk_mount" id="netatalk_mount" {$mount_checked} {$appleMountsACL}/><label for="netatalk_mount">{t}Make share visible for Apple systems{/t}</label>
+ {if $appleMountsACLset == FALSE}
+ {literal}
+ <script language="JavaScript">
+ document.getElementById('sharetype').onchange=function() {
+ var foobar=this[this.selectedIndex].value;
+ var box=document.getElementById('netatalk_mount');
+ if(foobar=="NFS"||foobar=="netatalk")
+ box.disabled=false;
+ else {
+ box.disabled=true;
+ box.checked=false;
+ }
+ };
+ document.getElementById('sharetype').onchange();
+ </script>
+ {/literal}
+ {/if}
+ <br>
+ <br>
+ {/if}
</td>
</tr>
<tr>
diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc
index f3e3596cdc740adb8fc77aeaaafab17b407238e1..43360391a44ec0bcc51a3241eea914783ca53c31 100644 (file)
name='user_edit_%KEY%-gofaxAccount' title='"._("Edit fax properies")."'>";
$sambaimg = "<input class='center' type='image' src='images/select_winstation.png' alt='"._("Samba")."'
name='user_edit_%KEY%-sambaAccount' title='"._("Edit samba properties")."'>";
+ $netatalkimg = "<input class='center' type='image' src='images/select_netatalk.png' alt='"._("Netatalk")."'
+ name='user_edit_%KEY%-netatalk' title='"._("Edit netatalk properties")."'>";
$tplcreateuserimg = "<input type='image' class='center' src='images/list_new.png' alt='"._("Create user from template")."'
name='userfrom_tpl_%KEY%' title='"._("Create user with this template")."'>";
$samba=$empty;
}
+ if(in_array("apple-user" ,$val['objectClass'])){
+ $netatalk = preg_replace("/%KEY%/", "$key", $netatalkimg);
+ }else{
+ $netatalk=$empty;
+ }
+
if(in_array("gosaUserTemplate",$val['objectClass'])){
$tpl = preg_replace("/%KEY%/", "$key", $tplimg);
$s_img_create_from_template = preg_replace("/%KEY%/", "$key", $tplcreateuserimg);
/* Create each field */
$field1 = array("string" => sprintf($tpl,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
$field2 = array("string" => sprintf($editlink,$key,$display).$ip_port, "attach" => "style='' title='dn: ".@LDAP::fix($val['dn'])."'");
- $field3 = array("string" => $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba, "attach" => "style='width:152px;'");
+ $field3 = array("string" => $usrimg2." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$netatalk, "attach" => "style='width:152px;'");
$field4 = array("string" => $s_img_create_from_template.preg_replace("/%KEY%/", "$key", $action),"attach" => "style='width:102px;border-right:0px;text-align:right;'");
$add = array($field1,$field2,$field3,$field4);
diff --git a/plugins/personal/netatalk/class_netatalk.inc b/plugins/personal/netatalk/class_netatalk.inc
--- /dev/null
@@ -0,0 +1,328 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2006 Gina Haeussge <osd@foosel.net>
+ Copyright (C) 2006 Bernd Zeimetz <bernd@zeimetz.de>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*! \brief netatalk plugin
+ \author Gina Haeussge <osd@foosel.net>
+ \author Bernd Zeimetz <bernd@zeimetz.de>
+ \version 0.1
+ \date 21.3.2006
+
+ This class provides the functionality to read and write all attributes
+ relevant for netatalk from/to the LDAP. It does syntax checking
+ and displays the formulars required.
+ */
+
+class netatalk extends plugin {
+
+ /* Definitions */
+ var $plHeadline = "Netatalk";
+ var $plDescription = "Manage netatalk account";
+
+ /* CLI vars */
+ var $cli_summary = "Manage netatalk account";
+ var $cli_description = "Manage Account \nfor netatalk";
+ var $cli_parameters = array ("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* Plugin specific values */
+ var $apple_user_homepath_raw = "";
+ var $apple_user_homeurl_raw = "";
+ var $apple_user_homeurl_xml = "";
+ var $apple_user_homeurl = "";
+ var $apple_user_homeDirectory = "";
+ var $apple_user_share = "";
+ var $shares = array();
+ var $shares_settings = array();
+ var $selectedshare = "";
+ var $mountDirectory = "/Network/Servers";
+
+ /* Attributes to save to LDAP */
+ var $attributes = array ("apple-user-homeurl", "apple-user-homeDirectory");
+
+ /* Attributes to use in smarty template */
+ var $smarty_attributes = array ("apple_user_homepath_raw", "shares", "selectedshare");
+
+ /* Attributes to save from $_POST */
+ var $post_attributes = array ("apple_user_share", "apple_user_homepath_raw");
+
+ /* Objectclasses */
+ var $objectclasses = array ("apple-user");
+
+ /* Checkboxes */
+ var $is_chk_box = array ();
+
+
+ /* The constructor just saves a copy of the config. You may add what ever you need. */
+ function netatalk($config, $dn = NULL) {
+
+ /* Include config object */
+ $this->config = $config;
+ plugin :: plugin($config, $dn);
+
+ /* Copy needed attributes */
+ foreach($this->attributes as $val) {
+ if (isset($this->attrs["$val"][0])) {
+ $name = str_replace('-', '_', $val);
+ $this->$name = $this->attrs["$val"][0];
+ }
+ }
+
+ if (strlen($this->apple_user_homeDirectory) >0) {
+ $this->apple_user_homepath_raw = substr($this->apple_user_homeDirectory, strrpos($this->apple_user_homeDirectory, '/') + 1 );
+ }
+
+ /* Save initial account state */
+ $this->initially_was_account = $this->is_account;
+ }
+
+ /* Execute the plugin, produce the output. */
+ function execute() {
+ plugin :: execute();
+
+ /* Use the smarty templating engine here... */
+ $smarty = get_smarty();
+ $display = "";
+
+ /* Do we need to flip is_account state? */
+ if (isset ($_POST['modify_state'])) {
+ $this->is_account = !$this->is_account;
+ }
+
+ /* Do we represent a valid account? */
+ if (!$this->is_account && $this->parent == NULL) {
+ $display = "<img alt=\"\"src=\"images/stop.png\" align=\"middle\"> <b>"._("This account has no netatalk extensions.")."</b>";
+
+ $display .= back_to_main();
+ return ($display);
+ }
+
+
+ /* Get netatalk shares */
+ $this->shares = array();
+ $ldap = $this->config->get_ldap_link();
+
+ if($this->dn === "new" || $this->dn == NULL) {
+ $ldap->cd($this->parent->by_object['user']->base);
+ } else {
+ $ldap->cd ($this->dn);
+ $ldap->cd ('..'); $ldap->cd ('..');
+ }
+ $ldap->search ("(&(objectClass=mount)(|(mountType=url)(mountType=nfs))(cn=*))");
+
+
+ /* Show tab dialog headers */
+ if ($this->parent != NULL) {
+ if ($this->is_account) {
+ $display = $this->show_header(_("Remove netatalk account"), _("This account has netatalk features enabled. You can disable them by clicking below."));
+ } else {
+ $errmsg="";
+ $obj = $this->parent->by_object['posixAccount'];
+ if (!($obj->is_account) ) {
+ $errmsg.="Posix features are needed for netatalk accounts, enable them first. ";
+ }
+ if ($ldap->count() == 0) {
+ $errmsg.="At least one share with netatalk or NFS mount entry needed.";
+ }
+ if($errmsg==""){
+ $display = $this->show_header(_("Create netatalk account"), _("This account has netatalk features disabled. You can enable them by clicking below."));
+ } else {
+ $display = $this->show_header(_("Create netatalk account"), _($errmsg), TRUE);
+ }
+ return ($display);
+ }
+ }
+
+
+ while ($attrs = $ldap->fetch()){
+ $tmp = split(":", $attrs["cn"][0]);
+ $host = trim($tmp[0]);
+ $dir = trim($tmp[1]);
+ $mountType = trim($attrs["mountType"][0]);
+ if ($mountType == "url") {
+ $mountTypeReal = "netatalk";
+ } else {
+ $mountTypeReal = $mountType;
+ }
+ $share = $attrs["cn"][0]. " (" . $mountTypeReal . ")";
+ $this->shares[$share] = $share;
+ $this->shares_settings[$share]["mountType"]=$mountType;
+ $this->shares_settings[$share]["dir"]=$dir;
+ $this->shares_settings[$share]["host"]=$host;
+
+ $oldShare=substr($this->apple_user_homeDirectory, 0, strrpos($this->apple_user_homeDirectory, '/'));
+ $newShare=($this->mountDirectory . "/". $host . $dir );
+ if (strcmp($oldShare, $newShare)==0) {
+ $this->selectedshare = $share;
+ }
+ }
+ asort($this->shares);
+ /* Assign attributes and ACL to smarty */
+
+ $smarty->assign("netatalkShareACL", chkacl($this->acl, "netatalkShare"));
+ $smarty->assign("netatalkUserHomepathACL", chkacl($this->acl, "netatalkUserHomepath"));
+ foreach ($this->smarty_attributes as $val) {
+ $smarty->assign("$val", $this-> $val);
+ if (in_array($val, $this->is_chk_box)) {
+ if ($this-> $val == "checked") {
+ $smarty->assign($val."CHK", " checked ");
+ } else {
+ $smarty->assign($val."CHK", "");
+ }
+ }
+ }
+
+ /* Let smarty fetch and process the page. */
+ $display .= ($smarty->fetch(get_template_path('netatalk.tpl', TRUE, dirname(__FILE__))));
+ return ($display);
+ }
+
+
+ /* Check if we have correct data */
+ function check() {
+ $message = array ();
+
+ if (strlen($this->apple_user_share) == 0) {
+ $message[] = _("You must select a share to use.");
+ }
+
+ return ($message);
+ }
+
+ /* Save to LDAP */
+ function save() {
+ /* remove a / at the end of the homepath, we neither need it there nor
+ * do we want to check for it later.
+ */
+ if(substr($this->apple_user_homepath_raw, -1, 1) === '/') {
+ $this->apple_user_homepath_raw=substr($this->apple_user_homepath_raw, 0, -1);
+ }
+
+ $mountType=$this->shares_settings[$this->apple_user_share]["mountType"];
+ $dir=$this->shares_settings[$this->apple_user_share]["dir"];
+ $host=$this->shares_settings[$this->apple_user_share]["host"];
+
+ /* Convert raw data to wished format */
+ if ($this->is_account) {
+ if($mountType=="url") {
+ $this->apple_user_homeurl_xml = '<home_dir><url>afp://'.$host.$dir . '</url><path>'.$this->apple_user_homepath_raw.'</path></home_dir>';
+ $this->apple_user_homeurl = base64_encode($this->apple_user_homeurl_xml);
+ } else {
+ $this->apple_user_homeurl = "";
+ }
+ $this->apple_user_homeDirectory = $this->mountDirectory . '/' . $host .$dir . '/' . $this->apple_user_homepath_raw;
+ } else {
+ $this->apple_user_homeurl = "";
+ $this->apple_user_homeDirectory = "";
+ }
+
+ $ldap = $this->config->get_ldap_link();
+
+ /* Call parents save to prepare $this->attrs */
+ plugin :: save();
+
+ /* Do attribute conversion */
+ foreach ($this->attributes as $val) {
+ $name = str_replace('-', '_', $val);
+ if ($this->$name != "") {
+ $this->attrs[$val] = $this->$name;
+ } else {
+ $this->attrs[$val] = array();
+ }
+ unset ($this->attrs[$name]);
+ }
+
+ /* Write back to ldap */
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $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) {
+ $this->handle_post_events("modify");
+ }
+ } else {
+ $this->handle_post_events("add");
+ }
+ }
+
+ /* Use Save_object for every Post handling */
+ function save_object() {
+ if (isset ($_POST['netatalkTab'])) {
+ /* Save ldap attributes */
+ plugin :: save_object();
+
+ foreach($this->post_attributes as $val) {
+ if (isset ($_POST[$val])) {
+ $this->$val = $_POST[$val];
+ } else {
+ $this->$val = "";
+ }
+ }
+
+ /* Specialhandling for checkboxes */
+ foreach ($this->is_chk_box as $val) {
+ if (isset ($_POST[$val])) {
+ $this-> $val = "checked";
+ } else {
+ $this-> $val = "unchecked";
+ }
+ }
+
+ $this->apple_user_homeurl_raw = 'afp://' . $this->apple_user_share;
+ }
+ }
+
+ function remove_from_parent() {
+ /* Cancel if there's nothing to do here */
+ if (!$this->initially_was_account) {
+ return;
+ }
+
+ /* include global link_info */
+ $ldap = $this->config->get_ldap_link();
+
+ /* Remove and write to LDAP */
+ plugin :: remove_from_parent();
+
+ /* Adapt attributes if needed */
+ // $method= new $this->method($this->config);
+ // $method->fixAttributesOnRemove($this);
+
+ @ DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify($this->attrs);
+
+ show_ldap_error($ldap->get_error());
+
+ /* remove the entry from LDAP */
+ unset ($this->attrs['uid']);
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events('remove');
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/personal/netatalk/main.inc b/plugins/personal/netatalk/main.inc
--- /dev/null
@@ -0,0 +1,126 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2006 Gina Haeussge <osd@foosel.net>
+ Copyright (C) 2006 Bernd Zeimetz <bernd@zeimetz.de>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+if (!$remove_lock) {
+ /* Reset requested? */
+ if (isset ($_POST['edit_cancel']) || (isset ($_GET['reset']) && $_GET['reset'] == 1)) {
+ del_lock($ui->dn);
+ sess_del('edit');
+ sess_del('netatalk');
+ }
+
+ /* Create netatalk object on demand */
+ if (!isset ($_SESSION['netatalk']) || (isset ($_GET['reset']) && $_GET['reset'] == 1)) {
+ $_SESSION['netatalk'] = new netatalk($config, $ui->dn);
+ }
+ $netatalk = $_SESSION['netatalk'];
+
+ /* save changes back to object */
+ if (isset ($_SESSION['edit'])) {
+ $netatalk->save_object();
+ }
+
+ /* Enter edit mode? */
+ if (isset ($_POST['edit'])) {
+
+ /* Check locking */
+ if (($username = get_lock($ui->dn)) != "") {
+ $_SESSION['back_plugin'] = $plug;
+ gen_locked_message($username, $ui->dn);
+ exit ();
+ }
+
+ /* Lock the current entry */
+ add_lock($ui->dn, $ui->dn);
+ $_SESSION['dn'] = $ui->dn;
+ $_SESSION['edit'] = TRUE;
+ }
+
+ /* Adjust acl's to mode */
+ if (isset ($_SESSION['edit'])) {
+ $acl = get_permissions($ui->dn, $ui->subtreeACL);
+ $netatalk->acl = get_module_permission($acl, "netatalk", $ui->dn);
+ } else {
+ $acl = get_permissions($ui->dn, $ui->subtreeACL);
+ $editacl = get_module_permission($acl, "netatalk", $ui->dn);
+ $netatalk->acl = "#none#";
+ }
+
+ /* save changes to LDAP and disable edit mode */
+ if (isset ($_POST['edit_finish'])) {
+
+ /* Perform checks */
+ $message = $netatalk->check();
+
+ /* No errors, save object */
+ if (count($message) == 0) {
+ $netatalk->save();
+ gosa_log("User/netatalk object'".$ui->dn."' has been saved");
+ $netatalk->acl = "#none#";
+ del_lock($ui->dn);
+ sess_del('edit');
+
+ /* Store object */
+ $_SESSION['netatalk'] = $netatalk;
+ } else {
+ /* Errors found, show message */
+ show_errors($message);
+ }
+ }
+
+ /* Execute formular */
+ $display = $netatalk->execute();
+
+ /* Store changes in session */
+ if (isset ($_SESSION['edit'])) {
+ $_SESSION['netatalk'] = $netatalk;
+ }
+
+ $info = "";
+ /* Show page footer depending on the mode */
+ if ($netatalk->is_account) {
+ $display .= "<p class=\"plugbottom\">";
+
+ /* Are we in edit mode? */
+ if (isset ($_SESSION['edit'])) {
+ $display .= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
+ $display .= " ";
+ $display .= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".$ui->dn." ";
+ } else {
+ $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png')."\"> ".$ui->dn." ";
+ if (isset ($editacl) && $editacl != "#none#") {
+ $info .= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> "._("Click the 'Edit' button below to change informations in this dialog");
+ $display .= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
+ }
+
+ $display .= "<input type=\"hidden\" name=\"ignore\">\n";
+ }
+ $display .= "</p>\n";
+ }
+
+ /* Page header*/
+ $display = print_header(get_template_path('images/netatalk.png'), _("Netatalk settings"), $info).$display;
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/personal/netatalk/netatalk.tpl b/plugins/personal/netatalk/netatalk.tpl
--- /dev/null
@@ -0,0 +1,26 @@
+<table summary="">
+<tr>
+ <td>
+ <label for="apple_user_share">{t}Share{/t}</label>
+ </td>
+ <td>
+ <select name="apple_user_share" id="apple_user_share" {$netatalkShareACL} >{html_options options=$shares selected=$selectedshare}</select>
+ </td>
+<tr>
+ <td>
+ <label for="apple_user_homepath_raw">{t}Path{/t}</label>
+ </td>
+ <td>
+ <input name="apple_user_homepath_raw" id="apple_user_homepath_raw" type="text" value="{$apple_user_homepath_raw}" size="25" maxlength="65" {$netatalkUserHomepathACL} />
+ </td>
+</tr>
+</table>
+
+<input type="hidden" name="netatalkTab" value="netatalkTab">
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ document.mainform.apple_user_homeurl_raw.focus();
+ -->
+</script>