3
class askClassName extends plugin
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 $forbidden = array();
13
var $ClassAlreadyExists = false;
15
function askClassName ($config, $dn= NULL,$ui = false, $objectClass)
18
$this->objectClass = $objectClass;
19
plugin::plugin ($config, $dn);
20
if(!isset($_SESSION['CurrentMainBase'])){
21
$_SESSION['CurrentMainBase'] = $this->config->current['BASE'];
27
/* Call parent execute */
30
/* Fill templating stuff */
31
$smarty = get_smarty();
34
/* The faifilter contais
35
* The base for all fai objects
37
$faifilter = $_SESSION['faifilter'];
39
/* First search for every ou, in given fai base
40
* With a second search detect all object that belong to the different ous.
43
$base = "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'];
44
if($faifilter['branch'] != "main"){
45
$base = $faifilter['branch'];
47
$ldap = $this->config->get_ldap_link();
48
$res= get_list("(objectClass=organizationalUnit)", $this->ui->subtreeACL, $base,
49
array("cn","description","objectClass"), GL_SIZELIMIT);
53
foreach($res as $objecttypes){
54
$res2= get_list("(objectClass=*)", $this->ui->subtreeACL, $objecttypes['dn'],
55
array("cn","description","objectClass","FAIclass"), GL_SIZELIMIT | GL_CONVERT);
57
foreach($res2 as $object){
58
/* skip class names with this name */
59
if(in_array($this->objectClass,$object['objectClass']) || in_array("FAIprofile",$object['objectClass'])){
60
$delete[] = $object['cn'][0];
64
if(!in_array("FAIprofile",$object['objectClass'])){
65
if(isset($object['cn'])){
66
$used[$object['cn'][0]]= $object['cn'][0];
73
* Depending on the object type we want to create, a different headline will be shown
75
switch($this->objectClass) {
76
case "FAIpartitionTable": $str =_("Create new FAI object - partition table.");break;
77
case "FAIpackageList" : $str =_("Create new FAI object - package bundle.");break;
78
case "FAIscript" : $str =_("Create new FAI object - script bundle.");break;
79
case "FAIvariable" : $str =_("Create new FAI object - variable bundle.");break;
80
case "FAIhook" : $str =_("Create new FAI object - hook bundle.");break;
81
case "FAIprofile" : $str =_("Create new FAI object - profile.");break;
82
case "FAItemplate" : $str =_("Create new FAI object - template.");break;
83
default : $str =_("Create new FAI object");break;
85
$smarty->assign("headline",$str);
87
/* Save forbidden class names
89
$this->forbidden = $delete;
91
/* Delete all class names which already have this type of object
93
foreach($delete as $del){
97
/* if there is no class name which is missing for this type
98
* of objectClass, we only can create a new one, disable selectBox
100
if(count ($used)==0){
101
$smarty->assign("ClassNamesAvailable", " disabled ");
102
$smarty->assign("grey", 'style="color:#C0C0C0"');
104
$smarty->assign("ClassNamesAvailable", "");
105
$smarty->assign("grey", "");
108
$smarty->assign("ClassNames", $used);
109
$smarty->assign("ClassName", $this->ClassName);
110
$display.= $smarty->fetch(get_template_path('askClassName.tpl', TRUE));
114
/* Get posts and set class name
116
function save_object()
118
if(isset($_POST['classSelector']) && $_POST['classSelector'] == 1
119
&& isset($_POST['edit_continue'])){
120
$this->ClassName = $_POST['UseTextInputName'];
121
$this->ClassAlreadyExists = true;
124
if(isset($_POST['classSelector']) && $_POST['classSelector'] == 2
125
&& isset($_POST['edit_continue'])){
126
$this->ClassAlreadyExists = false;
127
$this->ClassName = $_POST['SelectedClass'];
131
/* Check given class name
135
/* Call common method to give check the hook */
136
$message= plugin::check();
138
if($this->ClassName != preg_replace("/ /","",trim($this->ClassName))){
139
$message[] = _("Spaces are not allowed within class names.");
142
if(empty($this->ClassName)){
143
$message[]=_("The given class name is empty.");
146
if(in_array($this->ClassName,$this->forbidden)){
147
$message[]=_("The specified class name is already in use for this object type.");
154
/* Return the class name */
157
return($this->ClassName);
162
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: