aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilu33 <ilu33@users.noreply.github.com>2016-11-24 04:32:23 +0100
committerGitHub <noreply@github.com>2016-11-24 04:32:23 +0100
commitae4cf98458662e115bafe1b77d693729cfdaa48a (patch)
tree7ce1a64d01934d678573b7dd4d451e7e03abcf9a
parent1596391a2ebcdfe9955e28b1db14adc05a6856da (diff)
downloadvolse-hubzilla-ae4cf98458662e115bafe1b77d693729cfdaa48a.tar.gz
volse-hubzilla-ae4cf98458662e115bafe1b77d693729cfdaa48a.tar.bz2
volse-hubzilla-ae4cf98458662e115bafe1b77d693729cfdaa48a.zip
Configuring email notifications per channel
-rw-r--r--util/nconfig.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/util/nconfig.php b/util/nconfig.php
new file mode 100644
index 000000000..cb24b2151
--- /dev/null
+++ b/util/nconfig.php
@@ -0,0 +1,56 @@
+#!/usr/bin/env php
+<?php
+
+/**
+* set channel email notifications utility
+* This is a preliminary solution using the existing functions from include/channel.php.
+* More options would be nice.
+**/
+
+if(! file_exists('include/cli_startup.php')) {
+ echo 'Run from the top level $Projectname web directory, as util/nconfig <args>' . PHP_EOL;
+ exit(1);
+}
+
+require_once('include/cli_startup.php');
+require_once('include/channel.php');
+
+cli_startup();
+
+
+ if($argc != 2) {
+ echo 'Usage: util/nconfig channel_id|channel_address off|on' . PHP_EOL;
+ exit(1);
+ }
+
+ if(ctype_digit($argv[1])) {
+ $c = channelx_by_n($argv[1]);
+ }
+ else {
+ $c = channelx_by_nick($argv[1]);
+ }
+
+ if(! $c) {
+ echo t('Source channel not found.');
+ exit(1);
+ }
+
+ switch ($argv[2]) {
+ case 'off':
+ $result = notifications_off($c['channel_id']);
+ break;
+ case 'on':
+ $result = notifications_on($c['channel_id']);
+ break;
+ default:
+ echo 'Only on or off in lower cases are allowed' . PHP_EOL;
+ exit(1);
+ }
+
+ if($result['success'] == false) {
+ echo $result['message'];
+ exit(1);
+ }
+
+ exit(0);
+