-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgroup.php
93 lines (84 loc) · 2.98 KB
/
group.php
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Copyright 2005-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Chuck Hagenbuch <[email protected]>
* @author Ben Chavet <[email protected]>
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('ansel');
// check for grouping
$groupby = basename(Horde_Util::getFormData('groupby', $prefs->getValue('groupby')));
// check for pref update
$actionID = Horde_Util::getFormData('actionID');
if ($actionID == 'groupby' &&
($groupby == 'owner' || $groupby == 'none')) {
$prefs->setValue('groupby', $groupby);
}
// If we aren't supplied with a page number, default to page 0.
$gbpage = Horde_Util::getFormData('gbpage', 0);
$groups_perpage = $prefs->getValue('groupsperpage');
switch ($groupby) {
case 'owner':
try {
if ($num_groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->shares->countOwners(Horde_Perms::SHOW, null, false)) {
$groups = $GLOBALS['injector']->getInstance('Ansel_Storage')->shares->listOwners(
Horde_Perms::SHOW,
null,
false,
$gbpage * $groups_perpage,
$groups_perpage);
} else {
$groups = array();
}
} catch (Horde_Share_Exception $e) {
$notification->push($e->getMessage());
$num_groups = 0;
$groups = array();
}
break;
default:
Ansel::getUrlFor('view',
array(
'view' => 'List',
'groupby' => $groupby
),
true)->redirect();
exit;
}
// Set up pager.
$vars = Horde_Variables::getDefaultVariables();
$group_pager = new Horde_Core_Ui_Pager('gbpage',
$vars,
array(
'num' => $num_groups,
'url' => 'group.php',
'perpage' => $groups_perpage
));
$min = $gbpage * $groups_perpage;
$max = $min + $groups_perpage;
if ($max > $num_groups) {
$max = $num_groups - $min;
}
$start = $min + 1;
$end = min($num_groups, $min + $groups_perpage);
$count = 0;
$groupby_links = array();
if ($groupby !== 'owner') {
$groupby_links[] = Ansel::getUrlFor('group', array('actionID' => 'groupby', 'groupby' => 'owner'))->link() . _("owner") . '</a>';
}
if ($groupby !== 'none') {
$groupby_links[] = Ansel::getUrlFor('group', array('actionID' => 'groupby', 'groupby' => 'none'))->link() . _("none") . '</a>';
}
$page_output->header();
$notification->notify(array('listeners' => 'status'));
require ANSEL_TEMPLATES . '/group/header.inc';
foreach ($groups as $group) {
require ANSEL_TEMPLATES . '/group/' . $groupby . '.inc';
}
require ANSEL_TEMPLATES . '/group/footer.inc';
require ANSEL_TEMPLATES . '/group/pager.inc';
$page_output->footer();