1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
Copyright (C) 2011-2013 FusionDirectory
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class faiPackageConfiguration extends plugin
{
/* attribute list for save action */
var $ignore_account = TRUE;
var $attributes = array();
var $objectclasses = array();
var $Debconf_handle = NULL;
var $pkg_config ;
var $obj;
var $release;
/*! \brief Configure a FAI package entry.
@param Object $config FusionDirectory configuration object;
@param String The DN of the current package.
@param String The package name (e.g. apache)
@param String The release name (e.g. edge)
@param Array The current package configuration.
*/
function faiPackageConfiguration (&$config, $dn= NULL,$obj,$release,$pkg_config)
{
parent::__construct($config, $dn);
$this->obj = $obj;
$this->release = $release;
$this->pkg_config = $pkg_config;
/* Read pkg debconf info from supportDaemon
*/
$q = new supportDaemon();
$ret = $q->FAI_get_packages($this->release,array("package","template"),array($this->obj),0,1,true);
if($q->is_error()){
msg_dialog::display(_("Service infrastructure"),msgPool::siError($q->get_error()),ERROR_DIALOG);
}
/* If we do not get a useable answer, use an empty template
*/
$tpl = "";
if(isset($ret[0]) && isset($ret[0]['TEMPLATE'])){
$tpl = base64_decode($ret[0]['TEMPLATE']);
}
/* Create package configuration mask
*/
$this->Debconf_handle = new debconf(preg_replace('/_.*$/', '', get_browser_language()));
$this->Debconf_handle->load_from_string($tpl);
if($this->Debconf_handle->has_template()){
foreach($this->pkg_config as $var){
$this->Debconf_handle->SetDefault($var['Name'],$var['Value']);
}
}
}
/*! \brief Returns a html interface, that allow to modify
the package attributes.
@return String HTML content/ui for this plugin
*/
function execute()
{
/* Call parent execute */
parent::execute();
/* Fill templating stuff */
$smarty = get_smarty();
$smarty->assign("headline", sprintf(_("Debconf information for package '%s'"), $this->obj));
$this->Debconf_handle->PostCheck();
$smarty->assign("Config",$this->Debconf_handle->get_dialog());
return($smarty->fetch(get_template_path('faiPackageConfiguration.tpl', TRUE)));
}
/* Save data to object */
function save_object()
{
}
/* Check supplied data */
function check()
{
/* Call common method to give check the hook */
$message= plugin::check();
return ($message);
}
/*! \brief Returns an array with all configured attributes
@return Array All configured attributes.
*/
function save()
{
$this->Debconf_handle->PostCheck();
$pkgs = $this->Debconf_handle->template;
$tmp = array();
foreach($pkgs as $pkg){
$tmp[$this->obj][$pkg['Name']]['Value']= $pkg['Default'];
$tmp[$this->obj][$pkg['Name']]['Name'] = $pkg['Name'];
$tmp[$this->obj][$pkg['Name']]['Type'] = $pkg['Type'];
}
return($tmp);
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
|