1 <?php
3 class askObjectGroup extends plugin
4 {
5 /* attribute list for save action */
6 var $ignore_account = TRUE;
7 var $attributes = array();
8 var $objectclasses = array("whatever");
10 var $objectClass = false;
11 var $ObjectGroup = "";
12 var $ObjectGroups = array();
13 var $sw = "";
14 var $parent;
16 function askObjectGroup (&$config,$dn,$ui, $ObjectClass, $sw)
17 {
18 $this->ui = $ui;
19 plugin::plugin ($config, $dn);
20 $this->ObjectClass = $ObjectClass;
21 $this->sw = $sw;
23 /* Get a list of object groups */
24 $ldap = $this->config->get_ldap_link();
25 $ldap->cd($this->config->current['BASE']);
26 if (isset($this->config->current['HONOURUNITTAGS']) &&
27 preg_match('/true/i', $this->config->current['HONOURUNITTAGS'])) {
28 $ldap->search('(&(objectClass=gosaGroupOfNames)(gosaUnitTag='.$ui->gosaUnitTag.'))', array("cn"));
29 } else {
30 $ldap->search('(objectClass=gosaGroupOfNames)', array("cn"));
31 }
32 $tmp = array();
33 while($attrs = $ldap->fetch()) {
34 $tmp[$attrs['dn']] = $attrs['cn'][0];
35 }
36 asort($tmp, SORT_LOCALE_STRING);
37 $this->ObjectGroups = array_merge(array("" => _("None")), $tmp);
38 }
40 function execute()
41 {
42 /* Call parent execute */
43 plugin::execute();
45 /* Fill templating stuff */
46 $smarty = get_smarty();
47 $display= "";
49 /* Generate headline */
50 $str = "";
51 switch($this->ObjectClass) {
52 case "worktabs": $str =_("Create workstation"); break;
53 default: $str =_("Create");break;
54 }
55 $smarty->assign("headline", $str);
57 $smarty->assign("ogroups", $this->ObjectGroups);
58 $display.= $smarty->fetch(get_template_path('askObjectGroup.tpl', TRUE));
59 return($display);
60 }
62 /* Get posts and set class name
63 */
64 function save_object()
65 {
66 if (isset($_POST['SelectedOgroup']) && isset($_POST['edit_continue'])) {
67 if ($this->ObjectGroup != _("None")) {
68 $this->ObjectGroup = $_POST['SelectedOgroup'];
69 }
70 }
71 }
73 /* Return the class name */
74 function save()
75 {
76 return($this->ObjectGroup);
77 }
79 }
81 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
82 ?>