{"action":"created","comment":{"url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/comments/24933254","id":24933254,"diff_hunk":"@@ -0,0 +1,248 @@\n+<?php\n+/* For licensing terms, see /license.txt */\n+/**\n+ * Script to receipt request to subscribe and confirmation action to queue\n+ * @author Daniel Alejandro Barreto Alva <daniel.barreto@beeznest.com>\n+ * @package chamilo.plugin.advancedsubscription\n+ */\n+\n+/**\n+ * Init\n+ */\n+require_once __DIR__ . '/../config.php';\n+\n+$plugin = AdvancedSubscriptionPlugin::create();\n+// Get validation hash\n+$hash = Security::remove_XSS($_REQUEST['v']);\n+// Get data from request (GET or POST)\n+$data['a'] = Security::remove_XSS($_REQUEST['a']);\n+$data['s'] = intval($_REQUEST['s']);\n+$data['current_user_id'] = intval($_REQUEST['current_user_id']);\n+$data['u'] = intval($_REQUEST['u']);\n+$data['q'] = intval($_REQUEST['q']);\n+$data['e'] = intval($_REQUEST['e']);\n+$data['is_connected'] = isset($_REQUEST['is_connected']) ? boolval($_REQUEST['is_connected']) : false;\n+$data['profile_completed'] = isset($_REQUEST['profile_completed']) ? floatval($_REQUEST['profile_completed']) : 0;\n+// Init result array\n+$result = array('error' => true, 'errorMessage' => get_lang('ThereWasAnError'));\n+// Check if data is valid or is for start subscription\n+$verified = $plugin->checkHash($data, $hash) || $data['a'] == 'subscribe';\n+if ($verified) {\n+    switch($data['a']) {\n+        case 'check': // Check minimum requirements\n+            try {\n+                $res = AdvancedSubscriptionPlugin::create()->isAbleToRequest($data['u'], $data);\n+                if ($res) {\n+                    $result['error'] = false;\n+                    $result['errorMessage'] = 'No error';\n+                    $result['pass'] = true;\n+                } else {\n+                    $result['errorMessage'] = 'User can not be subscribed';\n+                    $result['pass'] = false;\n+                }\n+            } catch (\\Exception $e) {\n+                $result['errorMessage'] = $e->getMessage();\n+            }\n+            break;\n+        case 'subscribe': // Subscription\n+            // Start subscription to queue\n+            $res = AdvancedSubscriptionPlugin::create()->startSubscription($data['u'], $data['s'], $data);\n+            // Check if queue subscription was successful\n+            if ($res === true) {\n+                // Prepare data\n+                // Get session data\n+                $sessionArray = api_get_session_info($data['s']);\n+                $extraSession = new ExtraFieldValue('session');\n+                $var = $extraSession->get_values_by_handler_and_field_variable($data['s'], 'description');\n+                $sessionArray['description'] = $var['field_valiue'];\n+                $var = $extraSession->get_values_by_handler_and_field_variable($data['s'], 'target');\n+                $sessionArray['target'] = $var['field_valiue'];\n+                $var = $extraSession->get_values_by_handler_and_field_variable($data['s'], 'mode');\n+                $sessionArray['mode'] = $var['field_valiue'];\n+                $var = $extraSession->get_values_by_handler_and_field_variable($data['s'], 'publication_end_date');\n+                $sessionArray['publication_end_date'] = $var['field_value'];\n+                $var = $extraSession->get_values_by_handler_and_field_variable($data['s'], 'recommended_number_of_participants');\n+                $sessionArray['recommended_number_of_participants'] = $var['field_valiue'];\n+                // Get student data\n+                $studentArray = api_get_user_info($data['u']);\n+                $studentArray['picture'] = UserManager::get_user_picture_path_by_id($studentArray['user_id'], 'web', false, true);\n+                $studentArray['picture'] = UserManager::get_picture_user($studentArray['user_id'], $studentArray['picture']['file'], 22, USER_IMAGE_SIZE_MEDIUM);","path":"plugin/advancedsubscription/ajax/advsub.ajax.php","position":69,"original_position":69,"commit_id":"29d23c99ec56c232ee42c532266ee19ee409d9ec","original_commit_id":"1bdc1dd7191d1ba8da0b1b3ae10693e3e6f7e6ca","user":{"login":"ywarnier","id":609839,"avatar_url":"https://avatars.githubusercontent.com/u/609839?v=3","gravatar_id":"","url":"https://api.github.com/users/ywarnier","html_url":"https://github.com/ywarnier","followers_url":"https://api.github.com/users/ywarnier/followers","following_url":"https://api.github.com/users/ywarnier/following{/other_user}","gists_url":"https://api.github.com/users/ywarnier/gists{/gist_id}","starred_url":"https://api.github.com/users/ywarnier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ywarnier/subscriptions","organizations_url":"https://api.github.com/users/ywarnier/orgs","repos_url":"https://api.github.com/users/ywarnier/repos","events_url":"https://api.github.com/users/ywarnier/events{/privacy}","received_events_url":"https://api.github.com/users/ywarnier/received_events","type":"User","site_admin":false},"body":"OK. No, I don't think such a function exists.","created_at":"2015-02-18T19:39:17Z","updated_at":"2015-02-18T19:39:17Z","html_url":"https://github.com/chamilo/chamilo-lms/pull/495#discussion_r24933254","pull_request_url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/495","_links":{"self":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/comments/24933254"},"html":{"href":"https://github.com/chamilo/chamilo-lms/pull/495#discussion_r24933254"},"pull_request":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/495"}}},"pull_request":{"url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/495","id":29297773,"html_url":"https://github.com/chamilo/chamilo-lms/pull/495","diff_url":"https://github.com/chamilo/chamilo-lms/pull/495.diff","patch_url":"https://github.com/chamilo/chamilo-lms/pull/495.patch","issue_url":"https://api.github.com/repos/chamilo/chamilo-lms/issues/495","number":495,"state":"open","locked":false,"title":"Advanced subscription plugin","user":{"login":"danbarretodev","id":4552920,"avatar_url":"https://avatars.githubusercontent.com/u/4552920?v=3","gravatar_id":"","url":"https://api.github.com/users/danbarretodev","html_url":"https://github.com/danbarretodev","followers_url":"https://api.github.com/users/danbarretodev/followers","following_url":"https://api.github.com/users/danbarretodev/following{/other_user}","gists_url":"https://api.github.com/users/danbarretodev/gists{/gist_id}","starred_url":"https://api.github.com/users/danbarretodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbarretodev/subscriptions","organizations_url":"https://api.github.com/users/danbarretodev/orgs","repos_url":"https://api.github.com/users/danbarretodev/repos","events_url":"https://api.github.com/users/danbarretodev/events{/privacy}","received_events_url":"https://api.github.com/users/danbarretodev/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-13T20:48:39Z","updated_at":"2015-02-18T19:39:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af642f634a3d6c7b3989947e044cac8b7046a879","assignee":{"login":"ywarnier","id":609839,"avatar_url":"https://avatars.githubusercontent.com/u/609839?v=3","gravatar_id":"","url":"https://api.github.com/users/ywarnier","html_url":"https://github.com/ywarnier","followers_url":"https://api.github.com/users/ywarnier/followers","following_url":"https://api.github.com/users/ywarnier/following{/other_user}","gists_url":"https://api.github.com/users/ywarnier/gists{/gist_id}","starred_url":"https://api.github.com/users/ywarnier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ywarnier/subscriptions","organizations_url":"https://api.github.com/users/ywarnier/orgs","repos_url":"https://api.github.com/users/ywarnier/repos","events_url":"https://api.github.com/users/ywarnier/events{/privacy}","received_events_url":"https://api.github.com/users/ywarnier/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/chamilo/chamilo-lms/milestones/4","labels_url":"https://api.github.com/repos/chamilo/chamilo-lms/milestones/4/labels","id":858819,"number":4,"title":"1.10.0","description":"","creator":{"login":"ywarnier","id":609839,"avatar_url":"https://avatars.githubusercontent.com/u/609839?v=3","gravatar_id":"","url":"https://api.github.com/users/ywarnier","html_url":"https://github.com/ywarnier","followers_url":"https://api.github.com/users/ywarnier/followers","following_url":"https://api.github.com/users/ywarnier/following{/other_user}","gists_url":"https://api.github.com/users/ywarnier/gists{/gist_id}","starred_url":"https://api.github.com/users/ywarnier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ywarnier/subscriptions","organizations_url":"https://api.github.com/users/ywarnier/orgs","repos_url":"https://api.github.com/users/ywarnier/repos","events_url":"https://api.github.com/users/ywarnier/events{/privacy}","received_events_url":"https://api.github.com/users/ywarnier/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":22,"state":"open","created_at":"2014-11-09T01:29:53Z","updated_at":"2015-02-16T18:08:58Z","due_on":"2015-03-31T05:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/495/commits","review_comments_url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/495/comments","review_comment_url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/comments/{number}","comments_url":"https://api.github.com/repos/chamilo/chamilo-lms/issues/495/comments","statuses_url":"https://api.github.com/repos/chamilo/chamilo-lms/statuses/29d23c99ec56c232ee42c532266ee19ee409d9ec","head":{"label":"danbarretodev:advsub","ref":"advsub","sha":"29d23c99ec56c232ee42c532266ee19ee409d9ec","user":{"login":"danbarretodev","id":4552920,"avatar_url":"https://avatars.githubusercontent.com/u/4552920?v=3","gravatar_id":"","url":"https://api.github.com/users/danbarretodev","html_url":"https://github.com/danbarretodev","followers_url":"https://api.github.com/users/danbarretodev/followers","following_url":"https://api.github.com/users/danbarretodev/following{/other_user}","gists_url":"https://api.github.com/users/danbarretodev/gists{/gist_id}","starred_url":"https://api.github.com/users/danbarretodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbarretodev/subscriptions","organizations_url":"https://api.github.com/users/danbarretodev/orgs","repos_url":"https://api.github.com/users/danbarretodev/repos","events_url":"https://api.github.com/users/danbarretodev/events{/privacy}","received_events_url":"https://api.github.com/users/danbarretodev/received_events","type":"User","site_admin":false},"repo":{"id":15226947,"name":"chamilo-lms","full_name":"danbarretodev/chamilo-lms","owner":{"login":"danbarretodev","id":4552920,"avatar_url":"https://avatars.githubusercontent.com/u/4552920?v=3","gravatar_id":"","url":"https://api.github.com/users/danbarretodev","html_url":"https://github.com/danbarretodev","followers_url":"https://api.github.com/users/danbarretodev/followers","following_url":"https://api.github.com/users/danbarretodev/following{/other_user}","gists_url":"https://api.github.com/users/danbarretodev/gists{/gist_id}","starred_url":"https://api.github.com/users/danbarretodev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danbarretodev/subscriptions","organizations_url":"https://api.github.com/users/danbarretodev/orgs","repos_url":"https://api.github.com/users/danbarretodev/repos","events_url":"https://api.github.com/users/danbarretodev/events{/privacy}","received_events_url":"https://api.github.com/users/danbarretodev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danbarretodev/chamilo-lms","description":"Chamilo is a learning management system focusing on ease of use, re-usibality, collaboration and sharing.","fork":true,"url":"https://api.github.com/repos/danbarretodev/chamilo-lms","forks_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/forks","keys_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/teams","hooks_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/hooks","issue_events_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/issues/events{/number}","events_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/events","assignees_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/assignees{/user}","branches_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/branches{/branch}","tags_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/tags","blobs_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/git/refs{/sha}","trees_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/statuses/{sha}","languages_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/languages","stargazers_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/stargazers","contributors_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/contributors","subscribers_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/subscribers","subscription_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/subscription","commits_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/commits{/sha}","git_commits_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/git/commits{/sha}","comments_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/comments{/number}","issue_comment_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/issues/comments/{number}","contents_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/contents/{+path}","compare_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/merges","archive_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/downloads","issues_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/issues{/number}","pulls_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/pulls{/number}","milestones_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/milestones{/number}","notifications_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/labels{/name}","releases_url":"https://api.github.com/repos/danbarretodev/chamilo-lms/releases{/id}","created_at":"2013-12-16T13:49:48Z","updated_at":"2014-05-08T16:08:21Z","pushed_at":"2015-02-18T18:30:29Z","git_url":"git://github.com/danbarretodev/chamilo-lms.git","ssh_url":"git@github.com:danbarretodev/chamilo-lms.git","clone_url":"https://github.com/danbarretodev/chamilo-lms.git","svn_url":"https://github.com/danbarretodev/chamilo-lms","homepage":"http://www.chamilo.org","size":776780,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"chamilo:1.10.x","ref":"1.10.x","sha":"d440fae8bcae2a8230bed2b203a1116232561ac0","user":{"login":"chamilo","id":3460664,"avatar_url":"https://avatars.githubusercontent.com/u/3460664?v=3","gravatar_id":"","url":"https://api.github.com/users/chamilo","html_url":"https://github.com/chamilo","followers_url":"https://api.github.com/users/chamilo/followers","following_url":"https://api.github.com/users/chamilo/following{/other_user}","gists_url":"https://api.github.com/users/chamilo/gists{/gist_id}","starred_url":"https://api.github.com/users/chamilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chamilo/subscriptions","organizations_url":"https://api.github.com/users/chamilo/orgs","repos_url":"https://api.github.com/users/chamilo/repos","events_url":"https://api.github.com/users/chamilo/events{/privacy}","received_events_url":"https://api.github.com/users/chamilo/received_events","type":"Organization","site_admin":false},"repo":{"id":9103211,"name":"chamilo-lms","full_name":"chamilo/chamilo-lms","owner":{"login":"chamilo","id":3460664,"avatar_url":"https://avatars.githubusercontent.com/u/3460664?v=3","gravatar_id":"","url":"https://api.github.com/users/chamilo","html_url":"https://github.com/chamilo","followers_url":"https://api.github.com/users/chamilo/followers","following_url":"https://api.github.com/users/chamilo/following{/other_user}","gists_url":"https://api.github.com/users/chamilo/gists{/gist_id}","starred_url":"https://api.github.com/users/chamilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chamilo/subscriptions","organizations_url":"https://api.github.com/users/chamilo/orgs","repos_url":"https://api.github.com/users/chamilo/repos","events_url":"https://api.github.com/users/chamilo/events{/privacy}","received_events_url":"https://api.github.com/users/chamilo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chamilo/chamilo-lms","description":"Chamilo is a learning management system focusing on ease of use, re-usability, collaboration and sharing.","fork":false,"url":"https://api.github.com/repos/chamilo/chamilo-lms","forks_url":"https://api.github.com/repos/chamilo/chamilo-lms/forks","keys_url":"https://api.github.com/repos/chamilo/chamilo-lms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chamilo/chamilo-lms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chamilo/chamilo-lms/teams","hooks_url":"https://api.github.com/repos/chamilo/chamilo-lms/hooks","issue_events_url":"https://api.github.com/repos/chamilo/chamilo-lms/issues/events{/number}","events_url":"https://api.github.com/repos/chamilo/chamilo-lms/events","assignees_url":"https://api.github.com/repos/chamilo/chamilo-lms/assignees{/user}","branches_url":"https://api.github.com/repos/chamilo/chamilo-lms/branches{/branch}","tags_url":"https://api.github.com/repos/chamilo/chamilo-lms/tags","blobs_url":"https://api.github.com/repos/chamilo/chamilo-lms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chamilo/chamilo-lms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chamilo/chamilo-lms/git/refs{/sha}","trees_url":"https://api.github.com/repos/chamilo/chamilo-lms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chamilo/chamilo-lms/statuses/{sha}","languages_url":"https://api.github.com/repos/chamilo/chamilo-lms/languages","stargazers_url":"https://api.github.com/repos/chamilo/chamilo-lms/stargazers","contributors_url":"https://api.github.com/repos/chamilo/chamilo-lms/contributors","subscribers_url":"https://api.github.com/repos/chamilo/chamilo-lms/subscribers","subscription_url":"https://api.github.com/repos/chamilo/chamilo-lms/subscription","commits_url":"https://api.github.com/repos/chamilo/chamilo-lms/commits{/sha}","git_commits_url":"https://api.github.com/repos/chamilo/chamilo-lms/git/commits{/sha}","comments_url":"https://api.github.com/repos/chamilo/chamilo-lms/comments{/number}","issue_comment_url":"https://api.github.com/repos/chamilo/chamilo-lms/issues/comments/{number}","contents_url":"https://api.github.com/repos/chamilo/chamilo-lms/contents/{+path}","compare_url":"https://api.github.com/repos/chamilo/chamilo-lms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chamilo/chamilo-lms/merges","archive_url":"https://api.github.com/repos/chamilo/chamilo-lms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chamilo/chamilo-lms/downloads","issues_url":"https://api.github.com/repos/chamilo/chamilo-lms/issues{/number}","pulls_url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls{/number}","milestones_url":"https://api.github.com/repos/chamilo/chamilo-lms/milestones{/number}","notifications_url":"https://api.github.com/repos/chamilo/chamilo-lms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chamilo/chamilo-lms/labels{/name}","releases_url":"https://api.github.com/repos/chamilo/chamilo-lms/releases{/id}","created_at":"2013-03-29T17:31:19Z","updated_at":"2015-02-13T22:49:37Z","pushed_at":"2015-02-18T15:35:46Z","git_url":"git://github.com/chamilo/chamilo-lms.git","ssh_url":"git@github.com:chamilo/chamilo-lms.git","clone_url":"https://github.com/chamilo/chamilo-lms.git","svn_url":"https://github.com/chamilo/chamilo-lms","homepage":"http://www.chamilo.org","size":933753,"stargazers_count":74,"watchers_count":74,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":82,"mirror_url":null,"open_issues_count":5,"forks":82,"open_issues":5,"watchers":74,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/495"},"html":{"href":"https://github.com/chamilo/chamilo-lms/pull/495"},"issue":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/issues/495"},"comments":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/issues/495/comments"},"review_comments":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/495/comments"},"review_comment":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/495/commits"},"statuses":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/statuses/29d23c99ec56c232ee42c532266ee19ee409d9ec"}}}}