PDA

View Full Version : How do I modify the project module for assigning user roles?


Hazlitt
26-07-11, 11:23 PM
Hi, thanks for reading my post.

I want to modify the project module so that it displays four manager roles on the add project form. Each field is a drop down list of registered users.

Then when the form is submitted and the new project created, the users selected for each role are assigned to specific tasks on a project template.

I have succeeded in modifying the form :) , I but haven't managed to figure out how the code is handling the POST variables and therefore how to save assign the select users to specific tasks automatically. :confused:

Any help is gratefully appreciated.

Hazlitt

HaTaX
27-07-11, 03:11 PM
Can you post up some snippits of your code changes along with which file you're editing? _POST & _GET are pretty easy to deal with once you understand how they work. I can take a look and see if I can offer some advice on where you should make your tweaks, but it's a lot easier if I can see what you're working with and trying to accomplish.

Also, here's a good page to help describe how _POST and _GET work and the difference between them.
http://www.tizag.com/phpT/postget.php

Basically you pull a _POST parameter and place it in a variable to be used further down in the code. So if you had a url like:
http:\\webserver\index.php?gonnadosomething=maybe&someothervariable=whatever&acounter=3
You would get the value of a variable like so:
$myothervariable = $_GET['someothervariable'];

And then in the rest of the code, $myothervariable would be filled with what was passed in the URL. In my example $myothervariable would contain "whatever".

Hope this helps a little!

Hazlitt
28-07-11, 08:05 PM
Hi, many thanks for responding.

I edited the addedit.php file in the projects form and added four new fields :


<tr>
<td align="right" nowrap="nowrap">Project Manager</td>
<td colspan="2">
<?php echo arraySelect($users, 'project_manager', 'size="1" style="width:200px;" class="text"', $row->project_manager? $row->project_manager : $AppUI->user_id) ?>
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap">Design Manager</td>
<td colspan="2">
<?php echo arraySelect($users, 'design_manager', 'size="1" style="width:200px;" class="text"', $row->design_manager? $row->design_manager : $AppUI->user_id) ?>
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap">Costing Manager</td>
<td colspan="2">
<?php echo arraySelect($users, 'costing_manager', 'size="1" style="width:200px;" class="text"', $row->costing_manager? $row->costing_manager : $AppUI->user_id) ?>
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap">Project Support Team Manager</td>
<td colspan="2">
<?php echo arraySelect($users, 'team_manager', 'size="1" style="width:200px;" class="text"', $row->team_manager? $row->team_manager : $AppUI->user_id) ?>
</td>
</tr>


I checked the form and it's action is to POST to "?m=projects" so I tried adding print_r($_POST); to the beginning of the /modules/projects/index.php and all it outputs is "array()" without values. So I can't figure out where my posted field values are being cleared.

Here is what I would like to achieve. I have a project template that has a list of 30 tasks. Each task needs to be assigned to one of the 4 new management roles. So I want to automatically assign the users selected in one of the 4 management roles in the fields I added on the addedit.php form to the tasks when a new project is created.

I hope that makes sense, and thanks again for responding.

Hazlitt

HaTaX
02-08-11, 09:36 AM
Hmmm, let me think on this a little bit.

To get you started so you can see what's in the _POST variable, try dumping it this way:


echo "<pre>";
var_dump($_POST);
echo "</pre>\n";


That should give you the values that are in that array printed on the webpage you're working with.

Hazlitt
04-08-11, 06:54 PM
Hi HaTax,

Thanks for your help.

As you suggested I tried using var_dump instead of print_r to display the contents of the $_POST array when the create new project form is submitted back to the projects module. I added the code:


echo "<pre>";
var_dump($_POST);
echo "</pre>\n";


To the beginning of the /modules/projects/index.php and the result was the same:


array(0) {
}


I can't figure out where the POST variables are going.

Hazlitt
11-08-11, 08:42 PM
Forgive me for bumping this thread. Can anyone point in the right direction with this?

Thanks

elazor
23-03-13, 05:50 AM
I am trying to do the same thing !

Any help on how to code this would be great!!

Can we get a little bit of help here ? :)

ajdonnison
27-03-13, 03:49 PM
It isn't modules/projects/index.php that is being executed, which is why you don't see the POST variables showing up there, it is modules/projects/do_project_aed.php (the dosql field in the form).