public function getProtected($projectUuid)
 {
     $platformTable = with(new Platform())->getTable();
     $platformSharingTable = with(new PlatformSharing())->getTable();
     $platformsQuery = PlatformSharing::where('project_uuid', '=', $projectUuid)->join($platformTable, $platformSharingTable . '.platform_uuid', '=', $platformTable . '.platform_uuid')->orderBy('name', 'ASC');
     // add filters
     //
     $platformsQuery = DateFilter::apply($platformsQuery);
     $platformsQuery = LimitFilter::apply($platformsQuery);
     return $platformsQuery->get();
 }
 public function getAll()
 {
     $user = User::getIndex(Session::get('user_uid'));
     if ($user && $user->isAdmin()) {
         $toolsQuery = Tool::orderBy('create_date', 'DESC');
         // add filters
         //
         $toolsQuery = DateFilter::apply($toolsQuery);
         $toolsQuery = LimitFilter::apply($toolsQuery);
         return $toolsQuery->get();
     }
     return '';
 }
 public function getAll($userUid)
 {
     $user = User::getIndex($userUid);
     if ($user) {
         if ($user->isAdmin()) {
             $projectsQuery = Project::orderBy('create_date', 'DESC');
             // add filters
             //
             $projectsQuery = DateFilter::apply($projectsQuery);
             $projectsQuery = LimitFilter::apply($projectsQuery);
             return $projectsQuery->get();
         } else {
             return Response::make('This user is not an administrator.', 500);
         }
     } else {
         return Response::make('Administrator authorization is required.', 500);
     }
 }
 public function getByProject($projectUuid)
 {
     // check for inactive or non-existant project
     //
     $project = Project::where('project_uid', '=', $projectUuid)->first();
     if (!$project || !$project->isActive()) {
         return array();
     }
     $assessmentResultsQuery = AssessmentResult::where('project_uid', '=', $projectUuid);
     // add filters
     //
     $assessmentResultsQuery = DateFilter::apply($assessmentResultsQuery);
     $assessmentResultsQuery = TripletFilter::apply($assessmentResultsQuery, $projectUuid);
     // order results before applying filter
     //
     $assessmentResultsQuery = $assessmentResultsQuery->orderBy('create_date', 'DESC');
     // add limit filter
     //
     $assessmentResultsQuery = LimitFilter::apply($assessmentResultsQuery);
     // perform query
     //
     return $assessmentResultsQuery->get();
 }
 public function getAll()
 {
     $user = User::getIndex(Session::get('user_uid'));
     if ($user && $user->isAdmin()) {
         $executionRecordsQuery = ExecutionRecord::orderBy('create_date', 'DESC');
         // add filters
         //
         $executionRecordsQuery = DateFilter::apply($executionRecordsQuery);
         $executionRecordsQuery = TripletFilter2::apply($executionRecordsQuery, null);
         $executionRecordsQuery = LimitFilter::apply($executionRecordsQuery);
         // allow soft delete
         //
         $executionRecordsQuery = $executionRecordsQuery->whereNull('delete_date');
         return $executionRecordsQuery->get();
     }
 }
示例#6
0
 static function apply($query)
 {
     $query = DateFilter::after($query);
     $query = DateFilter::before($query);
     return $query;
 }
 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);
     }
 }
 public function getSharedVersions($packageUuid, $projectUuid)
 {
     $packageVersions = PackageVersion::where('package_uuid', '=', $packageUuid)->get();
     if (!strpos($projectUuid, '+')) {
         // get by a single project
         //
         foreach ($packageVersions as $packageVersion) {
             if ($packageVersion->isPublic()) {
                 // add to package versions query
                 //
                 if (!isset($packageVersionsQuery)) {
                     $packageVersionsQuery = PackageVersion::where('package_version_uuid', '=', $packageVersion->package_version_uuid);
                 } else {
                     $packageVersionsQuery = $packageVersionsQuery->orWhere('package_version_uuid', '=', $packageVersion->package_version_uuid);
                 }
                 // add filters
                 //
                 $packageVersionsQuery = DateFilter::apply($packageVersionsQuery);
                 $packageVersionsQuery = LimitFilter::apply($packageVersionsQuery);
             } elseif ($packageVersion->isProtected()) {
                 foreach (PackageVersionSharing::where('package_version_uuid', '=', $packageVersion->package_version_uuid)->get() as $packageVersionSharing) {
                     if ($packageVersionSharing->project_uuid == $projectUuid) {
                         // add to package versions query
                         //
                         if (!isset($packageVersionsQuery)) {
                             $packageVersionsQuery = PackageVersion::where('package_version_uuid', '=', $packageVersion->package_version_uuid);
                         } else {
                             $packageVersionsQuery = $packageVersionsQuery->orWhere('package_version_uuid', '=', $packageVersion->package_version_uuid);
                         }
                         // add filters
                         //
                         $packageVersionsQuery = DateFilter::apply($packageVersionsQuery);
                         $packageVersionsQuery = LimitFilter::apply($packageVersionsQuery);
                         break;
                     }
                 }
             }
         }
     } else {
         // get by multiple projects
         //
         $projectUuids = explode('+', $projectUuid);
         foreach ($packageVersions as $packageVersion) {
             if ($packageVersion->isPublic()) {
                 // add to package versions query
                 //
                 if (!isset($packageVersionsQuery)) {
                     $packageVersionsQuery = PackageVersion::where('package_version_uuid', '=', $packageVersion->package_version_uuid);
                 } else {
                     $packageVersionsQuery = $packageVersionsQuery->orWhere('package_version_uuid', '=', $packageVersion->package_version_uuid);
                 }
                 // add filters
                 //
                 $packageVersionsQuery = DateFilter::apply($packageVersionsQuery);
                 $packageVersionsQuery = LimitFilter::apply($packageVersionsQuery);
             } elseif ($packageVersion->isProtected()) {
                 foreach (PackageVersionSharing::where('package_version_uuid', '=', $packageVersion->package_version_uuid)->get() as $packageVersionSharing) {
                     foreach ($projectUuids as $projectUuid) {
                         if ($packageVersionSharing->project_uuid == $projectUuid) {
                             // add to package versions query
                             //
                             if (!isset($packageVersionsQuery)) {
                                 $packageVersionsQuery = PackageVersion::where('package_version_uuid', '=', $packageVersion->package_version_uuid);
                             } else {
                                 $packageVersionsQuery = $packageVersionsQuery->orWhere('package_version_uuid', '=', $packageVersion->package_version_uuid);
                             }
                             // add filters
                             //
                             $packageVersionsQuery = DateFilter::apply($packageVersionsQuery);
                             $packageVersionsQuery = LimitFilter::apply($packageVersionsQuery);
                             break 2;
                         }
                     }
                 }
             }
         }
     }
     // perform query
     //
     if (isset($packageVersionsQuery)) {
         return $packageVersionsQuery->get();
     } else {
         return array();
     }
 }