diff --git a/Source/Source.API.php b/Source/Source.API.php index 587d10c..a8003cd 100644 --- a/Source/Source.API.php +++ b/Source/Source.API.php @@ -697,6 +697,29 @@ } /** + * Fetch a new Repo object given a name. + * @param string Repository name + * @return multi Repo object + */ + static function load_from_name( $p_name ) { + $t_repo_table = plugin_table( 'repository', 'Source' ); + + $t_query = "SELECT * FROM $t_repo_table WHERE name LIKE " . db_param(); + $t_result = db_query_bound( $t_query, array( trim($p_name) ) ); + + if ( db_num_rows( $t_result ) < 1 ) { + trigger_error( ERROR_GENERIC, ERROR ); + } + + $t_row = db_fetch_array( $t_result ); + + $t_repo = new SourceRepo( $t_row['type'], $t_row['name'], $t_row['url'], $t_row['info'] ); + $t_repo->id = $t_row['id']; + + return $t_repo; + } + + /** * Fetch an array of all Repo objects. * @return array All repo objects. */ diff --git a/Source/pages/import.php b/Source/pages/import.php index 87f65d8..5ea4aaf 100644 --- a/Source/pages/import.php +++ b/Source/pages/import.php @@ -67,6 +67,9 @@ } elseif ( is_numeric( $f_repo_id ) ) { $t_repo_id = (int) $f_repo_id; $t_repos = array( SourceRepo::load( $t_repo_id ) ); +} else { + $f_repo_name = $f_repo_id; + $t_repos = array( SourceRepo::load_from_name( $f_repo_name ) ); } # Loop through all repos to be imported