[ticket/10631] Adding an extensions admin

PHPBB3-10631
This commit is contained in:
Michael Cullum 2012-02-29 21:23:50 +00:00 committed by Unknown Bliss
parent 1128ff1e58
commit 5e6b4c7192
11 changed files with 570 additions and 0 deletions

View file

@ -0,0 +1,27 @@
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<h1>{L_EXTENSIONS_ADMIN}</h1>
<p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_ENABLE_EXPLAIN}</p>
<!-- IF PRE -->
<p>{L_DELETE_CONFIRM}</p>
<form id="acp_extensions" method="post" action="{U_DELETE}">
<fieldset class="submit-buttons">
<legend>{L_DELETE}</legend>
<input class="button1" type="submit" name="{L_DELETE}" value="{L_DELETE}" />
</fieldset>
</form>
<!-- ELSE IF -->
<div class="successbox">
<p>{L_DELETE_SUCESS}</p>
<br />
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ENDIF -->
<!-- INCLUDE overall_footer.html -->

View file

@ -0,0 +1,27 @@
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<h1>{L_EXTENSIONS_ADMIN}</h1>
<p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_ENABLE_EXPLAIN}</p>
<!-- IF PRE -->
<p>{L_DISABLE_CONFIRM}</p>
<form id="acp_extensions" method="post" action="{U_DISABLE}">
<fieldset class="submit-buttons">
<legend>{L_DISABLE}</legend>
<input class="button1" type="submit" name="{L_DISABLE}" value="{L_DISABLE}" />
</fieldset>
</form>
<!-- ELSE IF -->
<div class="successbox">
<p>{L_DISABLE_SUCESS}</p>
<br />
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ENDIF -->
<!-- INCLUDE overall_footer.html -->

View file

@ -0,0 +1,27 @@
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<h1>{L_EXTENSIONS_ADMIN}</h1>
<p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_ENABLE_EXPLAIN}</p>
<!-- IF PRE -->
<p>{L_ENABLE_CONFIRM}</p>
<form id="acp_extensions" method="post" action="{U_ENABLE}">
<fieldset class="submit-buttons">
<legend>{L_ENABLE}</legend>
<input class="button1" type="submit" name="{L_ENABLE}" value="{L_ENABLE}" />
</fieldset>
</form>
<!-- ELSE IF -->
<div class="successbox">
<p>{L_ENABLE_SUCESS}</p>
<br />
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ENDIF -->
<!-- INCLUDE overall_footer.html -->

View file

@ -0,0 +1,60 @@
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<h1>{L_EXTENSIONS_ADMIN}</h1>
<p>{L_EXTENSIONS_EXPLAIN}</p>
<table cellspacing="1">
<col class="row1" /><col class="row2" /><col class="row2" />
<thead>
<tr>
<th>{L_EXTENSION_NAME}</th>
<th>{L_EXTENSION_OPTIONS}</th>
<th>{L_EXTENSION_ACTIONS}</th>
</tr>
</thead>
<tbody>
<!-- IF .enabled -->
<tr>
<td class="row3" colspan="3">
<strong>{L_ENABLED} {L_EXTENSIONS}</strong>
</td>
</tr>
<!-- BEGIN enabled -->
<tr>
<td><strong>{enabled.EXT_NAME}</strong></a></td>
<td style="text-align: center;"><a href="{enabled.U_DETAILS}">{L_DETAILS}</a></td>
<td style="text-align: center;"><a href="{enabled.U_DISABLE}">{L_DISABLE}</a>&nbsp;|&nbsp;<a href="{enabled.U_PURGE}">{L_PURGE}</a></td>
</tr>
<!-- END enabled -->
<!-- ENDIF -->
<!-- IF .disabled -->
<tr>
<td class="row3" colspan="3"><strong>{L_DISABLED} {L_EXTENSIONS}</strong></td>
</tr>
<!-- BEGIN disabled -->
<tr>
<td><strong>{disabled.EXT_NAME}</strong></a></td>
<td style="text-align: center;"><a href="{disabled.U_DETAILS}">{L_DETAILS}</a></td>
<td style="text-align: center;"><a href="{disabled.U_ENABLE}">{L_ENABLE}</a>&nbsp;|&nbsp;<a href="{disabled.U_PURGE}">{L_PURGE}</a>&nbsp;|&nbsp;<a href="{disabled.U_DELETE}">{L_DELETE}</a></td>
</tr>
<!-- END disabled -->
<!-- ENDIF -->
<!-- IF .avaliable -->
<tr>
<td class="row3" colspan="3"><strong>{L_AVALIABLE} {L_EXTENSIONS}</strong></td>
</tr>
<!-- BEGIN avaliable -->
<tr>
<td><strong>{avaliable.EXT_NAME}</strong></a></td>
<td style="text-align: center;"><a href="{avaliable.U_DETAILS}">{L_DETAILS}</a></td>
<td style="text-align: center;"><a href="{avaliable.U_ENABLE}">{L_ENABLE}</a>&nbsp;|&nbsp;<a href="{avaliable.U_DELETE}">{L_DELETE}</a></td>
</tr>
<!-- END avaliable -->
<!-- ENDIF -->
</tbody>
</table>
<!-- INCLUDE overall_footer.html -->

