From e4ebdbe4182b688ece07101ce7cae84967a18f45 Mon Sep 17 00:00:00 2001 From: psc Date: Thu, 18 Feb 2010 09:46:32 +0000 Subject: [PATCH] Apply patch for #2023 - Merge changeset 13812 from GOsa trunk - Always initialize @valid_packages to avoid a PHP error if no valid packages are specified (e.g. if only one package is specified that has invalid characters). - On initialization check for a configuration option "direct_packages_add" in the plugin configuration and depending what is set show a direct add field or not. Default is false. - Update locales git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@15646 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiPackage.inc | 89 ++++++++++++++++++- .../gosa-plugins/fai/admin/fai/faiPackage.tpl | 16 +++- .../fai/locale/de/LC_MESSAGES/messages.po | 59 +++++++----- trunk/gosa-plugins/fai/locale/messages.po | 56 +++++++----- 4 files changed, 172 insertions(+), 48 deletions(-) diff --git a/trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc b/trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc index d33d14807..e877dfd15 100644 --- a/trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc +++ b/trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc @@ -40,7 +40,7 @@ class faiPackage extends plugin var $usedPackages = array(); var $buffer = NULL; - var $newDialogShown =false; + var $newDialogShown = false; var $FAIstate = ""; var $view_logged = FALSE; @@ -52,6 +52,8 @@ class faiPackage extends plugin "hold", "clean", "aptitude", "aptitude-r", "pending", "dpkgc" ); + var $direct_packages_add = FALSE; + function faiPackage (&$config, $dn= NULL) { @@ -145,6 +147,11 @@ class faiPackage extends plugin if($this->dn == "new"){ $this->is_new =TRUE; } + /* Check weither its allowed to directly add packages */ + $direct_packages_add = $config->search("faiManagement","direct_packages_add",array("menu")); + if (preg_match("/^true$/i", $direct_packages_add) || preg_match("/yes/i", $direct_packages_add)) { + $this->direct_packages_add = TRUE; + } /* Generate package list */ $this->list= $this->genPkgs(TRUE); @@ -198,12 +205,89 @@ class faiPackage extends plugin * Add ******/ + if(isset($_POST['AddManualpkg']) && + isset($_POST['addPpkgsText']) && + strlen($_POST['addPpkgsText']) && + $this->acl_is_writeable("FAIpackage") && + !preg_match("/freeze/",$this->FAIstate)){ + + // Check all splitted packages for valid package names + $add_packages = preg_split( "/[\s,]+/", get_post('addPpkgsText'), -1, PREG_SPLIT_NO_EMPTY ); + $valid_packages = array(); + if( is_array($add_packages) ) { + $invalid_packages = array(); + foreach ($add_packages as $value) { + if(!preg_match( "/^[a-z0-9][-0-9a-z+\.]+$/",$value)){ + $invalid_packages[] = trim($value); + }else{ + $valid_packages[] = trim($value); + } + } + if(count($invalid_packages)){ + $str = implode(", ",$invalid_packages); + msg_dialog::display(_("Invalid package names"), + sprintf(_("The following package names don't match the Debian policy: %s"),$str), + ERROR_DIALOG); + } + + + // If we have a complete list of valid packages, add them + if(count($valid_packages)){ + + foreach($valid_packages as $key => $value){ + if(array_key_exists($value,$this->usedPackages)) { + unset($valid_packages[$key]); + } + } + + // Query SI-Deamon for additional package information + $daemon = new gosaSupportDaemon(); + $query_attrs = array("distribution", "package","version", "section", "description", "timestamp"); + $do_si_query = true; + + + foreach ($valid_packages as $value) { + + if( $do_si_query == true ) { + $res = $daemon->FAI_get_packages($this->FAIdebianRelease,$query_attrs,array($value),0,1); + if( ! $daemon->is_error()){ + + if(count($res)){ + + // We just use the last answer - there shouldn't be multiple + $res_attrs = array_pop( $res ); + $this->list[$value] = $res_attrs; + $this->usedPackages[$value] = $res_attrs['PACKAGE']; + + }else{ + $this->usedPackages[$value] = $value; + } + }else{ + msg_dialog::display(_("Service infrastructure"), + msgPool::siError($daemon->get_error()), + ERROR_DIALOG); + $do_si_query = false; + } + } + } + + ksort($this->usedPackages); + + /* Generate package list */ + $this->list= $this->genPkgs(TRUE); + } + } + } + /* + was pressed to open the package dialog */ - if(isset($_POST['Addpkg']) && $this->acl_is_writeable("FAIpackage") && !preg_match("/freeze/",$this->FAIstate)){ + if(isset($_POST['Addpkg']) && + $this->acl_is_writeable("FAIpackage") && + !preg_match("/freeze/",$this->FAIstate)){ $this->dialog = new faiPackageEntry($this->config, $this->FAIdebianRelease,$this->usedPackages); $this->is_dialog =true; } + /* Check image Posts */ foreach($_POST as $name => $value){ @@ -395,6 +479,7 @@ class faiPackage extends plugin $smarty->assign("release" ,$this->FAIdebianRelease); $smarty->assign("sections",$this->sections); $smarty->assign("section" ,$strsec); + $smarty->assign("direct_packages_add", $this->direct_packages_add); $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); return($display); } diff --git a/trunk/gosa-plugins/fai/admin/fai/faiPackage.tpl b/trunk/gosa-plugins/fai/admin/fai/faiPackage.tpl index 3ab7fdebb..3afc580c7 100644 --- a/trunk/gosa-plugins/fai/admin/fai/faiPackage.tpl +++ b/trunk/gosa-plugins/fai/admin/fai/faiPackage.tpl @@ -70,12 +70,22 @@

 {t}Used packages{/t}

