Пример #1
0
 static function apply($query)
 {
     // check for tool name
     //
     $toolName = Input::get('tool_name');
     if ($toolName != '') {
         $query = $query->where('tool_name', '=', $toolName);
     }
     // check for tool uuid
     //
     $toolUuid = Input::get('tool_uuid');
     if ($toolUuid != '') {
         $toolVersions = ToolVersion::where('tool_uuid', '=', $toolUuid)->get();
         $query = $query->where(function ($query) use($toolVersions) {
             for ($i = 0; $i < sizeof($toolVersions); $i++) {
                 if ($i == 0) {
                     $query->where('tool_version_uuid', '=', $toolVersions[$i]->tool_version_uuid);
                 } else {
                     $query->orWhere('tool_version_uuid', '=', $toolVersions[$i]->tool_version_uuid);
                 }
             }
         });
     }
     // check for tool version
     //
     $toolVersion = Input::get('tool_version');
     if ($toolVersion == 'latest') {
         $tool = $tool::where('tool_uuid', '=', $toolUuid)->first();
         if ($tool) {
             $latestVersion = $tool->getLatestVersion();
             $query = $query->where('tool_version_uuid', '=', $latestVersion->tool_version_uuid);
         }
     } else {
         if ($toolVersion != '') {
             $query = $query->where('tool_version_uuid', '=', $toolVersion);
         }
     }
     // check for tool version uuid
     //
     $toolVersionUuid = Input::get('tool_version_uuid');
     if ($toolVersionUuid == 'latest') {
         $tool = Tool::where('tool_uuid', '=', $toolVersionUuid)->first();
         if ($tool) {
             $latestVersion = $tool->getLatestVersion();
             $query = $query->where('tool_version_uuid', '=', $latestVersion->tool_version_uuid);
         }
     } else {
         if ($toolVersionUuid != '') {
             $query = $query->where('tool_version_uuid', '=', $toolVersionUuid);
         }
     }
     return $query;
 }
Пример #2
0
 public function getToolAttribute()
 {
     $toolVersion = ToolVersion::where('tool_version_uuid', '=', $this->tool_version_uuid)->first();
     if ($toolVersion != null) {
         $tool = Tool::where('tool_uuid', '=', $toolVersion->tool_uuid)->first();
     } else {
         $tool = null;
     }
     // get tool info from results
     //
     if (!$tool || !$toolVersion) {
         $assessmentResult = AssessmentResult::where('execution_record_uuid', '=', $this->execution_record_uuid)->first();
     }
     return array('name' => $tool ? $tool->name : ($assessmentResult ? $assessmentResult->tool_name : ''), 'version_string' => $toolVersion ? $toolVersion->version_string : ($assessmentResult ? $assessmentResult->tool_version : ''), 'tool_uuid' => $tool ? $tool->tool_uuid : '', 'tool_version_uuid' => $toolVersion ? $toolVersion->tool_version_uuid : '');
 }
Пример #3
0
 public function getToolVersionStringAttribute()
 {
     $toolVersion = ToolVersion::where('tool_version_uuid', '=', $this->tool_version_uuid)->first();
     return $toolVersion != null ? $toolVersion->version_string : 'latest';
 }
Пример #4
0
         //
         if (!$isPublic) {
             if (!($user->isAdmin() || $tool->isOwnedBy($user))) {
                 return Response::make('Insufficient priveleges to access tool.', 403);
             }
         }
     }
 }
 // check tool version routes
 //
 $toolVersionUuid = $route->getParameter('tool_version_uuid');
 if ($toolVersionUuid) {
     // get relevant attributes
     //
     $user = User::getIndex(Session::get('user_uid'));
     $toolVersion = ToolVersion::where('tool_version_uuid', '=', $toolVersionUuid)->first();
     $tool = Tool::where('tool_uuid', '=', $toolVersion->tool_uuid)->first();
     $isPublic = $tool->tool_sharing_status == 'public' || $tool->tool_sharing_status == 'PUBLIC';
     $authenticationRequired = $method != 'get' && !$isPublic;
     // check to see if user is logged in
     //
     if ($authenticationRequired && !$user) {
         return Response::make('Authentication required to access tool version.', 401);
     } else {
         // check to see if user has priveleges to view tool version
         //
         if (!$isPublic) {
             if (!($user->isAdmin() || $toolVersion->getTool()->isOwnedBy($user))) {
                 return Response::make('Insufficient priveleges to access tool version.', 403);
             }
         }
Пример #5
0
 public function getVersions($toolUuid)
 {
     $toolVersions = ToolVersion::where('tool_uuid', '=', $toolUuid)->get();
     return $toolVersions;
 }
 public function deleteIndex($toolVersionUuid)
 {
     $toolVersion = ToolVersion::where('tool_version_uuid', '=', $toolVersionUuid)->first();
     $toolVersion->delete();
     return $toolVersion;
 }
Пример #7
0
 public function getLatestVersion()
 {
     return ToolVersion::where('tool_uuid', '=', $this->tool_uuid)->orderBy('version_no', 'DESC')->first();
 }