예제 #1
0
 public function getAll($userUid)
 {
     $user = User::getIndex($userUid);
     if ($user) {
         if ($user->isAdmin()) {
             // check to see if there is an LDAP connection for this environment
             //
             $ldapConnectionConfig = Config::get('ldap.connections.' . App::environment());
             if ($ldapConnectionConfig != null) {
                 // use LDAP
                 //
                 $users = User::getAll();
                 // sort by date
                 //
                 $users->sortByDesc('create_date');
                 // add date filter
                 //
                 $users = self::filterByDate($users);
                 // add limit filter
                 //
                 $limit = Input::get('limit');
                 if ($limit != '') {
                     $users = $users->slice(0, $limit);
                 }
             } else {
                 // use SQL
                 //
                 $usersQuery = User::orderBy('create_date', 'DESC');
                 // add filters
                 //
                 $usersQuery = DateFilter::apply($usersQuery);
                 $usersQuery = LimitFilter::apply($usersQuery);
                 $users = $usersQuery->get();
             }
             return $users;
         } else {
             return Response::make('This user is not an administrator.', 500);
         }
     } else {
         return Response::make('Administrator authorization is required.', 500);
     }
 }