{"action":"created","comment":{"url":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/comments/57860638","id":57860638,"diff_hunk":"@@ -0,0 +1,177 @@\n+<?php\n+\n+/**\n+ * @file\n+ * Contains \\Drupal\\dbcdk_community\\Form\\QuarantineCreateForm.\n+ */\n+\n+namespace Drupal\\dbcdk_community\\Form;\n+\n+use DBCDK\\CommunityServices\\Api\\QuarantineApi;\n+use DBCDK\\CommunityServices\\ApiException;\n+use DBCDK\\CommunityServices\\Model\\Profile;\n+use Symfony\\Component\\DependencyInjection\\ContainerInterface;\n+use Drupal\\Core\\DependencyInjection\\ContainerInjectionInterface;\n+use Drupal\\Core\\Form\\FormBase;\n+use Drupal\\Core\\Form\\FormStateInterface;\n+use Drupal\\Core\\Url;\n+\n+/**\n+ * Create a Community Quarantine.\n+ */\n+class QuarantineCreateForm extends FormBase implements ContainerInjectionInterface {\n+\n+  /**\n+   * The date format the Community Client expects.\n+   */\n+  const DATE_FORMAT = 'Y-m-d';\n+\n+  /**\n+   * The Community Service Profile object from the username context.\n+   *\n+   * @var \\DBCDK\\CommunityServices\\Model\\Profile $profile\n+   */\n+  protected $profile;\n+\n+  /**\n+   * The DBCDK Community Service Quarantine API.\n+   *\n+   * @var \\DBCDK\\CommunityServices\\Api\\QuarantineApi $quarantineApi\n+   */\n+  protected $quarantineApi;\n+\n+  /**\n+   * QuarantineCreateForm constructor.\n+   *\n+   * @param \\DBCDK\\CommunityServices\\Model\\Profile $profile\n+   *   The Community Profile we wish to grant a quarantine.\n+   * @param \\DBCDK\\CommunityServices\\Api\\QuarantineApi $quarantine_api\n+   *   The Community Service Quarantine API.\n+   */\n+  public function __construct(Profile $profile, QuarantineApi $quarantine_api) {\n+    $this->profile = $profile;\n+    $this->quarantineApi = $quarantine_api;\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public static function create(ContainerInterface $container) {\n+    try {\n+      $profile_filter = [\n+        'where' => [\n+          'username' => $container->get('request_stack')->getCurrentRequest()->get('username'),\n+        ],\n+      ];\n+      /* @var \\DBCDK\\CommunityServices\\Api\\ProfileApi */\n+      $profile_api = $container->get('dbcdk_community.api.profile');\n+      $profile = $profile_api->profileFindOne(json_encode($profile_filter));\n+    }\n+    catch (ApiException $e) {\n+      \\Drupal::logger('DBCDK Community Service')->error($e);\n+      // Create an empty Profile instance. The constructor expects a Profile\n+      // object and will cause a fatal error if it receives something else and\n+      // we would like to display an empty page with a Drupal message in case of\n+      // an error.\n+      $profile = new Profile();\n+    }\n+\n+    return new static(\n+      $profile,\n+      $container->get('dbcdk_community.api.quarantine')\n+    );\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public function getFormId() {\n+    return 'dbcdk_community_quarantine_create_form';\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public function buildForm(array $form, FormStateInterface $form_state) {\n+    // Defensive coding to make sure we only display the \"create quarantine\"\n+    // form if we could find a Community Profile.\n+    if (empty($this->profile->getUsername())) {\n+      drupal_set_message($this->t('The system could not find the profile that should receive this quarantine. Please try again later or contact an administrator.'), 'error');\n+      return $form;\n+    }\n+\n+    $form['reason'] = [\n+      '#type' => 'textarea',\n+      '#title' => $this->t('Reason'),\n+      '#required' => TRUE,\n+    ];\n+\n+    $form['start'] = [\n+      '#type' => 'date',\n+      '#title' => $this->t('Start date'),\n+      '#date_date_format' => self::DATE_FORMAT,\n+      '#default_value' => date(self::DATE_FORMAT),\n+      '#required' => TRUE,\n+    ];\n+\n+    $form['end'] = [\n+      '#type' => 'date',\n+      '#title' => $this->t('End date'),\n+      '#date_date_format' => self::DATE_FORMAT,\n+      '#default_value' => date(self::DATE_FORMAT),\n+      '#required' => TRUE,\n+    ];\n+\n+    $form['actions']['#type'] = 'actions';\n+    $form['actions']['submit'] = [\n+      '#type' => 'submit',\n+      '#value' => $this->t('Create'),\n+      '#button_type' => 'primary',\n+    ];\n+    $form['actions']['cancel'] = [\n+      '#type' => 'link',\n+      '#title' => $this->t('Cancel'),\n+      '#url' => Url::fromRoute('page_manager.page_view_dbcdk_community_profile', [\n+        'username' => $this->profile->getUsername(),\n+      ]),\n+      '#attributes' => ['class' => ['button']],\n+    ];\n+\n+    return $form;\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public function submitForm(array &$form, FormStateInterface $form_state) {\n+    try {\n+      // Update fields on the Community Profile. The elements in the $fields\n+      // array represents the fields we wish to update.\n+      $fields = [\n+        'reason',\n+        'start',\n+        'end',\n+      ];\n+      $quarantine = [];\n+      foreach ($fields as $field) {\n+        $quarantine[$field] = $form_state->getValue($field);\n+      }\n+\n+      // Set the ID of the Drupal Moderator who created this quarantine.\n+      $quarantine['creatorId'] = $this->currentUser()->id();","path":"web/modules/custom/dbcdk_community/src/Form/QuarantineCreateForm.php","position":161,"original_position":161,"commit_id":"e3dac174b8504a64e8b6202a9a0eeafc3632b22b","original_commit_id":"e3dac174b8504a64e8b6202a9a0eeafc3632b22b","user":{"login":"kasperg","id":73966,"avatar_url":"https://avatars.githubusercontent.com/u/73966?v=3","gravatar_id":"","url":"https://api.github.com/users/kasperg","html_url":"https://github.com/kasperg","followers_url":"https://api.github.com/users/kasperg/followers","following_url":"https://api.github.com/users/kasperg/following{/other_user}","gists_url":"https://api.github.com/users/kasperg/gists{/gist_id}","starred_url":"https://api.github.com/users/kasperg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasperg/subscriptions","organizations_url":"https://api.github.com/users/kasperg/orgs","repos_url":"https://api.github.com/users/kasperg/repos","events_url":"https://api.github.com/users/kasperg/events{/privacy}","received_events_url":"https://api.github.com/users/kasperg/received_events","type":"User","site_admin":false},"body":"I think it would be good to have a little more elaborate description of why we set information about the Drupal user here and not a Community service id.","created_at":"2016-03-30T09:34:52Z","updated_at":"2016-03-30T09:34:52Z","html_url":"https://github.com/DBCDK/biblo-admin/pull/38#discussion_r57860638","pull_request_url":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/38","_links":{"self":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/comments/57860638"},"html":{"href":"https://github.com/DBCDK/biblo-admin/pull/38#discussion_r57860638"},"pull_request":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/38"}}},"pull_request":{"url":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/38","id":64436992,"html_url":"https://github.com/DBCDK/biblo-admin/pull/38","diff_url":"https://github.com/DBCDK/biblo-admin/pull/38.diff","patch_url":"https://github.com/DBCDK/biblo-admin/pull/38.patch","issue_url":"https://api.github.com/repos/DBCDK/biblo-admin/issues/38","number":38,"state":"open","locked":false,"title":"Quarantines","user":{"login":"kallehauge","id":3846700,"avatar_url":"https://avatars.githubusercontent.com/u/3846700?v=3","gravatar_id":"","url":"https://api.github.com/users/kallehauge","html_url":"https://github.com/kallehauge","followers_url":"https://api.github.com/users/kallehauge/followers","following_url":"https://api.github.com/users/kallehauge/following{/other_user}","gists_url":"https://api.github.com/users/kallehauge/gists{/gist_id}","starred_url":"https://api.github.com/users/kallehauge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kallehauge/subscriptions","organizations_url":"https://api.github.com/users/kallehauge/orgs","repos_url":"https://api.github.com/users/kallehauge/repos","events_url":"https://api.github.com/users/kallehauge/events{/privacy}","received_events_url":"https://api.github.com/users/kallehauge/received_events","type":"User","site_admin":false},"body":"This PR contains the following changes:\r\n\r\n* Add a Create Quarantine Form\r\n* Add a Edit Quarantine Form\r\n* Add a Quarantines Block to the Profile page\r\n* Generalise DBCDK Community date format since the usage outgrew \"birthdays\"","created_at":"2016-03-29T09:31:38Z","updated_at":"2016-03-30T09:34:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ed279500ac896ffe7b97c7ab0ff3a91872b1e75","assignee":{"login":"kasperg","id":73966,"avatar_url":"https://avatars.githubusercontent.com/u/73966?v=3","gravatar_id":"","url":"https://api.github.com/users/kasperg","html_url":"https://github.com/kasperg","followers_url":"https://api.github.com/users/kasperg/followers","following_url":"https://api.github.com/users/kasperg/following{/other_user}","gists_url":"https://api.github.com/users/kasperg/gists{/gist_id}","starred_url":"https://api.github.com/users/kasperg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasperg/subscriptions","organizations_url":"https://api.github.com/users/kasperg/orgs","repos_url":"https://api.github.com/users/kasperg/repos","events_url":"https://api.github.com/users/kasperg/events{/privacy}","received_events_url":"https://api.github.com/users/kasperg/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/38/commits","review_comments_url":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/38/comments","review_comment_url":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DBCDK/biblo-admin/issues/38/comments","statuses_url":"https://api.github.com/repos/DBCDK/biblo-admin/statuses/e3dac174b8504a64e8b6202a9a0eeafc3632b22b","head":{"label":"DBCDK:feature/quarantine-forms","ref":"feature/quarantine-forms","sha":"e3dac174b8504a64e8b6202a9a0eeafc3632b22b","user":{"login":"DBCDK","id":555633,"avatar_url":"https://avatars.githubusercontent.com/u/555633?v=3","gravatar_id":"","url":"https://api.github.com/users/DBCDK","html_url":"https://github.com/DBCDK","followers_url":"https://api.github.com/users/DBCDK/followers","following_url":"https://api.github.com/users/DBCDK/following{/other_user}","gists_url":"https://api.github.com/users/DBCDK/gists{/gist_id}","starred_url":"https://api.github.com/users/DBCDK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBCDK/subscriptions","organizations_url":"https://api.github.com/users/DBCDK/orgs","repos_url":"https://api.github.com/users/DBCDK/repos","events_url":"https://api.github.com/users/DBCDK/events{/privacy}","received_events_url":"https://api.github.com/users/DBCDK/received_events","type":"Organization","site_admin":false},"repo":{"id":51740597,"name":"biblo-admin","full_name":"DBCDK/biblo-admin","owner":{"login":"DBCDK","id":555633,"avatar_url":"https://avatars.githubusercontent.com/u/555633?v=3","gravatar_id":"","url":"https://api.github.com/users/DBCDK","html_url":"https://github.com/DBCDK","followers_url":"https://api.github.com/users/DBCDK/followers","following_url":"https://api.github.com/users/DBCDK/following{/other_user}","gists_url":"https://api.github.com/users/DBCDK/gists{/gist_id}","starred_url":"https://api.github.com/users/DBCDK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBCDK/subscriptions","organizations_url":"https://api.github.com/users/DBCDK/orgs","repos_url":"https://api.github.com/users/DBCDK/repos","events_url":"https://api.github.com/users/DBCDK/events{/privacy}","received_events_url":"https://api.github.com/users/DBCDK/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DBCDK/biblo-admin","description":"Admin application for biblo","fork":false,"url":"https://api.github.com/repos/DBCDK/biblo-admin","forks_url":"https://api.github.com/repos/DBCDK/biblo-admin/forks","keys_url":"https://api.github.com/repos/DBCDK/biblo-admin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DBCDK/biblo-admin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DBCDK/biblo-admin/teams","hooks_url":"https://api.github.com/repos/DBCDK/biblo-admin/hooks","issue_events_url":"https://api.github.com/repos/DBCDK/biblo-admin/issues/events{/number}","events_url":"https://api.github.com/repos/DBCDK/biblo-admin/events","assignees_url":"https://api.github.com/repos/DBCDK/biblo-admin/assignees{/user}","branches_url":"https://api.github.com/repos/DBCDK/biblo-admin/branches{/branch}","tags_url":"https://api.github.com/repos/DBCDK/biblo-admin/tags","blobs_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/refs{/sha}","trees_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DBCDK/biblo-admin/statuses/{sha}","languages_url":"https://api.github.com/repos/DBCDK/biblo-admin/languages","stargazers_url":"https://api.github.com/repos/DBCDK/biblo-admin/stargazers","contributors_url":"https://api.github.com/repos/DBCDK/biblo-admin/contributors","subscribers_url":"https://api.github.com/repos/DBCDK/biblo-admin/subscribers","subscription_url":"https://api.github.com/repos/DBCDK/biblo-admin/subscription","commits_url":"https://api.github.com/repos/DBCDK/biblo-admin/commits{/sha}","git_commits_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/commits{/sha}","comments_url":"https://api.github.com/repos/DBCDK/biblo-admin/comments{/number}","issue_comment_url":"https://api.github.com/repos/DBCDK/biblo-admin/issues/comments{/number}","contents_url":"https://api.github.com/repos/DBCDK/biblo-admin/contents/{+path}","compare_url":"https://api.github.com/repos/DBCDK/biblo-admin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DBCDK/biblo-admin/merges","archive_url":"https://api.github.com/repos/DBCDK/biblo-admin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DBCDK/biblo-admin/downloads","issues_url":"https://api.github.com/repos/DBCDK/biblo-admin/issues{/number}","pulls_url":"https://api.github.com/repos/DBCDK/biblo-admin/pulls{/number}","milestones_url":"https://api.github.com/repos/DBCDK/biblo-admin/milestones{/number}","notifications_url":"https://api.github.com/repos/DBCDK/biblo-admin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DBCDK/biblo-admin/labels{/name}","releases_url":"https://api.github.com/repos/DBCDK/biblo-admin/releases{/id}","deployments_url":"https://api.github.com/repos/DBCDK/biblo-admin/deployments","created_at":"2016-02-15T08:19:28Z","updated_at":"2016-02-15T12:37:38Z","pushed_at":"2016-03-30T08:48:44Z","git_url":"git://github.com/DBCDK/biblo-admin.git","ssh_url":"git@github.com:DBCDK/biblo-admin.git","clone_url":"https://github.com/DBCDK/biblo-admin.git","svn_url":"https://github.com/DBCDK/biblo-admin","homepage":null,"size":489,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"base":{"label":"DBCDK:develop","ref":"develop","sha":"61552d4bd3f4ab3e0b83c07fdfb6fdc2e3d06071","user":{"login":"DBCDK","id":555633,"avatar_url":"https://avatars.githubusercontent.com/u/555633?v=3","gravatar_id":"","url":"https://api.github.com/users/DBCDK","html_url":"https://github.com/DBCDK","followers_url":"https://api.github.com/users/DBCDK/followers","following_url":"https://api.github.com/users/DBCDK/following{/other_user}","gists_url":"https://api.github.com/users/DBCDK/gists{/gist_id}","starred_url":"https://api.github.com/users/DBCDK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBCDK/subscriptions","organizations_url":"https://api.github.com/users/DBCDK/orgs","repos_url":"https://api.github.com/users/DBCDK/repos","events_url":"https://api.github.com/users/DBCDK/events{/privacy}","received_events_url":"https://api.github.com/users/DBCDK/received_events","type":"Organization","site_admin":false},"repo":{"id":51740597,"name":"biblo-admin","full_name":"DBCDK/biblo-admin","owner":{"login":"DBCDK","id":555633,"avatar_url":"https://avatars.githubusercontent.com/u/555633?v=3","gravatar_id":"","url":"https://api.github.com/users/DBCDK","html_url":"https://github.com/DBCDK","followers_url":"https://api.github.com/users/DBCDK/followers","following_url":"https://api.github.com/users/DBCDK/following{/other_user}","gists_url":"https://api.github.com/users/DBCDK/gists{/gist_id}","starred_url":"https://api.github.com/users/DBCDK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBCDK/subscriptions","organizations_url":"https://api.github.com/users/DBCDK/orgs","repos_url":"https://api.github.com/users/DBCDK/repos","events_url":"https://api.github.com/users/DBCDK/events{/privacy}","received_events_url":"https://api.github.com/users/DBCDK/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DBCDK/biblo-admin","description":"Admin application for biblo","fork":false,"url":"https://api.github.com/repos/DBCDK/biblo-admin","forks_url":"https://api.github.com/repos/DBCDK/biblo-admin/forks","keys_url":"https://api.github.com/repos/DBCDK/biblo-admin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DBCDK/biblo-admin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DBCDK/biblo-admin/teams","hooks_url":"https://api.github.com/repos/DBCDK/biblo-admin/hooks","issue_events_url":"https://api.github.com/repos/DBCDK/biblo-admin/issues/events{/number}","events_url":"https://api.github.com/repos/DBCDK/biblo-admin/events","assignees_url":"https://api.github.com/repos/DBCDK/biblo-admin/assignees{/user}","branches_url":"https://api.github.com/repos/DBCDK/biblo-admin/branches{/branch}","tags_url":"https://api.github.com/repos/DBCDK/biblo-admin/tags","blobs_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/refs{/sha}","trees_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DBCDK/biblo-admin/statuses/{sha}","languages_url":"https://api.github.com/repos/DBCDK/biblo-admin/languages","stargazers_url":"https://api.github.com/repos/DBCDK/biblo-admin/stargazers","contributors_url":"https://api.github.com/repos/DBCDK/biblo-admin/contributors","subscribers_url":"https://api.github.com/repos/DBCDK/biblo-admin/subscribers","subscription_url":"https://api.github.com/repos/DBCDK/biblo-admin/subscription","commits_url":"https://api.github.com/repos/DBCDK/biblo-admin/commits{/sha}","git_commits_url":"https://api.github.com/repos/DBCDK/biblo-admin/git/commits{/sha}","comments_url":"https://api.github.com/repos/DBCDK/biblo-admin/comments{/number}","issue_comment_url":"https://api.github.com/repos/DBCDK/biblo-admin/issues/comments{/number}","contents_url":"https://api.github.com/repos/DBCDK/biblo-admin/contents/{+path}","compare_url":"https://api.github.com/repos/DBCDK/biblo-admin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DBCDK/biblo-admin/merges","archive_url":"https://api.github.com/repos/DBCDK/biblo-admin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DBCDK/biblo-admin/downloads","issues_url":"https://api.github.com/repos/DBCDK/biblo-admin/issues{/number}","pulls_url":"https://api.github.com/repos/DBCDK/biblo-admin/pulls{/number}","milestones_url":"https://api.github.com/repos/DBCDK/biblo-admin/milestones{/number}","notifications_url":"https://api.github.com/repos/DBCDK/biblo-admin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DBCDK/biblo-admin/labels{/name}","releases_url":"https://api.github.com/repos/DBCDK/biblo-admin/releases{/id}","deployments_url":"https://api.github.com/repos/DBCDK/biblo-admin/deployments","created_at":"2016-02-15T08:19:28Z","updated_at":"2016-02-15T12:37:38Z","pushed_at":"2016-03-30T08:48:44Z","git_url":"git://github.com/DBCDK/biblo-admin.git","ssh_url":"git@github.com:DBCDK/biblo-admin.git","clone_url":"https://github.com/DBCDK/biblo-admin.git","svn_url":"https://github.com/DBCDK/biblo-admin","homepage":null,"size":489,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/38"},"html":{"href":"https://github.com/DBCDK/biblo-admin/pull/38"},"issue":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/issues/38"},"comments":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/issues/38/comments"},"review_comments":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/38/comments"},"review_comment":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/pulls/38/commits"},"statuses":{"href":"https://api.github.com/repos/DBCDK/biblo-admin/statuses/e3dac174b8504a64e8b6202a9a0eeafc3632b22b"}}}}