1 | <?php |
---|
2 | /** |
---|
3 | * ProjectManager - Milestones user interface |
---|
4 | * |
---|
5 | * @link http://www.egroupware.org |
---|
6 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
7 | * @package projectmanager |
---|
8 | * @copyright (c) 2005 by Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
---|
10 | * @version $Id: class.uimilestones.inc.php 22355 2006-08-26 16:30:45Z ralfbecker $ |
---|
11 | */ |
---|
12 | |
---|
13 | include_once(PHPGW_INCLUDE_ROOT.'/projectmanager/inc/class.boprojectmanager.inc.php'); |
---|
14 | |
---|
15 | /** |
---|
16 | * Milestones user interface of the projectmanager |
---|
17 | */ |
---|
18 | class uimilestones extends boprojectmanager |
---|
19 | { |
---|
20 | /** |
---|
21 | * @var array $public_functions Functions to call via menuaction |
---|
22 | */ |
---|
23 | var $public_functions = array( |
---|
24 | 'edit' => true, |
---|
25 | 'view' => true, |
---|
26 | ); |
---|
27 | var $tpl; |
---|
28 | |
---|
29 | /** |
---|
30 | * Constructor, calls the constructor of the extended class |
---|
31 | */ |
---|
32 | function uimilestones() |
---|
33 | { |
---|
34 | $this->tpl =& CreateObject('etemplate.etemplate'); |
---|
35 | |
---|
36 | if ((int) $_REQUEST['pm_id']) |
---|
37 | { |
---|
38 | $pm_id = (int) $_REQUEST['pm_id']; |
---|
39 | } |
---|
40 | else |
---|
41 | { |
---|
42 | $pm_id = $GLOBALS['phpgw']->session->appsession('pm_id','projectmanager'); |
---|
43 | } |
---|
44 | if (!$pm_id) |
---|
45 | { |
---|
46 | $this->tpl->location(array( |
---|
47 | 'menuaction' => 'projectmanager.uiprojectmanager.index', |
---|
48 | 'msg' => lang('You need to select a project first'), |
---|
49 | )); |
---|
50 | } |
---|
51 | $this->boprojectmanager($pm_id); |
---|
52 | |
---|
53 | // check if we have at least read-access to this project |
---|
54 | if (!$this->check_acl(PHPGW_ACL_READ)) |
---|
55 | { |
---|
56 | $this->tpl->location(array( |
---|
57 | 'menuaction' => 'projectmanager.uiprojectmanager.index', |
---|
58 | 'msg' => lang('Permission denied !!!'), |
---|
59 | )); |
---|
60 | } |
---|
61 | if (!is_object($this->milestones)) |
---|
62 | { |
---|
63 | $this->milestones =& CreateObject('projectmanager.somilestones'); |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | * View a milestone, only calls edit(null,true); |
---|
69 | */ |
---|
70 | function view() |
---|
71 | { |
---|
72 | $this->edit(null,true); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Edit a milestone |
---|
77 | * |
---|
78 | * @param array $content=null posted content |
---|
79 | * @param boolean $view=false only view the milestone? |
---|
80 | */ |
---|
81 | function edit($content=null,$view=false) |
---|
82 | { |
---|
83 | $view = $view || $content['view'] || !$this->check_acl(PHPGW_ACL_EDIT); |
---|
84 | |
---|
85 | if (is_array($content)) |
---|
86 | { |
---|
87 | if ($content['pm_id'] != $this->data['pm_id']) |
---|
88 | { |
---|
89 | $this->read($content['pm_id']); |
---|
90 | } |
---|
91 | $this->milestones->data_merge($content); |
---|
92 | |
---|
93 | if ($this->check_acl(PHPGW_ACL_EDIT)) |
---|
94 | { |
---|
95 | if ($content['save'] || $content['apply']) |
---|
96 | { |
---|
97 | if ($this->milestones->save() != 0) |
---|
98 | { |
---|
99 | $msg = lang('Error: saving milestone'); |
---|
100 | unset($content['save']); |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | $msg = lang('Milestone saved'); |
---|
105 | $js = "opener.location.href='".$GLOBALS['phpgw']->link('/index.php',array( |
---|
106 | 'menuaction' => 'projectmanager.ganttchart.show', |
---|
107 | 'msg' => $msg, |
---|
108 | ))."';"; |
---|
109 | } |
---|
110 | } |
---|
111 | if ($content['delete'] && $content['ms_id']) |
---|
112 | { |
---|
113 | if ($this->milestones->delete(array( |
---|
114 | 'pm_id' => $content['pm_id'], |
---|
115 | 'ms_id' => $content['ms_id'], |
---|
116 | ))) |
---|
117 | { |
---|
118 | $msg = lang('Milestone deleted'); |
---|
119 | $js = "opener.location.href='".$GLOBALS['phpgw']->link('/index.php',array( |
---|
120 | 'menuaction' => 'projectmanager.ganttchart.show', |
---|
121 | 'msg' => $msg, |
---|
122 | ))."';"; |
---|
123 | } |
---|
124 | } |
---|
125 | if ($content['edit'] && $this->check_acl(PHPGW_ACL_EDIT)) |
---|
126 | { |
---|
127 | $view = false; |
---|
128 | } |
---|
129 | } |
---|
130 | if ($content['save'] || $content['cancel'] || $content['delete']) |
---|
131 | { |
---|
132 | $js .= 'window.close();'; |
---|
133 | echo '<html><body onload="'.$js.'"></body></html>'; |
---|
134 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
135 | } |
---|
136 | } |
---|
137 | elseif ($_REQUEST['ms_id']) |
---|
138 | { |
---|
139 | $this->milestones->read(array( |
---|
140 | 'ms_id' => $_REQUEST['ms_id'], |
---|
141 | )); |
---|
142 | } |
---|
143 | else |
---|
144 | { |
---|
145 | $this->milestones->data['pm_id'] = $this->data['pm_id']; |
---|
146 | } |
---|
147 | $content = $this->milestones->data + array( |
---|
148 | 'msg' => $msg, |
---|
149 | 'js' => '<script>'.$js.'</script>', |
---|
150 | ); |
---|
151 | |
---|
152 | if ($view) |
---|
153 | { |
---|
154 | $readonlys = array( |
---|
155 | 'edit' => !$this->check_acl(PHPGW_ACL_EDIT), |
---|
156 | 'save' => true, |
---|
157 | 'apply' => true, |
---|
158 | 'delete' => true, |
---|
159 | 'pm_id' => true, |
---|
160 | 'ms_title' => true, |
---|
161 | 'ms_date' => true, |
---|
162 | 'ms_description' => true, |
---|
163 | ); |
---|
164 | $sel_options = array( |
---|
165 | 'pm_id' => array($this->data['pm_id'] => $this->data['pm_title']), |
---|
166 | ); |
---|
167 | } |
---|
168 | else |
---|
169 | { |
---|
170 | $readonlys = array( |
---|
171 | 'edit' => true, |
---|
172 | ); |
---|
173 | $sel_options = array( |
---|
174 | 'pm_id' => $this->query_list('pm_title','pm_id'), |
---|
175 | ); |
---|
176 | } |
---|
177 | $readonlys['delete'] = !$this->milestones->data['ms_id'] || !$this->check_acl(PHPGW_ACL_EDIT); |
---|
178 | |
---|
179 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('projectmanager').' - '.($view ? lang('View milestone') : |
---|
180 | ($this->milestones->data['ms_id'] ? lang('Edit milestone') : lang('Add milestone'))); |
---|
181 | $this->tpl->read('projectmanager.milestone.edit'); |
---|
182 | $this->tpl->exec('projectmanager.uimilestones.edit',$content,$sel_options,$readonlys,$this->milestones->data+array( |
---|
183 | 'view' => $view, |
---|
184 | ),2); |
---|
185 | } |
---|
186 | } |
---|