Example #1
0
 /**
  * Used on github authorization between projects and users (see github.js)
  * Code moved from the old /GitHub.php file
  */
 public function connect()
 {
     $GitHub = new User(Session::uid());
     $workitem = new WorkItem();
     $workitem->loadById((int) $_GET['job']);
     $projectId = $workitem->getProjectId();
     $project = new Project($projectId);
     $connectResponse = $GitHub->processConnectResponse($project);
     if (!$connectResponse['error']) {
         if ($GitHub->storeCredentials($connectResponse['data']['access_token'], $project->getGithubId())) {
             $journal_message = sprintf("%s has been validated for project ##%s##", $GitHub->getNickname(), $project->getName());
             Utils::systemNotification($journal_message);
             Utils::redirect('./' . $workitem->getId());
         } else {
             // Something went wrong updating the users details, close this window and
             // display a proper error message to the user
             $message = 'Something went wrong and we could not complete the authorization process with GitHub. Please try again.';
         }
     } else {
         // We have an error on the response, close this window and display an error message
         // to the user
         $message = 'We received an error when trying to complete the authorization process with GitHub. Please notify a member of the O-Team for assistance.';
     }
     echo $message;
 }