]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - plugins/config_blocks/config_blocks.php
Move to new style config, with config in config/ directory.
[irc/unrealircd/unrealircd-webpanel.git] / plugins / config_blocks / config_blocks.php
CommitLineData
d885521a
VP
1<?php
2
3/* This plugin requires SQLAuth minimum version 1.0 */
4
5/** Define our PERMISSION to manage configuration blocks */
6define('PERMISSION_CONFIG_BLOCKS', 'config_blocks');
7
8class config_blocks
9{
10 public $name = "Configuration Blocks";
11 public $author = "Valware";
12 public $version = "1.0";
13 public $description = "Create and host remote config files";
14 public $email = "v.a.pond@outlook.com";
15
16 function __construct()
17 {
18 require_plugin("SQLAuth", "1.0");
19 Hook::func(HOOKTYPE_NAVBAR, 'config_blocks::add_navbar');
20 Hook::func(HOOKTYPE_USER_PERMISSION_LIST, 'config_blocks::permission_list');
21
22 $this->create_sql_table();
23 }
24
25 /** HOOKTYPE_NAVBAR
26 * If the current user has permission to manage config blocks,
27 * add a link to the "Tools" menu about it
28 */
29 public static function add_navbar(&$pages)
30 {
31 $page_name = "Config Blocks";
32 $page_link = "plugins/config_blocks/";
33 if (current_user_can(PERMISSION_CONFIG_BLOCKS))
34 $pages["Tools"][$page_name] = $page_link;
35 }
36
37 /** HOOKTYPE_USER_PERMISSION_LIST
38 * Add a permission in the Panel Users permission list.
39 */
40 public static function permission_list(&$list)
41 {
42 $list["Can manage Remote Configs in Config Blocks"] = PERMISSION_CONFIG_BLOCKS;
43 }
44
45 /** Creates the SQL table for storing config block information */
46 public static function create_sql_table()
47 {
48 $conn = sqlnew();
ea90b321 49 $conn->query("CREATE TABLE IF NOT EXISTS " . get_config("mysql::table_prefix") . "configblocks (
d885521a
VP
50 block_id int AUTO_INCREMENT NOT NULL,
51 block_name VARCHAR(255) NOT NULL,
52 block_value VARCHAR(255) NOT NULL,
53 added_ts VARCHAR(255),
54 added_username VARCHAR(255),
55 PRIMARY KEY (block_id)
56 )");
57 }
58
59}