groupviews.php 2.88 KB
Newer Older
Richard Mansfield's avatar
Richard Mansfield committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
/**
 * Mahara: Electronic portfolio, weblog, resume builder and social networking
 * Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
 *
 * 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 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */

define('INTERNAL', 1);
28
define('MENUITEM', 'groups');
Richard Mansfield's avatar
Richard Mansfield committed
29
30
31
32
33
34

define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'view');
define('SECTION_PAGE', 'groupviews');

require(dirname(dirname(__FILE__)) . '/init.php');
35
36
require_once(get_config('libroot') . 'view.php');
require_once(get_config('libroot') . 'group.php');
Richard Mansfield's avatar
Richard Mansfield committed
37
38
39
40
require_once('pieforms/pieform.php');

//@todo: group menu; group sideblock

41
42
43
44
45
46
47
$limit   = param_integer('limit', 5);
$offset  = param_integer('offset', 0);
$groupid = param_integer('group');
if (!$group = get_record('group', 'id', $groupid, 'deleted', 0)) {
    throw new GroupNotFoundException("Couldn't find group with id $groupid");
}
define('TITLE', $group->name . ' - ' . get_string('groupviews', 'view'));
Richard Mansfield's avatar
Richard Mansfield committed
48

49
$member = group_user_access($groupid);
50
$shared = param_boolean('shared', 0) && $member;
Richard Mansfield's avatar
Richard Mansfield committed
51
$can_edit = group_user_can_edit_views($groupid);
52

53
$smarty = smarty();
54
$smarty->assign('heading', $group->name);
55

56
57
58
59
60
61
if ($can_edit) {
    $data = View::get_myviews_data($limit, $offset, $groupid);
}
else {
    $data = View::view_search(null, $groupid, null, null, $limit, $offset);
}
Richard Mansfield's avatar
Richard Mansfield committed
62
63
64
65
66
67
68
69
70
71
72
73

$userid = $USER->get('id');

$pagination = build_pagination(array(
    'url' => get_config('wwwroot') . 'view/?',
    'count' => $data->count,
    'limit' => $limit,
    'offset' => $offset,
    'resultcounttextsingular' => get_string('view', 'view'),
    'resultcounttextplural' => get_string('views', 'view')
));

74
$smarty->assign('groupid', $groupid);
Richard Mansfield's avatar
Richard Mansfield committed
75
$smarty->assign('groupviews', 1);
76
$smarty->assign('groupname', $group->name);
77
$smarty->assign('grouptabs', group_get_menu_tabs($group));
78
$smarty->assign('member', $member);
Richard Mansfield's avatar
Richard Mansfield committed
79
80
$smarty->assign('views', $data->data);
$smarty->assign('pagination', $pagination['html']);
81
$smarty->assign('createviewform', pieform(create_view_form($groupid)));
82

83
if ($can_edit) { // && !$shared) {
84
85
86
87
    $smarty->display('view/index.tpl');
} else {
    $smarty->display('view/sharedviews.tpl');
}
Richard Mansfield's avatar
Richard Mansfield committed
88
89

?>