diff --git a/plugins/admin/systems/class_servRepositorySetup.inc b/plugins/admin/systems/class_servRepositorySetup.inc
index 2fa8a7cf6fa8551cb0dc13170e21ddde3a4071cd..413410c564bb8673cbd07bd998d97aa1c50de2b1 100644 (file)
class servRepositorySetup extends plugin
{
class servRepositorySetup extends plugin
{
- /* CLI vars */
- var $cli_summary = "Manage FAI repositories";
- var $cli_description = "Some longer text\nfor help";
- var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
/* attribute list for save action */
var $ignore_account = TRUE;
/* attribute list for save action */
var $ignore_account = TRUE;
- var $attributes = array("Release","ParentServer","Url");
+ var $attributes = array("Release","ParentServer","Url","cn");
var $objectclasses = array("whatever");
/* Attributes */
var $objectclasses = array("whatever");
/* Attributes */
- var $Release;
- var $ParentServer;
- var $Url;
- var $Sections=array();
- var $ParentServers;
-
- var $initialy_was=false;
+ var $Release = "";
+ var $ParentServer = "";
+ var $Url = "";
+ var $Sections = array();
+ var $ParentServers = "";
+ var $initialy_was = false;
+ var $cn = "";
function servRepositorySetup ($config, $dn= NULL,$data = false)
{
plugin::plugin ($config, $dn);
if($data != false){
function servRepositorySetup ($config, $dn= NULL,$data = false)
{
plugin::plugin ($config, $dn);
if($data != false){
- $this->Sections= $data['Sections'];
- $this->Url= $data['Url'];
- $this->Release= $data['Release'];
- $this->ParentServer= $data['ParentServer'];
- if(isset($data['initialy_was'])){
- $this->initialy_was= $data['initialy_was'];
+ foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){
+ if(isset($data[$atr])){
+ $this->$atr = $data[$atr];
+ }
}
}
}
}
}
}
$smarty= get_smarty();
if((isset($_POST['AddSection']))&&(isset($_POST['SectionName']))&&(!empty($_POST['SectionName']))){
$smarty= get_smarty();
if((isset($_POST['AddSection']))&&(isset($_POST['SectionName']))&&(!empty($_POST['SectionName']))){
- $this->Sections[$_POST['SectionName']]=$_POST['SectionName'];
+
+ /* Replace multiple spaces with a single, and cut of white spaces (trim)*/
+ $val = preg_replace("/\ \ * /" , " ", trim($_POST['SectionName']));
+
+ /* check if there are more than one entry given ( "section1 section2 )*/
+ if(preg_match("/ /",$val)){
+
+ /* Generate list of new section names */
+ $vals = split(" ",$val);
+
+ /* Add new entries */
+ foreach($vals as $entry){
+ $entry = trim($entry);
+ $this->Sections[$entry]=$entry;
+ }
+ }else{
+ $this->Sections[$val]=$val;
+ }
}
foreach($_POST as $name => $value){
if(preg_match("/^delete_/",$name)){
}
foreach($_POST as $name => $value){
if(preg_match("/^delete_/",$name)){
- if(isset($this->Sections[$value])){
- unset($this->Sections[$value]);
+
+ $val = preg_replace("/^delete_/","",$name);
+ $val = base64_decode(preg_replace("/_.*$/","",$val));
+
+ if(isset($this->Sections[$val])){
+ unset($this->Sections[$val]);
}
}
}
$divlist = new divSelectBox("servRepositorySetup");
}
}
}
$divlist = new divSelectBox("servRepositorySetup");
- $divlist->setHeight("120");
+ $divlist->setHeight("220");
$dellink = "<input type='image' src='images/edittrash.png' title='delete' alt='delete' name='delete_%s' value='%s'>";
foreach($this->Sections as $sec){
$divlist->AddEntry(array(
array("string"=>$sec),
$dellink = "<input type='image' src='images/edittrash.png' title='delete' alt='delete' name='delete_%s' value='%s'>";
foreach($this->Sections as $sec){
$divlist->AddEntry(array(
array("string"=>$sec),
- array("string"=>sprintf($dellink,$sec,$sec),"attach"=>"style='border-right:0px;width:20px;'")
+ array("string"=>sprintf($dellink,base64_encode($sec),$sec),"attach"=>"style='border-right:0px;width:20px;'")
));
}
));
}
$smarty->assign($attr ,$this->$attr);
$smarty->assign($attr."ACL" ,chkacl($this->acl,$attr));
}
$smarty->assign($attr ,$this->$attr);
$smarty->assign($attr."ACL" ,chkacl($this->acl,$attr));
}
-
- $smarty->assign("ParentServers" ,$this->getParentServers());
- $smarty->assign("ParentServerKeys",array_flip($this->getParentServers()));
+
+ $tmp = $this->getParentServers();
+ $smarty->assign("ParentServers" ,$tmp);
+ $smarty->assign("ParentServerKeys",array_flip($tmp));
return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE)));
}
return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE)));
}
/* Check supplied data */
function check()
{
/* Check supplied data */
function check()
{
- $message= array();
+ /* Call common method to give check the hook */
+ $message= plugin::check();
- if(!isset($this->Release)){
+ if(empty($this->Release)){
$message[]=_("Please enter a value for 'release'.");
}
$message[]=_("Please enter a value for 'release'.");
}
+ if(empty($this->Url)){
+ $message[] = _("Please specify a valid value for 'url'.");
+ }
+
return ($message);
}
return ($message);
}
function getParentServers()
{
function getParentServers()
{
-
$ret = array();
$ret = array();
-
$ldap = $this->config->get_ldap_link();
$ldap = $this->config->get_ldap_link();
-
$ldap->cd($this->config->current['BASE']);
$ldap->cd($this->config->current['BASE']);
-
$ldap->search("(objectClass=FAIrepositoryServer)",array("*"));
while($attr = $ldap->fetch()){
$ldap->search("(objectClass=FAIrepositoryServer)",array("*"));
while($attr = $ldap->fetch()){
+ if($attr['cn'][0] == $this->cn) continue;
$ret[$attr['cn'][0]]= $attr['cn'][0];
}
$ret[$attr['cn'][0]]= $attr['cn'][0];
}
- $ret['none']=_("Master");
+
+ $ret = array_merge($ret,$this->GetHookElements());
+
+ $ret['none']= " ";
+ asort($ret);
+ return($ret);
+ }
+
+ /* this funtions calls a defined hook
+ and parses all additional serverdata
+ */
+ function GetHookElements()
+ {
+ $ret = array();
+ $cmd= search_config($this->config->data['TABS'], "servrepository", "REPOSITORY_HOOK");
+ if(!empty($cmd)){
+ $res = shell_exec($cmd);
+ $res2 = trim($res);
+ if(!$res){
+ print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s'. Please check your gosa.conf."),$cmd));
+ }elseif(empty($res2)){
+ print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd));
+ }else{
+ $tmp = split("\n",$res);
+ foreach($tmp as $hook){
+ /* skip empty */
+ if(empty($hook)) continue;
+
+ if(preg_match("/;/",$hook)){
+ $hookinfo = split(";",$hook);
+ $ret[$hookinfo[0]] = $hookinfo[0];
+ }else{
+ $ret[$hook] = $hook;
+ }
+ }
+ }
+ }
return($ret);
}
return($ret);
}