3 /* This plugin requires SQLDB minimum version 1.0 */
5 /** Define our PERMISSION to manage configuration blocks */
6 define('PERMISSION_CONFIG_BLOCKS', 'config_blocks');
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";
16 function __construct()
18 require_plugin("SQLDB", "1.0");
19 Hook
::func(HOOKTYPE_NAVBAR
, 'config_blocks::add_navbar');
20 Hook
::func(HOOKTYPE_USER_PERMISSION_LIST
, 'config_blocks::permission_list');
22 $this->create_sql_table();
26 * If the current user has permission to manage config blocks,
27 * add a link to the "Tools" menu about it
29 public static function add_navbar(&$pages)
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;
37 /** HOOKTYPE_USER_PERMISSION_LIST
38 * Add a permission in the Panel Users permission list.
40 public static function permission_list(&$list)
42 $list["Can manage Remote Configs in Config Blocks"] = PERMISSION_CONFIG_BLOCKS
;
45 /** Creates the SQL table for storing config block information */
46 public static function create_sql_table()
49 $conn->query("CREATE TABLE IF NOT EXISTS " . get_config("mysql::table_prefix") . "configblocks (
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)