Skip to content

Commit

Permalink
Refactor mc_project_api.php
Browse files Browse the repository at this point in the history
- Improve PHPDoc
- Fix static analysis warnings
- Introduce new functions to avoid code duplication
  - mci_project_get_row()
  - mci_project_get_versions()
  - mci_project_initial_checks()

Fixes #33774, PR #1970
  • Loading branch information
dregad committed Feb 18, 2024
2 parents 4dc35ad + 856b7c6 commit 7abd130
Show file tree
Hide file tree
Showing 2 changed files with 252 additions and 245 deletions.
13 changes: 1 addition & 12 deletions api/soap/mc_api.php
Expand Up @@ -887,18 +887,7 @@ function mci_user_get_accessible_subprojects( $p_user_id, $p_parent_project_id,

$t_result = array();
foreach( user_get_accessible_subprojects( $p_user_id, $p_parent_project_id ) as $t_subproject_id ) {
$t_subproject_row = project_cache_row( $t_subproject_id );
$t_subproject = array();
$t_subproject['id'] = $t_subproject_id;
$t_subproject['name'] = $t_subproject_row['name'];
$t_subproject['status'] = mci_enum_get_array_by_id( $t_subproject_row['status'], 'project_status', $t_lang );
$t_subproject['enabled'] = $t_subproject_row['enabled'];
$t_subproject['view_state'] = mci_enum_get_array_by_id( $t_subproject_row['view_state'], 'project_view_state', $t_lang );
$t_subproject['access_min'] = mci_enum_get_array_by_id( $t_subproject_row['access_min'], 'access_levels', $t_lang );
$t_subproject['file_path'] = array_key_exists( 'file_path', $t_subproject_row ) ? $t_subproject_row['file_path'] : '';
$t_subproject['description'] = array_key_exists( 'description', $t_subproject_row ) ? $t_subproject_row['description'] : '';
$t_subproject['subprojects'] = mci_user_get_accessible_subprojects( $p_user_id, $t_subproject_id, $t_lang );
$t_result[] = $t_subproject;
$t_result[] = mci_project_get_row( $t_subproject_id, $p_user_id, $t_lang );
}

return $t_result;
Expand Down

0 comments on commit 7abd130

Please sign in to comment.