{"action":"created","comment":{"url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/comments/23766787","id":23766787,"diff_hunk":"@@ -491,6 +156,298 @@ function emptyDuration() {\n         $('#duration').val('');\n     }\n }\n-</script>\n-<?php\n+</script>\";\n+\n+if (isset($_POST['formSent']) && $_POST['formSent']) {\n+\t$formSent = 1;\n+}\n+\n+global $_configuration;\n+$defaultBeforeDays = isset($_configuration['session_days_before_coach_access']) ?\n+    $_configuration['session_days_before_coach_access'] : 0;\n+$defaultAfterDays = isset($_configuration['session_days_after_coach_access'])\n+    ? $_configuration['session_days_after_coach_access'] : 0;\n+\n+$nb_days_acess_before = $defaultBeforeDays;\n+$nb_days_acess_after = $defaultAfterDays;\n+\n+$thisYear=date('Y');\n+$thisMonth=date('m');\n+$thisDay=date('d');\n+\n+$dayList = array();\n+\n+for ($i = 1; $i <= 31; $i++) {\n+    $day = sprintf(\"%02d\", $i);\n+    $dayList[$day] = $day;\n+}\n+\n+$monthList = array();\n+\n+for ($i = 1; $i <= 12; $i++) {\n+    $month = sprintf(\"%02d\", $i);\n+    \n+    $monthList[$month] = $month;\n+}\n+\n+$yearList = array();\n+\n+for ($i = $thisYear - 5; $i <= ($thisYear + 5); $i++) {\n+    $yearList[$i] = $i;\n+}\n+\n+$tool_name = get_lang('AddSession');\n+\n+$urlAction = api_get_self();\n+\n+$categoriesList = SessionManager::get_all_session_category();\n+\n+$categoriesOptions = array(\n+    '0' => get_lang('None')\n+);\n+\n+if ($categoriesList != false) {\n+    foreach ($categoriesList as $categoryItem) {\n+        $categoriesOptions[$categoryItem['id']] = $categoryItem['name'];\n+    }\n+}\n+\n+function check_session_name($name) {\n+    $session = SessionManager::get_session_by_name($name);\n+\n+    return empty($session) ? true : false;\n+}\n+\n+$form = new FormValidator('add_session', 'post', $urlAction);\n+\n+$form->addElement('header', $tool_name);\n+\n+$form->addElement('text', 'name', get_lang('SessionName'), array(\n+    'class' => 'span4',\n+    'maxlength' => 50,\n+    'value' => $formSent ? api_htmlentities($name,ENT_QUOTES,$charset) : ''\n+));\n+$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');\n+$form->addRule('name', get_lang('SessionNameAlreadyExists'), 'callback', 'check_session_name');\n+\n+$sql = \"SELECT COUNT(1) FROM $tbl_user WHERE status = 1\";\n+$rs = Database::query($sql);\n+$countUsers = Database::result($rs, 0, 0);\n+\n+if (intval($countUsers) < 50) {\n+    $orderClause = \"ORDER BY \";\n+    $orderClause .= api_sort_by_first_name() ? \"firstname, lastname, username\"  : \"lastname, firstname, username\";\n+\n+    $sql=\"SELECT user_id, lastname, firstname, username FROM $tbl_user \"\n+        . \"WHERE status = '1' \"\n+        . $orderClause;\n+\n+    if (api_is_multiple_url_enabled()) {\n+        $userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);\n+        $accessUrlId = api_get_current_access_url_id();\n+        \n+        if ($accessUrlId != -1) {\n+            $sql = \"SELECT user.user_id, username, lastname, firstname FROM $tbl_user user \"\n+                . \"INNER JOIN $userRelAccessUrlTable url_user ON (url_user.user_id = user.user_id) \"\n+                . \"WHERE access_url_id = $accessUrlId AND status = 1 \"\n+                . $orderClause;\n+        }\n+    }\n+\n+    $result = Database::query($sql);\n+\t$coachesList = Database::store_result($result);\n+\n+    $coachesOptions = array();\n+\n+    foreach($coachesList as $coachItem){\n+        $coachesOptions[$coachItem['username']] = api_get_person_name(\n+            $coachItem['firstname'],\n+            $coachItem['lastname']\n+        ).' ('.$coachItem['username'].')';\n+    }\n+\n+    $form->addElement('select', 'coach_username', get_lang('CoachName'), $coachesOptions, array(\n+        'id' => 'coach_username',\n+        'class' => 'chzn-select',\n+        'style' => 'width:350px;'\n+    ));\n+    $form->addElement('advanced_settings', Display::return_icon('synthese_view.gif') . ' ' . get_lang('ActivityCoach'));\n+} else {\n+    $form->addElement('text', 'coach_username', get_lang('CoachName'), array(\n+        'class' => 'span4',\n+        'maxlength' => 50,\n+        'onkeyup' => \"xajax_search_coachs(document.getElementById('coach_username').value)\",\n+        'id' => 'coach_username'\n+    ));\n+}\n+\n+$form->addRule('coach_username', get_lang('ThisFieldIsRequired'), 'required');\n+$form->add_html('<div id=\"ajax_list_coachs\"></div>');\n+\n+$form->add_select('session_category', get_lang('SessionCategory'), $categoriesOptions, array(\n+    'id' => 'session_category',\n+    'class' => 'chzn-select',\n+    'style' => 'width:350px;'\n+));\n+\n+$form->addElement('advanced_settings','<a class=\"btn-show\" id=\"advanced_parameters\" href=\"javascript://\">'.get_lang('DefineSessionOptions').'</a>');\n+\n+$form->addElement('html','<div id=\"options\" style=\"display:none\">');\n+\n+$form->addElement('text', 'nb_days_acess_before', array('', '', get_lang('DaysBefore')), array(\n+    'style' => 'width: 30px;',\n+    'value' => $nb_days_acess_before\n+));\n+\n+$form->addElement('text', 'nb_days_acess_after', array('', '', get_lang('DaysAfter')), array(\n+    'style' => 'width: 30px;',\n+    'value' => $nb_days_acess_after\n+));\n+\n+$form->addElement('html','</div>');\n+\n+$form->addElement('checkbox', 'start_limit', '', get_lang('DateStartSession'), array(\n+    'onchange' => 'disable_starttime(this)',\n+    'id' => 'start_limit'\n+));\n+\n+$form->addElement('html','<div id=\"start_date\" style=\"display:none\">');\n+\n+$startDateGroup = array ();","path":"main/admin/session_add.php","position":550,"original_position":550,"commit_id":"8816451cd56fe6cfeba8e3ba42dca8fe13d7317d","original_commit_id":"8816451cd56fe6cfeba8e3ba42dca8fe13d7317d","user":{"login":"jmontoyaa","id":158935,"avatar_url":"https://avatars.githubusercontent.com/u/158935?v=3","gravatar_id":"","url":"https://api.github.com/users/jmontoyaa","html_url":"https://github.com/jmontoyaa","followers_url":"https://api.github.com/users/jmontoyaa/followers","following_url":"https://api.github.com/users/jmontoyaa/following{/other_user}","gists_url":"https://api.github.com/users/jmontoyaa/gists{/gist_id}","starred_url":"https://api.github.com/users/jmontoyaa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmontoyaa/subscriptions","organizations_url":"https://api.github.com/users/jmontoyaa/orgs","repos_url":"https://api.github.com/users/jmontoyaa/repos","events_url":"https://api.github.com/users/jmontoyaa/events{/privacy}","received_events_url":"https://api.github.com/users/jmontoyaa/received_events","type":"User","site_admin":false},"body":"You should not use this kind of tricky code to handle dates.\r\nYou can use:\r\n\r\n<pre>$form->addElement('date_picker', 'start_date');</pre>\r\n\r\nSee example here:\r\n\r\nhttps://github.com/chamilo/chamilo-lms/blob/1.9.x/main/calendar/agenda.lib.php#L1806\r\n\r\n","created_at":"2015-01-29T13:28:30Z","updated_at":"2015-01-29T13:28:30Z","html_url":"https://github.com/chamilo/chamilo-lms/pull/460#discussion_r23766787","pull_request_url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/460","_links":{"self":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/comments/23766787"},"html":{"href":"https://github.com/chamilo/chamilo-lms/pull/460#discussion_r23766787"},"pull_request":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/460"}}},"pull_request":{"url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/460","id":28211433,"html_url":"https://github.com/chamilo/chamilo-lms/pull/460","diff_url":"https://github.com/chamilo/chamilo-lms/pull/460.diff","patch_url":"https://github.com/chamilo/chamilo-lms/pull/460.patch","issue_url":"https://api.github.com/repos/chamilo/chamilo-lms/issues/460","number":460,"state":"open","locked":false,"title":"Allow add session extra fields - res BT#9089","user":{"login":"AngelFQC","id":1697880,"avatar_url":"https://avatars.githubusercontent.com/u/1697880?v=3","gravatar_id":"","url":"https://api.github.com/users/AngelFQC","html_url":"https://github.com/AngelFQC","followers_url":"https://api.github.com/users/AngelFQC/followers","following_url":"https://api.github.com/users/AngelFQC/following{/other_user}","gists_url":"https://api.github.com/users/AngelFQC/gists{/gist_id}","starred_url":"https://api.github.com/users/AngelFQC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AngelFQC/subscriptions","organizations_url":"https://api.github.com/users/AngelFQC/orgs","repos_url":"https://api.github.com/users/AngelFQC/repos","events_url":"https://api.github.com/users/AngelFQC/events{/privacy}","received_events_url":"https://api.github.com/users/AngelFQC/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-28T17:16:18Z","updated_at":"2015-01-29T13:28:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5e7e18f1b8ccab0512ae70bbf90120a3bc82981f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/460/commits","review_comments_url":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/460/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/460/comments","statuses_url":"https://api.github.com/repos/chamilo/chamilo-lms/statuses/8816451cd56fe6cfeba8e3ba42dca8fe13d7317d","head":{"label":"AngelFQC:9089","ref":"9089","sha":"8816451cd56fe6cfeba8e3ba42dca8fe13d7317d","user":{"login":"AngelFQC","id":1697880,"avatar_url":"https://avatars.githubusercontent.com/u/1697880?v=3","gravatar_id":"","url":"https://api.github.com/users/AngelFQC","html_url":"https://github.com/AngelFQC","followers_url":"https://api.github.com/users/AngelFQC/followers","following_url":"https://api.github.com/users/AngelFQC/following{/other_user}","gists_url":"https://api.github.com/users/AngelFQC/gists{/gist_id}","starred_url":"https://api.github.com/users/AngelFQC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AngelFQC/subscriptions","organizations_url":"https://api.github.com/users/AngelFQC/orgs","repos_url":"https://api.github.com/users/AngelFQC/repos","events_url":"https://api.github.com/users/AngelFQC/events{/privacy}","received_events_url":"https://api.github.com/users/AngelFQC/received_events","type":"User","site_admin":false},"repo":{"id":22071905,"name":"chamilo-lms","full_name":"AngelFQC/chamilo-lms","owner":{"login":"AngelFQC","id":1697880,"avatar_url":"https://avatars.githubusercontent.com/u/1697880?v=3","gravatar_id":"","url":"https://api.github.com/users/AngelFQC","html_url":"https://github.com/AngelFQC","followers_url":"https://api.github.com/users/AngelFQC/followers","following_url":"https://api.github.com/users/AngelFQC/following{/other_user}","gists_url":"https://api.github.com/users/AngelFQC/gists{/gist_id}","starred_url":"https://api.github.com/users/AngelFQC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AngelFQC/subscriptions","organizations_url":"https://api.github.com/users/AngelFQC/orgs","repos_url":"https://api.github.com/users/AngelFQC/repos","events_url":"https://api.github.com/users/AngelFQC/events{/privacy}","received_events_url":"https://api.github.com/users/AngelFQC/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AngelFQC/chamilo-lms","description":"Chamilo is a learning management system focusing on ease of use, re-usability, collaboration and sharing.","fork":true,"url":"https://api.github.com/repos/AngelFQC/chamilo-lms","forks_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/forks","keys_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/teams","hooks_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/hooks","issue_events_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/issues/events{/number}","events_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/events","assignees_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/assignees{/user}","branches_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/branches{/branch}","tags_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/tags","blobs_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/git/refs{/sha}","trees_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/statuses/{sha}","languages_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/languages","stargazers_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/stargazers","contributors_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/contributors","subscribers_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/subscribers","subscription_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/subscription","commits_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/commits{/sha}","git_commits_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/git/commits{/sha}","comments_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/comments{/number}","issue_comment_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/issues/comments/{number}","contents_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/contents/{+path}","compare_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/merges","archive_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/downloads","issues_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/issues{/number}","pulls_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/pulls{/number}","milestones_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/milestones{/number}","notifications_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/labels{/name}","releases_url":"https://api.github.com/repos/AngelFQC/chamilo-lms/releases{/id}","created_at":"2014-07-21T16:36:20Z","updated_at":"2015-01-28T16:49:28Z","pushed_at":"2015-01-29T13:20:51Z","git_url":"git://github.com/AngelFQC/chamilo-lms.git","ssh_url":"git@github.com:AngelFQC/chamilo-lms.git","clone_url":"https://github.com/AngelFQC/chamilo-lms.git","svn_url":"https://github.com/AngelFQC/chamilo-lms","homepage":"http://www.chamilo.org","size":827461,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"chamilo:1.10.x","ref":"1.10.x","sha":"cdc9cb6fcb5e04fee837d2d46da5d7df01321e13","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-01-28T16:04:39Z","pushed_at":"2015-01-29T11:48:32Z","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":923212,"stargazers_count":71,"watchers_count":71,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":81,"mirror_url":null,"open_issues_count":8,"forks":81,"open_issues":8,"watchers":71,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/460"},"html":{"href":"https://github.com/chamilo/chamilo-lms/pull/460"},"issue":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/issues/460"},"comments":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/issues/460/comments"},"review_comments":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/pulls/460/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/460/commits"},"statuses":{"href":"https://api.github.com/repos/chamilo/chamilo-lms/statuses/8816451cd56fe6cfeba8e3ba42dca8fe13d7317d"}}}}