Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions acp/boardrules_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

class boardrules_info
{
/**
* Return ACP module configuration.
*
* @return array
*/
public function module()
{
return array(
Expand Down
6 changes: 6 additions & 0 deletions acp/boardrules_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@

class boardrules_module
{
/** @var string */
public $page_title;

/** @var string */
public $tpl_name;

/** @var string */
public $u_action;

/**
* Main ACP module
*
* @param int $id
* @param string $mode
* @return void
* @throws \Exception
*/
public function main($id, $mode)
Expand Down
31 changes: 19 additions & 12 deletions controller/admin_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public function display_language_dashboard()
* @param int $parent_id Category to display rules from; default: 0
* @return void
* @access public
* @throws \phpbb\boardrules\exception\base If stored rule data is invalid
*/
public function display_rules($language, $parent_id = 0)
{
Expand Down Expand Up @@ -295,7 +296,7 @@ public function display_rules($language, $parent_id = 0)
$this->template->assign_block_vars('breadcrumb', array(
'RULE_TITLE' => $entity->get_title(),

'S_CURRENT_LEVEL' => $entity->get_id() == $parent_id,
'S_CURRENT_LEVEL' => $entity->get_id() === (int) $parent_id,

'U_RULE' => "{$this->u_action}&language={$language}&parent_id=" . $entity->get_id(),
));
Expand Down Expand Up @@ -405,7 +406,7 @@ public function copy_ruleset($target_language, $return_to = '')
{
$copy_result = $this->ruleset_operator->copy($source_language, $target_language);
}
catch (\InvalidArgumentException | \RuntimeException $e)
catch (\Exception $e)
{
trigger_error($this->lang->lang($e->getMessage()) . adm_back_link($return_url), E_USER_WARNING);
}
Expand Down Expand Up @@ -508,6 +509,7 @@ protected function get_ruleset_return_url($language, $return_to)
* @param int $parent_id Category to display rules from; default: 0
* @return void
* @access public
* @throws \phpbb\boardrules\exception\base If stored rule data is invalid
*/
public function add_rule($language, $parent_id = 0)
{
Expand Down Expand Up @@ -548,6 +550,7 @@ public function add_rule($language, $parent_id = 0)
* @param int $rule_id The rule identifier to edit
* @return void
* @access public
* @throws \phpbb\boardrules\exception\base If the rule does not exist or stored rule data is invalid
*/
public function edit_rule($rule_id)
{
Expand Down Expand Up @@ -590,6 +593,7 @@ public function edit_rule($rule_id)
* @param array $data The form data to be processed
* @return void
* @access protected
* @throws \phpbb\boardrules\exception\base If stored rule data is invalid
*/
protected function add_edit_rule_data($entity, $data)
{
Expand Down Expand Up @@ -686,7 +690,7 @@ protected function add_edit_rule_data($entity, $data)
}

// Change rule parent
if (isset($data['rule_parent_id']) && ($data['rule_parent_id'] != $entity->get_parent_id()))
if (isset($data['rule_parent_id']) && ($entity->get_parent_id() !== (int) $data['rule_parent_id']))
{
try
{
Expand Down Expand Up @@ -765,6 +769,7 @@ protected function add_edit_rule_data($entity, $data)
* @param int $rule_id The rule identifier to delete
* @return void
* @access public
* @throws \phpbb\boardrules\exception\out_of_bounds If the rule does not exist
*/
public function delete_rule($rule_id)
{
Expand Down Expand Up @@ -813,6 +818,7 @@ public function delete_rule($rule_id)
* @param int $amount The number of places to move the rule
* @return void
* @access public
* @throws \phpbb\boardrules\exception\out_of_bounds If the rule does not exist after moving
*/
public function move_rule($rule_id, $direction, $amount = 1)
{
Expand Down Expand Up @@ -955,13 +961,14 @@ protected function has_copy_source(array $languages, $target_language)
}

/**
* Build pull down menu options of available rule parents
*
* @param \phpbb\boardrules\entity\rule_interface $entity The rule entity object
* @param int $parent_id Category to display rules from; default: 0
* @return void
* @access protected
*/
* Build pull down menu options of available rule parents
*
* @param \phpbb\boardrules\entity\rule_interface $entity The rule entity object
* @param int $parent_id Category to display rules from; default: 0
* @return void
* @access protected
* @throws \phpbb\boardrules\exception\base If stored rule data is invalid
*/
protected function build_parent_select_menu($entity, $parent_id = 0)
{
// Prepare rule pull-down field
Expand Down Expand Up @@ -992,8 +999,8 @@ protected function build_parent_select_menu($entity, $parent_id = 0)
'RULE_ID' => $rule_menu_item->get_id(),
'RULE_TITLE' => $padding . $rule_menu_item->get_title(),

'S_DISABLED' => ($rule_menu_item->get_left_id() > $entity->get_left_id() && $rule_menu_item->get_right_id() < $entity->get_right_id()) || $rule_menu_item->get_id() == $entity->get_id(),
'S_RULE_PARENT' => $rule_menu_item->get_id() == $parent_id,
'S_DISABLED' => ($rule_menu_item->get_left_id() > $entity->get_left_id() && $rule_menu_item->get_right_id() < $entity->get_right_id()) || $rule_menu_item->get_id() === $entity->get_id(),
'S_RULE_PARENT' => $rule_menu_item->get_id() === (int) $parent_id,
));
}
}
Expand Down
5 changes: 5 additions & 0 deletions controller/admin_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function set_ruleset_published($language, $published, $return_to = '');
* @param int $parent_id Category to display rules from; default: 0
* @return void
* @access public
* @throws \phpbb\boardrules\exception\base If stored rule data is invalid
*/
public function display_rules($language, $parent_id = 0);

Expand All @@ -77,6 +78,7 @@ public function save_ruleset_intro($language);
* @param int $parent_id Category to display rules from; default: 0
* @return void
* @access public
* @throws \phpbb\boardrules\exception\base If stored rule data is invalid
*/
public function add_rule($language, $parent_id = 0);

Expand All @@ -86,6 +88,7 @@ public function add_rule($language, $parent_id = 0);
* @param int $rule_id The rule identifier to edit
* @return void
* @access public
* @throws \phpbb\boardrules\exception\base If the rule does not exist or stored rule data is invalid
*/
public function edit_rule($rule_id);

Expand All @@ -95,6 +98,7 @@ public function edit_rule($rule_id);
* @param int $rule_id The rule identifier to delete
* @return void
* @access public
* @throws \phpbb\boardrules\exception\out_of_bounds If the rule does not exist
*/
public function delete_rule($rule_id);

Expand All @@ -106,6 +110,7 @@ public function delete_rule($rule_id);
* @param int $amount The number of places to move the rule
* @return void
* @access public
* @throws \phpbb\boardrules\exception\out_of_bounds If the rule does not exist after moving
*/
public function move_rule($rule_id, $direction, $amount = 1);

Expand Down
3 changes: 2 additions & 1 deletion controller/main_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function __construct(\phpbb\config\config $config, \phpbb\controller\help
*
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
* @access public
* @throws \phpbb\boardrules\exception\base If stored rule data is invalid
*/
public function display()
{
Expand Down Expand Up @@ -176,7 +177,7 @@ public function display()
}

// Assign values to template vars for the rules page
$intro_text = (string) $this->ruleset_operator->get_intro_text($display_language);
$intro_text = $this->ruleset_operator->get_intro_text($display_language);

$this->template->assign_vars(array(
'S_BOARD_RULES' => true,
Expand Down
1 change: 1 addition & 0 deletions controller/main_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface main_interface
*
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
* @access public
* @throws \phpbb\boardrules\exception\base If stored rule data is invalid
*/
public function display();
}
6 changes: 3 additions & 3 deletions entity/rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function set_message($message)
/**
* Check if bbcode is enabled on the message
*
* @return int
* @return int OPTION_FLAG_BBCODE when enabled, otherwise 0
* @access public
*/
public function message_bbcode_enabled()
Expand Down Expand Up @@ -385,7 +385,7 @@ public function message_disable_bbcode()
/**
* Check if magic_url is enabled on the message
*
* @return int
* @return int OPTION_FLAG_LINKS when enabled, otherwise 0
* @access public
*/
public function message_magic_url_enabled()
Expand Down Expand Up @@ -422,7 +422,7 @@ public function message_disable_magic_url()
/**
* Check if smilies are enabled on the message
*
* @return int
* @return int OPTION_FLAG_SMILIES when enabled, otherwise 0
* @access public
*/
public function message_smilies_enabled()
Expand Down
7 changes: 4 additions & 3 deletions entity/rule_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function set_message($message);
/**
* Check if bbcode is enabled on the message
*
* @return bool
* @return int OPTION_FLAG_BBCODE when enabled, otherwise 0
* @access public
*/
public function message_bbcode_enabled();
Expand All @@ -144,7 +144,7 @@ public function message_disable_bbcode();
/**
* Check if magic_url is enabled on the message
*
* @return bool
* @return int OPTION_FLAG_LINKS when enabled, otherwise 0
* @access public
*/
public function message_magic_url_enabled();
Expand All @@ -168,7 +168,7 @@ public function message_disable_magic_url();
/**
* Check if smilies are enabled on the message
*
* @return bool
* @return int OPTION_FLAG_SMILIES when enabled, otherwise 0
* @access public
*/
public function message_smilies_enabled();
Expand Down Expand Up @@ -221,6 +221,7 @@ public function get_language();
* @param string $language language iso
* @return rule_interface $this object for chaining calls; load()->set()->save()
* @access public
* @throws \phpbb\boardrules\exception\unexpected_value If the language is not installed
*/
public function set_language($language);

Expand Down
1 change: 1 addition & 0 deletions migrations/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function __construct(\phpbb\db\driver\driver_interface $db, $table_prefix
*
* @param string $new_column Name of the column to be updated
* @param string $old_column Name of the column with old data
* @return void
*/
public function change_rule_language($new_column, $old_column)
{
Expand Down
2 changes: 2 additions & 0 deletions migrations/v20x/m15_update_lang_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public function update_data()

/**
* Change rule_language values from lang_id to lang_iso
*
* @return void
*/
public function change_rule_language()
{
Expand Down
1 change: 1 addition & 0 deletions migrations/v20x/m16_update_lang_postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function update_data()
* To work around this, we re-create a new rule_language column with
* the new data type and copy the new data to it via specific queries.
*
* @return void
* @throws \RuntimeException
*/
public function alter_rule_language()
Expand Down
12 changes: 12 additions & 0 deletions migrations/v30x/m18_ruleset_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@

class m18_ruleset_status extends \phpbb\db\migration\migration
{
/**
* {@inheritdoc}
*/
public function effectively_installed()
{
return $this->db_tools->sql_table_exists($this->table_prefix . 'boardrules_rulesets');
}

/**
* {@inheritdoc}
*/
public static function depends_on()
{
return array(
Expand All @@ -25,6 +31,9 @@ public static function depends_on()
);
}

/**
* {@inheritdoc}
*/
public function update_schema()
{
return array(
Expand All @@ -41,6 +50,9 @@ public function update_schema()
);
}

/**
* {@inheritdoc}
*/
public function revert_schema()
{
return array(
Expand Down
12 changes: 12 additions & 0 deletions migrations/v30x/m19_list_style_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@

class m19_list_style_options extends \phpbb\db\migration\migration
{
/**
* {@inheritdoc}
*/
public function effectively_installed()
{
return $this->config['boardrules_list_style'] !== 'disc';
}

/**
* {@inheritdoc}
*/
public static function depends_on()
{
return array(
Expand All @@ -25,13 +31,19 @@ public static function depends_on()
);
}

/**
* {@inheritdoc}
*/
public function update_data()
{
return array(
array('config.update', array('boardrules_list_style', 'unordered')),
);
}

/**
* {@inheritdoc}
*/
public function revert_data()
{
return array(
Expand Down
Loading