{"action":"created","comment":{"url":"https://api.github.com/repos/compucorp/civihr/pulls/comments/201708347","pull_request_review_id":136261057,"id":201708347,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTcwODM0Nw==","diff_hunk":"@@ -430,4 +431,62 @@ public function getInaccessibleFeedConfigs(\n \n     return $inaccessibleFeeds;\n   }\n+\n+  /**\n+   * Returns a LeaveRequestCalendarFeedConfig object if an\n+   * active feed config with the given hash is found.\n+   *\n+   * @param string $hash\n+   *\n+   * @return LeaveRequestCalendarFeedConfig\n+   */\n+  public static function findActiveByHash($hash) {\n+    $feedConfig = new self();\n+    $feedConfig->is_active = 1;\n+    $feedConfig->hash = $hash;\n+\n+    if (!$feedConfig->find(TRUE)) {\n+      throw new InvalidLeaveRequestCalendarFeedConfigException(\n+        \"An enabled feed with the given hash does not exist!\"\n+      );\n+    }\n+\n+    return $feedConfig;\n+  }\n+\n+  /**\n+   * Returns the departments the feed config has set for the\n+   * composed of property.\n+   *\n+   * @return string\n+   */\n+  public function getDepartmentsComposedOf() {","path":"uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/BAO/LeaveRequestCalendarFeedConfig.php","position":41,"original_position":41,"commit_id":"dabec6d312bc24eb10e8719b96f503ecac937d7e","original_commit_id":"f50d70c0f8c39bc58ba2097fe5611ddab1c35b24","user":{"login":"davialexandre","id":388373,"node_id":"MDQ6VXNlcjM4ODM3Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/388373?v=4","gravatar_id":"","url":"https://api.github.com/users/davialexandre","html_url":"https://github.com/davialexandre","followers_url":"https://api.github.com/users/davialexandre/followers","following_url":"https://api.github.com/users/davialexandre/following{/other_user}","gists_url":"https://api.github.com/users/davialexandre/gists{/gist_id}","starred_url":"https://api.github.com/users/davialexandre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davialexandre/subscriptions","organizations_url":"https://api.github.com/users/davialexandre/orgs","repos_url":"https://api.github.com/users/davialexandre/repos","events_url":"https://api.github.com/users/davialexandre/events{/privacy}","received_events_url":"https://api.github.com/users/davialexandre/received_events","type":"User","site_admin":false},"body":"Do we really need the `ComposedOf` as part of the method name? Why not simply `getDepartments()`, `getLocations()` etc? It doesn't matter for the other classes that this information is stored as an array inside `composed_of`","created_at":"2018-07-11T14:21:24Z","updated_at":"2018-07-11T14:39:37Z","html_url":"https://github.com/compucorp/civihr/pull/2752#discussion_r201708347","pull_request_url":"https://api.github.com/repos/compucorp/civihr/pulls/2752","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/compucorp/civihr/pulls/comments/201708347"},"html":{"href":"https://github.com/compucorp/civihr/pull/2752#discussion_r201708347"},"pull_request":{"href":"https://api.github.com/repos/compucorp/civihr/pulls/2752"}}},"pull_request":{"url":"https://api.github.com/repos/compucorp/civihr/pulls/2752","id":200407501,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwNDA3NTAx","html_url":"https://github.com/compucorp/civihr/pull/2752","diff_url":"https://github.com/compucorp/civihr/pull/2752.diff","patch_url":"https://github.com/compucorp/civihr/pull/2752.patch","issue_url":"https://api.github.com/repos/compucorp/civihr/issues/2752","number":2752,"state":"open","locked":false,"title":"PCHR-3870: Provide Functionality for getting Leave Ical Feed Via URL","user":{"login":"tunbola","id":6951813,"node_id":"MDQ6VXNlcjY5NTE4MTM=","avatar_url":"https://avatars1.githubusercontent.com/u/6951813?v=4","gravatar_id":"","url":"https://api.github.com/users/tunbola","html_url":"https://github.com/tunbola","followers_url":"https://api.github.com/users/tunbola/followers","following_url":"https://api.github.com/users/tunbola/following{/other_user}","gists_url":"https://api.github.com/users/tunbola/gists{/gist_id}","starred_url":"https://api.github.com/users/tunbola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tunbola/subscriptions","organizations_url":"https://api.github.com/users/tunbola/orgs","repos_url":"https://api.github.com/users/tunbola/repos","events_url":"https://api.github.com/users/tunbola/events{/privacy}","received_events_url":"https://api.github.com/users/tunbola/received_events","type":"User","site_admin":false},"body":"## Overview\r\nThis PR adds functionality for actual Leave request Ical feed generation off the Feed configuration.\r\nThis PR also depends on https://github.com/compucorp/civihr-employee-portal/pull/511 which allows the calendar feed URL not to be blocked by the public firewall and to be publicly accessible. \r\n\r\n## Before\r\n- The functionality for generating Leave request Ical feed was not present.\r\n## After\r\nTrying to retrieve the Ical for a disabled feed or non existent hash\r\n\r\n![feedgenerator2](https://user-images.githubusercontent.com/6951813/42515364-84375726-8453-11e8-8d90-92063468164a.gif)\r\n\r\nTrying to retrieve the Ical for a valid and enabled feed\r\n\r\n\r\n![feedgenerator](https://user-images.githubusercontent.com/6951813/42515365-8475da14-8453-11e8-8d08-f7be1bbc0980.gif)\r\n\r\n## Technical Details\r\n- A new public URL `civicrm/calendar-feed` was added that allows a user add a calendar feed to his preferred calendar application. \r\nA fully formed feed URL is similar to: `civicrm/calendar-feed?hash=7f9e70bebdc30dab872829893c47a3ac` where the hash is the feed config hash.\r\n- A new class `LeaveRequestCalendarFeedData` was added to encapsulate the logic needed for fetching associated data for a feed configuration. The class also provides a get method for returning prepared data in a format expected for the Leave request data Ical conversion.\r\n- A `LeaveRequestCalendarFeedIcal` was also added that accepts an `LeaveRequestCalendarFeedData` object in its get method and converts the prepared data to an Ical format.\r\n- For the purpose of display in the calendar, some changes were made to time for Leave requests in days:\r\n AM - 6 AM to 12 PM\r\n PM - 12:01 PM to 7 PM\r\n All Day - 6 AM to 7 PM\r\n\r\nA new `LeaveTime` CalendarFeed helper class was added to adjust the dates.\r\n- The calendar feed URL when visited for a valid calendar feed downloads an ical file as an attachment.\r\n\r\nA PHP Ical library https://github.com/zcontent/icalendar, was used in generating the Ical format off the Leave request calendar feed data. The library itself was added to a vendor folder in the HRCore extension.\r\nThe calendar feed URL invokes the get method of the `CRM_HRLeaveAndAbsences_Page_LeaveRequestCalendarFeed` function\r\n```php\r\n  <item>\r\n    <path>civicrm/calendar-feed</path>\r\n    <page_callback>CRM_HRLeaveAndAbsences_Page_LeaveRequestCalendarFeed::get</page_callback>\r\n    <title>LeaveCalendarFeed</title>\r\n    <access_callback>1</access_callback>\r\n    <is_public>true</is_public>\r\n  </item>\r\n```\r\nThe get method is used to render the Leave Ical data as a browser attachment\r\n```php\r\n  public static function get() {\r\n    try {\r\n      $feedHash = CRM_Utils_Array::value('hash', $_GET);\r\n      $leaveFeedData = new LeaveRequestCalendarFeedData($feedHash);\r\n      $leaveFeedIcal = new LeaveRequestCalendarFeedIcal();\r\n      $leaveFeedIcal = $leaveFeedIcal->get($leaveFeedData);\r\n\r\n      header('Content-Type: text/calendar; charset=utf-8');\r\n      header('Content-Disposition: attachment; filename=\"cal.ics\"');\r\n      echo $leaveFeedIcal;\r\n      die();\r\n\r\n    } catch(Exception $e) {\r\n      http_response_code(404);\r\n      echo $e->getMessage();\r\n      die();\r\n    }\r\n  }\r\n```","created_at":"2018-07-10T14:03:17Z","updated_at":"2018-07-11T14:39:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17afa8feaebce5c5ffaa4e29db19baede4e19a06","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/compucorp/civihr/pulls/2752/commits","review_comments_url":"https://api.github.com/repos/compucorp/civihr/pulls/2752/comments","review_comment_url":"https://api.github.com/repos/compucorp/civihr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/compucorp/civihr/issues/2752/comments","statuses_url":"https://api.github.com/repos/compucorp/civihr/statuses/dabec6d312bc24eb10e8719b96f503ecac937d7e","head":{"label":"compucorp:PCHR-3870-provide-ical-url","ref":"PCHR-3870-provide-ical-url","sha":"dabec6d312bc24eb10e8719b96f503ecac937d7e","user":{"login":"compucorp","id":2040164,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNDAxNjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2040164?v=4","gravatar_id":"","url":"https://api.github.com/users/compucorp","html_url":"https://github.com/compucorp","followers_url":"https://api.github.com/users/compucorp/followers","following_url":"https://api.github.com/users/compucorp/following{/other_user}","gists_url":"https://api.github.com/users/compucorp/gists{/gist_id}","starred_url":"https://api.github.com/users/compucorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/compucorp/subscriptions","organizations_url":"https://api.github.com/users/compucorp/orgs","repos_url":"https://api.github.com/users/compucorp/repos","events_url":"https://api.github.com/users/compucorp/events{/privacy}","received_events_url":"https://api.github.com/users/compucorp/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"node_id":"MDEwOlJlcG9zaXRvcnkxMDA4NjkwMw==","name":"civihr","full_name":"compucorp/civihr","owner":{"login":"compucorp","id":2040164,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNDAxNjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2040164?v=4","gravatar_id":"","url":"https://api.github.com/users/compucorp","html_url":"https://github.com/compucorp","followers_url":"https://api.github.com/users/compucorp/followers","following_url":"https://api.github.com/users/compucorp/following{/other_user}","gists_url":"https://api.github.com/users/compucorp/gists{/gist_id}","starred_url":"https://api.github.com/users/compucorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/compucorp/subscriptions","organizations_url":"https://api.github.com/users/compucorp/orgs","repos_url":"https://api.github.com/users/compucorp/repos","events_url":"https://api.github.com/users/compucorp/events{/privacy}","received_events_url":"https://api.github.com/users/compucorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/compucorp/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/compucorp/civihr","forks_url":"https://api.github.com/repos/compucorp/civihr/forks","keys_url":"https://api.github.com/repos/compucorp/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/compucorp/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/compucorp/civihr/teams","hooks_url":"https://api.github.com/repos/compucorp/civihr/hooks","issue_events_url":"https://api.github.com/repos/compucorp/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/compucorp/civihr/events","assignees_url":"https://api.github.com/repos/compucorp/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/compucorp/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/compucorp/civihr/tags","blobs_url":"https://api.github.com/repos/compucorp/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/compucorp/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/compucorp/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/compucorp/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/compucorp/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/compucorp/civihr/languages","stargazers_url":"https://api.github.com/repos/compucorp/civihr/stargazers","contributors_url":"https://api.github.com/repos/compucorp/civihr/contributors","subscribers_url":"https://api.github.com/repos/compucorp/civihr/subscribers","subscription_url":"https://api.github.com/repos/compucorp/civihr/subscription","commits_url":"https://api.github.com/repos/compucorp/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/compucorp/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/compucorp/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/compucorp/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/compucorp/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/compucorp/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/compucorp/civihr/merges","archive_url":"https://api.github.com/repos/compucorp/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/compucorp/civihr/downloads","issues_url":"https://api.github.com/repos/compucorp/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/compucorp/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/compucorp/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/compucorp/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/compucorp/civihr/labels{/name}","releases_url":"https://api.github.com/repos/compucorp/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/compucorp/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2018-07-11T12:39:53Z","pushed_at":"2018-07-11T13:29:34Z","git_url":"git://github.com/compucorp/civihr.git","ssh_url":"git@github.com:compucorp/civihr.git","clone_url":"https://github.com/compucorp/civihr.git","svn_url":"https://github.com/compucorp/civihr","homepage":null,"size":65641,"stargazers_count":30,"watchers_count":30,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":42,"mirror_url":null,"archived":false,"open_issues_count":9,"license":null,"forks":42,"open_issues":9,"watchers":30,"default_branch":"staging"}},"base":{"label":"compucorp:PCHR-3793-calendar-feeds","ref":"PCHR-3793-calendar-feeds","sha":"7513f3447236ed6d9d58f520d8f46b41497970d9","user":{"login":"compucorp","id":2040164,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNDAxNjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2040164?v=4","gravatar_id":"","url":"https://api.github.com/users/compucorp","html_url":"https://github.com/compucorp","followers_url":"https://api.github.com/users/compucorp/followers","following_url":"https://api.github.com/users/compucorp/following{/other_user}","gists_url":"https://api.github.com/users/compucorp/gists{/gist_id}","starred_url":"https://api.github.com/users/compucorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/compucorp/subscriptions","organizations_url":"https://api.github.com/users/compucorp/orgs","repos_url":"https://api.github.com/users/compucorp/repos","events_url":"https://api.github.com/users/compucorp/events{/privacy}","received_events_url":"https://api.github.com/users/compucorp/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"node_id":"MDEwOlJlcG9zaXRvcnkxMDA4NjkwMw==","name":"civihr","full_name":"compucorp/civihr","owner":{"login":"compucorp","id":2040164,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNDAxNjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2040164?v=4","gravatar_id":"","url":"https://api.github.com/users/compucorp","html_url":"https://github.com/compucorp","followers_url":"https://api.github.com/users/compucorp/followers","following_url":"https://api.github.com/users/compucorp/following{/other_user}","gists_url":"https://api.github.com/users/compucorp/gists{/gist_id}","starred_url":"https://api.github.com/users/compucorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/compucorp/subscriptions","organizations_url":"https://api.github.com/users/compucorp/orgs","repos_url":"https://api.github.com/users/compucorp/repos","events_url":"https://api.github.com/users/compucorp/events{/privacy}","received_events_url":"https://api.github.com/users/compucorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/compucorp/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/compucorp/civihr","forks_url":"https://api.github.com/repos/compucorp/civihr/forks","keys_url":"https://api.github.com/repos/compucorp/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/compucorp/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/compucorp/civihr/teams","hooks_url":"https://api.github.com/repos/compucorp/civihr/hooks","issue_events_url":"https://api.github.com/repos/compucorp/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/compucorp/civihr/events","assignees_url":"https://api.github.com/repos/compucorp/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/compucorp/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/compucorp/civihr/tags","blobs_url":"https://api.github.com/repos/compucorp/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/compucorp/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/compucorp/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/compucorp/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/compucorp/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/compucorp/civihr/languages","stargazers_url":"https://api.github.com/repos/compucorp/civihr/stargazers","contributors_url":"https://api.github.com/repos/compucorp/civihr/contributors","subscribers_url":"https://api.github.com/repos/compucorp/civihr/subscribers","subscription_url":"https://api.github.com/repos/compucorp/civihr/subscription","commits_url":"https://api.github.com/repos/compucorp/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/compucorp/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/compucorp/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/compucorp/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/compucorp/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/compucorp/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/compucorp/civihr/merges","archive_url":"https://api.github.com/repos/compucorp/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/compucorp/civihr/downloads","issues_url":"https://api.github.com/repos/compucorp/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/compucorp/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/compucorp/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/compucorp/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/compucorp/civihr/labels{/name}","releases_url":"https://api.github.com/repos/compucorp/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/compucorp/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2018-07-11T12:39:53Z","pushed_at":"2018-07-11T13:29:34Z","git_url":"git://github.com/compucorp/civihr.git","ssh_url":"git@github.com:compucorp/civihr.git","clone_url":"https://github.com/compucorp/civihr.git","svn_url":"https://github.com/compucorp/civihr","homepage":null,"size":65641,"stargazers_count":30,"watchers_count":30,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":42,"mirror_url":null,"archived":false,"open_issues_count":9,"license":null,"forks":42,"open_issues":9,"watchers":30,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/compucorp/civihr/pulls/2752"},"html":{"href":"https://github.com/compucorp/civihr/pull/2752"},"issue":{"href":"https://api.github.com/repos/compucorp/civihr/issues/2752"},"comments":{"href":"https://api.github.com/repos/compucorp/civihr/issues/2752/comments"},"review_comments":{"href":"https://api.github.com/repos/compucorp/civihr/pulls/2752/comments"},"review_comment":{"href":"https://api.github.com/repos/compucorp/civihr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/compucorp/civihr/pulls/2752/commits"},"statuses":{"href":"https://api.github.com/repos/compucorp/civihr/statuses/dabec6d312bc24eb10e8719b96f503ecac937d7e"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"davialexandre"}}