1 <?php
3 class InstallRecipe extends plugin
4 {
5 public $member = array();
6 public $ksTemplate = "";
7 public $ksKeyboardlayout = "";
8 public $ksSystemLocale = "";
9 public $ksTimezone = "";
10 public $ksTimeUTC = "";
11 public $ksNTPServer = "";
12 public $ksMirror = "";
13 public $ksMirrorTorrent = "";
14 public $ksRootEnabled = "";
15 public $ksRootPasswordHash = "";
16 public $ksKernelPackage = "";
17 public $ksPartitionTable = "";
19 public $objectclasses = array('installRecipe');
20 public $attributes = array("member","ksTemplate","ksKeyboardlayout","ksSystemLocale",
21 "ksTimezone","ksTimeUTC","ksNTPServer","ksMirror","ksMirrorTorrent",
22 "ksRootEnabled","ksRootPasswordHash","ksKernelPackage","ksPartitionTable");
24 function __construct(&$config, $dn)
25 {
26 plugin::plugin($config, $dn);
28 // Prepare list of timezones
29 $tmp = timezone::_get_tz_zones();
30 $list = array();
31 foreach($tmp['TIMEZONES'] as $name => $offset){
32 if($offset >= 0){
33 $list[$name] = $name." ( + ".sprintf("%0.2f",$offset/(60*60))." "._("hours").")";
34 }else{
35 $offset = $offset * -1;
36 $list[$name] = $name." ( - ".sprintf("%0.2f",($offset/(60*60)))." "._("hours").")";
37 }
38 }
39 $this->timezones = $list;
40 }
42 function execute()
43 {
44 plugin::execute();
45 $smarty = get_smarty();
46 $smarty->assign('timezones', $this->timezones);
47 foreach($this->attributes as $attr){
48 $smarty->assign($attr, $this->$attr);
49 }
50 return($smarty->fetch(get_template_path('goto/Device/InstallRecipe.tpl', TRUE)));
51 }
54 function save()
55 {
56 plugin::save();
57 $this->cleanup();
58 $ldap=$this->config->get_ldap_link();
59 $ldap->cd($this->config->current['BASE']);
60 $ldap->cd($this->dn);
61 $ldap->modify($this->attrs);
62 new log("modify","Device/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
63 if (!$ldap->success()){
64 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
65 }else{
66 $this->handle_post_events("modify");
67 }
68 }
70 static function plInfo()
71 {
72 return (array(
73 "plShortName" => _("Device"),
74 "plDescription" => _("Registered device"),
75 "plSelfModify" => FALSE,
76 "plDepends" => array(),
77 "plPriority" => 1,
78 "plSection" => array("administration"),
79 "plCategory" => array("Device"),
80 "plProvidedAcls" => array(
81 "member" => _("Member"),
82 "ksTemplate" => _("Template"),
83 "ksKeyboardlayout" => _("Keyboard layout"),
84 "ksSystemLocale" => _("System locale"),
85 "ksTimezone" => _("Timezone"),
86 "ksTimeUTC" => _("Time"),
87 "ksNTPServer" => _("NTP-Server"),
88 "ksMirror" => _("Kickstart mirror"),
89 "ksMirrorTorrent" => _("Kickstart torrent mirror"),
90 "ksRootEnabled" => _("Root login enabled"),
91 "ksRootPasswordHash" => _("Root password hash"),
92 "ksKernelPackage" => _("Kernal package"),
93 "ksPartitionTable" => _("Partition table")
94 )
95 )
96 );
97 }
98 }
100 ?>