View file

@ -0,0 +1,27 @@
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<h1>{L_EXTENSIONS_ADMIN}</h1>
<p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_ENABLE_EXPLAIN}</p>
<!-- IF PRE -->
<p>{L_PURGE_CONFIRM}</p>
<form id="acp_extensions" method="post" action="{U_PURGE}">
<fieldset class="submit-buttons">
<legend>{L_PURGE}</legend>
<input class="button1" type="submit" name="{L_PURGE}" value="{L_PURGE}" />
</fieldset>
</form>
<!-- ELSE IF -->
<div class="successbox">
<p>{L_PURGE_SUCESS}</p>
<br />
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ENDIF -->
<!-- INCLUDE overall_footer.html -->

View file

@ -0,0 +1,265 @@
<?php
/**
*
* @package acp
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package acp
*/
class acp_extensions
{
var $u_action;
function main()
{
// Start the page
global $user, $template, $request;
$user->add_lang(array('install', 'acp/customisations'));
$this->page_title = 'ACP_EXTENSIONS';
$action = $request->variable('action', '');
$ext_name = $request->variable('ext_name', '');
// Set action to list if not set
if (empty($action))
{
$action = "list";
}
// What are we doing?
switch ($action)
{
case 'list':
default:
$this->list_enabled_exts();
$this->list_disabled_exts();
$this->tpl_name = 'acp_ext_list';
break;
case 'enable_pre':
$this->tpl_name = 'acp_ext_enable';
$template->assign_vars(array(
'PRE' => true,
'U_ENABLE' => $this->u_action . '&amp;action=enable&amp;ext_name=' . $ext_name,
)
);
break;
case 'enable':
$name = $request->variable('ext_name', '');
$this->enable_extension($name);
$this->tpl_name = 'acp_ext_enable';
break;
case 'disable_pre':
$this->tpl_name = 'acp_ext_disable';
$template->assign_vars(array(
'PRE' => true,
'U_DISABLE' => $this->u_action . '&amp;action=disable&amp;ext_name=' . $ext_name,
)
);
break;
case 'disable':
$name = $request->variable('ext_name', '');
$this->disable_extension($name);
$this->tpl_name = 'acp_ext_disable';
break;
case 'purge_pre':
$this->tpl_name = 'acp_ext_purge';
$template->assign_vars(array(
'PRE' => true,
'U_PURGE' => $this->u_action . '&amp;action=purge&amp;ext_name=' . $ext_name,
)
);
break;
case 'purge':
$name = $request->variable('ext_name', '');
$this->purge_extension($name);
$this->tpl_name = 'acp_ext_purge';
break;
case 'delete_pre':
$this->tpl_name = 'acp_ext_delete';
$template->assign_vars(array(
'PRE' => true,
'U_DELETE' => $this->u_action . '&amp;action=delete&amp;ext_name=' . $ext_name,
)
);
break;
case 'delete':
$name = $request->variable('ext_name', '');
$this->tpl_name = 'acp_ext_delete';
break;
case 'details':
$name = $request->variable('ext_name', '');
$filepath = $phpbb_root_path . 'ext/' . $name . '/extension.json';
$this->tpl_name = 'acp_ext_details';
$this->get_meta_info($filepath);
break;
}
}
function enable_extension($name)
{
global $phpbb_extension_manager, $template, $cache;
$phpbb_extension_manager->enable($name);
$template->assign_vars(array(
'U_RETURN' => $this->u_action . '&amp;action=list',
));
$cache->purge();
}
function disable_extension($name)
{
global $phpbb_extension_manager, $template, $cache;
$phpbb_extension_manager->disable($name);
$template->assign_vars(array(
'U_RETURN' => $this->u_action . '&amp;action=list',
));
$cache->purge();
}
function purge_extension($name)
{
global $phpbb_extension_manager, $template, $cache;
$phpbb_extension_manager->purge($name);
$template->assign_vars(array(
'U_RETURN' => $this->u_action . '&amp;action=list',
));
$cache->purge();
}
function list_enabled_exts()
{
global $db, $template;
$sql = 'SELECT ext_name
FROM ' . EXT_TABLE . '
WHERE ext_active= 1
ORDER BY ext_name ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('enabled', array(
'EXT_NAME' => $row['ext_name'],
'U_DETAILS' => $this->u_action . '&amp;action=details&amp;ext_name=' . $row['ext_name'],
'U_PURGE' => $this->u_action . '&amp;action=purge_pre&amp;ext_name=' . $row['ext_name'],
'U_DISABLE' => $this->u_action . '&amp;action=disable_pre&amp;ext_name=' . $row['ext_name'],
));
}
$db->sql_freeresult($result);
return;
}
function list_disabled_exts()
{
global $db, $template;
$sql = 'SELECT ext_name
FROM ' . EXT_TABLE . '
WHERE ext_active= 0
ORDER BY ext_name ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('disabled', array(
'EXT_NAME' => $row['ext_name'],
'U_DETAILS' => $this->u_action . '&amp;action=details&amp;ext_name=' . $row['ext_name'],
'U_PURGE' => $this->u_action . '&amp;action=purge_pre&amp;ext_name=' . $row['ext_name'],
'U_DELETE' => $this->u_action . '&amp;action=delete_pre&amp;ext_name=' . $row['ext_name'],
'U_ENABLE' => $this->u_action . '&amp;action=enable_pre&amp;ext_name=' . $row['ext_name'],
));
}
$db->sql_freeresult($result);
return;
}
function list_avaliable_exts()
{
$phpbb_extension_manager->load_extensions();
$allavailable = array_keys($phpbb_extension_manager->all_available());
$allconfigured = array_keys($phpbb_extension_manager->all_configured());
$uninstalled = array_diff($allavailable, $allconfigured);
foreach ($uninstalled as $ext)
{
$template->assign_block_vars('disabled', array(
'EXT_NAME' => $ext['ext_name'],
'U_DETAILS' => $this->u_action . '&amp;action=details&amp;ext_name=' . $ext['ext_name'],
'U_DELETE' => $this->u_action . '&amp;action=delete_pre&amp;ext_name=' . $ext['ext_name'],
'U_ENABLE' => $this->u_action . '&amp;action=enable_pre&amp;ext_name=' . $ext['ext_name'],
));
}
return;
}
function get_meta_info($filepath)
{
global $template;
$metadatafile = file_get_contents($filepath);
$metadata = json_decode($metadatafile,true);
$name = $metadata["name"];
$type = $metadata["type"];
$description = $metadata["description"];
$homepage = $metadata["homepage"];
$version = $metadata["version"];
$time = $metadata["time"];
$licence = $metadata["licence"];
$require_php = $metadata["require"]["php"];
$require_phpbb = $metadata["require"]["phpbb"];
$display_name = $metadata["extra"]["display-name"];
$template->assign_vars(array(
'NAME' => $name,
'TYPE' => $type,
'DESCRIPTION' => $description,
'HOMEPAGE' => $homepage,
'VERSION' => $version,
'TIME' => $time,
'LICENSE' => $licence,
'REQUIRE_PHP' => $require_php,
'REQUIRE_PHPBB' => $require_phpbb,
'DISPLAY_NAME' => $display_name,
)
);
foreach ($metadata["authors"] as $author)
{
$template->assign_block_vars('authors', array(
'AUTHOR_NAME' => $author["name"],
'AUTHOR_USERNAME' => $author["username"],
'AUTHOR_EMAIL' => $author["email"],
'AUTHOR_HOMEPAGE' => $author["homepage"],
'AUTHOR_TYPE' => $author["type"],
));
}
}
}

