3 * Project Management Facility : Admin
5 * Copyright 1999/2000, Sourceforge.net Tim Perdue
6 * Copyright 2002 GForge, LLC, Tim Perdue
7 * Copyright 2010, FusionForge Team
8 * http://fusionforge.org
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with FusionForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 require_once('../../env.inc.php');
28 require_once $gfcommon.'include/pre.php';
29 require_once $gfwww.'pm/include/ProjectGroupHTML.class.php';
30 require_once $gfcommon.'pm/ProjectGroupFactory.class.php';
31 require_once $gfcommon.'pm/ProjectCategory.class.php';
33 if (!session_loggedin()) {
37 $group_id = getIntFromRequest('group_id');
38 $group_project_id = getIntFromRequest('group_project_id');
44 $g = group_get_object($group_id);
45 if (!$g || !is_object($g)) {
47 } elseif ($g->isError()) {
48 exit_error($g->getErrorMessage(),'pm');
51 $update_cat = getStringFromRequest('update_cat');
52 $add_cat = getStringFromRequest('add_cat');
53 $delete = getStringFromRequest('delete');
54 $id = getIntFromRequest('id');
58 if (getStringFromRequest('post_changes')) {
62 $pg = new ProjectGroup($g,$group_project_id);
63 if (!$pg || !is_object($pg)) {
64 exit_error(_('Unable to create ProjectCategory Object'),'pm');
65 } elseif ($pg->isError()) {
66 exit_error($pg->getErrorMessage(),'pm');
69 if (getStringFromRequest('addproject')) {
70 $project_name = getStringFromRequest('project_name');
71 $description = getStringFromRequest('description');
72 $is_public = getStringFromRequest('is_public');
73 $send_all_posts_to = getStringFromRequest('send_all_posts_to');
78 session_require_perm ('pm_admin', $group_id) ;
79 if (!$pg->create($project_name,$description,$is_public,$send_all_posts_to)) {
80 exit_error($pg->getErrorMessage(),'pm');
82 $feedback .= _('Subproject Inserted');
83 $warning_msg .= _("Please configure also the roles (by default, it's 'No Access')");
86 } else if ($add_cat) {
87 $name = getStringFromRequest('name');
90 Add a project_category
92 session_require_perm ('pm', $pg->getID(), 'manager') ;
94 $pc = new ProjectCategory($pg);
95 if (!$pc || !is_object($pc)) {
96 exit_error(_('Unable to create ProjectCategory Object'),'pm');
98 if (!$pc->create($name)) {
99 exit_error(_('Error inserting: ').$pc->getErrorMessage(),'pm');
101 $feedback .= _('Category Inserted');
105 } else if ($update_cat) {
106 $id = getIntFromRequest('id');
107 $name = getStringFromRequest('name');
110 Update a project_category
112 session_require_perm ('pm', $pg->getID(), 'manager') ;
114 $pc = new ProjectCategory($pg,$id);
115 if (!$pc || !is_object($pc)) {
116 exit_error(_('Unable to create ProjectCategory Object'),'pm');
117 } elseif ($pc->isError()) {
118 exit_error($pc->getErrorMessage(),'pm');
120 if (!$pc->update($name)) {
121 exit_error(_('Error updating: '.$pc->getErrorMessage()),'pm');
123 $feedback .= _('Category Updated');
129 } else if (getStringFromRequest('update_pg')) {
130 $project_name = getStringFromRequest('project_name');
131 $description = getStringFromRequest('description');
132 $send_all_posts_to = getStringFromRequest('send_all_posts_to');
137 session_require_perm ('pm', $pg->getID(), 'manager') ;
139 if (!$pg->update($project_name,$description,$send_all_posts_to)) {
140 exit_error($pg->getErrorMessage(),'pm');
142 $feedback .= _('Updated successfully');
145 } else if ($delete) {
146 $sure = getStringFromRequest('sure');
147 $really_sure = getStringFromRequest('really_sure');
153 session_require_perm ('pm', $pg->getID(), 'manager') ;
155 if (!$pg->delete(getStringFromRequest('sure'),getStringFromRequest('really_sure'))) {
156 exit_error($pg->getErrorMessage(),'pm');
158 $feedback .= _('Successfully Deleted');
167 if ($add_cat && $group_project_id) {
169 // FORM TO ADD CATEGORIES
172 $pg = new ProjectGroup($g,$group_project_id);
173 if (!$pg || !is_object($pg)) {
174 exit_error(_('Unable to create ProjectCategory Object'),'pm');
175 } elseif ($pg->isError()) {
176 exit_error($pg->getErrorMessage(),'pm');
179 session_require_perm ('pm', $pg->getID(), 'manager') ;
181 $title = sprintf(_('Add Categories to: %s'), $pg->getName());
182 pm_header(array ('title'=>$title));
185 List of possible categories for this ArtifactType
187 $result=$pg->getCategories();
189 $rows=db_numrows($result);
190 if ($result && $rows > 0) {
192 $title_arr[]=_('Id');
193 $title_arr[]=_('Title');
195 echo $GLOBALS['HTML']->listTableTop ($title_arr);
197 for ($i=0; $i < $rows; $i++) {
198 echo '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'>'.
199 '<td>'.db_result($result, $i, 'category_id').'</td>'.
200 '<td><a href="'.getStringFromServer('PHP_SELF').'?update_cat=1&id='.
201 db_result($result, $i, 'category_id').'&group_id='.$group_id.'&group_project_id='. $pg->getID() .'">'.
202 db_result($result, $i, 'category_name').'</a></td></tr>';
205 echo $GLOBALS['HTML']->listTableBottom();
208 echo "\n<p class=\"warning_msg\">"._('No categories defined')."</p>";
213 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post">
214 <input type="hidden" name="add_cat" value="y" />
215 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
216 <strong><?php echo _('Category Name') ?>:</strong><br />
217 <input type="text" name="name" value="" size="15" maxlength="30" /><br />
219 <span class="important"><?php echo _('Once you add a category, it cannot be deleted') ?></span>
221 <input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" />
227 } elseif ($update_cat && $group_project_id && $id) {
230 // FORM TO UPDATE CATEGORIES
233 Allow modification of a category
236 $pg = new ProjectGroup($g,$group_project_id);
237 if (!$pg || !is_object($pg)) {
238 exit_error(_('Unable to create ProjectCategory Object'),'pm');
239 } elseif ($pg->isError()) {
240 exit_error($pg->getErrorMessage(),'pm');
243 session_require_perm ('pm', $pg->getID(), 'manager') ;
245 $title = sprintf(_('Modify a Category in: %s'), $pg->getName());
247 $ac = new ProjectCategory($pg,$id);
248 if (!$ac || !is_object($ac)) {
249 exit_error(_('Unable to create ProjectCategory Object'),'pm');
250 } elseif ($ac->isError()) {
251 exit_error($ac->getErrorMessage(),'pm');
253 pm_header(array ('title'=>$title));
256 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post" />
257 <input type="hidden" name="update_cat" value="y" />
258 <input type="hidden" name="id" value="<?php echo $ac->getID(); ?>" />
259 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
261 <strong><?php echo _('Category Name')?>:</strong><br />
262 <input type="text" name="name" value="<?php echo $ac->getName(); ?>" />
264 <div class="warning"><?php echo _('It is not recommended that you change the category name because other things are dependent upon it. When you change the category name, all related items will be changed to the new name.')?></div>
266 <input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" />
273 } elseif (getStringFromRequest('addproject')) {
275 Create a new subproject
277 session_require_perm ('pm_admin', $group_id) ;
279 pm_header(array ('title'=>_('Add a new subproject')));
282 <p><?php echo _('Add a new subproject to the Tasks. <strong>This is different than adding a task to a subproject.</strong>') ?></p>
285 <form action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id"; ?>" method="post">
286 <input type="hidden" name="addproject" value="y" />
287 <input type="hidden" name="post_changes" value="y" />
289 <strong><?php echo _('Is Public?')?></strong><br />
290 <input type="radio" name="is_public" value="1" checked="checked" /><?php echo _('Yes') ?><br />
291 <input type="radio" name="is_public" value="0" /><?php echo _('No') ?><p />
293 <h3><?php echo _('New Subproject Name').utils_requiredField() ?></h3>
295 <input type="text" name="project_name" value="" size="15" maxlength="30" />
297 <strong><?php echo _('Description').utils_requiredField() ?></strong><br />
298 <input type="text" name="description" value="" size="40" maxlength="80" />
300 <strong><?php echo _('Send All Updates To')?>:</strong><br />
301 <input type="text" name="send_all_posts_to" value="" size="40" maxlength="80" /><br />
303 <input type="submit" name="submit" value="<?php echo _('Submit') ?>" />
308 } else if (getStringFromRequest('update_pg') && $group_project_id) {
310 $pg = new ProjectGroup($g,$group_project_id);
311 if (!$pg || !is_object($pg)) {
312 exit_error(_('Could Not Get ProjectGroup'),'pm');
313 } elseif ($pg->isError()) {
314 exit_error($pg->getErrorMessage(),'pm');
317 session_require_perm ('pm', $pg->getID(), 'manager') ;
319 pm_header(array('title'=>_('Update Subproject Tasks: ').$pg->getName()));
322 <p><?php echo _('You can modify an existing subproject using this form. Please note that private subprojects can still be viewed by members of your project, but not the general public.') ?></p>
325 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>" method="post">
326 <input type="hidden" name="post_changes" value="y" />
327 <input type="hidden" name="update_pg" value="y" />
328 <input type="hidden" name="group_project_id" value="<?php echo $pg->getID(); ?>" />
332 <strong><?php echo _('Is Public?')?></strong><br />
333 <input type="radio" name="is_public" value="1"<?php echo (($pg->isPublic()=='1')?' checked="checked"':''); ?> /> <?php echo _('Yes') ?><br />
334 <input type="radio" name="is_public" value="0"<?php echo (($pg->isPublic()=='0')?' checked="checked"':''); ?> /> <?php echo _('No') ?><br />
335 <input type="radio" name="is_public" value="9"<?php echo (($pg->isPublic()=='9')?' checked="checked"':''); ?> /> <?php echo _('Deleted')?><br />
339 <td><strong><?php echo _('Subproject Name').utils_requiredField() ?>:</strong><br />
340 <input type="text" name="project_name" value="<?php echo $pg->getName() ?>" />
345 <strong><?php echo _('Description').utils_requiredField() ?>:</strong><br />
346 <input type="text" name="description" value="<?php echo $pg->getDescription(); ?>" size="40" maxlength="80" /><br />
351 <strong><?php echo _('Send All Updates To')?>:</strong><br />
352 <input type="text" name="send_all_posts_to" value="<?php echo $pg->getSendAllPostsTo(); ?>" size="40" maxlength="80" /><br />
357 <strong><a href="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id&add_cat=1&group_project_id=".$pg->getID(); ?>"><?php echo _('Add/Edit Categories')?></a></strong><br />
358 <strong><a href="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id&delete=1&group_project_id=".$pg->getID(); ?>"><?php echo _('Permanently delete this subproject and all its data.')?></a></strong><br />
363 <input type="submit" name="submit" value="<?php echo _('Update') ?>" />
372 } else if ($delete && $group_project_id) {
375 $pg = new ProjectGroup($g,$group_project_id);
376 if (!$pg || !is_object($pg)) {
377 exit_error(_('Could Not Get ProjectGroup'),'pm');
378 } elseif ($pg->isError()) {
379 exit_error($pg->getErrorMessage(),'pm');
382 session_require_perm ('pm', $pg->getID(), 'manager') ;
384 pm_header(array('title'=>_('Delete')));
387 <form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_project_id='.$group_project_id; ?>" method="post">
388 <input type="hidden" name="post_changes" value="y" />
389 <input type="hidden" name="delete" value="y" /><br />
390 <?php echo _('You are about to permanently and irretrievably delete this subproject and all its related data!'); ?>
392 <input type="checkbox" name="sure" value="1" /><?php echo _('I\'m Sure') ?><br />
393 <input type="checkbox" name="really_sure" value="1" /><?php echo _('I\'m Really Sure'); ?>
395 <input type="submit" name="post_changes" value="<?php echo _('Delete') ?>" />
404 $pgf = new ProjectGroupFactory($g);
405 if (!$pgf || !is_object($pgf)) {
406 exit_error(_('Could Not Get Factory'),'pm');
407 } elseif ($pgf->isError()) {
408 exit_error($pgf->getErrorMessage(),'pm');
414 pm_header(array('title'=>_('Tasks Administration')));
417 // Show link to create new subproject
419 if (forge_check_perm ('pm_admin', $group_id)) {
422 <a href="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id; ?>&addproject=1"><?php echo _('Add a Subproject') ?></a><br />
423 <?php echo _('Add a subproject, which can contain a set of tasks. This is different than creating a new task.') ?>
428 $pg_arr = $pgf->getProjectGroups();
430 if (count($pg_arr) < 1 || $pg_arr == false) {
431 echo '<h2>' . _('No Subprojects Found in this Project') . '</h2>';
432 echo '<p>' . _('You may add new Subprojects using the "Add a Subproject" link above.') . '</p>';
435 for ($i=0; $i<count($pg_arr); $i++) {
436 echo '<a href="'. getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_project_id='.$pg_arr[$i]->getID().'&update_pg=1">'._('Edit/Update Subproject').': <strong>'.$pg_arr[$i]->getName().'</strong></a><p />';