mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/10631] Adding an extensions admin
PHPBB3-10631
This commit is contained in:
committed by
Unknown Bliss
parent
1128ff1e58
commit
5e6b4c7192
265
phpBB/includes/acp/acp_extensions.php
Normal file
265
phpBB/includes/acp/acp_extensions.php
Normal 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 . '&action=enable&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 . '&action=disable&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 . '&action=purge&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 . '&action=delete&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 . '&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 . '&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 . '&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 . '&action=details&ext_name=' . $row['ext_name'],
|
||||
'U_PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $row['ext_name'],
|
||||
'U_DISABLE' => $this->u_action . '&action=disable_pre&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 . '&action=details&ext_name=' . $row['ext_name'],
|
||||
'U_PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $row['ext_name'],
|
||||
'U_DELETE' => $this->u_action . '&action=delete_pre&ext_name=' . $row['ext_name'],
|
||||
'U_ENABLE' => $this->u_action . '&action=enable_pre&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 . '&action=details&ext_name=' . $ext['ext_name'],
|
||||
'U_DELETE' => $this->u_action . '&action=delete_pre&ext_name=' . $ext['ext_name'],
|
||||
'U_ENABLE' => $this->u_action . '&action=enable_pre&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"],
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
34
phpBB/includes/acp/info/acp_extensions.php
Normal file
34
phpBB/includes/acp/info/acp_extensions.php
Normal 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()
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user