[ticket/416] Only allow adding module more than once on proper modules
B3P-416
This commit is contained in:
@@ -443,6 +443,13 @@ class portal_module
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not install if module already exists in the
|
||||||
|
// column and it can't be added more than once
|
||||||
|
if (!$this->c_class->can_multi_include() && !$this->modules_constraints->can_move_module($this->portal_columns->number_to_string($add_column), $module_classname))
|
||||||
|
{
|
||||||
|
trigger_error($this->user->lang['MODULE_ADD_ONCE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SELECT module_order
|
$sql = 'SELECT module_order
|
||||||
FROM ' . PORTAL_MODULES_TABLE . '
|
FROM ' . PORTAL_MODULES_TABLE . '
|
||||||
WHERE module_column = ' . $add_column . '
|
WHERE module_column = ' . $add_column . '
|
||||||
@@ -505,6 +512,13 @@ class portal_module
|
|||||||
// Find new modules
|
// Find new modules
|
||||||
foreach ($modules_list as $module_class => $module)
|
foreach ($modules_list as $module_class => $module)
|
||||||
{
|
{
|
||||||
|
// Do not install if module already exists in the
|
||||||
|
// column and it can't be added more than once
|
||||||
|
if (!$module->can_multi_include() && !$this->modules_constraints->can_move_module($this->portal_columns->number_to_string($add_column), $module_class))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module->get_allowed_columns() & $this->portal_columns->string_to_constant($add_module))
|
if ($module->get_allowed_columns() & $this->portal_columns->string_to_constant($add_module))
|
||||||
{
|
{
|
||||||
if ($module->get_language())
|
if ($module->get_language())
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ class announcements extends module_base
|
|||||||
*/
|
*/
|
||||||
public $language = 'portal_announcements_module';
|
public $language = 'portal_announcements_module';
|
||||||
|
|
||||||
|
/** @var bool Can include this module multiple times */
|
||||||
|
protected $multiple_includes = true;
|
||||||
|
|
||||||
/** @var \phpbb\auth\auth */
|
/** @var \phpbb\auth\auth */
|
||||||
protected $auth;
|
protected $auth;
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ class custom extends module_base
|
|||||||
*/
|
*/
|
||||||
public $custom_acp_tpl = 'acp_portal_custom';
|
public $custom_acp_tpl = 'acp_portal_custom';
|
||||||
|
|
||||||
|
/** @var bool Can include this module multiple times */
|
||||||
|
protected $multiple_includes = true;
|
||||||
|
|
||||||
/** @var \phpbb\config\config */
|
/** @var \phpbb\config\config */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ class links extends module_base
|
|||||||
*/
|
*/
|
||||||
public $custom_acp_tpl = 'acp_portal_links';
|
public $custom_acp_tpl = 'acp_portal_links';
|
||||||
|
|
||||||
|
/** @var bool Can include this module multiple times */
|
||||||
|
protected $multiple_includes = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constants
|
* constants
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ class main_menu extends module_base
|
|||||||
*/
|
*/
|
||||||
public $custom_acp_tpl = 'acp_portal_menu';
|
public $custom_acp_tpl = 'acp_portal_menu';
|
||||||
|
|
||||||
|
/** @var bool Can include this module multiple times */
|
||||||
|
protected $multiple_includes = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constants
|
* constants
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ class module_base implements module_interface
|
|||||||
/** @var string Module language file */
|
/** @var string Module language file */
|
||||||
protected $language;
|
protected $language;
|
||||||
|
|
||||||
|
/** @var bool Can include this module multiple times */
|
||||||
|
protected $multiple_includes = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -97,4 +100,12 @@ class module_base implements module_interface
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function can_multi_include()
|
||||||
|
{
|
||||||
|
return $this->multiple_includes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,9 +95,16 @@ interface module_interface
|
|||||||
* Executes any additional commands for uninstalling the module
|
* Executes any additional commands for uninstalling the module
|
||||||
*
|
*
|
||||||
* @param int $module_id Module's ID
|
* @param int $module_id Module's ID
|
||||||
* @param \phpbb\db\driver $db phpBB dbal driver
|
* @param \phpbb\db\driver\driver_interface $db phpBB dbal driver
|
||||||
*
|
*
|
||||||
* @return bool True if uninstall was successful, false if not
|
* @return bool True if uninstall was successful, false if not
|
||||||
*/
|
*/
|
||||||
public function uninstall($module_id, $db);
|
public function uninstall($module_id, $db);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether module can be included more than once
|
||||||
|
*
|
||||||
|
* @return bool True if module can be included more than once, false if not
|
||||||
|
*/
|
||||||
|
public function can_multi_include();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,16 +41,19 @@ class news extends module_base
|
|||||||
*/
|
*/
|
||||||
public $language = 'portal_news_module';
|
public $language = 'portal_news_module';
|
||||||
|
|
||||||
|
/** @var bool Can include this module multiple times */
|
||||||
|
protected $multiple_includes = true;
|
||||||
|
|
||||||
/** @var \phpbb\auth\auth */
|
/** @var \phpbb\auth\auth */
|
||||||
protected $auth;
|
protected $auth;
|
||||||
|
|
||||||
/** @var \phpbb\cache */
|
/** @var \phpbb\cache\service */
|
||||||
protected $cache;
|
protected $cache;
|
||||||
|
|
||||||
/** @var \phpbb\config\config */
|
/** @var \phpbb\config\config */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
/** @var \phpbb\db\driver */
|
/** @var \phpbb\db\driver\driver_Interface */
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
/** @var \phpbb\pagination */
|
/** @var \phpbb\pagination */
|
||||||
@@ -62,7 +65,7 @@ class news extends module_base
|
|||||||
/** @var \phpbb\request\request */
|
/** @var \phpbb\request\request */
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
/** @var \phpbb\template */
|
/** @var \phpbb\template\template */
|
||||||
protected $template;
|
protected $template;
|
||||||
|
|
||||||
/** @var string PHP file extension */
|
/** @var string PHP file extension */
|
||||||
@@ -81,13 +84,13 @@ class news extends module_base
|
|||||||
* Construct a news object
|
* Construct a news object
|
||||||
*
|
*
|
||||||
* @param \phpbb\auth\auth $auth phpBB auth
|
* @param \phpbb\auth\auth $auth phpBB auth
|
||||||
* @param \phpbb\cache $cache phpBB cache system
|
* @param \phpbb\cache\service $cache phpBB cache system
|
||||||
* @param \phpbb\config\config $config phpBB config
|
* @param \phpbb\config\config $config phpBB config
|
||||||
* @param \phpbb\db\driver $db phpBB db driver
|
* @param \phpbb\db\driver\driver_interface $db phpBB db driver
|
||||||
* @param \phpbb\pagination $pagination phpBB pagination
|
* @param \phpbb\pagination $pagination phpBB pagination
|
||||||
* @param \board3\portal\includes\modules_helper $modules_helper Portal modules helper
|
* @param \board3\portal\includes\modules_helper $modules_helper Portal modules helper
|
||||||
* @param \phpbb\request\request $request phpBB request
|
* @param \phpbb\request\request $request phpBB request
|
||||||
* @param \phpbb\template $template phpBB template
|
* @param \phpbb\template\template $template phpBB template
|
||||||
* @param string $phpbb_root_path phpBB root path
|
* @param string $phpbb_root_path phpBB root path
|
||||||
* @param string $phpEx php file extension
|
* @param string $phpEx php file extension
|
||||||
* @param \phpbb\user $user phpBB user object
|
* @param \phpbb\user $user phpBB user object
|
||||||
|
|||||||
Reference in New Issue
Block a user