{"action":"created","comment":{"url":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/comments/51734170","id":51734170,"diff_hunk":"@@ -6,6 +6,125 @@\n /** PROGRAMES **/\n add_action( 'wp_ajax_send_vote', 'sc_send_vote' );\n add_action( 'wp_ajax_nopriv_send_vote', 'sc_send_vote' );\n+add_action( 'wp_ajax_search_program', 'sc_search_program' );\n+add_action( 'wp_ajax_nopriv_search_program', 'sc_search_program' );\n+add_action( 'wp_ajax_add_new_program', 'sc_add_new_program' );\n+add_action( 'wp_ajax_nopriv_add_new_program', 'sc_add_new_program' );\n+\n+/**\n+ * Function to look up a program with a title similar to the title from the search on the add program form\n+ *\n+ * @return json response\n+ */\n+function sc_add_new_program() {\n+    $nom = sanitize_text_field( $_POST[\"nom\"] );\n+    $email_usuari = sanitize_email( $_POST[\"email_usuari\"] );\n+    $comentari_usuari = sanitize_text_field( $_POST[\"comentari_usuari\"] );\n+    $descripcio = sanitize_text_field( $_POST[\"descripcio\"] );\n+    $autor_programa = sanitize_text_field( $_POST[\"autor_programa\"] );\n+    $lloc_web_programa = sanitize_text_field( $_POST[\"lloc_web_programa\"] );\n+    $llicencia = sanitize_text_field( $_POST[\"llicencia\"] );\n+    $categoria_programa = sanitize_text_field( $_POST[\"categoria_programa\"] );\n+    $slug = sanitize_title_with_dashes( $nom );\n+    $baixades = json_decode(stripslashes($_POST[\"baixades\"]));\n+\n+    $terms = array(\n+        'categoria-programa' => array($categoria_programa),\n+        'llicencia' => array($llicencia)\n+    );\n+\n+    $metadata = array(\n+        'autor_programa' => $autor_programa,\n+        'lloc_web_programa' => $lloc_web_programa\n+    );\n+\n+    $return = sc_add_draft_content('programa', $nom, $descripcio, $slug, $terms, $metadata);\n+\n+    if( $return['status'] == 1 ) {\n+        //Related downloads\n+        $terms_baixada = array(\n+            'categoria-programa' => array($categoria_programa)\n+        );\n+\n+        //Logo and screenshot file upload\n+        $logo_attach_id = sc_upload_file( 'logo', $return['post_id'] );\n+        $screenshot_attach_id = sc_upload_file( 'captura', $return['post_id'] );\n+        $metadata = array(\n+            'logotip_programa' => wp_get_attachment_url( $logo_attach_id ),\n+            'imatge_destacada_1' => wp_get_attachment_url( $screenshot_attach_id )\n+        );\n+        sc_update_metadata ( $return['post_id'], $metadata );\n+\n+\n+        foreach ( $baixades as $baixada ) {\n+            $metadata_baixada = array (\n+                'url_baixada' => $baixada->url,\n+                'versio_baixada' => $baixada->versio,\n+                'arquitectura_baixada' => $baixada->arquitectura,\n+                'post_id' => $return['post_id']\n+            );\n+            $return_baixada = sc_add_draft_content('baixada', $nom, '', $slug, $terms_baixada, $metadata_baixada);\n+        }\n+\n+        if( $return_baixada['status'] == 1 ) {\n+            $to_email = \"web@softcatala.org\";","path":"inc/ajax_operations.php","position":65,"original_position":65,"commit_id":"d11691171bcba03ca7ba62fd5d53887c9f53bea7","original_commit_id":"d11691171bcba03ca7ba62fd5d53887c9f53bea7","user":{"login":"xavivars","id":134083,"avatar_url":"https://avatars.githubusercontent.com/u/134083?v=3","gravatar_id":"","url":"https://api.github.com/users/xavivars","html_url":"https://github.com/xavivars","followers_url":"https://api.github.com/users/xavivars/followers","following_url":"https://api.github.com/users/xavivars/following{/other_user}","gists_url":"https://api.github.com/users/xavivars/gists{/gist_id}","starred_url":"https://api.github.com/users/xavivars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xavivars/subscriptions","organizations_url":"https://api.github.com/users/xavivars/orgs","repos_url":"https://api.github.com/users/xavivars/repos","events_url":"https://api.github.com/users/xavivars/events{/privacy}","received_events_url":"https://api.github.com/users/xavivars/received_events","type":"User","site_admin":false},"body":"Segurament volem enviar-ho a la llista del Rebost...","created_at":"2016-02-03T15:20:16Z","updated_at":"2016-02-03T15:20:16Z","html_url":"https://github.com/Softcatala/wp-softcatala/pull/103#discussion_r51734170","pull_request_url":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/103","_links":{"self":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/comments/51734170"},"html":{"href":"https://github.com/Softcatala/wp-softcatala/pull/103#discussion_r51734170"},"pull_request":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/103"}}},"pull_request":{"url":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/103","id":58146329,"html_url":"https://github.com/Softcatala/wp-softcatala/pull/103","diff_url":"https://github.com/Softcatala/wp-softcatala/pull/103.diff","patch_url":"https://github.com/Softcatala/wp-softcatala/pull/103.patch","issue_url":"https://api.github.com/repos/Softcatala/wp-softcatala/issues/103","number":103,"state":"open","locked":false,"title":"Programes afegeix","user":{"login":"PauGNU","id":506393,"avatar_url":"https://avatars.githubusercontent.com/u/506393?v=3","gravatar_id":"","url":"https://api.github.com/users/PauGNU","html_url":"https://github.com/PauGNU","followers_url":"https://api.github.com/users/PauGNU/followers","following_url":"https://api.github.com/users/PauGNU/following{/other_user}","gists_url":"https://api.github.com/users/PauGNU/gists{/gist_id}","starred_url":"https://api.github.com/users/PauGNU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PauGNU/subscriptions","organizations_url":"https://api.github.com/users/PauGNU/orgs","repos_url":"https://api.github.com/users/PauGNU/repos","events_url":"https://api.github.com/users/PauGNU/events{/privacy}","received_events_url":"https://api.github.com/users/PauGNU/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-03T14:44:20Z","updated_at":"2016-02-03T15:20:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f494a72064b35c50e81b3899bc214cf3e2061554","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/103/commits","review_comments_url":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/103/comments","review_comment_url":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Softcatala/wp-softcatala/issues/103/comments","statuses_url":"https://api.github.com/repos/Softcatala/wp-softcatala/statuses/d11691171bcba03ca7ba62fd5d53887c9f53bea7","head":{"label":"Softcatala:programes_afegeix","ref":"programes_afegeix","sha":"d11691171bcba03ca7ba62fd5d53887c9f53bea7","user":{"login":"Softcatala","id":978352,"avatar_url":"https://avatars.githubusercontent.com/u/978352?v=3","gravatar_id":"","url":"https://api.github.com/users/Softcatala","html_url":"https://github.com/Softcatala","followers_url":"https://api.github.com/users/Softcatala/followers","following_url":"https://api.github.com/users/Softcatala/following{/other_user}","gists_url":"https://api.github.com/users/Softcatala/gists{/gist_id}","starred_url":"https://api.github.com/users/Softcatala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Softcatala/subscriptions","organizations_url":"https://api.github.com/users/Softcatala/orgs","repos_url":"https://api.github.com/users/Softcatala/repos","events_url":"https://api.github.com/users/Softcatala/events{/privacy}","received_events_url":"https://api.github.com/users/Softcatala/received_events","type":"Organization","site_admin":false},"repo":{"id":41410176,"name":"wp-softcatala","full_name":"Softcatala/wp-softcatala","owner":{"login":"Softcatala","id":978352,"avatar_url":"https://avatars.githubusercontent.com/u/978352?v=3","gravatar_id":"","url":"https://api.github.com/users/Softcatala","html_url":"https://github.com/Softcatala","followers_url":"https://api.github.com/users/Softcatala/followers","following_url":"https://api.github.com/users/Softcatala/following{/other_user}","gists_url":"https://api.github.com/users/Softcatala/gists{/gist_id}","starred_url":"https://api.github.com/users/Softcatala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Softcatala/subscriptions","organizations_url":"https://api.github.com/users/Softcatala/orgs","repos_url":"https://api.github.com/users/Softcatala/repos","events_url":"https://api.github.com/users/Softcatala/events{/privacy}","received_events_url":"https://api.github.com/users/Softcatala/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Softcatala/wp-softcatala","description":"Tema WordPress utilitzat pel web de Softcatalà","fork":false,"url":"https://api.github.com/repos/Softcatala/wp-softcatala","forks_url":"https://api.github.com/repos/Softcatala/wp-softcatala/forks","keys_url":"https://api.github.com/repos/Softcatala/wp-softcatala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Softcatala/wp-softcatala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Softcatala/wp-softcatala/teams","hooks_url":"https://api.github.com/repos/Softcatala/wp-softcatala/hooks","issue_events_url":"https://api.github.com/repos/Softcatala/wp-softcatala/issues/events{/number}","events_url":"https://api.github.com/repos/Softcatala/wp-softcatala/events","assignees_url":"https://api.github.com/repos/Softcatala/wp-softcatala/assignees{/user}","branches_url":"https://api.github.com/repos/Softcatala/wp-softcatala/branches{/branch}","tags_url":"https://api.github.com/repos/Softcatala/wp-softcatala/tags","blobs_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/refs{/sha}","trees_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Softcatala/wp-softcatala/statuses/{sha}","languages_url":"https://api.github.com/repos/Softcatala/wp-softcatala/languages","stargazers_url":"https://api.github.com/repos/Softcatala/wp-softcatala/stargazers","contributors_url":"https://api.github.com/repos/Softcatala/wp-softcatala/contributors","subscribers_url":"https://api.github.com/repos/Softcatala/wp-softcatala/subscribers","subscription_url":"https://api.github.com/repos/Softcatala/wp-softcatala/subscription","commits_url":"https://api.github.com/repos/Softcatala/wp-softcatala/commits{/sha}","git_commits_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/commits{/sha}","comments_url":"https://api.github.com/repos/Softcatala/wp-softcatala/comments{/number}","issue_comment_url":"https://api.github.com/repos/Softcatala/wp-softcatala/issues/comments{/number}","contents_url":"https://api.github.com/repos/Softcatala/wp-softcatala/contents/{+path}","compare_url":"https://api.github.com/repos/Softcatala/wp-softcatala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Softcatala/wp-softcatala/merges","archive_url":"https://api.github.com/repos/Softcatala/wp-softcatala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Softcatala/wp-softcatala/downloads","issues_url":"https://api.github.com/repos/Softcatala/wp-softcatala/issues{/number}","pulls_url":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls{/number}","milestones_url":"https://api.github.com/repos/Softcatala/wp-softcatala/milestones{/number}","notifications_url":"https://api.github.com/repos/Softcatala/wp-softcatala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Softcatala/wp-softcatala/labels{/name}","releases_url":"https://api.github.com/repos/Softcatala/wp-softcatala/releases{/id}","deployments_url":"https://api.github.com/repos/Softcatala/wp-softcatala/deployments","created_at":"2015-08-26T07:04:31Z","updated_at":"2016-01-14T06:34:20Z","pushed_at":"2016-02-03T15:17:31Z","git_url":"git://github.com/Softcatala/wp-softcatala.git","ssh_url":"git@github.com:Softcatala/wp-softcatala.git","clone_url":"https://github.com/Softcatala/wp-softcatala.git","svn_url":"https://github.com/Softcatala/wp-softcatala","homepage":null,"size":7748,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":25,"forks":0,"open_issues":25,"watchers":0,"default_branch":"master"}},"base":{"label":"Softcatala:master","ref":"master","sha":"94dc789fcdb9d411a14f9aa44228005d4dfe6aca","user":{"login":"Softcatala","id":978352,"avatar_url":"https://avatars.githubusercontent.com/u/978352?v=3","gravatar_id":"","url":"https://api.github.com/users/Softcatala","html_url":"https://github.com/Softcatala","followers_url":"https://api.github.com/users/Softcatala/followers","following_url":"https://api.github.com/users/Softcatala/following{/other_user}","gists_url":"https://api.github.com/users/Softcatala/gists{/gist_id}","starred_url":"https://api.github.com/users/Softcatala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Softcatala/subscriptions","organizations_url":"https://api.github.com/users/Softcatala/orgs","repos_url":"https://api.github.com/users/Softcatala/repos","events_url":"https://api.github.com/users/Softcatala/events{/privacy}","received_events_url":"https://api.github.com/users/Softcatala/received_events","type":"Organization","site_admin":false},"repo":{"id":41410176,"name":"wp-softcatala","full_name":"Softcatala/wp-softcatala","owner":{"login":"Softcatala","id":978352,"avatar_url":"https://avatars.githubusercontent.com/u/978352?v=3","gravatar_id":"","url":"https://api.github.com/users/Softcatala","html_url":"https://github.com/Softcatala","followers_url":"https://api.github.com/users/Softcatala/followers","following_url":"https://api.github.com/users/Softcatala/following{/other_user}","gists_url":"https://api.github.com/users/Softcatala/gists{/gist_id}","starred_url":"https://api.github.com/users/Softcatala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Softcatala/subscriptions","organizations_url":"https://api.github.com/users/Softcatala/orgs","repos_url":"https://api.github.com/users/Softcatala/repos","events_url":"https://api.github.com/users/Softcatala/events{/privacy}","received_events_url":"https://api.github.com/users/Softcatala/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Softcatala/wp-softcatala","description":"Tema WordPress utilitzat pel web de Softcatalà","fork":false,"url":"https://api.github.com/repos/Softcatala/wp-softcatala","forks_url":"https://api.github.com/repos/Softcatala/wp-softcatala/forks","keys_url":"https://api.github.com/repos/Softcatala/wp-softcatala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Softcatala/wp-softcatala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Softcatala/wp-softcatala/teams","hooks_url":"https://api.github.com/repos/Softcatala/wp-softcatala/hooks","issue_events_url":"https://api.github.com/repos/Softcatala/wp-softcatala/issues/events{/number}","events_url":"https://api.github.com/repos/Softcatala/wp-softcatala/events","assignees_url":"https://api.github.com/repos/Softcatala/wp-softcatala/assignees{/user}","branches_url":"https://api.github.com/repos/Softcatala/wp-softcatala/branches{/branch}","tags_url":"https://api.github.com/repos/Softcatala/wp-softcatala/tags","blobs_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/refs{/sha}","trees_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Softcatala/wp-softcatala/statuses/{sha}","languages_url":"https://api.github.com/repos/Softcatala/wp-softcatala/languages","stargazers_url":"https://api.github.com/repos/Softcatala/wp-softcatala/stargazers","contributors_url":"https://api.github.com/repos/Softcatala/wp-softcatala/contributors","subscribers_url":"https://api.github.com/repos/Softcatala/wp-softcatala/subscribers","subscription_url":"https://api.github.com/repos/Softcatala/wp-softcatala/subscription","commits_url":"https://api.github.com/repos/Softcatala/wp-softcatala/commits{/sha}","git_commits_url":"https://api.github.com/repos/Softcatala/wp-softcatala/git/commits{/sha}","comments_url":"https://api.github.com/repos/Softcatala/wp-softcatala/comments{/number}","issue_comment_url":"https://api.github.com/repos/Softcatala/wp-softcatala/issues/comments{/number}","contents_url":"https://api.github.com/repos/Softcatala/wp-softcatala/contents/{+path}","compare_url":"https://api.github.com/repos/Softcatala/wp-softcatala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Softcatala/wp-softcatala/merges","archive_url":"https://api.github.com/repos/Softcatala/wp-softcatala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Softcatala/wp-softcatala/downloads","issues_url":"https://api.github.com/repos/Softcatala/wp-softcatala/issues{/number}","pulls_url":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls{/number}","milestones_url":"https://api.github.com/repos/Softcatala/wp-softcatala/milestones{/number}","notifications_url":"https://api.github.com/repos/Softcatala/wp-softcatala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Softcatala/wp-softcatala/labels{/name}","releases_url":"https://api.github.com/repos/Softcatala/wp-softcatala/releases{/id}","deployments_url":"https://api.github.com/repos/Softcatala/wp-softcatala/deployments","created_at":"2015-08-26T07:04:31Z","updated_at":"2016-01-14T06:34:20Z","pushed_at":"2016-02-03T15:17:31Z","git_url":"git://github.com/Softcatala/wp-softcatala.git","ssh_url":"git@github.com:Softcatala/wp-softcatala.git","clone_url":"https://github.com/Softcatala/wp-softcatala.git","svn_url":"https://github.com/Softcatala/wp-softcatala","homepage":null,"size":7748,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":25,"forks":0,"open_issues":25,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/103"},"html":{"href":"https://github.com/Softcatala/wp-softcatala/pull/103"},"issue":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/issues/103"},"comments":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/issues/103/comments"},"review_comments":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/103/comments"},"review_comment":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/pulls/103/commits"},"statuses":{"href":"https://api.github.com/repos/Softcatala/wp-softcatala/statuses/d11691171bcba03ca7ba62fd5d53887c9f53bea7"}}}}