summaryrefslogtreecommitdiffstats
path: root/static
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-09-04 15:31:17 -0400
committerrsiddharth <s@ricketyspace.net>2020-09-04 15:31:17 -0400
commit555035786594e3295aa5290520a16e2e2fb8293f (patch)
tree840f2abedd403f628ffb85df1836cf634447ea6c /static
parentf617ba2bdf8216f94a300e7c85278b806acf4dae (diff)
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.
Diffstat (limited to 'static')
-rw-r--r--static/volunteer/submit/index.php38
1 files changed, 32 insertions, 6 deletions
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) {