commit c08f344ce54ea07d3687cfc31001f9e1d6fd2b16 Author: smarcet Date: Fri Oct 2 13:29:41 2020 -0300 Fixed country list order Change-Id: I8cb7039f4d71a9b325ffbda811db68c0ea3f40ea Signed-off-by: smarcet diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 88318d1..155ecde 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -11,6 +11,8 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ + +use App\Http\Utils\CountryList; use App\libs\Auth\Repositories\IBannedIPRepository; use App\libs\Auth\Repositories\IGroupRepository; use Auth\Repositories\IUserRepository; @@ -585,7 +587,7 @@ class AdminController extends Controller { return View::make("admin.users", [ 'page' => $this->user_repository->getAllByPage(new PagingInfo(1, 10)), - 'countries' => $countries, + 'countries' => CountryList::getCountries(), ] ); } @@ -622,13 +624,11 @@ class AdminController extends Controller { $lang2Code[] = $lang; } - // get countries database - $countries = $isoCodes->getCountries()->toArray(); return View::make("admin.edit-user", [ 'user' => $user, - 'countries' => $countries, + 'countries' => CountryList::getCountries(), 'languages' => $lang2Code, ] ); diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 695dbdf..9c8dce9 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -12,6 +12,7 @@ * limitations under the License. **/ use App\Http\Controllers\Controller; +use App\Http\Utils\CountryList; use App\Services\Auth\IUserService; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; @@ -59,7 +60,6 @@ final class RegisterController extends Controller $this->memento_service = $memento_service; } - /** * @param LaravelRequest $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View @@ -68,17 +68,14 @@ final class RegisterController extends Controller public function showRegistrationForm(LaravelRequest $request) { try { - // init database - $isoCodes = new IsoCodesFactory(); - // get countries database - $countries = $isoCodes->getCountries()->toArray(); + $params = [ "redirect_uri" => '', "email" => '', "first_name" => '', "last_name" => '', "client_id" => '', - 'countries' => $countries + 'countries' => CountryList::getCountries() ]; // check if we have a former oauth2 request diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index cb2c40f..c0d159b 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -13,6 +13,7 @@ **/ use App\Http\Controllers\OpenId\DiscoveryController; use App\Http\Controllers\OpenId\OpenIdController; +use App\Http\Utils\CountryList; use Auth\Exceptions\AuthenticationException; use Auth\Exceptions\UnverifiedEmailMemberException; use Exception; @@ -452,15 +453,12 @@ final class UserController extends OpenIdController $lang2Code[] = $lang; } - // get countries database - $countries = $isoCodes->getCountries()->toArray(); - return View::make("profile", [ 'user' => $user, "openid_url" => $this->server_configuration_service->getUserIdentityEndpointURL($user->getIdentifier()), "sites" => $sites, 'actions' => $actions, - 'countries' => $countries, + 'countries' => CountryList::getCountries(), 'languages' => $lang2Code, ]); } diff --git a/app/Http/Utils/CountryList.php b/app/Http/Utils/CountryList.php new file mode 100644 index 0000000..0d0327c --- /dev/null +++ b/app/Http/Utils/CountryList.php @@ -0,0 +1,37 @@ +getName()); + $bl = strtolower($b->getName()); + if ($al == $bl) { + return 0; + } + return ($al > $bl) ? +1 : -1; + } + + public static function getCountries(){ + // init database + $isoCodes = new IsoCodesFactory(); + $countries = $isoCodes->getCountries()->toArray(); + usort($countries, array('App\Http\Utils\CountryList','countrySort')); + return $countries; + } +} \ No newline at end of file