function requirement_edit_assoc_releases($req_id, $assoc_releases) { global $db; $tbl_req = REQ_TBL; $f_req_proj_id = $tbl_req . "." . REQ_PROJECT_ID; $f_req_id = $tbl_req . "." . REQ_ID; $f_req_filename = $tbl_req . "." . REQ_FILENAME; $tbl_req_ver_assoc_rel = REQ_VERS_ASSOC_REL; $f_req_ver_assoc_rel_id = $tbl_req_ver_assoc_rel . "." . REQ_VERS_ASSOC_REL_ID; $f_req_ver_assoc_rel_req_id = $tbl_req_ver_assoc_rel . "." . REQ_VERS_ASSOC_REL_REQ_ID; $f_req_ver_assoc_rel_rel_id = $tbl_req_ver_assoc_rel . "." . REQ_VERS_ASSOC_REL_REL_ID; $tbl_release = RELEASE_TBL; $f_release_id = $tbl_release . "." . RELEASE_ID; $f_release_project_id = $tbl_release . "." . PROJECT_ID; $f_release_name = $tbl_release . "." . RELEASE_NAME; $f_release_archive = $tbl_release . "." . RELEASE_ARCHIVE; $s_project_properties = session_get_project_properties(); $project_id = $s_project_properties['project_id']; $release_ids = admin_get_releases($project_id); foreach ($release_ids as $row) { $q = "\tSELECT {$f_req_ver_assoc_rel_id}\n\t\t\t\tFROM {$tbl_req_ver_assoc_rel}\n\t\t\t\tWHERE {$f_req_ver_assoc_rel_req_id} = {$req_id}\n\t\t\t\t\tAND\t{$f_req_ver_assoc_rel_rel_id} = " . $row[RELEASE_ID]; $rs = db_query($db, $q); $record_exists = db_num_rows($db, $rs); if (util_array_key_search($row[RELEASE_ID], $assoc_releases)) { if (!$record_exists) { $q = "\tINSERT INTO {$tbl_req_ver_assoc_rel}\n\t\t\t\t\t\t\t({$f_req_ver_assoc_rel_req_id}, {$f_req_ver_assoc_rel_rel_id})\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t({$req_id}, " . $row[RELEASE_ID] . ")"; } } else { if ($record_exists) { $q = "\tDELETE FROM {$tbl_req_ver_assoc_rel}\n\t\t\t\t\t\tWHERE {$f_req_ver_assoc_rel_req_id} = {$req_id}\n\t\t\t\t\t\t\tAND\t{$f_req_ver_assoc_rel_rel_id} = " . $row[RELEASE_ID]; } } db_query($db, $q); } }
function session_records_set_selected($property_set) { //print"session_records_set_selected<br>"; //print_r($_SESSION['properties'][$property_set]['records']); #################################################################################################### # get all the records displayed on the page $displayed_records = $_SESSION['properties'][$property_set]['displayed_records']; $displayed_groups = $_SESSION['properties'][$property_set]['displayed_select_group']; #################################################################################################### #################################################################################################### # set the posted variables # define posted variables $posted_records = array(); $posted_groups = array(); foreach ($_POST as $key => $value) { # $posted_records[record_id] = record_group $exploded_post = explode("_", $key, 3); if ($exploded_post[0] == "row") { $posted_records[$exploded_post[1]] = $value; } # $posted_groups = (group_name1, group_name2, ...) $exploded_post = explode("_", $key, 2); if ($exploded_post[0] == "allpages") { $posted_groups[] = $value; } } //print_r($posted_groups);exit; #################################################################################################### //print_r($posted_records); //print_r($posted_groups); //print_r($displayed_groups); #################################################################################################### # set the select_group variables # loop through all groups displayed on the page foreach ($displayed_groups as $displayed_group_name) { # if $displayed_group_name checked on page $posted_group_name_match = util_array_value_search($displayed_group_name, $posted_groups); //print $posted_group_name_match.":".$displayed_group_name."<br>"; if ($posted_group_name_match) { /* # add $displayed_group_name to group_name $_SESSION['properties'][$property_set]['select_group'][] = $displayed_group_name; //print_r($_SESSION['properties'][$property_set]['select_group']); */ # check if group was selected on previous page, and if not if (!util_array_value_search($displayed_group_name, $_SESSION['properties'][$property_set]['select_group'])) { # add $displayed_group_name to group_name $_SESSION['properties'][$property_set]['select_group'][] = $displayed_group_name; # remove any tests in session of that group foreach ($_SESSION['properties'][$property_set]['records'] as $record_id => $group_name) { if ($group_name == $displayed_group_name) { //print"unset $record_id<br>"; unset($_SESSION['properties'][$property_set]['records'][$record_id]); } } } # remove all records of that group but only if they have been posted foreach ($posted_records as $record_id => $group_name) { if ($group_name == $displayed_group_name) { //print"unset $record_id<br>"; unset($_SESSION['properties'][$property_set]['records'][$record_id]); } } } else { # remove $displayed_group_name from select_group $_SESSION['properties'][$property_set]['select_group'] = array_diff($_SESSION['properties'][$property_set]['select_group'], array("{$displayed_group_name}")); } } #################################################################################################### //print_r($_SESSION['properties'][$property_set]['select_group']); //print">select group<br><br>"; #################################################################################################### # set the records variables # loop through displayed records foreach ($displayed_records as $displayed_record_id => $displayed_record_group) { $displayed_record_group_match = util_array_value_search($displayed_record_group, $_SESSION['properties'][$property_set]['select_group']); //print"<br>search_value: $displayed_record_group, restult: $displayed_record_group_match<br>";print_r($_SESSION['properties'][$property_set]['select_group']);print"<br>"; $posted_records_id_match = util_array_key_search($displayed_record_id, $posted_records); if ($displayed_record_group_match) { //print"displayed_record_group_match<BR>"; # if posted_record id matches $displayed_record id if ($posted_records_id_match) { # remove id from records unset($_SESSION['properties'][$property_set]['records'][$displayed_record_id]); } else { # add id $_SESSION['properties'][$property_set]['records'][$displayed_record_id] = "{$displayed_record_group}"; } } else { //print"false displayed_record_group_match<BR>"; if ($posted_records_id_match) { $_SESSION['properties'][$property_set]['records'][$displayed_record_id] = "{$displayed_record_group}"; } else { unset($_SESSION['properties'][$property_set]['records'][$displayed_record_id]); } } } #################################################################################################### /* print "<br>"; print"<textarea cols=100 rows=30>"; print_r($_SESSION['properties'][$property_set]); print"". NEWLINE; print"\n\$_POST:"; print_r($_POST); print"</textarea>"; */ }
# add projects and preferences to $associated_projects. # the array format is: # $associated_projects[project_id][project_preference] = project_preference_value # if (isset($exploded_post[1])) { if (util_array_value_search($exploded_post[1], $project_preferences)) { $associated_projects[$associated_project_id][$exploded_post[1]] = $value; } } } # fill in any project prefs which are left out # i.e. unchecked checkboxes foreach ($associated_projects as $key_project => $value_preferences) { # look for project prefs not set in $project_pref foreach ($project_preferences as $row_project_preference) { if (!util_array_key_search($row_project_preference, $value_preferences)) { $associated_projects[$key_project][$row_project_preference] = "N"; } } } if (isset($_POST['add_to_projects'])) { $add_to_projects = $_POST['add_to_projects']; } else { $add_to_projects = array(); } user_edit(session_validate_form_get_field("username"), session_validate_form_get_field("password"), session_validate_form_get_field("first_name_required"), session_validate_form_get_field("last_name_required"), session_validate_form_get_field("email_required"), session_validate_form_get_field("phone"), $_POST['tempest_admin'], $_POST['default_project'], $associated_projects, $add_to_projects); session_validate_form_reset(); # --------------------------------------------------------------------- # $Log: user_edit_action.php,v $ # Revision 1.4 2008/08/04 06:54:58 peter_thal # added sorting function to several tables