1 <?php
3 class InstallRecipe extends plugin
4 {
5 public $kickstartTemplateDN = "";
6 public $kickstartKeyboardlayout = "";
7 public $kickstartSystemLocale = "";
8 public $kickstartTimezone = "";
9 public $kickstartTimeUTC = "";
10 public $kickstartNTPServer = "";
11 public $kickstartMirrorDN = "";
12 public $kickstartRootEnabled = "";
13 public $kickstartRootPasswordHash = "";
14 public $kickstartKernelPackage = "";
15 public $kickstartPartitionTable = "";
17 public $objectclasses = array('installRecipe');
18 public $attributes = array("kickstartTemplateDN","kickstartKeyboardlayout","kickstartSystemLocale",
19 "kickstartTimezone","kickstartTimeUTC","kickstartNTPServer","kickstartMirrorDN",
20 "kickstartRootEnabled","kickstartRootPasswordHash","kickstartKernelPackage","kickstartPartitionTable");
22 function __construct(&$config, $dn)
23 {
24 plugin::plugin($config, $dn);
26 // Preset some values for new accounts
27 if(!$this->is_account){
29 // Preset the device timezone
30 $tz = timezone::get_default_timezone();
31 $this->kickstartTimezone = $tz['name'];
32 }
34 // Prepare list of timezones
35 $tmp = timezone::_get_tz_zones();
36 $list = array();
37 foreach($tmp['TIMEZONES'] as $name => $offset){
38 if($offset >= 0){
39 $list[$name] = $name." ( + ".sprintf("%0.2f",$offset/(60*60))." "._("hours").")";
40 }else{
41 $offset = $offset * -1;
42 $list[$name] = $name." ( - ".sprintf("%0.2f",($offset/(60*60)))." "._("hours").")";
43 }
44 }
45 uksort($list, 'strnatcasecmp');
46 $this->timezones = $list;
47 }
49 function execute()
50 {
51 plugin::execute();
52 $smarty = get_smarty();
53 $smarty->assign('timezones', $this->timezones);
54 foreach($this->attributes as $attr){
55 $smarty->assign($attr, $this->$attr);
56 }
57 return($smarty->fetch(get_template_path('goto/Device/InstallRecipe.tpl', TRUE)));
58 }
61 function save_object()
62 {
63 plugin::save_object();
64 $this->kickstartRootEnabled = isset($_POST['kickstartRootEnabled']);
65 }
68 function save()
69 {
70 plugin::save();
72 $this->cleanup();
73 $ldap=$this->config->get_ldap_link();
74 $ldap->cd($this->config->current['BASE']);
75 $ldap->cd($this->dn);
76 $ldap->modify($this->attrs);
77 new log("modify","Device/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
78 if (!$ldap->success()){
79 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
80 }else{
81 $this->handle_post_events("modify");
82 }
83 }
85 static function plInfo()
86 {
87 return (array(
88 "plShortName" => _("Device"),
89 "plDescription" => _("Registered device"),
90 "plSelfModify" => FALSE,
91 "plDepends" => array(),
92 "plPriority" => 1,
93 "plSection" => array("administration"),
94 "plCategory" => array("Device"),
95 "plProvidedAcls" => array(
96 "member" => _("Member"),
97 "kickstartTemplateDN" => _("Template"),
98 "kickstartKeyboardlayout" => _("Keyboard layout"),
99 "kickstartSystemLocale" => _("System locale"),
100 "kickstartTimezone" => _("Timezone"),
101 "kickstartTimeUTC" => _("Time"),
102 "kickstartNTPServer" => _("NTP-Server"),
103 "kickstartMirrorDN" => _("Kickstart mirror"),
104 "kickstartRootEnabled" => _("Root login enabled"),
105 "kickstartRootPasswordHash" => _("Root password hash"),
106 "kickstartKernelPackage" => _("Kernal package"),
107 "kickstartPartitionTable" => _("Partition table")
108 )
109 )
110 );
111 }
112 }
114 ?>