/
SetController.php
85 lines (79 loc) · 3.58 KB
/
SetController.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
<?php
/* ----------------------------------------------------------------------
* app/controllers/manage/SetController.php :
* ----------------------------------------------------------------------
* CollectiveAccess
* Open-source collections management software
* ----------------------------------------------------------------------
*
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
* Copyright 2009 Whirl-i-Gig
*
* For more information visit http://www.CollectiveAccess.org
*
* This program is free software; you may redistribute it and/or modify it under
* the terms of the provided license as published by Whirl-i-Gig
*
* CollectiveAccess is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* This source code is free and modifiable under the terms of
* GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
* the "license.txt" file for details, or visit the CollectiveAccess web site at
* http://www.CollectiveAccess.org
*
* ----------------------------------------------------------------------
*/
require_once(__CA_LIB_DIR__."/core/Controller/ActionController.php");
require_once(__CA_LIB_DIR__."/ca/ResultContext.php");
require_once(__CA_MODELS_DIR__."/ca_sets.php");
class SetController extends ActionController {
# -------------------------------------------------------
public function ListSets() {
JavascriptLoadManager::register('tableList');
$t_set = new ca_sets();
$this->view->setVar('t_set', $t_set);
$va_set_list = caExtractValuesByUserLocale($t_set->getSets(array('user_id' => $this->request->getUserID(), 'access' => __CA_SET_EDIT_ACCESS__)), null, null, array());
if ($va_set_list) {
foreach ($va_set_list as $id => $va_set) {
$va_set_list[$id]['can_delete'] = $this->UserCanDeleteSet($va_set['user_id']);
}
}
$this->view->setVar('set_list', $va_set_list);
// get content types for sets
$this->view->setVar('table_list', caFilterTableList($t_set->getFieldInfo('table_num', 'BOUNDS_CHOICE_LIST')));
//$t_set->htmlFormElement('table_num', '', array('id' => 'tableList'))
$o_result_context = new ResultContext($this->request, 'ca_sets', 'basic_search');
$o_result_context->setAsLastFind();
$o_result_context->setResultList(array_keys($va_set_list));
$o_result_context->saveContext();
$this->render('set_list_html.php');
}
# -------------------------------------------------------
private function UserCanDeleteSet($user_id) {
$can_delete = FALSE;
// If users can delete all sets, show Delete button
if ($this->request->user->canDoAction('can_delete_sets')) {
$can_delete = TRUE;
}
// If users can delete own sets, and this set belongs to them, show Delete button
if ($this->request->user->canDoAction('can_delete_own_sets')) {
if ($user_id == $this->request->getUserID()) {
$can_delete = TRUE;
}
}
return $can_delete;
}
# -------------------------------------------------------
/**
*
*/
public function Info() {
$t_set = new ca_sets($vn_set_id = $this->request->getParameter('set_id', pInteger));
$this->view->setVar('sets', caExtractValuesByUserLocale($t_set->getSets(array('user_id' => $this->request->getUserID(), 'access' => __CA_SET_EDIT_ACCESS__)), null, null, array()));
return $this->render('widget_set_info_html.php', true);
}
# -------------------------------------------------------
}
?>