Permalink
Browse files

Added users roles inside projects.

  • Loading branch information...
1 parent 44ef0a8 commit 342d8bcb4677aec9c18c983b4b8fca69a347cec2 Filippo committed Jul 31, 2010
Showing with 391 additions and 2 deletions.
  1. BIN data/phpcollab_unit_test.db
  2. +8 −2 plugins/idProjectManagementPlugin/config/routing.yml
  3. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginIssueFormFilter.class.php
  4. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginIssueReferenceFormFilter.class.php
  5. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginIssueUserFormFilter.class.php
  6. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginLogTimeFormFilter.class.php
  7. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginMessageFormFilter.class.php
  8. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginMilestoneFormFilter.class.php
  9. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginPriorityFormFilter.class.php
  10. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginProfileFormFilter.class.php
  11. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginProjectUserFormFilter.class.php
  12. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginProjectsTrackersFormFilter.class.php
  13. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginStatusFormFilter.class.php
  14. +13 −0 plugins/idProjectManagementPlugin/lib/filter/doctrine/PluginTrackerFormFilter.class.php
  15. +13 −0 plugins/idProjectManagementPlugin/lib/form/doctrine/PluginIssueReferenceForm.class.php
  16. +13 −0 plugins/idProjectManagementPlugin/lib/form/doctrine/PluginIssueUserForm.class.php
  17. +30 −0 plugins/idProjectManagementPlugin/lib/form/doctrine/PluginProjectUserForm.class.php
  18. +13 −0 plugins/idProjectManagementPlugin/lib/form/doctrine/PluginProjectsTrackersForm.class.php
  19. +17 −0 plugins/idProjectManagementPlugin/lib/model/doctrine/PluginProjectUser.class.php
  20. +30 −0 plugins/idProjectManagementPlugin/modules/idProject/actions/actions.class.php
  21. +25 −0 plugins/idProjectManagementPlugin/modules/idProject/templates/settingsSuccess.php
  22. +67 −0 test/functional/fe/idProjectAssociateUserToProjectWithGroupTest.php
  23. +19 −0 web/css/custom-prod.css
