Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117879243
kolab_client_task_group.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
kolab_client_task_group.php
View Options
<?php
/*
+--------------------------------------------------------------------------+
| This file is part of the Kolab Web Admin Panel |
| |
| Copyright (C) 2011-2012, Kolab Systems AG |
| |
| This program is free software: you can redistribute it and/or modify |
| it under the terms of the GNU Affero General Public License as published |
| by the Free Software Foundation, either version 3 of the License, or |
| (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public License |
| along with this program. If not, see <http://www.gnu.org/licenses/> |
+--------------------------------------------------------------------------+
| Author: Aleksander Machniak <machniak@kolabsys.com> |
+--------------------------------------------------------------------------+
*/
class
kolab_client_task_group
extends
kolab_client_task
{
protected
$ajax_only
=
true
;
protected
$menu
=
array
(
'add'
=>
'group.add'
,
);
protected
$list_attribs
=
array
(
'cn'
);
/**
* Default action.
*/
public
function
action_default
()
{
$this
->
output
->
set_object
(
'content'
,
'group'
,
true
);
$this
->
output
->
set_object
(
'task_navigation'
,
$this
->
menu
());
$this
->
action_list
();
// display form to add group if logged-in user has right to do so
$caps
=
$this
->
get_capability
(
'actions'
);
if
(!
empty
(
$caps
[
'group.add'
]))
{
$this
->
action_add
();
}
else
{
$this
->
output
->
command
(
'set_watermark'
,
'taskcontent'
);
}
}
/**
* Group information (form) action.
*/
public
function
action_info
()
{
$id
=
$this
->
get_input
(
'id'
,
'POST'
);
$result
=
$this
->
api_get
(
'group.info'
,
array
(
'id'
=>
$id
));
$group
=
$result
->
get
();
$output
=
$this
->
group_form
(
null
,
$group
);
$this
->
output
->
set_object
(
'taskcontent'
,
$output
);
}
/**
* Groups adding (form) action.
*/
public
function
action_add
()
{
$data
=
$this
->
get_input
(
'data'
,
'POST'
);
$output
=
$this
->
group_form
(
null
,
$data
,
true
);
$this
->
output
->
set_object
(
'taskcontent'
,
$output
);
}
/**
* Group edit/add form.
*/
private
function
group_form
(
$attribs
,
$data
=
array
())
{
if
(
empty
(
$attribs
[
'id'
]))
{
$attribs
[
'id'
]
=
'group-form'
;
}
// Form sections
$sections
=
array
(
'system'
=>
'group.system'
,
'other'
=>
'group.other'
,
);
// field-to-section map and fields order
$fields_map
=
array
(
'type_id'
=>
'system'
,
'type_id_name'
=>
'system'
,
'cn'
=>
'system'
,
'gidnumber'
=>
'system'
,
'mail'
=>
'system'
,
'member'
=>
'system'
,
'uniquemember'
=>
'system'
,
'memberurl'
=>
'system'
,
);
// Prepare fields
list
(
$fields
,
$types
,
$type
)
=
$this
->
form_prepare
(
'group'
,
$data
);
$add_mode
=
empty
(
$data
[
'id'
]);
$accttypes
=
array
();
foreach
(
$types
as
$idx
=>
$elem
)
{
$accttypes
[
$idx
]
=
array
(
'value'
=>
$idx
,
'content'
=>
$elem
[
'name'
]);
}
// Add user type id selector
$fields
[
'type_id'
]
=
array
(
'section'
=>
'system'
,
'type'
=>
kolab_form
::
INPUT_SELECT
,
'options'
=>
$accttypes
,
'onchange'
=>
"kadm.group_save(true, 'system')"
,
);
// Hide account type selector if there's only one type
if
(
count
(
$accttypes
)
<
2
||
!
$add_mode
)
{
$fields
[
'type_id'
][
'type'
]
=
kolab_form
::
INPUT_HIDDEN
;
}
// Create mode
if
(
$add_mode
)
{
// Page title
$title
=
$this
->
translate
(
'group.add'
);
}
// Edit mode
else
{
$title
=
$data
[
'cn'
];
// Add user type name
$fields
[
'type_id_name'
]
=
array
(
'label'
=>
'group.type_id'
,
'section'
=>
'system'
,
'value'
=>
$accttypes
[
$type
][
'content'
],
);
}
// Create form object and populate with fields
$form
=
$this
->
form_create
(
'group'
,
$attribs
,
$sections
,
$fields
,
$fields_map
,
$data
,
$add_mode
);
$form
->
set_title
(
kolab_html
::
escape
(
$title
));
return
$form
->
output
();
}
private
function
parse_members
(
$list
)
{
// convert to key=>value array, see kolab_api_service_form_value::list_options_uniquemember()
foreach
(
$list
as
$idx
=>
$value
)
{
if
(!
empty
(
$value
[
'displayname'
]))
{
$list
[
$idx
]
=
$value
[
'displayname'
];
}
elseif
(!
empty
(
$value
[
'cn'
]))
{
$list
[
$idx
]
=
$value
[
'cn'
];
}
else
{
//console("No display name or cn for $idx");
}
if
(!
empty
(
$value
[
'mail'
]))
{
$list
[
$idx
]
.=
' <'
.
$value
[
'mail'
]
.
'>'
;
}
}
return
$list
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Apr 5, 10:51 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823706
Default Alt Text
kolab_client_task_group.php (5 KB)
Attached To
Mode
rWAP webadmin
Attached
Detach File
Event Timeline