function project_copy_users($p_destination_id, $p_source_id) { # Copy all users from current project over to another project $rows = project_get_local_user_rows($p_source_id); for ($i = 0; $i < sizeof($rows); $i++) { extract($rows[$i], EXTR_PREFIX_ALL, 'v'); # if there is no duplicate then add a new entry # otherwise just update the access level for the existing entry if (project_includes_user($p_destination_id, $v_user_id)) { project_update_user_access($p_destination_id, $v_user_id, $v_access_level); } else { project_add_user($p_destination_id, $v_user_id, $v_access_level); } } }
/** * Copy all users and their permissions from the source project to the * destination project. The $p_access_level_limit parameter can be used to * limit the access level for users as they're copied to the destination * project (the highest access level they'll receieve in the destination * project will be equal to $p_access_level_limit). * @param int Destination project ID * @param int Source project ID * @param int Access level limit (null = no limit) * @return null */ function project_copy_users($p_destination_id, $p_source_id, $p_access_level_limit = null) { # Copy all users from current project over to another project $t_rows = project_get_local_user_rows($p_source_id); $t_count = count($t_rows); for ($i = 0; $i < $t_count; $i++) { $t_row = $t_rows[$i]; if ($p_access_level_limit !== null && $t_row['access_level'] > $p_access_level_limit) { $t_destination_access_level = $p_access_level_limit; } else { $t_destination_access_level = $t_row['access_level']; } # if there is no duplicate then add a new entry # otherwise just update the access level for the existing entry if (project_includes_user($p_destination_id, $t_row['user_id'])) { project_update_user_access($p_destination_id, $t_row['user_id'], $t_destination_access_level); } else { project_add_user($p_destination_id, $t_row['user_id'], $t_destination_access_level); } } }
/** * Gets the managers of the current selected project * * @param $version_id * @return string */ public function calculate_person_in_charge($version_id) { $person_in_charge = ''; $project_id = helper_get_current_project(); if ($project_id == 0) { $project_id = version_get_field($version_id, 'project_id'); } $project_related_users = project_get_local_user_rows($project_id); $count = 0; foreach ($project_related_users as $project_related_user) { if ($project_related_user['project_id'] == $project_id && $project_related_user['access_level'] == 70 && user_is_enabled($project_related_user['user_id'])) { if ($count > 0) { $person_in_charge .= ', '; } $person_in_charge .= user_get_realname($project_related_user['user_id']); $count++; } } return $person_in_charge; }