From 555035786594e3295aa5290520a16e2e2fb8293f Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 4 Sep 2020 15:31:17 -0400 Subject: volunteer: automatically created GitLab issue * static/volunteer/submit/index.php (conf, gl_new_issue): New functions. (send): Send email and create GitLab issue on fsfi/volunteer-tracker repository. --- static/volunteer/submit/index.php | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'static/volunteer') diff --git a/static/volunteer/submit/index.php b/static/volunteer/submit/index.php index 635e6c0..216b706 100644 --- a/static/volunteer/submit/index.php +++ b/static/volunteer/submit/index.php @@ -19,14 +19,40 @@ function email_valid($e) { return false; } +function conf() { + return json_decode(file_get_contents( + $_SERVER['DOCUMENT_ROOT'] . '/conf.json' + )); +} + +function gl_new_issue($title, $desc) { + $conf = conf(); + $cmd = sprintf("%s -v --request POST" + . " --header 'Private-Token: %s'" + . " %s/1047/issues" + . " -d title='%s'" + . " -d description='%s'", + $conf->curl, + $conf->token, + $conf->api, + urlencode($title), + urlencode($desc)); + $o = NULL; + exec($cmd, $o); + return true; +} + function send($n, $e, $m) { $p = $n . ' <' . $e . '>'; - return mail(to(), - $p . ' wants to volunteer for FSF India', - 'Per says:' . PHP_EOL . PHP_EOL . $m - . PHP_EOL . PHP_EOL . '---' . PHP_EOL - . 'Message originating from ' . $_SERVER['REMOTE_ADDR'] - ); + $s = $p . ' wants to volunteer for FSF India'; + $msg = 'Per says:' . PHP_EOL . PHP_EOL . $m + . PHP_EOL . PHP_EOL . '---' . PHP_EOL + . 'Message originating from ' . $_SERVER['REMOTE_ADDR']; + + $mo = mail(to(), $s, $msg); + $go = gl_new_issue($s, $msg); + + return $mo && $go; } function em_fw($t) { -- cgit v1.2.3