View
Binary file not shown.
@@ -65,13 +65,19 @@ sf_guard_user_show:
project_staff_list:
url: /:sf_culture/idProject/:id/staff_list
- param: { module: idProject, action: staffList}
+ param: { module: idProject, action: staffList }
requirements:
sf_culture: (?:en|it)
update_project_staff_list:
url: /:sf_culture/idProject/:id/staff_list/update
- param: { module: idProject, action: updateStaffList}
+ param: { module: idProject, action: updateStaffList }
+ requirements:
+ sf_culture: (?:en|it)
+
+update_project_user_role:
+ url: /:sf_culture/idProject/:id/projectuser/update/:profile_id
+ param: { module: idProject, action: updateSettingsProjectUserRoleList }
requirements:
sf_culture: (?:en|it)
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginIssue form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginIssueFormFilter extends BaseIssueFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginIssueReference form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginIssueReferenceFormFilter extends BaseIssueReferenceFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginIssueUser form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginIssueUserFormFilter extends BaseIssueUserFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginLogTime form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginLogTimeFormFilter extends BaseLogTimeFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginMessage form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginMessageFormFilter extends BaseMessageFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginMilestone form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginMilestoneFormFilter extends BaseMilestoneFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginPriority form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginPriorityFormFilter extends BasePriorityFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginProfile form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginProfileFormFilter extends BaseProfileFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginProjectUser form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginProjectUserFormFilter extends BaseProjectUserFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginProjectsTrackers form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginProjectsTrackersFormFilter extends BaseProjectsTrackersFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginStatus form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginStatusFormFilter extends BaseStatusFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginTracker form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage filter
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormFilterPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginTrackerFormFilter extends BaseTrackerFormFilter
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginIssueReference form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage form
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginIssueReferenceForm extends BaseIssueReferenceForm
+{
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginIssueUser form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage form
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginIssueUserForm extends BaseIssueUserForm
+{
+}
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * PluginProjectUser form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage form
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginProjectUserForm extends BaseProjectUserForm
+{
+ public function setup() {
+ parent::setup();
+
+ $this->widgetSchema['role'] = new sfWidgetFormChoice(array('choices' => ProjectUser::getCodesAndRolesNoAdmin()));
+ $this->validatorSchema['role'] = new sfValidatorChoice(array('choices' => array_keys(ProjectUser::getCodesAndRolesNoAdmin()), 'required' => true));
+ }
+
+ public static function generateFormsForProject(Project $project)
+ {
+ $forms = array();
+ foreach ($project->getUsers() as $profile)
+ {
+ $project_user = Doctrine::getTable('ProjectUser')->findOneByProjectIdAndProfileId($project->id, $profile->id);
+ $forms[] = new ProjectUserForm($project_user);
+ }
+ return $forms;
+ }
+}
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * PluginProjectsTrackers form.
+ *
+ * @package ##PROJECT_NAME##
+ * @subpackage form
+ * @author ##AUTHOR_NAME##
+ * @version SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+abstract class PluginProjectsTrackersForm extends BaseProjectsTrackersForm
+{
+}
@@ -36,8 +36,25 @@ public static function getRoleByProfileIdAndProjectId($profile_id, $project_id)
}
}
+ public static function getCodesAndRolesNoAdmin()
+ {
+ $roles = self::$roles;
+ unset($roles['admin']);
+ return array_flip($roles);
+ }
+
public static function getCodesAndRoles()
{
return array_flip(self::$roles);
}
+
+ public function preSave($event)
+ {
+ parent::preSave($event);
+
+ if (!in_array($this->get('role'), self::$roles))
+ {
+ $this->set('role', self::$roles['developer']);
+ }
+ }
}
@@ -188,6 +188,7 @@ public function executeSettings(sfWebRequest $request)
$this->form_overview = new ProjectFormOnlyTitleAndDescription($this->project);
$this->form_staff = new ProjectFormOnlyMembers($this->project);
$this->form_tracker = new ProjectFormOnlyTrackers($this->project);
+ $this->forms_projectuser = ProjectUserForm::generateFormsForProject($this->project);
}
public function executeUpdateTitleAndDescription(sfWebRequest $request)
@@ -196,6 +197,7 @@ public function executeUpdateTitleAndDescription(sfWebRequest $request)
$this->form_staff = new ProjectFormOnlyMembers($this->project);
$this->form_tracker = new ProjectFormOnlyTrackers($this->project);
+ $this->forms_projectuser = ProjectUserForm::generateFormsForProject($this->project);
$this->form_overview = new ProjectFormOnlyTitleAndDescription($this->project);
$this->form_overview->bind($request->getParameter($this->form_overview->getName()));
@@ -215,6 +217,7 @@ public function executeUpdateTrackers(sfWebRequest $request)
$this->form_staff = new ProjectFormOnlyMembers($this->project);
$this->form_overview = new ProjectFormOnlyTitleAndDescription($this->project);
$this->form_tracker = new ProjectFormOnlyTrackers($this->project);
+ $this->forms_projectuser = ProjectUserForm::generateFormsForProject($this->project);
$this->form_tracker->bind($request->getParameter($this->form_tracker->getName()));
if ($this->form_tracker->isValid())
@@ -229,12 +232,39 @@ public function executeUpdateTrackers(sfWebRequest $request)
public function executeUpdateSettingsStaffList(sfWebRequest $request)
{
$this->form_staff = $this->validateStaffForm($request);
+
$this->form_overview = new ProjectFormOnlyTitleAndDescription($this->project);
$this->form_tracker = new ProjectFormOnlyTrackers($this->project);
+ $this->forms_projectuser = ProjectUserForm::generateFormsForProject($this->project);
$this->setTemplate('settings');
}
+ public function executeUpdateSettingsProjectUserRoleList(sfWebRequest $request)
+ {
+ $this->forward404Unless($this->project = Doctrine::getTable('Project')->find(array($request->getParameter('id'))), sprintf('Object project does not exist (%s).', array($request->getParameter('id'))));
+ if(!$request->hasParameter('profile_id') ||
+ !($project_user = Doctrine::getTable('ProjectUser')->findOneByProjectIdAndProfileId($this->project->id, $request->getParameter('profile_id'))))
+ {
+ $this->getUser()->setFlash('error', 'Error submitting the project user role form.');
+ $this->redirect('@project_settings?id='.$this->project->id);
+ }
+
+ $form = new ProjectUserForm($project_user);
+ $form->bind($request->getParameter($form->getName()));
+ if ($form->isValid())
+ {
+ $form->save();
+ $this->getUser()->setFlash('notice', 'Modification applied with success');
+ }
+ else
+ {
+ $this->getUser()->setFlash('error', 'There are errors in the form submitted');
+ }
+
+ $this->redirect('@project_settings?id='.$this->project->id);
+ }
+
/**
* checks if the form is valid and redirect to the right page
*
@@ -12,12 +12,18 @@
<?php echo $sf_user->getFlash('notice'); ?>
</div>
<?php endif; ?>
+ <?php if ($sf_user->hasFlash('error')): ?>
+ <div class="error">
+ <?php echo $sf_user->getFlash('error'); ?>
+ </div>
+ <?php endif; ?>
<div class="tabs">
<ul class="tabNavigation">
<li><a href="#overview">Overview</a></li>
<li><a href="#trackers">Trackers</a></li>
<!--li><a href="#modules">Modules</a></li-->
<li><a href="#staff">Staff</a></li>
+ <li><a href="#usersroles">Users roles</a></li>
<!--li><a href="#invoicing">Invoicing</a></li>
<li><a href="#wiki">Wiki</a></li>
<li><a href="#repository">Repository</a></li-->
@@ -42,6 +48,25 @@
<?php include_partial('idProject/staff_form', array('form' => $form_staff,
'url' => '@edit_project_staff?id='.$project->id)); ?>
</div>
+ <div id="usersroles" class="settings">
+ <?php //include_partial('idProject/projectuser_form', array('form' => $form_projectuser)); ?>
+ <?php foreach($forms_projectuser as $key => $form_projectuser): ?>
+ <form id="project_user_<?php echo $key ?>" class="project-user" action="<?php echo url_for('@update_project_user_role?id='.$project->id.'&profile_id='.$form_projectuser->getObject()->getProfile()->getId())?>" method="post">
+ <div class="span-7" >
+ <h4><?php echo $form_projectuser->getObject()->getProfile()->getUser()->getUsername();?></h4>
+ <?php echo $form_projectuser->getObject()->getProfile()->getEmail();?>
+ </div>
+ <div class="span-12" >
+ <?php echo $form_projectuser ?>
+ </div>
+ <div class="span-2 last" >
+ <input type="submit" value="Save" class="button block-green medium-round"/>
+ </div>
+ <div class="clear"></div>
+ </form>
+ <hr/>
+ <?php endforeach; ?>
+ </div>
</div>
</div>
Oops, something went wrong.

0 comments on commit 342d8bc

Please sign in to comment.