So how about some examples of using it? The following code generated the sample box above directly from the database. To be honest, I ripped this directly out of the task manager that I wrote for SourceForge. It's OK, because VA Linux is GPLing all of this code anyway.
<?php
/*
List of possible users that this one could be assigned to
*/
$sql="SELECT user.user_id,user.user_name ".
"FROM user,user_group WHERE user.user_id=user_group.user_id ".
"AND user_group.group_id='$group_id' AND user_group.project_flags IN (1,2)";
$result3=db_query($sql);
/*
Get the list of ids this is assigned to and convert to array
to pass into multiple select box
*/
$result2=db_query("SELECT assigned_to_id FROM project_assigned_to WHERE project_task_id='$project_task_id'");
build_multiple_select_box($result3,'assigned_to[]',result_column_to_array($result2));
?>
Not too difficult, right? Now on to the receiving page...
<?php
$user_count=count($assigned_to);
/*
DELETE THEN Insert the people this task is assigned to
*/
$toss=db_query("DELETE FROM project_assigned_to WHERE project_task_id='$project_task_id'");
for ($i=0; $i<$user_count; $i++) {
$sql="INSERT INTO project_assigned_to VALUES ('','$project_task_id','$assigned_to[$i]')";
$result=db_query($sql);
}
?>
I hope this is all very useful. Please and let me know if you have created some utilities that others could use.
<?php
/*
List of possible users that this one could be assigned to
*/
$sql="SELECT user.user_id,user.user_name ".
"FROM user,user_group WHERE user.user_id=user_group.user_id ".
"AND user_group.group_id='$group_id' AND user_group.project_flags IN (1,2)";
$result3=db_query($sql);
/*
Get the list of ids this is assigned to and convert to array
to pass into multiple select box
*/
$result2=db_query("SELECT assigned_to_id FROM project_assigned_to WHERE project_task_id='$project_task_id'");
build_multiple_select_box($result3,'assigned_to[]',result_column_to_array($result2));
?>
Not too difficult, right? Now on to the receiving page...
<?php
$user_count=count($assigned_to);
/*
DELETE THEN Insert the people this task is assigned to
*/
$toss=db_query("DELETE FROM project_assigned_to WHERE project_task_id='$project_task_id'");
for ($i=0; $i<$user_count; $i++) {
$sql="INSERT INTO project_assigned_to VALUES ('','$project_task_id','$assigned_to[$i]')";
$result=db_query($sql);
}
?>
I hope this is all very useful. Please and let me know if you have created some utilities that others could use.