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