Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fusiondirectory
fusiondirectory
Commits
75d1e695
Commit
75d1e695
authored
Aug 05, 2014
by
Côme Bernigaud
Committed by
Benoit Mortier
Aug 05, 2014
Browse files
Fixes
#3247
Using objects::open in simpleManagement, added a generic compute_dn
parent
ed260777
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/simpleplugin/class_simpleManagement.inc
View file @
75d1e695
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2013 FusionDirectory
Copyright (C) 2013
-2014
FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -244,35 +244,95 @@ class simpleManagement extends management
return
parent
::
renderList
();
}
// Overridden new handler - We've different types of departments to create!
function
newEntry
(
$action
=
''
,
$target
=
array
(),
$all
=
array
(),
$altTabClass
=
''
,
$altTabType
=
''
,
$altAclCategory
=
''
)
/*!
* \brief This method intiates the object creation.
*
* \param String $action The name of the action which was the used as trigger.
*
* \param Array $target A list of object dns, which should be affected by this method.
*
* \param Array $all A combination of both 'action' and 'target'.
*
* \param String $altTabClass Empty string.
*
* \param String $altTabType Empty string.
*
* \param String $altAclCategory Empty string.
*/
function
newEntry
(
$action
=
""
,
$target
=
array
(),
$all
=
array
(),
$altTabClass
=
""
,
$altTabType
=
""
,
$altAclCategory
=
""
)
{
$type
=
strtoupper
(
preg_replace
(
'/^new_/'
,
''
,
$action
));
$infos
=
$this
->
config
->
data
[
'OBJECTS'
][
$type
];
return
management
::
newEntry
(
$action
,
$target
,
$all
,
$infos
[
'tabClass'
],
$infos
[
'tabGroup'
],
$infos
[
'aclCategory'
]);
$this
->
displayApplyBtn
=
FALSE
;
$this
->
dn
=
'new'
;
$this
->
is_new
=
TRUE
;
$this
->
is_single_edit
=
FALSE
;
set_object_info
(
$this
->
dn
);
// Open object
$this
->
tabObject
=
objects
::
open
(
$this
->
dn
,
$type
);
$this
->
tabObject
->
set_acl_base
(
$this
->
headpage
->
getBase
());
$this
->
tabObject
->
parent
=
&
$this
;
@
DEBUG
(
DEBUG_TRACE
,
__LINE__
,
__FUNCTION__
,
__FILE__
,
$this
->
dn
,
"Create new entry initiated!"
);
}
function
editEntry
(
$action
=
''
,
$target
=
array
(),
$all
=
array
(),
$altTabClass
=
''
,
$altTabType
=
''
,
$altAclCategory
=
''
)
/*!
* \brief This method opens an existing object or a list of existing objects to be edited.
*
* \param String $action The name of the action which was the used as trigger.
*
* \param Array $target A list of object dns, which should be affected by this method.
*
* \param Array $all A combination of both 'action' and 'target'.
*
* \param String $altTabClass Empty string.
*
* \param String $altTabType Empty string.
*
* \param String $altAclCategory Empty string.
*/
function
editEntry
(
$action
=
""
,
$target
=
array
(),
$all
=
array
(),
$altTabClass
=
""
,
$altTabType
=
""
,
$altAclCategory
=
""
)
{
$type
=
$this
->
getType
(
$target
[
0
]);
$infos
=
$this
->
config
->
data
[
'OBJECTS'
][
$type
];
$str
=
management
::
editEntry
(
$action
,
$target
,
$all
,
$infos
[
'tabClass'
],
$infos
[
'tabGroup'
],
$infos
[
'aclCategory'
]);
if
(
isset
(
$all
[
'subaction'
]))
{
$tab
=
preg_replace
(
'/^tab_/'
,
''
,
$all
[
'subaction'
]);
if
(
isset
(
$this
->
tabObject
->
by_object
[
$tab
]))
{
$this
->
tabObject
->
current
=
$tab
;
}
else
{
trigger_error
(
'Unknown tab: '
.
$tab
);
}
// Do not create a new tabObject while there is already one opened,
// the user may have just pressed F5 to reload the page.
if
(
is_object
(
$this
->
tabObject
))
{
return
;
}
if
(
!
empty
(
$str
))
{
return
$str
;
$this
->
displayApplyBtn
=
(
count
(
$target
)
==
1
);
// Single edit - we only got one object dn.
if
(
count
(
$target
)
==
1
)
{
$type
=
$this
->
getType
(
$target
[
0
]);
$this
->
is_new
=
FALSE
;
$this
->
is_single_edit
=
TRUE
;
// Get the dn of the object and creates lock
$this
->
dn
=
array_pop
(
$target
);
set_object_info
(
$this
->
dn
);
$user
=
get_lock
(
$this
->
dn
);
if
(
$user
!=
""
)
{
return
gen_locked_message
(
$user
,
$this
->
dn
,
TRUE
);
}
add_lock
(
$this
->
dn
,
$this
->
ui
->
dn
);
// Open object
$this
->
tabObject
=
objects
::
open
(
$this
->
dn
,
$type
);
$this
->
tabObject
->
set_acl_base
(
$this
->
dn
);
$this
->
tabObject
->
parent
=
&
$this
;
@
DEBUG
(
DEBUG_TRACE
,
__LINE__
,
__FUNCTION__
,
__FILE__
,
$this
->
dn
,
"Edit entry initiated!"
);
if
(
isset
(
$all
[
'subaction'
]))
{
$tab
=
preg_replace
(
'/^tab_/'
,
''
,
$all
[
'subaction'
]);
if
(
isset
(
$this
->
tabObject
->
by_object
[
$tab
]))
{
$this
->
tabObject
->
current
=
$tab
;
}
else
{
trigger_error
(
'Unknown tab: '
.
$tab
);
}
}
}
}
...
...
include/simpleplugin/class_simplePlugin.inc
View file @
75d1e695
...
...
@@ -220,6 +220,25 @@ class simplePlugin extends plugin
return
isset
(
$this
->
attributesAccess
[
$name
]);
}
/*! \brief This function returns the dn this object should have
*/
public
function
compute_dn
()
{
if
(
!
$this
->
mainTab
)
{
die
(
'Only main tab can compute dn'
);
}
if
(
!
isset
(
$this
->
parent
)
||
!
(
$this
->
parent
instanceof
simpleTabs
))
{
die
(
'Could not compute dn: no parent tab class'
);
}
$infos
=
$this
->
parent
->
objectInfos
();
if
(
$infos
===
FALSE
)
{
die
(
'Could not compute dn: cloud not find objectType infos from tab class'
);
}
$attr
=
$infos
[
'mainAttr'
];
$ou
=
$infos
[
'ou'
];
return
$attr
.
'='
.
$this
->
attributesAccess
[
$attr
]
->
computeLdapValue
()
.
','
.
$ou
.
$this
->
base
;
}
/*! \brief This function update the values of LDAP attributes as class attribute,
so that plugin code works correctly
...
...
include/simpleplugin/class_simpleTabs.inc
View file @
75d1e695
...
...
@@ -26,7 +26,8 @@
* */
class
simpleTabs
extends
tabs
{
protected
$specialTabs
=
TRUE
;
public
$objectType
=
FALSE
;
protected
$specialTabs
=
TRUE
;
/*
* You should either call __construct($type, $dn, [$copied_object]) or __construct($config, $data, $dn, $category, [$copied_object])
...
...
@@ -38,7 +39,7 @@ class simpleTabs extends tabs
if
(
is_string
(
func_get_arg
(
0
)))
{
$type
=
func_get_arg
(
0
);
$dn
=
func_get_arg
(
1
);
$infos
=
objects
::
infos
(
$type
);
$infos
=
objects
::
infos
(
$type
);
$config_object
=
$config
;
$data
=
$config
->
data
[
'TABS'
][
$infos
[
'tabGroup'
]];
...
...
@@ -46,6 +47,7 @@ class simpleTabs extends tabs
if
(
func_num_args
()
>=
3
)
{
$copied_object
=
func_get_arg
(
2
);
}
$this
->
objectType
=
$type
;
}
else
{
$config_object
=
func_get_arg
(
0
);
$data
=
func_get_arg
(
1
);
...
...
@@ -82,6 +84,14 @@ class simpleTabs extends tabs
return
parent
::
save
();
}
function
objectInfos
()
{
if
(
$this
->
objectType
===
FALSE
)
{
return
FALSE
;
}
return
objects
::
infos
(
$this
->
objectType
);
}
}
class
simpleTabs_noSpecial
extends
simpleTabs
...
...
Côme Chilliet
@cchilliet
mentioned in issue
#1085 (closed)
·
Sep 02, 2017
mentioned in issue
#1085 (closed)
mentioned in issue #1085
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment