Skip to content

Commit 9b41c17

Browse files
committed
Add MCP component
1 parent 31146f1 commit 9b41c17

7 files changed

Lines changed: 183 additions & 1 deletion

File tree

config/skeletons.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ services:
3636
tags:
3737
- { name: phpbb.skeleton.ext.skeleton }
3838

39+
phpbb.skeleton.ext.skeleton.mcp:
40+
class: phpbb\skeleton\skeleton
41+
arguments:
42+
- 'mcp'
43+
- false
44+
- []
45+
- ['mcp/main_info.php', 'mcp/main_module.php', 'styles/prosilver/template/mcp_demo_body.html', 'language/en/info_mcp_demo.php']
46+
tags:
47+
- { name: phpbb.skeleton.ext.skeleton }
48+
3949
phpbb.skeleton.ext.skeleton.ucp:
4050
class: phpbb\skeleton\skeleton
4151
arguments:
@@ -52,7 +62,7 @@ services:
5262
- 'migration'
5363
- false
5464
- []
55-
- ['migrations/install_acp_module.php', 'migrations/install_ucp_module.php', 'migrations/install_user_schema.php']
65+
- ['migrations/install_acp_module.php', 'migrations/install_mcp_module.php', 'migrations/install_ucp_module.php', 'migrations/install_user_schema.php']
5666
tags:
5767
- { name: phpbb.skeleton.ext.skeleton }
5868

language/en/common.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
'SKELETON_QUESTION_COMPONENT_HTMLLISTENER_UI' => 'Styles listeners',
7979
'SKELETON_QUESTION_COMPONENT_ACP' => 'Create a sample ACP administration module?',
8080
'SKELETON_QUESTION_COMPONENT_ACP_UI' => 'Administration control panel (ACP)',
81+
'SKELETON_QUESTION_COMPONENT_MCP' => 'Create a sample MCP moderation module?',
82+
'SKELETON_QUESTION_COMPONENT_MCP_UI' => 'Moderator control panel (MCP)',
8183
'SKELETON_QUESTION_COMPONENT_UCP' => 'Create a sample UCP user module?',
8284
'SKELETON_QUESTION_COMPONENT_UCP_UI' => 'User control panel (UCP)',
8385
'SKELETON_QUESTION_COMPONENT_MIGRATION' => 'Create sample database migrations?',
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
if (!defined('IN_PHPBB'))
15+
{
16+
exit;
17+
}
18+
19+
if (empty($lang) || !is_array($lang))
20+
{
21+
$lang = array();
22+
}
23+
24+
$lang = array_merge($lang, array(
25+
'MCP_DEMO' => 'Front',
26+
'MCP_DEMO_TITLE' => 'Demo Module',
27+
));

skeleton/mcp/main_info.php.tpl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
namespace {EXTENSION.vendor_name}\{EXTENSION.extension_name}\mcp;
15+
16+
class main_info
17+
{
18+
function module()
19+
{
20+
return array(
21+
'filename' => '\{EXTENSION.vendor_name}\{EXTENSION.extension_name}\mcp\main_module',
22+
'title' => 'MCP_DEMO_TITLE',
23+
'modes' => array(
24+
'front' => array(
25+
'title' => 'MCP_DEMO',
26+
'auth' => 'ext_{EXTENSION.vendor_name}/{EXTENSION.extension_name}',
27+
'cat' => array('MCP_DEMO_TITLE')
28+
),
29+
),
30+
);
31+
}
32+
}

skeleton/mcp/main_module.php.tpl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
namespace {EXTENSION.vendor_name}\{EXTENSION.extension_name}\mcp;
15+
16+
class main_module
17+
{
18+
var $u_action;
19+
20+
function main($id, $mode)
21+
{
22+
global $template, $user;
23+
24+
$this->tpl_name = 'mcp_demo_body';
25+
$this->page_title = $user->lang('MCP_DEMO_TITLE');
26+
add_form_key('acme/demo');
27+
28+
$template->assign_var('U_POST_ACTION', $this->u_action);
29+
}
30+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Forum Software package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
namespace {EXTENSION.vendor_name}\{EXTENSION.extension_name}\migrations;
15+
16+
class install_mcp_module extends \phpbb\db\migration\migration
17+
{
18+
public function effectively_installed()
19+
{
20+
$sql = 'SELECT module_id
21+
FROM ' . $this->table_prefix . "modules
22+
WHERE module_class = 'mcp'
23+
AND module_langname = 'MCP_DEMO_TITLE'";
24+
$result = $this->db->sql_query($sql);
25+
$module_id = $this->db->sql_fetchfield('module_id');
26+
$this->db->sql_freeresult($result);
27+
28+
return $module_id !== false;
29+
}
30+
31+
static public function depends_on()
32+
{
33+
return array('\phpbb\db\migration\data\v31x\v314');
34+
}
35+
36+
public function update_data()
37+
{
38+
return array(
39+
array('module.add', array(
40+
'mcp',
41+
0,
42+
'MCP_DEMO_TITLE'
43+
)),
44+
array('module.add', array(
45+
'mcp',
46+
'MCP_DEMO_TITLE',
47+
array(
48+
'module_basename' => '\{EXTENSION.vendor_name}\{EXTENSION.extension_name}\mcp\main_module',
49+
'modes' => array('front'),
50+
),
51+
)),
52+
);
53+
}
54+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
&lt;!-- INCLUDE mcp_header.html -->
2+
3+
<form method="post" id="mcp" action="&#123;U_POST_ACTION}">
4+
5+
<h2>&#123;L_MCP_DEMO_TITLE}</h2>
6+
7+
<div class="panel">
8+
<div class="inner">
9+
10+
<fieldset>
11+
<dl>
12+
<dt><label for="username">&#123;L_SELECT_USER}&#123;L_COLON}</label></dt>
13+
<dd><input name="username" id="username" type="text" class="inputbox" /></dd>
14+
</dl>
15+
</fieldset>
16+
17+
</div>
18+
</div>
19+
20+
<fieldset class="submit-buttons">
21+
<input type="reset" value="&#123;L_RESET}" name="reset" class="button2" />&nbsp;
22+
<input type="submit" name="submituser" value="&#123;L_SUBMIT}" class="button1" />
23+
&#123;S_FORM_TOKEN}
24+
</fieldset>
25+
</form>
26+
27+
&lt;!-- INCLUDE mcp_footer.html -->

0 commit comments

Comments
 (0)