index eb27521f5c591d5c891999b72a8ba5c20b71c9c7..de42cecfb929b592940532a6697e304d723fe129 100644 (file)
var $ignore_account = TRUE;
/* Attributes for this Object */
- var $attributes = array("cn","description","FAIpackage","section","mirror","release");
+ var $attributes = array("cn","description","FAIpackage","FAIdebianRelease","FAIdebianSection","FAIdebianMirror");
/* ObjectClasses for this Object*/
- var $objectclasses = array("top","FAIclass","FAIpackageList");
+ var $objectclasses = array("top","FAIclass","FAIpackageList","FAIrepository");
/* Class name of the Ldap ObjectClass for the Sub Object */
var $subClass = "";
var $dialog = NULL; // a dialog, e.g. new disk dialog
var $SubObjects = array(); // All leafobjects of this object
- var $section = ""; // The selected section
- var $release = ""; // selected release
- var $mirror = ""; // selected mirror
+ var $FAIdebianRelease = ""; // The selected release
+ var $FAIdebianSection = ""; // selected section
+ var $FAIdebianMirror = ""; // selected mirror
var $servers = array(); // All available servers
- var $sections = array(); // All possible sections
- var $releases = array(); // All release types
+ var $releases = array(); // All possible releases
+ var $sections = array(); // All section types
- var $mirrors = array(); // The combination of server/section/release
+ var $mirrors = array(); // The combination of server/release/section
var $confDir = "";
+ var $usedPackages = array();
function faiPackage ($config, $dn= NULL)
{
$this->dn =$dn;
}
+ if(isset($this->attrs['FAIpackage'])){
+ unset($this->attrs['FAIpackage']['count']);
+ foreach($this->attrs['FAIpackage'] as $pkg){
+ $this->usedPackages[$pkg] = $pkg;
+ }
+ }else{
+ $this->usedPackages = array();
+ }
$this->confDir = CONFIG_DIR."/fai/";
- $this->FAIpackage = "test";
+ $this->FAIpackage = array();
}
function execute()
$smarty= get_smarty();
$display= "";
+ $disableRelease = false;
+ $disableMirror = false;
+ $disableOptions = false;
+ $disableSection = false;
+
/* Assign variables */
foreach($this->attributes as $attrs){
$smarty->assign($attrs,$this->$attrs);
}
- /* Second try */
-
- /* Check available server entries in CONFIG_DIR/fai
- */
+ /* Post handling for Section, Release and Mirror Setup */
+ if(isset($_POST['SetSection'])){
+ $this->FAIdebianSection = $_POST['FAIdebianSectionS'];
+ }
+ if(isset($_POST['SetRelease'])){
+ $this->FAIdebianRelease = $_POST['FAIdebianReleaseS'];
+ }
+ if(isset($_POST['SetMirror'])){
+ $this->FAIdebianMirror = $_POST['FAIdebianMirrorS'];
+ }
+
+ if(empty($this->FAIdebianRelease)){
+ $disableSection = $disableMirror = $disableOptions = true;
+ }elseif(empty($this->FAIdebianSection)){
+ $disableRelease = $disableMirror = $disableOptions = true;
+ }elseif(empty($this->FAIdebianMirror)){
+ $disableRelease = $disableSection = $disableOptions = true;
+ }else{
+ $disableRelease = $disableSection = true;
+ }
+
+ $smarty->assign("ReleaseACL" , "");
+ $smarty->assign("MirrorACL" , "");
+ $smarty->assign("OptionACL" , "");
+ $smarty->assign("SectionACL" , "");
+
+ if($disableOptions){
+ $smarty->assign("OptionACL"," disabled ");
+ }
+ if($disableRelease){
+ $smarty->assign("ReleaseACL"," disabled ");
+ }
+ if($disableMirror){
+ $smarty->assign("MirrorACL"," disabled ");
+ }
+ if($disableSection){
+ $smarty->assign("SectionACL"," disabled ");
+ }
+
+ $this->genMirror();
+
+ $availableServer = array();
+ foreach($this->mirrors as $mir){
+ if(($mir['release'] == $this->FAIdebianRelease)&&($mir['section']==$this->FAIdebianSection)){
+ $availableServer[$mir['mirror']]=$mir['mirror'];
+ }
+ }
+
+ if($disableMirror){
+ $availableServer[$mir['mirror']]=array("---");
+ }
+
+ if(isset($_POST['Addpkg'])){
+ $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->confDir.$this->FAIdebianMirror."/".$this->FAIdebianRelease."/".$this->FAIdebianSection,$this->usedPackages);
+ $this->is_dialog =true;
+ }
+
+ if(isset($_POST['Delpkg'])){
+ unset($this->usedPackages[$_POST['usedPackages']]);
+ }
+
+ if(isset($_POST['CancelSubObject'])){
+ $this->dialog = false;
+ $this->is_dialog=false;
+ }
+
+ if(isset($_POST['SaveSubObject'])) {
+ $this->dialog->save_object();
+ if(count($this->dialog->check())){
+ foreach($this->dialog->check() as $msgs){
+ print_red($msgs);
+ }
+ }else{
+ $use = $this->dialog->save();
+ $this->usedPackages = $use;
+ $this->dialog = false;
+ $this->is_dialog=false;
+ }
+ }
+
+ if($this->is_dialog){
+ return $this->dialog->execute();
+ }
+
+ $smarty->assign("mirrors" ,$availableServer);
+ $smarty->assign("mirror" ,$this->FAIdebianMirror);
+ $smarty->assign("releases",$this->releases);
+ $smarty->assign("release" ,$this->FAIdebianRelease);
+ $smarty->assign("sections",$this->sections);
+ $smarty->assign("section" ,$this->FAIdebianSection);
+ $smarty->assign("usedPackages",$this->printUsedPackages());
+ $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE));
+ return($display);
+ }
+
+ function genMirror(){
$confDir = $this->confDir;
if(!is_readable($confDir)){
print_red(sprintf(_("Can't read configuration folder '%s'."),$confDir));
/* Try to catch all available mirrors
Possibly check if each server is reachable
*/
+
+ $this->servers= array();
+ $this->releases=array();
+ $this->sections=array();
$this->mirrors= array();
$fd = opendir($confDir);
while($mirror = readdir($fd)){
$mirrorDir = $confDir.$mirror."/";
$fe = opendir($mirrorDir);
- while($section = readdir($fe)){
- if((is_dir($mirrorDir.$section))&&(($section != "." )&&($section!=".."))){
+ while($release = readdir($fe)){
+ if((is_dir($mirrorDir.$release))&&(($release != "." )&&($release!=".."))){
- $sectionDir = $mirrorDir.$section."/";
+ $releaseDir = $mirrorDir.$release."/";
- $ff = opendir($sectionDir);
- while($release = readdir($ff)){
- if((is_file($sectionDir.$release))&&(($release != "." )&&($release!="..")&&(!preg_match("/.*\.in$/",$release)))){
+ $ff = opendir($releaseDir);
+ while($section = readdir($ff)){
+ if((is_file($releaseDir.$section))&&(($section != "." )&&($section!="..")&&(!preg_match("/.*\.in$/",$section)))){
$this->servers[$mirror]=$mirror;
- $this->sections[$section]=$section;
$this->releases[$release]=$release;
+ $this->sections[$section]=$section;
- if(empty($this->mirror)){
- $this->mirror= $mirror;
+ if(empty($this->FAIdebianRelease)){
+ $this->servers= array("---");
}
- if(empty($this->section)){
- $this->section = $section;
+ if(empty($this->FAIdebianSection)){
+ $this->releases= array("---");
}
- if(empty($this->release)){
- $this->release = $release;
+ if(empty($this->FAIdebianSection)){
+ $this->FAIdebianSection = $section;
}
$arr=array();
$arr['mirror'] = $mirror;
- $arr['section']= $section;
- $arr['release']= $release;
+ $arr['release']= $release;
+ $arr['section']= $section;
$this->mirrors[] = $arr ;
}
fclose($fd);
}
- $availableServer = array();
- foreach($this->mirrors as $mir){
- if(($mir['section'] == $this->section)&&($mir['release']==$this->release)){
- $availableServer[$mir['mirror']]=$mir['mirror'];
- }
- }
- if(isset($_POST['Addpkg'])){
- $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->confDir.$this->mirror."/".$this->section."/".$this->release);
- $this->is_dialog =true;
- }
-
- if($this->is_dialog){
- return $this->dialog->execute();
- }
-
-
- $smarty->assign("mirrors" ,$availableServer);
- $smarty->assign("mirror" ,$this->mirror);
- $smarty->assign("sections",$this->sections);
- $smarty->assign("section" ,$this->section);
- $smarty->assign("releases",$this->releases);
- $smarty->assign("release" ,$this->release);
- $smarty->assign("usedPackages",$this->usedPackages);
- $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE));
- return($display);
}
/* Delete me, and all my subtrees
*/
function save_object()
{
+
plugin::save_object();
foreach($this->attributes as $attrs){
if(isset($_POST[$attrs])){
function check()
{
$message= array();
- $str = utf8_encode("üöä");
- if((preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->description))){
- $message[]=_("Please enter a valid description.");
+
+ if(count($this->usedPackages)==0){
+ $message[]=_("Please select a least one Package.");
}
+
+ if((empty($this->FAIdebianRelease))||(empty($this->FAIdebianSection))||(empty($this->FAIdebianMirror))){
+ $message[]=_("Please choose a valid combination for your repository setup.");
+ }
+
return ($message);
}
+ function printUsedPackages(){
+ $a_ret=array();
+ if(is_array($this->usedPackages)) {
+ foreach($this->usedPackages as $usedName){
+ $a_ret[$usedName] = $usedName;
+ }
+ }
+ return($a_ret);
+ }
/* Save to LDAP */
function save()
plugin::save();
$ldap = $this->config->get_ldap_link();
-
+
+ $this->attrs['FAIpackage'] = array();
+ foreach($this->usedPackages as $pkg => $obj){
+ $this->attrs['FAIpackage'][] = $pkg;
+ }
+
$ldap->cat($this->dn);
if($ldap->count()!=0){
/* Write FAIscript to ldap*/