{"action":"created","comment":{"url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/comments/58419624","id":58419624,"diff_hunk":"@@ -0,0 +1,205 @@\n+<?php\n+/*\n+ You may not change or alter any portion of this comment or credits\n+ of supporting developers from this source code or any supporting source code\n+ which is considered copyrighted (c) material of the original comment or credit authors.\n+\n+ This program is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n+*/\n+\n+use Xoops\\Core\\Kernel\\CriteriaElement;\n+use Xoops\\Core\\Service\\AbstractContract;\n+use Xoops\\Core\\Service\\Response;\n+use Xoops\\Core\\Service\\Contract\\NotificationsInterface;\n+\n+/**\n+ * Notifications provider for service manager\n+ *\n+ * @category  Module\n+ * @package   Notifications\n+ * @author    Alain91 <alain091@gmail.com>\n+ * @copyright XOOPS Project (http://xoops.org)\n+ * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)\n+ * @link      http://xoops.org\n+ * @since     2.6.0\n+ */\n+class NotificationsProvider extends AbstractContract implements NotificationsInterface\n+{\n+\tprotected $xoops_url;\n+\tprotected $xoops_upload_url;\n+\n+    public function __construct()\n+    {\n+\t\t$this->xoops_url = \\XoopsBaseConfig::get('url');\n+\t\t$this->xoops_upload_url = \\XoopsBaseConfig::get('uploads-url');\n+    }\n+\n+    /**\n+     * getName - get a short name for this service provider. This should be unique within the\n+     * scope of the named service, so using module dirname is suggested.\n+     *\n+     * @return string - a unique name for the service provider\n+     */\n+    public function getName()\n+    {\n+        return 'notifications';\n+    }\n+\n+    /**\n+     * getDescription - get human readable description of the service provider\n+     *\n+     * @return string\n+     */\n+    public function getDescription()\n+    {\n+        return 'Traditional XOOPS notifications.';\n+    }\n+\n+    public function notifyUser(Response $response, $template_dir, $template, $subject, $tags)\n+    {\n+        $notification = new NotificationsNotification();\n+        $ret = $notification->notifyUser($template_dir, $template, $subject, $tags);\n+        if (!$ret)\n+            $response->setSuccess(false)->addErrorMessage('Unable to notify user');           \n+    }\n+\n+    public function getObjectsArray(Response $response, CriteriaElement $criteria = null, $id_as_key = false)\n+    {\n+        $handler = Notifications::getInstance()->getHandlerNotification();\n+        $ret = $handler->getObjectsArray($criteria, $id_as_key);\n+        if ($ret)\n+            $response->setValue($ret);\n+        else\n+            $response->setSuccess(false)->addErrorMessage('Unable to getObjectsArray');\n+    }\n+    \n+    public function getNotification(Response $response, $module_id, $category, $item_id, $event, $user_id)\n+    {\n+        $handler = Notifications::getInstance()->getHandlerNotification();\n+        $ret = $handler->getNotification($module_id, $category, $item_id, $event, $user_id);\n+        if ($ret)\n+            $response->setValue($ret);\n+        else\n+            $response->setSuccess(false)->addErrorMessage('Unable to getNotification');\n+    }\n+    \n+    public function isSubscribed(Response $response, $category, $item_id, $event, $module_id, $user_id)\n+    {\n+        $handler = Notifications::getInstance()->getHandlerNotification();\n+        $ret = $handler->isSubscribed($module_id, $category, $item_id, $event, $user_id);\n+        $response->setValue((int)$ret);\n+    }\n+    \n+    public function subscribe(Response $response, $category, $item_id, $events, $mode = null, $module_id = null, $user_id = null)\n+    {\n+        $handler = Notifications::getInstance()->getHandlerNotification();\n+        $ret = $handler->suscribe($category, $item_id, $events, $mode, $module_id, $user_id);\n+        if (!$ret)\n+            $response->setSuccess(false)->addErrorMessage('Unable to suscribe');\n+    }\n+\n+    public function getByUser(Response $response, $user_id)\n+    {\n+        $handler = Notifications::getInstance()->getHandlerNotification();\n+        $ret = $handler->getByUser($user_id);\n+        $response->setValue($ret);\n+    }\n+    \n+    public function getSubscribedEvents(Response $response, $category, $item_id, $module_id, $user_id)\n+    {\n+        $handler = Notifications::getInstance()->getHandlerNotification();\n+        $ret = $handler->getSubscribedEvents($category, $item_id, $module_id, $user_id);\n+        $response->setValue($ret);\n+    }\n+\n+    public function getByItemId(Response $response, $module_id, $item_id, $order = null, $status = null)\n+    {\n+        $handler = Notifications::getInstance()->getHandlerNotification();\n+        $ret = $handler->getByItemId($module_id, $item_id, $order, $status);\n+        $response->setValue($ret);\n+    }\n+    \n+    public function triggerEvents(\n+        Response $response,\n+        $category,\n+        $item_id,\n+        $events,\n+        $extra_tags = array(),\n+        $user_list = array(),\n+        $module_id = null,\n+        $omit_user_id = null\n+    ) {\n+        $handler = Notifications::getInstance()->getHandlerNotification();\n+        $ret = $handler->triggerEvents($category, $item_id, $events, $extra_tags, $user_list, $module_id, $omit_user_id);\n+        if (!ret)\n+            $response->setSuccess(false)->addErrorMessage('Unable to triggerEvents');\n+    }\n+    \n+    public function triggerEvent(\n+        Response $response,\n+        $category,\n+        $item_id,\n+        $event,\n+        $extra_tags = array(),\n+        $user_list = array(),\n+        $module_id = null,\n+        $omit_user_id = null\n+    ) {\n+        $helper = Notifications::getInstance();\n+        $handler = $helper->getHandlerNotification();\n+        if (empty($category) AND empty($module_id)) {","path":"htdocs/modules/notifications/class/NotificationsProvider.php","position":152,"original_position":152,"commit_id":"41288efea46febce4c7641e67769a2ad6fe6ea1c","original_commit_id":"41288efea46febce4c7641e67769a2ad6fe6ea1c","user":{"login":"geekwright","id":3181636,"avatar_url":"https://avatars.githubusercontent.com/u/3181636?v=3","gravatar_id":"","url":"https://api.github.com/users/geekwright","html_url":"https://github.com/geekwright","followers_url":"https://api.github.com/users/geekwright/followers","following_url":"https://api.github.com/users/geekwright/following{/other_user}","gists_url":"https://api.github.com/users/geekwright/gists{/gist_id}","starred_url":"https://api.github.com/users/geekwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geekwright/subscriptions","organizations_url":"https://api.github.com/users/geekwright/orgs","repos_url":"https://api.github.com/users/geekwright/repos","events_url":"https://api.github.com/users/geekwright/events{/privacy}","received_events_url":"https://api.github.com/users/geekwright/received_events","type":"User","site_admin":false},"body":"Would be better if `AND` was `&&`. That is generally considered best practice.","created_at":"2016-04-04T18:05:13Z","updated_at":"2016-04-04T18:05:13Z","html_url":"https://github.com/XOOPS/XoopsCore/pull/474#discussion_r58419624","pull_request_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/474","_links":{"self":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/comments/58419624"},"html":{"href":"https://github.com/XOOPS/XoopsCore/pull/474#discussion_r58419624"},"pull_request":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/474"}}},"pull_request":{"url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/474","id":65177097,"html_url":"https://github.com/XOOPS/XoopsCore/pull/474","diff_url":"https://github.com/XOOPS/XoopsCore/pull/474.diff","patch_url":"https://github.com/XOOPS/XoopsCore/pull/474.patch","issue_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues/474","number":474,"state":"open","locked":false,"title":"experimental - same functionalities","user":{"login":"alain91","id":3891288,"avatar_url":"https://avatars.githubusercontent.com/u/3891288?v=3","gravatar_id":"","url":"https://api.github.com/users/alain91","html_url":"https://github.com/alain91","followers_url":"https://api.github.com/users/alain91/followers","following_url":"https://api.github.com/users/alain91/following{/other_user}","gists_url":"https://api.github.com/users/alain91/gists{/gist_id}","starred_url":"https://api.github.com/users/alain91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alain91/subscriptions","organizations_url":"https://api.github.com/users/alain91/orgs","repos_url":"https://api.github.com/users/alain91/repos","events_url":"https://api.github.com/users/alain91/events{/privacy}","received_events_url":"https://api.github.com/users/alain91/received_events","type":"User","site_admin":false},"body":"Just to check the functionalities.\r\n\r\nThe service provides all the Handler do.","created_at":"2016-04-04T16:51:34Z","updated_at":"2016-04-04T18:05:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"126c8b64160c59b8b6bd5f665bd79cf466dd985b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/474/commits","review_comments_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/474/comments","review_comment_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues/474/comments","statuses_url":"https://api.github.com/repos/XOOPS/XoopsCore/statuses/41288efea46febce4c7641e67769a2ad6fe6ea1c","head":{"label":"alain91:notif","ref":"notif","sha":"41288efea46febce4c7641e67769a2ad6fe6ea1c","user":{"login":"alain91","id":3891288,"avatar_url":"https://avatars.githubusercontent.com/u/3891288?v=3","gravatar_id":"","url":"https://api.github.com/users/alain91","html_url":"https://github.com/alain91","followers_url":"https://api.github.com/users/alain91/followers","following_url":"https://api.github.com/users/alain91/following{/other_user}","gists_url":"https://api.github.com/users/alain91/gists{/gist_id}","starred_url":"https://api.github.com/users/alain91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alain91/subscriptions","organizations_url":"https://api.github.com/users/alain91/orgs","repos_url":"https://api.github.com/users/alain91/repos","events_url":"https://api.github.com/users/alain91/events{/privacy}","received_events_url":"https://api.github.com/users/alain91/received_events","type":"User","site_admin":false},"repo":{"id":16463533,"name":"XoopsCore","full_name":"alain91/XoopsCore","owner":{"login":"alain91","id":3891288,"avatar_url":"https://avatars.githubusercontent.com/u/3891288?v=3","gravatar_id":"","url":"https://api.github.com/users/alain91","html_url":"https://github.com/alain91","followers_url":"https://api.github.com/users/alain91/followers","following_url":"https://api.github.com/users/alain91/following{/other_user}","gists_url":"https://api.github.com/users/alain91/gists{/gist_id}","starred_url":"https://api.github.com/users/alain91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alain91/subscriptions","organizations_url":"https://api.github.com/users/alain91/orgs","repos_url":"https://api.github.com/users/alain91/repos","events_url":"https://api.github.com/users/alain91/events{/privacy}","received_events_url":"https://api.github.com/users/alain91/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alain91/XoopsCore","description":"XoopsCore","fork":true,"url":"https://api.github.com/repos/alain91/XoopsCore","forks_url":"https://api.github.com/repos/alain91/XoopsCore/forks","keys_url":"https://api.github.com/repos/alain91/XoopsCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alain91/XoopsCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alain91/XoopsCore/teams","hooks_url":"https://api.github.com/repos/alain91/XoopsCore/hooks","issue_events_url":"https://api.github.com/repos/alain91/XoopsCore/issues/events{/number}","events_url":"https://api.github.com/repos/alain91/XoopsCore/events","assignees_url":"https://api.github.com/repos/alain91/XoopsCore/assignees{/user}","branches_url":"https://api.github.com/repos/alain91/XoopsCore/branches{/branch}","tags_url":"https://api.github.com/repos/alain91/XoopsCore/tags","blobs_url":"https://api.github.com/repos/alain91/XoopsCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alain91/XoopsCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alain91/XoopsCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/alain91/XoopsCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alain91/XoopsCore/statuses/{sha}","languages_url":"https://api.github.com/repos/alain91/XoopsCore/languages","stargazers_url":"https://api.github.com/repos/alain91/XoopsCore/stargazers","contributors_url":"https://api.github.com/repos/alain91/XoopsCore/contributors","subscribers_url":"https://api.github.com/repos/alain91/XoopsCore/subscribers","subscription_url":"https://api.github.com/repos/alain91/XoopsCore/subscription","commits_url":"https://api.github.com/repos/alain91/XoopsCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/alain91/XoopsCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/alain91/XoopsCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/alain91/XoopsCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/alain91/XoopsCore/contents/{+path}","compare_url":"https://api.github.com/repos/alain91/XoopsCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alain91/XoopsCore/merges","archive_url":"https://api.github.com/repos/alain91/XoopsCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alain91/XoopsCore/downloads","issues_url":"https://api.github.com/repos/alain91/XoopsCore/issues{/number}","pulls_url":"https://api.github.com/repos/alain91/XoopsCore/pulls{/number}","milestones_url":"https://api.github.com/repos/alain91/XoopsCore/milestones{/number}","notifications_url":"https://api.github.com/repos/alain91/XoopsCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alain91/XoopsCore/labels{/name}","releases_url":"https://api.github.com/repos/alain91/XoopsCore/releases{/id}","deployments_url":"https://api.github.com/repos/alain91/XoopsCore/deployments","created_at":"2014-02-02T21:21:30Z","updated_at":"2015-05-07T22:20:53Z","pushed_at":"2016-04-04T16:48:55Z","git_url":"git://github.com/alain91/XoopsCore.git","ssh_url":"git@github.com:alain91/XoopsCore.git","clone_url":"https://github.com/alain91/XoopsCore.git","svn_url":"https://github.com/alain91/XoopsCore","homepage":null,"size":22405,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"XOOPS:master","ref":"master","sha":"cde4990bf428be71023956e53047b793aa47ca50","user":{"login":"XOOPS","id":3910043,"avatar_url":"https://avatars.githubusercontent.com/u/3910043?v=3","gravatar_id":"","url":"https://api.github.com/users/XOOPS","html_url":"https://github.com/XOOPS","followers_url":"https://api.github.com/users/XOOPS/followers","following_url":"https://api.github.com/users/XOOPS/following{/other_user}","gists_url":"https://api.github.com/users/XOOPS/gists{/gist_id}","starred_url":"https://api.github.com/users/XOOPS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XOOPS/subscriptions","organizations_url":"https://api.github.com/users/XOOPS/orgs","repos_url":"https://api.github.com/users/XOOPS/repos","events_url":"https://api.github.com/users/XOOPS/events{/privacy}","received_events_url":"https://api.github.com/users/XOOPS/received_events","type":"Organization","site_admin":false},"repo":{"id":12440699,"name":"XoopsCore","full_name":"XOOPS/XoopsCore","owner":{"login":"XOOPS","id":3910043,"avatar_url":"https://avatars.githubusercontent.com/u/3910043?v=3","gravatar_id":"","url":"https://api.github.com/users/XOOPS","html_url":"https://github.com/XOOPS","followers_url":"https://api.github.com/users/XOOPS/followers","following_url":"https://api.github.com/users/XOOPS/following{/other_user}","gists_url":"https://api.github.com/users/XOOPS/gists{/gist_id}","starred_url":"https://api.github.com/users/XOOPS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XOOPS/subscriptions","organizations_url":"https://api.github.com/users/XOOPS/orgs","repos_url":"https://api.github.com/users/XOOPS/repos","events_url":"https://api.github.com/users/XOOPS/events{/privacy}","received_events_url":"https://api.github.com/users/XOOPS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/XOOPS/XoopsCore","description":"Core Framework for next version of XOOPS CMS: 2.6.0","fork":false,"url":"https://api.github.com/repos/XOOPS/XoopsCore","forks_url":"https://api.github.com/repos/XOOPS/XoopsCore/forks","keys_url":"https://api.github.com/repos/XOOPS/XoopsCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/XOOPS/XoopsCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/XOOPS/XoopsCore/teams","hooks_url":"https://api.github.com/repos/XOOPS/XoopsCore/hooks","issue_events_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues/events{/number}","events_url":"https://api.github.com/repos/XOOPS/XoopsCore/events","assignees_url":"https://api.github.com/repos/XOOPS/XoopsCore/assignees{/user}","branches_url":"https://api.github.com/repos/XOOPS/XoopsCore/branches{/branch}","tags_url":"https://api.github.com/repos/XOOPS/XoopsCore/tags","blobs_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/XOOPS/XoopsCore/statuses/{sha}","languages_url":"https://api.github.com/repos/XOOPS/XoopsCore/languages","stargazers_url":"https://api.github.com/repos/XOOPS/XoopsCore/stargazers","contributors_url":"https://api.github.com/repos/XOOPS/XoopsCore/contributors","subscribers_url":"https://api.github.com/repos/XOOPS/XoopsCore/subscribers","subscription_url":"https://api.github.com/repos/XOOPS/XoopsCore/subscription","commits_url":"https://api.github.com/repos/XOOPS/XoopsCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/XOOPS/XoopsCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/XOOPS/XoopsCore/contents/{+path}","compare_url":"https://api.github.com/repos/XOOPS/XoopsCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/XOOPS/XoopsCore/merges","archive_url":"https://api.github.com/repos/XOOPS/XoopsCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/XOOPS/XoopsCore/downloads","issues_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues{/number}","pulls_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls{/number}","milestones_url":"https://api.github.com/repos/XOOPS/XoopsCore/milestones{/number}","notifications_url":"https://api.github.com/repos/XOOPS/XoopsCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/XOOPS/XoopsCore/labels{/name}","releases_url":"https://api.github.com/repos/XOOPS/XoopsCore/releases{/id}","deployments_url":"https://api.github.com/repos/XOOPS/XoopsCore/deployments","created_at":"2013-08-28T17:54:02Z","updated_at":"2016-03-10T07:59:13Z","pushed_at":"2016-04-04T16:51:34Z","git_url":"git://github.com/XOOPS/XoopsCore.git","ssh_url":"git@github.com:XOOPS/XoopsCore.git","clone_url":"https://github.com/XOOPS/XoopsCore.git","svn_url":"https://github.com/XOOPS/XoopsCore","homepage":"http://xoops.org","size":23332,"stargazers_count":57,"watchers_count":57,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":60,"mirror_url":null,"open_issues_count":44,"forks":60,"open_issues":44,"watchers":57,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/474"},"html":{"href":"https://github.com/XOOPS/XoopsCore/pull/474"},"issue":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/issues/474"},"comments":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/issues/474/comments"},"review_comments":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/474/comments"},"review_comment":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/474/commits"},"statuses":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/statuses/41288efea46febce4c7641e67769a2ad6fe6ea1c"}}}}