aboutsummaryrefslogtreecommitdiffstats
path: root/util/pconfig
blob: 802590f7aacd1f90154fad322bb8d03a16f059d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env php
<?php

// Red pconfig utility

require_once('include/cli_startup.php');
require_once('include/zot.php');

cli_startup();

$helpArgs = getopt('h', array('help'));
if (count($helpArgs) === 1) {
	echo <<<'EndOfOutput'
Gets, sets, or lists personal (per channel) configuration settings.

Usage: util/pconfig <channel_id>
       util/pconfig <channel_id> <family>
       util/pconfig <channel_id> <family> <key>
       util/pconfig <channel_id> <family> <key> <value>

  util/pconfig <channel_id>
	Displays all of the the channel's config entries

  util/pconfig <channel_id> <family>
	Displays all of the channel's config entries for the specified family 
	(system, database, etc)

  util/pconfig <channel_id> <family> <key>
	Displays single config entry for the specified family and key

  util/pconfig <channel_id> <family> <key> <value>
	Set config entry for specified family and key to value and display result

Notes:
  For site-wide configuration settings, use util/config

  Details for configuration options can be found at:

EndOfOutput;
	echo '    ' . App::get_baseurl() . '/help/hidden_configs' . PHP_EOL . PHP_EOL;
	return;
}


if($argc > 4) {
	set_pconfig($argv[1],$argv[2],$argv[3],$argv[4]);
	build_sync_packet($argv[1]);
	echo "pconfig[{$argv[1]}][{$argv[2]}][{$argv[3]}] = " . get_pconfig($argv[1],$argv[2],$argv[3]) . "\n";
}

if($argc == 4) {
	echo "pconfig[{$argv[1]}][{$argv[2]}][{$argv[3]}] = " . get_pconfig($argv[1],$argv[2],$argv[3]) . "\n";
}

if($argc == 3) {
	load_pconfig($argv[1],$argv[2]);
	foreach(App::$config[$argv[1]][$argv[2]] as $k => $x) {
		echo "pconfig[{$argv[1]}][{$argv[2]}][{$k}] = " . $x . "\n";
	}
}

if($argc == 2) {
	$r = q("select * from pconfig where uid = " . intval($argv[1]));
	if($r) {
		foreach($r as $rr) {
			echo "pconfig[{$rr['uid']}][{$rr['cat']}][{$rr['k']}] = " . $rr['v'] . "\n";
		}
	}
}