{$divlist} -
+ + {render acl=$FAIpackageACL} - -{/render} + + +{if $direct_packages_add} + + +   + +{else} + +{/if} +{/render} diff --git a/trunk/gosa-plugins/fai/locale/de/LC_MESSAGES/messages.po b/trunk/gosa-plugins/fai/locale/de/LC_MESSAGES/messages.po index b46a1fcfc..3ebe8cdf8 100644 --- a/trunk/gosa-plugins/fai/locale/de/LC_MESSAGES/messages.po +++ b/trunk/gosa-plugins/fai/locale/de/LC_MESSAGES/messages.po @@ -13,7 +13,7 @@ msgid "" msgstr "" "Project-Id-Version: messages\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-02-10 15:41+0100\n" +"POT-Creation-Date: 2010-02-11 13:22+0100\n" "PO-Revision-Date: 2008-12-04 11:27+0100\n" "Last-Translator: Cajus Pollmeier \n" "Language-Team: deutsch \n" @@ -52,7 +52,7 @@ msgstr "Sie können diese Erweiterung erst verwenden, wenn FAI aktiviert wurde." #: admin/fai/tabsTemplate.inc:33 admin/fai/class_FAI.inc:548 #: admin/fai/class_faiHook.inc:239 admin/fai/class_faiProfile.inc:259 #: admin/fai/class_faiHookEntry.inc:62 admin/fai/class_faiHookEntry.inc:65 -#: admin/fai/class_faiVariable.inc:142 admin/fai/class_faiPackage.inc:272 +#: admin/fai/class_faiVariable.inc:142 admin/fai/class_faiPackage.inc:356 #: admin/fai/tabsVariable.inc:33 msgid "Error" msgstr "Fehler" @@ -89,8 +89,8 @@ msgstr "FAI Release" #: admin/fai/class_faiVariable.inc:398 admin/fai/class_faiVariableEntry.inc:90 #: admin/fai/class_faiVariableEntry.inc:99 #: admin/fai/class_faiVariableEntry.inc:102 -#: admin/fai/class_faiVariableEntry.inc:137 admin/fai/class_faiPackage.inc:456 -#: admin/fai/class_faiPackage.inc:582 admin/fai/faiPartitionTable.tpl:9 +#: admin/fai/class_faiVariableEntry.inc:137 admin/fai/class_faiPackage.inc:541 +#: admin/fai/class_faiPackage.inc:667 admin/fai/faiPartitionTable.tpl:9 #: admin/fai/faiPartitionTableEntry.tpl:6 admin/fai/faiProfile.tpl:9 msgid "Name" msgstr "Name" @@ -98,7 +98,8 @@ msgstr "Name" #: admin/systems/services/repository/class_servRepository.inc:352 #: admin/fai/class_faiManagement.inc:788 #: admin/fai/class_faiPackageConfiguration.inc:35 admin/fai/class_FAI.inc:566 -#: admin/fai/class_faiPackage.inc:478 admin/fai/class_faiPackageEntry.inc:53 +#: admin/fai/class_faiPackage.inc:266 admin/fai/class_faiPackage.inc:563 +#: admin/fai/class_faiPackageEntry.inc:53 #: admin/fai/class_faiPackageEntry.inc:193 msgid "Service infrastructure" msgstr "Dienst-Infrastruktur" @@ -140,7 +141,7 @@ msgstr "Sektionen" #: admin/systems/services/repository/servRepositorySetup.tpl:19 #: admin/systems/services/repository/class_divListRepositories.inc:23 #: admin/fai/faiPackage.tpl:37 admin/fai/branch_selector.tpl:25 -#: admin/fai/class_faiPackage.inc:588 +#: admin/fai/class_faiPackage.inc:673 msgid "Release" msgstr "Release" @@ -168,7 +169,7 @@ msgid "Add repository" msgstr "Repository hinzufügen" #: admin/fai/faiPackageConfiguration.tpl:1 admin/fai/class_divListFai.inc:68 -#: admin/fai/class_faiPackage.inc:574 +#: admin/fai/class_faiPackage.inc:659 msgid "Package" msgstr "Paket" @@ -286,7 +287,7 @@ msgstr "Nur Lesen" #: admin/fai/faiHookEntry.tpl:19 admin/fai/faiHook.tpl:21 #: admin/fai/class_faiHook.inc:563 admin/fai/class_faiProfile.inc:492 #: admin/fai/class_faiHookEntry.inc:197 admin/fai/class_faiVariable.inc:399 -#: admin/fai/class_faiVariableEntry.inc:138 admin/fai/class_faiPackage.inc:583 +#: admin/fai/class_faiVariableEntry.inc:138 admin/fai/class_faiPackage.inc:668 #: admin/fai/faiPartitionTable.tpl:21 admin/fai/faiPartitionTableEntry.tpl:13 #: admin/fai/faiProfile.tpl:21 msgid "Description" @@ -351,7 +352,7 @@ msgstr "Zeige die Objekte, auf die Folgendes passt" msgid "Generic" msgstr "Allgemein" -#: admin/fai/faiPackage.tpl:45 admin/fai/class_faiPackage.inc:585 +#: admin/fai/faiPackage.tpl:45 admin/fai/class_faiPackage.inc:670 msgid "Section" msgstr "Section" @@ -367,6 +368,10 @@ msgstr "Bitte wählen Sie die Installations-Methode" msgid "Used packages" msgstr "Verwendete Pakete" +#: admin/fai/faiPackage.tpl:82 +msgid "Add from list" +msgstr "Aus Liste hinzufügen" + #: admin/fai/class_faiPartitionTableEntry.inc:176 msgid "primary" msgstr "primär" @@ -529,7 +534,7 @@ msgid "FAI template" msgstr "FAI-Vorlage" #: admin/fai/class_faiTemplate.inc:545 admin/fai/class_faiScript.inc:646 -#: admin/fai/class_faiPackage.inc:585 admin/fai/class_faiPackage.inc:588 +#: admin/fai/class_faiPackage.inc:670 admin/fai/class_faiPackage.inc:673 msgid "Readonly" msgstr "Nur Lesen" @@ -656,7 +661,8 @@ msgstr "Vorlagen-Gruppe" msgid "" "The specified classname '%s' is invalid. Scripts must not start with a dash." msgstr "" -"Der angegebene Klassen-Name ist ungültig. Skripte dürfen nicht mit einem Bindestrich beginnn." +"Der angegebene Klassen-Name ist ungültig. Skripte dürfen nicht mit einem " +"Bindestrich beginnn." #: admin/fai/class_askClassName.inc:189 #, php-format @@ -1409,50 +1415,59 @@ msgstr "Variablen-Eintrag" msgid "FAI variable entry " msgstr "FAI-Variablen-Eintrag" -#: admin/fai/class_faiPackage.inc:329 admin/fai/class_faiPackage.inc:330 +#: admin/fai/class_faiPackage.inc:228 +msgid "Invalid package names" +msgstr "Ungültige Paketnamen" + +#: admin/fai/class_faiPackage.inc:229 +#, php-format +msgid "The following package names don't match the Debian policy: %s" +msgstr "Die folgenden Paketnamen entsprechen nicht der Debian policy: %s" + +#: admin/fai/class_faiPackage.inc:413 admin/fai/class_faiPackage.inc:414 msgid "Configured" msgstr "Konfiguriert" -#: admin/fai/class_faiPackage.inc:336 admin/fai/class_faiPackage.inc:337 +#: admin/fai/class_faiPackage.inc:420 admin/fai/class_faiPackage.inc:421 msgid "Package marked for removal" msgstr "Paket zum Entfernen vorgemerkt" -#: admin/fai/class_faiPackage.inc:353 +#: admin/fai/class_faiPackage.inc:437 msgid "Mark package for removal" msgstr "Paket zum Entfernen vormerken" -#: admin/fai/class_faiPackage.inc:359 +#: admin/fai/class_faiPackage.inc:443 msgid "Configure this package" msgstr "Dieses Paket konfigurieren" -#: admin/fai/class_faiPackage.inc:363 +#: admin/fai/class_faiPackage.inc:447 msgid "Remove this package" msgstr "Dieses Paket entfernen" -#: admin/fai/class_faiPackage.inc:442 +#: admin/fai/class_faiPackage.inc:527 msgid "Please select a least one package!" msgstr "Bitte wählen Sie mindestens ein Paket!" -#: admin/fai/class_faiPackage.inc:446 +#: admin/fai/class_faiPackage.inc:531 msgid "" "Please choose a valid release/section combination for your repository setup!" msgstr "" "Bitte wählen Sie eine gültige Kombination aus Release und Sektion für Ihr " "gewünschtes Repository!" -#: admin/fai/class_faiPackage.inc:575 +#: admin/fai/class_faiPackage.inc:660 msgid "FAI Package list" msgstr "FAI-Paketliste" -#: admin/fai/class_faiPackage.inc:584 +#: admin/fai/class_faiPackage.inc:669 msgid "Packages" msgstr "Pakete" -#: admin/fai/class_faiPackage.inc:586 +#: admin/fai/class_faiPackage.inc:671 msgid "Install Method" msgstr "Installations-Methode" -#: admin/fai/class_faiPackage.inc:587 +#: admin/fai/class_faiPackage.inc:672 msgid "Package configuration" msgstr "Paket-Konfiguration" diff --git a/trunk/gosa-plugins/fai/locale/messages.po b/trunk/gosa-plugins/fai/locale/messages.po index 4a23d8c45..b158485e6 100644 --- a/trunk/gosa-plugins/fai/locale/messages.po +++ b/trunk/gosa-plugins/fai/locale/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-02-10 15:41+0100\n" +"POT-Creation-Date: 2010-02-11 13:22+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -46,7 +46,7 @@ msgstr "" #: admin/fai/tabsTemplate.inc:33 admin/fai/class_FAI.inc:548 #: admin/fai/class_faiHook.inc:239 admin/fai/class_faiProfile.inc:259 #: admin/fai/class_faiHookEntry.inc:62 admin/fai/class_faiHookEntry.inc:65 -#: admin/fai/class_faiVariable.inc:142 admin/fai/class_faiPackage.inc:272 +#: admin/fai/class_faiVariable.inc:142 admin/fai/class_faiPackage.inc:356 #: admin/fai/tabsVariable.inc:33 msgid "Error" msgstr "" @@ -83,8 +83,8 @@ msgstr "" #: admin/fai/class_faiVariable.inc:398 admin/fai/class_faiVariableEntry.inc:90 #: admin/fai/class_faiVariableEntry.inc:99 #: admin/fai/class_faiVariableEntry.inc:102 -#: admin/fai/class_faiVariableEntry.inc:137 admin/fai/class_faiPackage.inc:456 -#: admin/fai/class_faiPackage.inc:582 admin/fai/faiPartitionTable.tpl:9 +#: admin/fai/class_faiVariableEntry.inc:137 admin/fai/class_faiPackage.inc:541 +#: admin/fai/class_faiPackage.inc:667 admin/fai/faiPartitionTable.tpl:9 #: admin/fai/faiPartitionTableEntry.tpl:6 admin/fai/faiProfile.tpl:9 msgid "Name" msgstr "" @@ -92,7 +92,8 @@ msgstr "" #: admin/systems/services/repository/class_servRepository.inc:352 #: admin/fai/class_faiManagement.inc:788 #: admin/fai/class_faiPackageConfiguration.inc:35 admin/fai/class_FAI.inc:566 -#: admin/fai/class_faiPackage.inc:478 admin/fai/class_faiPackageEntry.inc:53 +#: admin/fai/class_faiPackage.inc:266 admin/fai/class_faiPackage.inc:563 +#: admin/fai/class_faiPackageEntry.inc:53 #: admin/fai/class_faiPackageEntry.inc:193 msgid "Service infrastructure" msgstr "" @@ -134,7 +135,7 @@ msgstr "" #: admin/systems/services/repository/servRepositorySetup.tpl:19 #: admin/systems/services/repository/class_divListRepositories.inc:23 #: admin/fai/faiPackage.tpl:37 admin/fai/branch_selector.tpl:25 -#: admin/fai/class_faiPackage.inc:588 +#: admin/fai/class_faiPackage.inc:673 msgid "Release" msgstr "" @@ -160,7 +161,7 @@ msgid "Add repository" msgstr "" #: admin/fai/faiPackageConfiguration.tpl:1 admin/fai/class_divListFai.inc:68 -#: admin/fai/class_faiPackage.inc:574 +#: admin/fai/class_faiPackage.inc:659 msgid "Package" msgstr "" @@ -278,7 +279,7 @@ msgstr "" #: admin/fai/faiHookEntry.tpl:19 admin/fai/faiHook.tpl:21 #: admin/fai/class_faiHook.inc:563 admin/fai/class_faiProfile.inc:492 #: admin/fai/class_faiHookEntry.inc:197 admin/fai/class_faiVariable.inc:399 -#: admin/fai/class_faiVariableEntry.inc:138 admin/fai/class_faiPackage.inc:583 +#: admin/fai/class_faiVariableEntry.inc:138 admin/fai/class_faiPackage.inc:668 #: admin/fai/faiPartitionTable.tpl:21 admin/fai/faiPartitionTableEntry.tpl:13 #: admin/fai/faiProfile.tpl:21 msgid "Description" @@ -341,7 +342,7 @@ msgstr "" msgid "Generic" msgstr "" -#: admin/fai/faiPackage.tpl:45 admin/fai/class_faiPackage.inc:585 +#: admin/fai/faiPackage.tpl:45 admin/fai/class_faiPackage.inc:670 msgid "Section" msgstr "" @@ -357,6 +358,10 @@ msgstr "" msgid "Used packages" msgstr "" +#: admin/fai/faiPackage.tpl:82 +msgid "Add from list" +msgstr "" + #: admin/fai/class_faiPartitionTableEntry.inc:176 msgid "primary" msgstr "" @@ -506,7 +511,7 @@ msgid "FAI template" msgstr "" #: admin/fai/class_faiTemplate.inc:545 admin/fai/class_faiScript.inc:646 -#: admin/fai/class_faiPackage.inc:585 admin/fai/class_faiPackage.inc:588 +#: admin/fai/class_faiPackage.inc:670 admin/fai/class_faiPackage.inc:673 msgid "Readonly" msgstr "" @@ -1344,48 +1349,57 @@ msgstr "" msgid "FAI variable entry " msgstr "" -#: admin/fai/class_faiPackage.inc:329 admin/fai/class_faiPackage.inc:330 +#: admin/fai/class_faiPackage.inc:228 +msgid "Invalid package names" +msgstr "" + +#: admin/fai/class_faiPackage.inc:229 +#, php-format +msgid "The following package names don't match the Debian policy: %s" +msgstr "" + +#: admin/fai/class_faiPackage.inc:413 admin/fai/class_faiPackage.inc:414 msgid "Configured" msgstr "" -#: admin/fai/class_faiPackage.inc:336 admin/fai/class_faiPackage.inc:337 +#: admin/fai/class_faiPackage.inc:420 admin/fai/class_faiPackage.inc:421 msgid "Package marked for removal" msgstr "" -#: admin/fai/class_faiPackage.inc:353 +#: admin/fai/class_faiPackage.inc:437 msgid "Mark package for removal" msgstr "" -#: admin/fai/class_faiPackage.inc:359 +#: admin/fai/class_faiPackage.inc:443 msgid "Configure this package" msgstr "" -#: admin/fai/class_faiPackage.inc:363 +#: admin/fai/class_faiPackage.inc:447 msgid "Remove this package" msgstr "" -#: admin/fai/class_faiPackage.inc:442 +#: admin/fai/class_faiPackage.inc:527 msgid "Please select a least one package!" msgstr "" -#: admin/fai/class_faiPackage.inc:446 +#: admin/fai/class_faiPackage.inc:531 msgid "" "Please choose a valid release/section combination for your repository setup!" msgstr "" -#: admin/fai/class_faiPackage.inc:575 +#: admin/fai/class_faiPackage.inc:660 msgid "FAI Package list" msgstr "" -#: admin/fai/class_faiPackage.inc:584 +#: admin/fai/class_faiPackage.inc:669 msgid "Packages" msgstr "" -#: admin/fai/class_faiPackage.inc:586 +#: admin/fai/class_faiPackage.inc:671 msgid "Install Method" msgstr "" -#: admin/fai/class_faiPackage.inc:587 +#: admin/fai/class_faiPackage.inc:672 msgid "Package configuration" msgstr "" -- 2.30.2