Exemplo n.º 1
0
/**
 * 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);
        }
    }
}
Exemplo n.º 2
0
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);
        }
    }
}