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
mahara
mahara
Commits
297cd029
Commit
297cd029
authored
Nov 14, 2006
by
Martyn Smith
Committed by
Martyn Smith
Nov 14, 2006
Browse files
Add edit groups
parent
2c488e69
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/contacts/groups/edit.php
0 → 100644
View file @
297cd029
<?php
/**
* This program is part of Mahara
*
* 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
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core
* @author Martyn Smith <martyn@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
define
(
'MENUITEM'
,
'mycontacts'
);
define
(
'SUBMENUITEM'
,
'mygroups'
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
require_once
(
'form.php'
);
$id
=
param_integer
(
'id'
,
null
);
$group_data
=
get_record
(
'usr_group'
,
'id'
,
$id
,
'owner'
,
$USER
->
id
);
if
(
!
$group_data
)
{
$SESSION
->
add_err_msg
(
get_string
(
'canteditdontown'
));
redirect
(
'./'
);
}
$group_members
=
get_column
(
'usr_group_member'
,
'member'
,
'grp'
,
$group_data
->
id
);
$editgroup
=
form
(
array
(
'name'
=>
'editgroup'
,
'method'
=>
'post'
,
'elements'
=>
array
(
'name'
=>
array
(
'type'
=>
'text'
,
'title'
=>
get_string
(
'groupname'
),
'rules'
=>
array
(
'required'
=>
true
),
'defaultvalue'
=>
$group_data
->
name
,
),
'description'
=>
array
(
'type'
=>
'wysiwyg'
,
'title'
=>
get_string
(
'groupdescription'
),
'rows'
=>
10
,
'cols'
=>
80
,
'defaultvalue'
=>
$group_data
->
description
,
),
'members'
=>
array
(
'type'
=>
'userlist'
,
'title'
=>
get_string
(
'groupmembers'
),
'rules'
=>
array
(
'required'
=>
true
),
'defaultvalue'
=>
$group_members
,
),
'id'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$id
,
),
'submit'
=>
array
(
'type'
=>
'submitcancel'
,
'value'
=>
array
(
get_string
(
'savegroup'
),
get_string
(
'cancel'
)),
),
),
));
function
editgroup_validate
(
Form
$form
,
$values
)
{
global
$USER
;
global
$SESSION
;
$gid
=
get_field
(
'usr_group'
,
'id'
,
'owner'
,
$USER
->
id
,
'name'
,
$values
[
'name'
]);
if
(
$gid
&&
$gid
!=
$values
[
'id'
])
{
$form
->
set_error
(
'name'
,
get_string
(
'groupalreadyexists'
));
}
// check owner
$id
=
get_field
(
'usr_group'
,
'id'
,
'id'
,
$values
[
'id'
],
'owner'
,
$USER
->
id
);
if
(
!
$id
)
{
$SESSION
->
add_err_msg
(
get_string
(
'canteditdontown'
));
redirect
(
'./'
);
}
}
function
editgroup_cancel_submit
()
{
redirect
(
'./'
);
}
function
editgroup_submit
(
$values
)
{
global
$USER
;
global
$SESSION
;
db_begin
();
$now
=
db_format_timestamp
(
time
());
update_record
(
'usr_group'
,
(
object
)
array
(
'id'
=>
$values
[
'id'
],
'name'
=>
$values
[
'name'
],
'owner'
=>
$USER
->
id
,
'description'
=>
$values
[
'description'
],
'mtime'
=>
$now
,
),
'id'
);
delete_records
(
'usr_group_member'
,
'grp'
,
$values
[
'id'
]);
foreach
(
$values
[
'members'
]
as
$member
)
{
insert_record
(
'usr_group_member'
,
(
object
)
array
(
'grp'
=>
$values
[
'id'
],
'member'
=>
$member
,
'ctime'
=>
$now
,
)
);
}
$SESSION
->
add_ok_msg
(
get_string
(
'groupsaved'
));
db_commit
();
redirect
(
'./'
);
}
$smarty
=
smarty
();
$smarty
->
assign
(
'editgroup'
,
$editgroup
);
$smarty
->
display
(
'contacts/groups/edit.tpl'
);
?>
htdocs/theme/default/templates/contacts/groups/edit.tpl
0 → 100644
View file @
297cd029
{
include
file
=
"header.tpl"
}
{
include
file
=
"adminmenu.tpl"
}
<div
class=
"content"
>
<h2>
{
str
tag
=
"editgroup"
}
</h2>
{
$editgroup
}
</div>
{
include
file
=
"footer.tpl"
}
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