View file

@ -0,0 +1,34 @@
<?php
/**
*
* @package acp
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @package module_install
*/
class acp_extensions_info
{
function module()
{
return array(
'filename' => 'acp_extensions',
'title' => 'ACP_EXTENSIONS',
'version' => '1.0.0',
'modes' => array(
'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_CAT_SYSTEM')),
),
);
}
function install()
{
}
function uninstall()
{
}
}

View file

@ -345,6 +345,7 @@ INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_board', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_bots', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_bots', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_clearlogs', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_clearlogs', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_email', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_email', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_extensions', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_fauth', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_fauth', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forum', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forum', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forumadd', 1); INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forumadd', 1);

View file

@ -81,6 +81,7 @@ $lang = array_merge($lang, array(
'ACP_EMAIL_SETTINGS' => 'Email settings', 'ACP_EMAIL_SETTINGS' => 'Email settings',
'ACP_EXTENSION_GROUPS' => 'Manage extension groups', 'ACP_EXTENSION_GROUPS' => 'Manage extension groups',
'ACP_EXTENSIONS' => 'Manage board extensions',
'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions', 'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions',
'ACP_FORUM_LOGS' => 'Forum logs', 'ACP_FORUM_LOGS' => 'Forum logs',

View file

@ -0,0 +1,100 @@
<?php
/**
*
* acp_mods [English]
*
* @package language
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
/**
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* DO NOT CHANGE
*/
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'EXTENSION' => 'Extension',
'EXTENSIONS' => 'Extensions',
'EXTENSIONS_ADMIN' => 'Extensions Admin',
'EXTENSIONS_EXPLAIN' => 'The Extensions Admin is a tool in your phpBB Board which allows you to manage all of your extensions. For more information about extensions please visit <a href="http://phpbb.com/mods/extensions/">this page</a> on phpBBs Offical Website.',
'DETAILS' => 'Details',
'AVALIABLE' => 'Avaliable',
'ENABLED' => 'Enabled',
'DISBALED' => 'Disabled',
'ENABLE' => 'Enable',
'DISABLE' => 'Disable',
'PURGE' => 'Purge',
'DELETE' => 'Delete',
'ENABLED' => 'Enabled',
'DISABLED' => 'Disabled',
'PURGED' => 'Purged',
'DELETED' => 'Deleted',
'ENABLE_EXPLAIN' => 'Enabling an extension allows you to use it on your board.',
'DISABLE_EXPLAIN' => 'Disabling an extension keeps the files and data intact but is not working on your board.',
'PURGE_EXPLAIN' => 'Purging an extension keeps the files but not the data on your board.',
'DELETE_EXPLAIN' => 'Deleting an extension removes all traces of the extension except from your logs.',
'ENABLE_SUCESS' => 'Your extension was enabled sucessfully',
'DISABLE_SUCESS' => 'Your extension was disabled sucessfully',
'PURGE_SUCESS' => 'Your extension was purged sucessfully',
'DELETE_SUCESS' => 'Your extension was deleted sucessfully',
'ENABLE_FAIL' => 'Your extension could not be enabled',
'DISABLE_FAIL' => 'Your extension could not be disabled',
'PURGE_FAIL' => 'Your extension could not be purged',
'DELETE_FAIL' => 'Your extension could not be deleted',
'EXTENSION_NAME' => 'Extension Name',
'EXTENSION_ACTIONS' => 'Actions',
'EXTENSION_OPTIONS' => 'Options',
'ENABLE_CONFIRM' => 'Are you sure you wish to enable this extension?',
'DISABLE_CONFIRM' => 'Are your sure you wish to disable this extension?',
'PURGE_CONFIRM' => 'Are you sure you wish to purge (and not disable) this extension? This action will wipe the extension data on this board and is not reversible.',
'DELETE_CONFIRM' => 'Are you sure you wish to delete (and not purge or disable) this extension? This action will remove the extension and all of its data from this board and is not reversible.',
'WARNING' => 'Warning',
'RETURN' => 'Return',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => '',
));
?>

View file

@ -226,6 +226,7 @@ $lang = array_merge($lang, array(
'acl_a_switchperm' => array('lang' => 'Can use others permissions', 'cat' => 'permissions'), 'acl_a_switchperm' => array('lang' => 'Can use others permissions', 'cat' => 'permissions'),
'acl_a_styles' => array('lang' => 'Can manage styles', 'cat' => 'misc'), 'acl_a_styles' => array('lang' => 'Can manage styles', 'cat' => 'misc'),
'acl_a_extensions' => array('lang' => 'Can manage extensions', 'cat' => 'misc'),
'acl_a_viewlogs' => array('lang' => 'Can view logs', 'cat' => 'misc'), 'acl_a_viewlogs' => array('lang' => 'Can view logs', 'cat' => 'misc'),
'acl_a_clearlogs' => array('lang' => 'Can clear logs', 'cat' => 'misc'), 'acl_a_clearlogs' => array('lang' => 'Can clear logs', 'cat' => 'misc'),
'acl_a_modules' => array('lang' => 'Can manage modules', 'cat' => 'misc'), 'acl_a_modules' => array('lang' => 'Can manage modules', 'cat' => 'misc'),