コード例 #1
0
 static function apply($query, $projectUuid)
 {
     // check for package name
     //
     $packageName = Input::get('package_name');
     if ($packageName != '') {
         $query = $query->where('package_name', '=', $packageName);
     }
     // check for package uuid
     //
     $packageUuid = Input::get('package_uuid');
     if ($packageUuid != '') {
         $packageVersions = PackageVersion::where('package_uuid', '=', $packageUuid)->get();
         $query = $query->where(function ($query) use($packageVersions) {
             for ($i = 0; $i < sizeof($packageVersions); $i++) {
                 if ($i == 0) {
                     $query->where('package_version_uuid', '=', $packageVersions[$i]->package_version_uuid);
                 } else {
                     $query->orWhere('package_version_uuid', '=', $packageVersions[$i]->package_version_uuid);
                 }
             }
         });
     }
     // check for package version
     //
     $packageVersion = Input::get('package_version');
     if ($packageVersion == 'latest') {
         $package = Package::where('package_uuid', '=', $packageUuid)->first();
         if ($package) {
             $latestVersion = $package->getLatestVersion($projectUuid);
             if ($latestVersion) {
                 $query = $query->where('package_version_uuid', '=', $latestVersion->package_version_uuid);
             }
         }
     } else {
         if ($packageVersion != '') {
             $query = $query->where('package_version_uuid', '=', $packageVersion);
         }
     }
     // check for package version uuid
     //
     $packageVersionUuid = Input::get('package_version_uuid');
     if ($packageVersionUuid == 'latest') {
         $package = Package::where('package_uuid', '=', $packageUuid)->first();
         if ($package) {
             $latestVersion = $package->getLatestVersion($projectUuid);
             if ($latestVersion) {
                 $query = $query->where('package_version_uuid', '=', $latestVersion->package_version_uuid);
             }
         }
     } else {
         if ($packageVersionUuid != '') {
             $query = $query->where('package_version_uuid', '=', $packageVersionUuid);
         }
     }
     return $query;
 }
コード例 #2
0
 /**
  * accessor methods
  */
 public function getPackageAttribute()
 {
     $packageVersion = PackageVersion::where('package_version_uuid', '=', $this->package_version_uuid)->first();
     if ($packageVersion != null) {
         $package = Package::where('package_uuid', '=', $packageVersion->package_uuid)->first();
     } else {
         $package = null;
     }
     // get package info from results
     //
     if (!$package || !$packageVersion) {
         $assessmentResult = AssessmentResult::where('execution_record_uuid', '=', $this->execution_record_uuid)->first();
     }
     return array('name' => $package ? $package->name : ($assessmentResult ? $assessmentResult->package_name : ''), 'version_string' => $packageVersion ? $packageVersion->version_string : ($assessmentResult ? $assessmentResult->package_version : ''), 'package_uuid' => $package ? $package->package_uuid : '', 'package_version_uuid' => $packageVersion ? $packageVersion->package_version_uuid : '');
 }
コード例 #3
0
 public function checkCompatibility()
 {
     $error = $this->getPlatform($platformUuid, $platformVersionUuid);
     if ($error) {
         return $error;
     }
     $projectUuid = Input::get('project_uuid');
     $packageUuid = Input::get('package_uuid');
     $packageVersionUuid = Input::get('package_version_uuid');
     // latest package version
     //
     if ($packageVersionUuid == NULL) {
         $package = Package::where('package_uuid', '=', $packageUuid)->first();
         $packageVersionUuid = $package->getLatestVersion($projectUuid);
     }
     // if record found then package version is incompatible with platform version
     //
     $incompatible = PackagePlatform::where('package_uuid', '=', $packageUuid)->where('package_version_uuid', '=', $packageVersionUuid)->where('platform_uuid', '=', $platformUuid)->where('platform_version_uuid', '=', $platformVersionUuid)->first();
     if ($incompatible) {
         return Response::make('incompatible', 500);
     }
     return Response::make('compatible', 200);
 }
コード例 #4
0
 public function getPackage()
 {
     return Package::where('package_uuid', '=', $this->package_uuid)->first();
 }
コード例 #5
0
 private function getPackageTypeId($attributes)
 {
     // get package type id
     //
     if (Input::get('package_uuid') != NULL) {
         // existing packages
         //
         $package = Package::where('package_uuid', '=', $attributes['package_uuid'])->first();
         return $package->package_type_id;
     } else {
         // new packages
         //
         return Input::get('package_type_id');
     }
 }
コード例 #6
0
 public function getPackageNameAttribute()
 {
     $package = Package::where('package_uuid', '=', $this->package_uuid)->first();
     return $package != null ? $package->name : '?';
 }
コード例 #7
0
ファイル: filters.php プロジェクト: pombredanne/open-swamp
     if (!$user) {
         return Response::make('The request requires user authentication.', 401);
     }
     break;
 case 'get':
 case 'put':
 case 'delete':
     // check package routes
     //
     $packageUuid = $route->getParameter('package_uuid');
     $isPackageVersionRoute = $request->segment(3) == 'versions' || $request->segment(4) == 'versions';
     if ($packageUuid && $packageUuid != 'all' && !$isPackageVersionRoute) {
         // get relevant attributes
         //
         $user = User::getIndex(Session::get('user_uid'));
         $package = Package::where('package_uuid', '=', $packageUuid)->first();
         $authenticationRequired = $method != 'get' && !$package->isPublic();
         // check to see if user is logged in
         //
         if ($authenticationRequired && !$user) {
             return Response::make('Authentication required to access package.', 401);
         } else {
             // check to see if user has priveleges to view package
             //
             if ($package && !$package->isPublic()) {
                 if (!$user->isAdmin() && !$package->isAvailableTo($user)) {
                     return Response::make('Insufficient priveleges to access package.', 403);
                 }
             }
         }
     }
コード例 #8
0
 public function getToolPermissionStatus($toolUuid)
 {
     $tool = Tool::where('tool_uuid', '=', $toolUuid)->first();
     $package = Input::has('package_uuid') ? Package::where('package_uuid', '=', Input::get('package_uuid'))->first() : null;
     $project = Input::has('project_uid') ? Project::where('project_uid', '=', Input::get('project_uid'))->first() : null;
     $user = Input::has('user_uid') ? User::getIndex(Input::get('user_uid')) : User::getIndex(Session::get('user_uid'));
     // Parasoft tool
     //
     if ($tool->isParasoftTool()) {
         return $tool->getParasoftPermissionStatus($package, $project, $user);
     }
     return Response::json(array('success', true));
 }
コード例 #9
0
 public function deleteIndex($packageUuid)
 {
     $package = Package::where('package_uuid', '=', $packageUuid)->first();
     $package->delete();
     return $package;
 }