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
bc77b97d
Commit
bc77b97d
authored
Sep 09, 2014
by
Côme Bernigaud
Committed by
Benoit Mortier
Sep 09, 2014
Browse files
Added template management into simpleManagement
parent
b9dd2f34
Changes
3
Hide whitespace changes
Inline
Side-by-side
ihtml/themes/default/simpleplugin.tpl
View file @
bc77b97d
...
...
@@ -4,7 +4,13 @@
{/
foreach
}
</div>
<input
name=
"
{
$hiddenPostedInput
}
"
value=
"1"
type=
"hidden"
/>
{
if
is_array
(
$hiddenPostedInput
)
}
{
foreach
from
=
$hiddenPostedInput
item
=
hiddenPostedInput_item
}
<input
name=
"
{
$hiddenPostedInput_item
}
"
value=
"1"
type=
"hidden"
/>
{/
foreach
}
{
else
}
<input
name=
"
{
$hiddenPostedInput
}
"
value=
"1"
type=
"hidden"
/>
{/
if
}
<!-- Place cursor -->
<script
type=
"text/javascript"
>
...
...
include/simpleplugin/class_simpleManagement.inc
View file @
bc77b97d
...
...
@@ -18,6 +18,76 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class
templateDialog
{
protected
$simpleManagement
;
protected
$type
;
protected
$template
=
NULL
;
protected
$templates
;
protected
$tabObject
;
protected
$post_finish
=
'template_continue'
;
protected
$post_cancel
=
'template_cancel'
;
function
__construct
(
$simpleManagement
,
$type
)
{
$this
->
simpleManagement
=
$simpleManagement
;
$this
->
type
=
$type
;
$this
->
templates
=
objects
::
getTemplates
(
$this
->
type
);
}
function
save_object
()
{
if
(
isset
(
$_POST
[
$this
->
post_cancel
]))
{
return
$this
->
handle_cancel
();
}
if
((
isset
(
$_POST
[
$this
->
post_finish
])
||
isset
(
$_GET
[
$this
->
post_finish
]))
&&
is_object
(
$this
->
template
))
{
$this
->
template
->
save_object
();
return
$this
->
handle_finish
();
}
if
(
isset
(
$_POST
[
'template'
])
&&
isset
(
$this
->
templates
[
$_POST
[
'template'
]])
)
{
if
(
is_object
(
$this
->
template
))
{
trigger_error
(
'redefining template object'
);
}
$this
->
template
=
new
template
(
$this
->
type
,
$_POST
[
'template'
]);
}
if
(
is_object
(
$this
->
template
))
{
$this
->
template
->
save_object
();
}
return
TRUE
;
}
function
execute
()
{
$smarty
=
get_smarty
();
if
(
is_object
(
$this
->
template
))
{
$smarty
->
assign
(
'template_dialog'
,
$this
->
template
->
execute
());
}
else
{
$smarty
->
assign
(
'templates'
,
$this
->
templates
);
}
$display
=
$smarty
->
fetch
(
get_template_path
(
'template.tpl'
));
return
$display
;
}
function
handle_finish
()
{
$this
->
simpleManagement
->
closeDialogs
();
$this
->
simpleManagement
->
openTabObject
(
$this
->
template
->
apply
(),
$this
->
template
->
getBase
());
return
FALSE
;
}
function
handle_cancel
()
{
$this
->
simpleManagement
->
closeDialogs
();
return
FALSE
;
}
}
class
simpleManagement
extends
management
{
...
...
@@ -129,6 +199,8 @@ class simpleManagement extends management
$this
->
headpage
->
categories
[]
=
$i
[
'aclCategory'
];
if
(
$this
->
autoActions
)
{
$this
->
registerAction
(
'new_'
.
$object
,
'newEntry'
);
$this
->
registerAction
(
'new_template_'
.
$object
,
'newEntryTemplate'
);
$this
->
registerAction
(
'template_apply_'
.
$object
,
'newEntryFromTemplate'
);
$icon
=
'geticon.php?context=actions&icon=document-new&size=16'
;
if
(
isset
(
$i
[
'icon'
]))
{
$icon
=
$i
[
'icon'
];
...
...
@@ -145,6 +217,20 @@ class simpleManagement extends management
'label'
=>
$i
[
'name'
],
'acl'
=>
$i
[
'aclCategory'
]
.
'/'
.
$i
[
'mainTab'
]
.
'[c]'
,
);
$this
->
headpage
->
xmlData
[
'actionmenu'
][
'action'
][
0
][
'action'
][]
=
array
(
'name'
=>
'new_template_'
.
$object
,
'type'
=>
'entry'
,
'image'
=>
$icon
,
'label'
=>
sprintf
(
_
(
'%s template'
),
$i
[
'name'
]),
'acl'
=>
$i
[
'aclCategory'
]
.
'/'
.
$i
[
'mainTab'
]
.
'[c]'
,
);
$this
->
headpage
->
xmlData
[
'actionmenu'
][
'action'
][
0
][
'action'
][]
=
array
(
'name'
=>
'template_apply_'
.
$object
,
'type'
=>
'entry'
,
'image'
=>
$icon
,
'label'
=>
sprintf
(
_
(
'%s from template'
),
$i
[
'name'
]),
'acl'
=>
$i
[
'aclCategory'
]
.
'/'
.
$i
[
'mainTab'
]
.
'[c]'
,
);
}
}
$this
->
headpage
->
registerElementFilter
(
'filterRowLink'
,
'simpleManagement::filterRowLink'
);
...
...
@@ -186,7 +272,7 @@ class simpleManagement extends management
if
(
$this
->
autoFilter
)
{
$this
->
configureFilterCategory
();
$attributes
=
$this
->
autoFilterAttributes
;
$filter
=
'(|'
;
$filter
=
'(|'
;
foreach
(
$this
->
objectTypes
as
$object
)
{
$tag
=
'FILTER'
.
$object
;
$filter
.
=
'$'
.
$tag
;
...
...
@@ -220,7 +306,7 @@ class simpleManagement extends management
$contents
=
file_get_contents
(
$file
);
$data
=
xml
::
xml2array
(
$contents
,
1
);
foreach
(
array
(
'departmentBrowser'
,
'departmentRootVisible'
,
'baseMode'
,
'multiSelect'
)
as
$var
)
{
$data
[
'list'
][
'definition'
][
"
$var
"
]
=
(
$this
->
$var
?
'true'
:
'false'
);
$data
[
'list'
][
'definition'
][
"
$var
"
]
=
(
$this
->
$var
?
'true'
:
'false'
);
}
return
$data
;
}
...
...
@@ -272,12 +358,23 @@ class simpleManagement extends management
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
;
$this
->
openTabObject
(
objects
::
open
(
$this
->
dn
,
$type
),
$this
->
headpage
->
getBase
());
@
DEBUG
(
DEBUG_TRACE
,
__LINE__
,
__FUNCTION__
,
__FILE__
,
$this
->
dn
,
"Create new entry initiated!"
);
}
function
newEntryTemplate
(
$action
=
""
,
$target
=
array
(),
$all
=
array
())
{
$action
=
preg_replace
(
'/^new_template_/'
,
'new_'
,
$action
);
$this
->
newEntry
(
$action
,
$target
,
$all
);
$this
->
tabObject
->
setTemplateMode
(
'template_cn'
);
}
function
newEntryFromTemplate
(
$action
)
{
$type
=
preg_replace
(
'/^template_apply_/'
,
''
,
$action
);
$this
->
dialogObject
=
new
templateDialog
(
$this
,
$type
);
}
/*!
* \brief This method opens an existing object or a list of existing objects to be edited.
...
...
@@ -321,9 +418,7 @@ class simpleManagement extends management
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
;
$this
->
openTabObject
(
objects
::
open
(
$this
->
dn
,
$type
),
$this
->
dn
);
@
DEBUG
(
DEBUG_TRACE
,
__LINE__
,
__FUNCTION__
,
__FILE__
,
$this
->
dn
,
"Edit entry initiated!"
);
if
(
isset
(
$all
[
'subaction'
]))
{
$tab
=
preg_replace
(
'/^tab_/'
,
''
,
$all
[
'subaction'
]);
...
...
@@ -422,9 +517,8 @@ class simpleManagement extends management
$acl
=
$this
->
ui
->
get_permissions
(
$dn
,
$infos
[
'aclCategory'
]
.
"/"
.
$infos
[
'mainTab'
]);
if
(
preg_match
(
"/d/"
,
$acl
))
{
// Delete the object
$this
->
dn
=
$dn
;
$this
->
tabObject
=
objects
::
open
(
$this
->
dn
,
$type
);
$this
->
tabObject
->
parent
=
&
$this
;
$this
->
dn
=
$dn
;
$this
->
openTabObject
(
objects
::
open
(
$this
->
dn
,
$type
),
$this
->
dn
);
$this
->
tabObject
->
delete
();
// Remove the lock for the current object.
...
...
include/simpleplugin/class_simplePlugin.inc
View file @
bc77b97d
...
...
@@ -117,33 +117,7 @@ class simplePlugin extends plugin
// We call plugin constructor
parent
::
__construct
(
$config
,
$dn
,
$object
);
if
(
$this
->
is_template
&&
$this
->
mainTab
)
{
/* Unshift special section for template infos */
$this
->
attributesInfo
=
array_merge
(
array
(
'_template'
=>
array
(
'class'
=>
array
(
'fullwidth'
),
'name'
=>
_
(
'Template settings'
),
'attrs'
=>
array
(
'_template_cn'
=>
new
StringAttribute
(
_
(
'Template name'
),
_
(
'This is the name of the template'
),
'_template_cn'
,
TRUE
)
)
),
'_template_dummy'
=>
array
(
'class'
=>
array
(
'invisible'
),
'name'
=>
'_template_dummy'
,
'attrs'
=>
array
()
)
),
$this
->
attributesInfo
);
$this
->
attributesAccess
[
'_template_cn'
]
=&
$this
->
attributesInfo
[
'_template'
][
'attrs'
][
'_template_cn'
];
$this
->
attributesAccess
[
'_template_cn'
]
->
setInLdap
(
FALSE
);
$this
->
attributesAccess
[
'_template_cn'
]
->
setValue
(
$this
->
_template_cn
);
unset
(
$this
->
_template_cn
);
}
$this
->
setTemplate
(
$this
->
is_template
);
$this
->
orig_dn
=
$dn
;
...
...
@@ -176,6 +150,38 @@ class simplePlugin extends plugin
}
}
function
setTemplate
(
$bool
)
{
parent
::
setTemplate
(
$bool
);
if
(
$this
->
is_template
&&
$this
->
mainTab
)
{
/* Unshift special section for template infos */
$this
->
attributesInfo
=
array_merge
(
array
(
'_template'
=>
array
(
'class'
=>
array
(
'fullwidth'
),
'name'
=>
_
(
'Template settings'
),
'attrs'
=>
array
(
'_template_cn'
=>
new
StringAttribute
(
_
(
'Template name'
),
_
(
'This is the name of the template'
),
'_template_cn'
,
TRUE
)
)
),
'_template_dummy'
=>
array
(
'class'
=>
array
(
'invisible'
),
'name'
=>
'_template_dummy'
,
'attrs'
=>
array
()
)
),
$this
->
attributesInfo
);
$this
->
attributesAccess
[
'_template_cn'
]
=&
$this
->
attributesInfo
[
'_template'
][
'attrs'
][
'_template_cn'
];
$this
->
attributesAccess
[
'_template_cn'
]
->
setInLdap
(
FALSE
);
$this
->
attributesAccess
[
'_template_cn'
]
->
setValue
(
$this
->
_template_cn
);
unset
(
$this
->
_template_cn
);
}
}
protected
function
loadAttributes
()
{
// We load attributes values
...
...
@@ -271,6 +277,17 @@ class simplePlugin extends plugin
return
$attr
.
'='
.
$this
->
attributesAccess
[
$attr
]
->
computeLdapValue
()
.
','
.
$ou
.
$this
->
base
;
}
function
getRequiredAttributes
()
{
$tmp
=
array
();
foreach
(
$this
->
attributesAccess
as
$attr
)
{
if
(
$attr
->
isRequired
())
{
$tmp
[]
=
$attr
->
getLdapName
();
}
}
return
$tmp
;
}
/*! \brief This function update the values of LDAP attributes as class attribute,
so that plugin code works correctly
...
...
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