From 7b7fde2a00926c120316045593faeb829fd39865 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 7 May 2015 15:48:14 +0200 Subject: [PATCH 1/7] [ticket/541] Update for final release of Board3 Portal B3P-541 --- composer.json | 4 ++-- migrations/v210.php | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 migrations/v210.php diff --git a/composer.json b/composer.json index cd70a7ea..c3b12d8d 100644 --- a/composer.json +++ b/composer.json @@ -3,8 +3,8 @@ "type": "phpbb-extension", "description": "Adds a portal with several blocks to your forum. You can change the settings, move the blocks, add new blocks and more in the ACP.", "homepage": "http://www.board3.de", - "version": "2.1.0-rc3", - "time": "2015-05-07 14:01:15", + "version": "2.1.0", + "time": "2015-05-07 14:47:44", "license": "GPL-2.0", "authors": [{ "name": "Marc Alexander", diff --git a/migrations/v210.php b/migrations/v210.php new file mode 100644 index 00000000..3512afc8 --- /dev/null +++ b/migrations/v210.php @@ -0,0 +1,25 @@ + Date: Wed, 3 Jun 2015 10:49:23 +0200 Subject: [PATCH 2/7] [ticket/555] Add setting for default currency B3P-555 --- modules/donation.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/donation.php b/modules/donation.php index f15f4e09..a9ac5deb 100644 --- a/modules/donation.php +++ b/modules/donation.php @@ -44,7 +44,7 @@ class donation extends module_base /** @var \phpbb\config\config */ protected $config; - /** @var \phpbb\template */ + /** @var \phpbb\template\template */ protected $template; /** @var \phpbb\user */ @@ -54,7 +54,7 @@ class donation extends module_base * Construct a stylechanger object * * @param \phpbb\config\config $config phpBB config - * @param \phpbb\template $template phpBB template + * @param \phpbb\template\template $template phpBB template * @param \phpbb\user $user phpBB user object */ public function __construct($config, $template, $user) @@ -112,6 +112,7 @@ class donation extends module_base { $this->config->set('board3_pay_acc_' . $module_id, 'your@paypal.com'); $this->config->set('board3_pay_custom_' . $module_id, true); + $this->config->set('board3_pay_default_' . $module_id, 'EUR'); return true; } @@ -123,6 +124,7 @@ class donation extends module_base $del_config = array( 'board3_pay_acc_' . $module_id, 'board3_pay_custom_' . $module_id, + 'board3_pay_default_' . $module_id, ); $sql = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE ' . $db->sql_in_set('config_name', $del_config); From 367d5168bd7a726241d086b56d59a4c8dbf4999b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 3 Jun 2015 11:06:42 +0200 Subject: [PATCH 3/7] [ticket/555] Add default currency to donation modules in migration B3P-555 --- migrations/v210.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/migrations/v210.php b/migrations/v210.php index 3512afc8..a9652c71 100644 --- a/migrations/v210.php +++ b/migrations/v210.php @@ -20,6 +20,23 @@ class v210 extends \phpbb\db\migration\migration { return array( array('config.update', array('board3_portal_version', '2.1.0')), + array('custom', array(array($this, 'add_donation_setting'))), ); } + + /** + * Adds default currency setting to already installed donation modules + */ + public function add_donation_setting() + { + $sql = 'SELECT module_id + FROM ' . $this->table_prefix . "portal_modules + WHERE module_classname = '\\\board3\\\portal\\\modules\\\donation'"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $this->config->set('board3_pay_default_' . $row['module_id'], 'EUR'); + } + $this->db->sql_freeresult($result); + } } From a5ccbb48c76aa3cf0b5b00ec7861a34746be74ed Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 3 Jun 2015 12:53:21 +0200 Subject: [PATCH 4/7] [ticket/555] Allow defining default currency in ACP B3P-555 --- config/modules.yml | 2 + includes/modules_helper.php | 4 +- modules/donation.php | 99 ++++++++++++++++++- .../portal/modules/donation_center.html | 21 +--- .../portal/modules/donation_side.html | 19 +--- .../portal/modules/donation_center.html | 21 +--- .../portal/modules/donation_side.html | 19 +--- 7 files changed, 114 insertions(+), 71 deletions(-) diff --git a/config/modules.yml b/config/modules.yml index 3688a31c..dab80771 100644 --- a/config/modules.yml +++ b/config/modules.yml @@ -84,8 +84,10 @@ services: class: board3\portal\modules\donation arguments: - @config + - @request - @template - @user + - @board3.portal.modules_helper tags: - { name: board3.portal.module } diff --git a/includes/modules_helper.php b/includes/modules_helper.php index cc9b1956..5b5cb214 100644 --- a/includes/modules_helper.php +++ b/includes/modules_helper.php @@ -85,7 +85,9 @@ class modules_helper public function generate_select_box($key, $select_ary, $selected_options) { // Build options - $options = '' : '">'; foreach ($select_ary as $id => $option) { $options .= ''; diff --git a/modules/donation.php b/modules/donation.php index a9ac5deb..cfe8e5c8 100644 --- a/modules/donation.php +++ b/modules/donation.php @@ -44,24 +44,56 @@ class donation extends module_base /** @var \phpbb\config\config */ protected $config; + /** @var \phpbb\request\request_interface */ + protected $request; + /** @var \phpbb\template\template */ protected $template; /** @var \phpbb\user */ protected $user; + /** @var \board3\portal\includes\modules_helper */ + protected $helper; + + /** @var array List of currencies supported in donations */ + protected $currencies = array( + 'AUD', + 'CAD', + 'CZK', + 'DKK', + 'HKD', + 'HUF', + 'NZD', + 'NOK', + 'PLN', + 'GBP', + 'SGD', + 'SEK', + 'CHF', + 'JPY', + 'USD', + 'EUR', + 'MXN', + 'ILS', + ); + /** - * Construct a stylechanger object + * Construct a donation module object * * @param \phpbb\config\config $config phpBB config + * @param \phpbb\request\request_interface $request Request * @param \phpbb\template\template $template phpBB template * @param \phpbb\user $user phpBB user object + * @param \board3\portal\includes\modules_helper $helper Board3 Portal modules helper */ - public function __construct($config, $template, $user) + public function __construct($config, $request, $template, $user, $helper) { $this->config = $config; + $this->request = $request; $this->template = $template; $this->user = $user; + $this->helper = $helper; } /** @@ -74,6 +106,8 @@ class donation extends module_base 'PAY_CUSTOM_CENTER' => (!empty($this->config['board3_pay_custom_' . $module_id])) ? $this->user->data['username_clean'] : false, )); + $this->build_currency_select($module_id, 'b3p_donation_currency_center'); + return 'donation_center.html'; } @@ -87,6 +121,8 @@ class donation extends module_base 'PAY_CUSTOM_SIDE' => (!empty($this->config['board3_pay_custom_' . $module_id])) ? $this->user->data['username_clean'] : false, )); + $this->build_currency_select($module_id, 'b3p_donation_currency_side', true); + return 'donation_side.html'; } @@ -101,10 +137,69 @@ class donation extends module_base 'legend1' => 'ACP_PORTAL_PAYPAL_SETTINGS', 'board3_pay_acc_' . $module_id => array('lang' => 'PORTAL_PAY_ACC', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true), 'board3_pay_custom_' . $module_id => array('lang' => 'PORTAL_PAY_CUSTOM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'board3_pay_default_' . $module_id => array('lang' => 'PORTAL_PAY_DEFAULT', 'validate' => 'string', 'type' => 'custom', 'method' => 'select_currency', 'submit' => 'save_currency', 'explain' => true), ) ); } + /** + * Build currency select for block name + * + * @param int $module_id Module ID + * @param string $block_name Name of template block + * @param bool $short Whether short ISO titles should be used + */ + protected function build_currency_select($module_id, $block_name, $short = false) + { + foreach ($this->currencies as $currency) + { + $this->template->assign_block_vars($block_name, array( + 'VALUE' => $currency, + 'TITLE' => ($short) ? $currency : $this->user->lang($currency), + 'SELECTED' => $currency === $this->config['board3_pay_default_' . $module_id], + )); + } + } + + /** + * Create select box for attachment filetype + * + * @param mixed $value Value of input + * @param string $key Key name + * @param int $module_id Module ID + * + * @return string Forum select box HTML + */ + public function select_currency($value, $key, $module_id) + { + $currencies = $selected = array(); + foreach ($this->currencies as $currency) + { + $currencies[] = array( + 'title' => $this->user->lang($currency), + 'value' => $currency, + ); + + if ($currency === $this->config['board3_pay_default_' . $module_id]) + { + $selected[] = $currency; + } + } + + return $this->helper->generate_select_box($key, $currencies, $selected); + } + + /** + * Save currency setting + * + * @param string $key + * @param int $module_id + */ + public function save_currency($key, $module_id) + { + $this->config->set($key, $this->request->variable('board3_pay_default_' . $module_id, '')); + } + /** * {@inheritdoc} */ diff --git a/styles/prosilver/template/portal/modules/donation_center.html b/styles/prosilver/template/portal/modules/donation_center.html index e6c7c65e..239f904d 100644 --- a/styles/prosilver/template/portal/modules/donation_center.html +++ b/styles/prosilver/template/portal/modules/donation_center.html @@ -20,24 +20,9 @@ diff --git a/styles/prosilver/template/portal/modules/donation_side.html b/styles/prosilver/template/portal/modules/donation_side.html index 22b84a30..4478276e 100644 --- a/styles/prosilver/template/portal/modules/donation_side.html +++ b/styles/prosilver/template/portal/modules/donation_side.html @@ -14,22 +14,9 @@ diff --git a/styles/subsilver2/template/portal/modules/donation_center.html b/styles/subsilver2/template/portal/modules/donation_center.html index 2f80c603..17342e7d 100644 --- a/styles/subsilver2/template/portal/modules/donation_center.html +++ b/styles/subsilver2/template/portal/modules/donation_center.html @@ -21,24 +21,9 @@ diff --git a/styles/subsilver2/template/portal/modules/donation_side.html b/styles/subsilver2/template/portal/modules/donation_side.html index d5d708e9..8bb5ed81 100644 --- a/styles/subsilver2/template/portal/modules/donation_side.html +++ b/styles/subsilver2/template/portal/modules/donation_side.html @@ -16,22 +16,9 @@ From d3cca6a3e253959e856733613b635167612d0fef Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 3 Jun 2015 12:55:25 +0200 Subject: [PATCH 5/7] [ticket/555] Add missing language entries B3P-555 --- language/de/modules/portal_donation_module.php | 8 +++++--- language/en/modules/portal_donation_module.php | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/language/de/modules/portal_donation_module.php b/language/de/modules/portal_donation_module.php index d98f36bf..f9646b2a 100644 --- a/language/de/modules/portal_donation_module.php +++ b/language/de/modules/portal_donation_module.php @@ -57,9 +57,11 @@ $lang = array_merge($lang, array( 'ILS' => 'Neue Israelische Schekel (ILS)', // ACP - 'ACP_PORTAL_PAYPAL_SETTINGS' => 'Paypal Einstellungen', + 'ACP_PORTAL_PAYPAL_SETTINGS' => 'Paypal Einstellungen', 'ACP_PORTAL_PAYPAL_SETTINGS_EXP' => 'Hier kannst du die Paypal Einstellungen ändern.', - 'PORTAL_PAY_ACC' => 'Paypal Account', + 'PORTAL_PAY_ACC' => 'Paypal Account', 'PORTAL_PAY_ACC_EXP' => 'Gib deine e-mail-Adresse an, die du bei Paypal benutzt, z.B. xxx@xxx.com', - 'PORTAL_PAY_CUSTOM' => 'Benutzername an die Paypal Zahlung anhängen', + 'PORTAL_PAY_CUSTOM' => 'Benutzername an die Paypal Zahlung anhängen', + 'PORTAL_PAY_DEFAULT' => 'Standard-Währung', + 'PORTAL_PAY_DEFAULT_EXP' => 'Währung die standardmäßig in der Drop-Down-Liste ausgewählt ist.' )); diff --git a/language/en/modules/portal_donation_module.php b/language/en/modules/portal_donation_module.php index d43307fc..40aa0667 100644 --- a/language/en/modules/portal_donation_module.php +++ b/language/en/modules/portal_donation_module.php @@ -61,5 +61,7 @@ $lang = array_merge($lang, array( 'ACP_PORTAL_PAYPAL_SETTINGS_EXP' => 'This is where you customize the Paypal block.', 'PORTAL_PAY_ACC' => 'Paypal account to use', 'PORTAL_PAY_ACC_EXP' => 'Enter your Paypal e-mail address eg. xxx@xxx.com', - 'PORTAL_PAY_CUSTOM' => 'Append username to Paypal donation', + 'PORTAL_PAY_CUSTOM' => 'Append username to Paypal donation', + 'PORTAL_PAY_DEFAULT' => 'Default currency', + 'PORTAL_PAY_DEFAULT_EXP' => 'Currency that will be selected by default in currency drop down list.' )); From 530d84167460bdb6da0610b7cf141999fce022b4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 3 Jun 2015 13:36:21 +0200 Subject: [PATCH 6/7] [ticket/555] Fix tests B3P-555 --- includes/modules_helper.php | 6 +++++- tests/unit/acp/move_module_test.php | 17 +++++++++-------- tests/unit/includes/modules_helper_test.php | 17 +++++++++++++++-- .../portal/modules_manager_confirm_box_test.php | 7 ++++++- tests/unit/portal/modules_manager_test.php | 7 ++++++- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/includes/modules_helper.php b/includes/modules_helper.php index 5b5cb214..80332f8f 100644 --- a/includes/modules_helper.php +++ b/includes/modules_helper.php @@ -86,7 +86,6 @@ class modules_helper { // Build options $options = '', + array('', 'foobar', array( '1' => array( @@ -68,7 +68,7 @@ class board3_includes_modules_helper_test extends \board3\portal\tests\testframe ), ), array('two')), - array('', + array('', 'foobar', array( '1' => array( @@ -81,6 +81,19 @@ class board3_includes_modules_helper_test extends \board3\portal\tests\testframe ), ), array('one')), + array('', + 'foobar', + array( + '1' => array( + 'value' => 'one', + 'title' => 'two', + ), + '2' => array( + 'value' => 'two', + 'title' => 'three', + ), + ), + array('one', 'two')), ); } diff --git a/tests/unit/portal/modules_manager_confirm_box_test.php b/tests/unit/portal/modules_manager_confirm_box_test.php index a59bdd2d..dc0b6807 100644 --- a/tests/unit/portal/modules_manager_confirm_box_test.php +++ b/tests/unit/portal/modules_manager_confirm_box_test.php @@ -47,14 +47,19 @@ class modules_manager_confirm_box_test extends \board3\portal\tests\testframewor $request =new \phpbb_mock_request(); $this->request = $request; $this->user = $user; + $auth = new \phpbb\auth\auth(); $config = new \phpbb\config\config(array()); + $controller_helper = new \board3\portal\tests\mock\controller_helper($phpbb_root_path, $phpEx); + $controller_helper->add_route('board3_portal_controller', 'portal'); + $modules_helper = new \board3\portal\includes\modules_helper($auth, $config, $controller_helper, $this->request); + $this->portal_helper = new \board3\portal\includes\helper(array( new \board3\portal\modules\clock($config, null), new \board3\portal\modules\birthday_list($config, null, $this->db, $user), new \board3\portal\modules\welcome($config, new \phpbb_mock_request, $this->db, $user, $this->phpbb_root_path, $this->phpEx), - new \board3\portal\modules\donation($config, null, $user), + new \board3\portal\modules\donation($config, $this->request, null, $user, $modules_helper), )); $this->portal_columns = new \board3\portal\portal\columns(); diff --git a/tests/unit/portal/modules_manager_test.php b/tests/unit/portal/modules_manager_test.php index 6ed0737a..00e41f59 100644 --- a/tests/unit/portal/modules_manager_test.php +++ b/tests/unit/portal/modules_manager_test.php @@ -41,12 +41,17 @@ class board3_portal_modules_manager_test extends \board3\portal\tests\testframew $request =new \phpbb_mock_request(); $config = new \phpbb\config\config(array()); + $auth = new \phpbb\auth\auth(); + + $controller_helper = new \board3\portal\tests\mock\controller_helper($phpbb_root_path, $phpEx); + $controller_helper->add_route('board3_portal_controller', 'portal'); + $modules_helper = new \board3\portal\includes\modules_helper($auth, $config, $controller_helper, $this->request); $portal_helper = new \board3\portal\includes\helper(array( new \board3\portal\modules\clock($config, null), new \board3\portal\modules\birthday_list($config, null, $this->db, $user), new \board3\portal\modules\welcome($config, new \phpbb_mock_request, $this->db, $user, $this->phpbb_root_path, $this->phpEx), - new \board3\portal\modules\donation($config, null, $user), + new \board3\portal\modules\donation($config, $request, null, $user, $modules_helper), )); $this->portal_columns = new \board3\portal\portal\columns(); From 522b4d3087067b86e9c4cd3401d0daa6f32cc6b5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 3 Jun 2015 13:59:26 +0200 Subject: [PATCH 7/7] [ticket/558] Fix coding guidelines infractions B3P-558 --- acp/portal_module.php | 36 +++++++++++----------- includes/functions.php | 4 +-- includes/modules_helper.php | 2 +- migrations/v210_beta1.php | 2 +- modules/announcements.php | 22 ++++++------- modules/attachments.php | 14 ++++----- modules/latest_members.php | 2 +- modules/leaders.php | 8 ++--- modules/main_menu.php | 2 +- modules/news.php | 22 ++++++------- modules/poll.php | 20 ++++++------ modules/recent.php | 6 ++-- modules/stylechanger.php | 2 +- modules/welcome.php | 6 ++-- tests/unit/acp/move_module_test.php | 2 +- tests/unit/portal/modules_manager_test.php | 2 +- 16 files changed, 76 insertions(+), 76 deletions(-) diff --git a/acp/portal_module.php b/acp/portal_module.php index e3b0c4f0..eb7ed658 100644 --- a/acp/portal_module.php +++ b/acp/portal_module.php @@ -66,7 +66,7 @@ class portal_module define('PORTAL_CONFIG_TABLE', $this->phpbb_container->getParameter('board3.portal.config.table')); } - if(!function_exists('obtain_portal_config')) + if (!function_exists('obtain_portal_config')) { include($this->root_path . 'includes/functions.' . $this->php_ext); } @@ -145,7 +145,7 @@ class portal_module 'MODULE_SHOW_IMAGE' => (in_array($this->portal_columns->number_to_string($module_data['module_column']), array('center', 'top', 'bottom'))) ? false : true, )); - if($module_data['module_classname'] != '\board3\portal\modules\custom') + if ($module_data['module_classname'] != '\board3\portal\modules\custom') { $groups_ary = explode(',', $module_data['module_group_ids']); @@ -154,7 +154,7 @@ class portal_module FROM ' . GROUPS_TABLE . ' ORDER BY group_id ASC'; $result = $this->db->sql_query($sql); - while($row = $this->db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $this->template->assign_block_vars('permission_setting', array( 'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false, @@ -194,7 +194,7 @@ class portal_module // Reset module $reset_module = $this->request->variable('module_reset', 0); - if($reset_module && !empty($module_data)) + if ($reset_module && !empty($module_data)) { $this->modules_manager->reset_module($id, $mode, $module_id, $module_data); } @@ -243,7 +243,7 @@ class portal_module continue; } - if(isset($null['type']) && $null['type'] == 'custom') + if (isset($null['type']) && $null['type'] == 'custom') { continue; } @@ -266,7 +266,7 @@ class portal_module FROM ' . GROUPS_TABLE . ' ORDER BY group_id ASC'; $result = $this->db->sql_query($sql); - while($row = $this->db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $groups_ary[] = $row['group_id']; } @@ -283,7 +283,7 @@ class portal_module 'module_status' => $this->request->variable('module_status', self::B3_MODULE_ENABLED), ); - if(!(isset($this->c_class->hide_name) && $this->c_class->hide_name == true)) + if (!(isset($this->c_class->hide_name) && $this->c_class->hide_name == true)) { $sql_ary['module_name'] = $this->request->variable('module_name', '', true); } @@ -299,7 +299,7 @@ class portal_module $this->cache->destroy('sql', PORTAL_MODULES_TABLE); $this->cache->destroy('sql', CONFIG_TABLE); - if(isset($module_name)) + if (isset($module_name)) { if (isset($module_data) && $module_data['module_classname'] !== '\board3\portal\modules\custom') { @@ -314,7 +314,7 @@ class portal_module } // show custom HTML files on the settings page of the modules instead of the standard board3 portal one, if chosen by module - if(!isset($this->c_class->custom_acp_tpl) || empty($this->c_class->custom_acp_tpl)) + if (!isset($this->c_class->custom_acp_tpl) || empty($this->c_class->custom_acp_tpl)) { $this->tpl_name = 'portal/acp_portal_config'; } @@ -361,7 +361,7 @@ class portal_module $l_explain = (isset($this->user->lang[$vars['lang'] . '_EXP'])) ? $this->user->lang[$vars['lang'] . '_EXP'] : ''; } - if($vars['type'] != 'custom') + if ($vars['type'] != 'custom') { $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); } @@ -410,7 +410,7 @@ class portal_module $portal_modules = obtain_portal_modules(); $installed_modules = $module_column = array(); - foreach($portal_modules as $cur_module) + foreach ($portal_modules as $cur_module) { $installed_modules[] = $cur_module['module_classname']; // Create an array with the columns the module is in @@ -427,11 +427,11 @@ class portal_module { $this->modules_manager->move_module_vertical($module_id, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_DOWN); } - else if($action == 'move_right') + else if ($action == 'move_right') { $this->modules_manager->move_module_horizontal($module_id, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_RIGHT); } - else if($action == 'move_left') + else if ($action == 'move_left') { $this->modules_manager->move_module_horizontal($module_id, \board3\portal\portal\modules\database_handler::MOVE_DIRECTION_LEFT); } @@ -502,7 +502,7 @@ class portal_module if (is_array($error)) { $error_output = ''; - foreach($error as $cur_error) + foreach ($error as $cur_error) { $error_output .= $cur_error . '
'; } @@ -556,7 +556,7 @@ class portal_module } // we sort the $fileinfo array by the name of the modules - foreach($fileinfo as $key => $cur_file) + foreach ($fileinfo as $key => $cur_file) { $name_ary[$key] = $cur_file['name']; } @@ -600,7 +600,7 @@ class portal_module { $portal_modules = obtain_portal_modules(); - foreach($portal_modules as $row) + foreach ($portal_modules as $row) { if (!($this->c_class = $this->portal_helper->get_module($row['module_classname']))) { @@ -613,7 +613,7 @@ class portal_module $template_column = $this->portal_columns->number_to_string($row['module_column']); // find out of we can move modules to the left or right - if(($this->c_class->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($row['module_column'] + 1))) || ($this->c_class->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($row['module_column'] + 2)) && $row['module_column'] != 2)) + if (($this->c_class->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($row['module_column'] + 1))) || ($this->c_class->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($row['module_column'] + 2)) && $row['module_column'] != 2)) { /** * check if we can actually move @@ -643,7 +643,7 @@ class portal_module $move_right = false; } - if(($this->c_class->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($row['module_column'] - 1))) || ($this->c_class->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($row['module_column'] - 2)) && $row['module_column'] != 2)) + if (($this->c_class->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($row['module_column'] - 1))) || ($this->c_class->get_allowed_columns() & $this->portal_columns->string_to_constant($this->portal_columns->number_to_string($row['module_column'] - 2)) && $row['module_column'] != 2)) { /** * check if we can actually move diff --git a/includes/functions.php b/includes/functions.php index 2d8affd5..7cb51633 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -340,7 +340,7 @@ function get_portal_tracking_info($fetch_news) $db->sql_freeresult($result); // @todo: do not use $current_forum here as this is already used by the outside foreach - foreach($forum_ids as $current_forum) + foreach ($forum_ids as $current_forum) { $user_lastmark[$current_forum] = (isset($mark_time[$current_forum])) ? $mark_time[$current_forum] : $user->data['user_lastmark']; } @@ -471,7 +471,7 @@ function get_user_groups() WHERE user_id = ' . (int) $user->data['user_id'] . ' ORDER BY group_id ASC'; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + while ($row = $db->sql_fetchrow($result)) { $groups_ary[] = $row['group_id']; } diff --git a/includes/modules_helper.php b/includes/modules_helper.php index cc9b1956..65cde18e 100644 --- a/includes/modules_helper.php +++ b/includes/modules_helper.php @@ -109,7 +109,7 @@ class modules_helper $forum_list = make_forum_select(false, false, true, true, true, false, true); $selected_options = $select_ary = array(); - if(isset($this->config[$key]) && strlen($this->config[$key]) > 0) + if (isset($this->config[$key]) && strlen($this->config[$key]) > 0) { $selected_options = explode(',', $this->config[$key]); } diff --git a/migrations/v210_beta1.php b/migrations/v210_beta1.php index 2acb1028..ecc7768c 100644 --- a/migrations/v210_beta1.php +++ b/migrations/v210_beta1.php @@ -201,7 +201,7 @@ class v210_beta1 extends \phpbb\db\migration\migration $sql = 'SELECT group_id, group_name FROM ' . $this->table_prefix . 'groups WHERE ' . $this->db->sql_in_set('group_name', $in_ary); $result = $this->db->sql_query($sql); - while($row = $this->db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $groups_ary[$row['group_name']] = $row['group_id']; } diff --git a/modules/announcements.php b/modules/announcements.php index a7504b0a..a98fb309 100644 --- a/modules/announcements.php +++ b/modules/announcements.php @@ -138,7 +138,7 @@ class announcements extends module_base ); $topic_icons = false; - if(!empty($fetch_news['topic_icons'])) + if (!empty($fetch_news['topic_icons'])) { $topic_icons = true; } @@ -182,7 +182,7 @@ class announcements extends module_base // Get disallowed forums $disallow_access = $this->modules_helper->get_disallowed_forums($permissions); - if($this->config['board3_announcements_forum_exclude_' . $module_id] == true) + if ($this->config['board3_announcements_forum_exclude_' . $module_id] == true) { $disallow_access = array_merge($disallow_access, $forum_from); $forum_from = array(); @@ -190,18 +190,18 @@ class announcements extends module_base $global_f = 0; - if(sizeof($forum_from)) + if (sizeof($forum_from)) { $disallow_access = array_diff($forum_from, $disallow_access); - if(!sizeof($disallow_access)) + if (!sizeof($disallow_access)) { return array(); } - foreach($disallow_access as $acc_id) + foreach ($disallow_access as $acc_id) { $str_where .= 'forum_id = ' . (int) $acc_id . ' OR '; - if($global_f < 1 && $acc_id > 0) + if ($global_f < 1 && $acc_id > 0) { $global_f = $acc_id; } @@ -209,7 +209,7 @@ class announcements extends module_base } else { - foreach($disallow_access as $acc_id) + foreach ($disallow_access as $acc_id) { $str_where .= 'forum_id <> ' . (int) $acc_id . ' AND '; } @@ -247,12 +247,12 @@ class announcements extends module_base $this->template->assign_block_vars('announcements', $announcements_row); // Show the announcements overview - if($announcement < 0) + if ($announcement < 0) { $count = $fetch_news['topic_count']; for ($i = 0; $i < $count; $i++) { - if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) + if (isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) { $open_bracket = '[ '; $close_bracket = ' ]'; @@ -352,7 +352,7 @@ class announcements extends module_base $this->pagination->generate_template_pagination($view_topic_url, 'announcements.center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true); - if(!empty($fetch_news[$i]['attachments'])) + if (!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { @@ -415,7 +415,7 @@ class announcements extends module_base $this->pagination->generate_template_pagination($view_topic_url, 'announcements.center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true); - if(!empty($fetch_news[$i]['attachments'])) + if (!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { diff --git a/modules/attachments.php b/modules/attachments.php index 5c0b1103..f9a72cc0 100644 --- a/modules/attachments.php +++ b/modules/attachments.php @@ -230,12 +230,12 @@ class attachments extends module_base // Get filetypes and put them into an array $filetypes = $this->get_selected_filetypes($module_id); - if($this->config['board3_attachments_forum_ids_' . $module_id] !== '') + if ($this->config['board3_attachments_forum_ids_' . $module_id] !== '') { $attach_forums_config = (strpos($this->config['board3_attachments_forum_ids_' . $module_id], ',') !== false) ? explode(',', $this->config['board3_attachments_forum_ids_' . $module_id]) : array($this->config['board3_attachments_forum_ids_' . $module_id]); $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true))); - if($this->config['board3_attachments_forum_exclude_' . $module_id]) + if ($this->config['board3_attachments_forum_exclude_' . $module_id]) { $forum_list = array_unique(array_diff($forum_list, $attach_forums_config)); } @@ -249,15 +249,15 @@ class attachments extends module_base $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true))); } - if(sizeof($forum_list)) + if (sizeof($forum_list)) { $attach_forums = true; $where = 'AND ' . $this->db->sql_in_set('t.forum_id', $forum_list); } - if(sizeof($filetypes)) + if (sizeof($filetypes)) { - if($this->config['board3_attachments_exclude_' . $module_id]) + if ($this->config['board3_attachments_exclude_' . $module_id]) { $where .= ' AND ' . $this->db->sql_in_set('a.extension', $filetypes, true); } @@ -267,7 +267,7 @@ class attachments extends module_base } } - if($attach_forums === true) + if ($attach_forums === true) { // Just grab all attachment info from database $sql = 'SELECT @@ -328,7 +328,7 @@ class attachments extends module_base protected function get_selected_filetypes($module_id) { $selected = array(); - if(isset($this->config['board3_attachments_filetype_' . $module_id]) && strlen($this->config['board3_attachments_filetype_' . $module_id]) > 0) + if (isset($this->config['board3_attachments_filetype_' . $module_id]) && strlen($this->config['board3_attachments_filetype_' . $module_id]) > 0) { $selected = explode(',', $this->config['board3_attachments_filetype_' . $module_id]); } diff --git a/modules/latest_members.php b/modules/latest_members.php index e391d144..b80c02ce 100644 --- a/modules/latest_members.php +++ b/modules/latest_members.php @@ -81,7 +81,7 @@ class latest_members extends module_base ORDER BY user_regdate DESC'; $result = $this->db->sql_query_limit($sql, $this->config['board3_max_last_member_' . $module_id], 0, 600); - while(($row = $this->db->sql_fetchrow($result)) && ($row['username'])) + while (($row = $this->db->sql_fetchrow($result)) && ($row['username'])) { $this->template->assign_block_vars('latest_members', array( 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), diff --git a/modules/leaders.php b/modules/leaders.php index 41c4c078..041b686c 100644 --- a/modules/leaders.php +++ b/modules/leaders.php @@ -93,7 +93,7 @@ class leaders extends module_base $this->user->add_lang('groups'); $order_legend = ($this->config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; - if($this->config['board3_leaders_ext_' . $module_id]) + if ($this->config['board3_leaders_ext_' . $module_id]) { $legends = array(); $groups = array(); @@ -160,9 +160,9 @@ class leaders extends module_base if (sizeof($groups)) { - foreach($groups as $group_id => $group) + foreach ($groups as $group_id => $group) { - if(sizeof($group['group_users'])) + if (sizeof($group['group_users'])) { $group_name = ($group['group_type'] == GROUP_SPECIAL) ? $this->user->lang['G_' . $group['group_name']] : $group['group_name']; $u_group = append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&g=' . $group_id); @@ -173,7 +173,7 @@ class leaders extends module_base 'U_GROUP' => $u_group, )); - foreach($group['group_users'] as $group_user) + foreach ($group['group_users'] as $group_user) { $this->template->assign_block_vars('group.member', array( 'USER_ID' => $group_user['user_id'], diff --git a/modules/main_menu.php b/modules/main_menu.php index d533ee12..a06cec95 100644 --- a/modules/main_menu.php +++ b/modules/main_menu.php @@ -366,7 +366,7 @@ class main_menu extends module_base { $message = $this->user->lang['LINK_ADDED']; - if($link_type != self::LINK_CAT && sizeof($links) < 1) + if ($link_type != self::LINK_CAT && sizeof($links) < 1) { trigger_error($this->user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING); } diff --git a/modules/news.php b/modules/news.php index 718d1b00..de37e3df 100644 --- a/modules/news.php +++ b/modules/news.php @@ -139,7 +139,7 @@ class news extends module_base ); $topic_icons = false; - if(!empty($fetch_news['topic_icons'])) + if (!empty($fetch_news['topic_icons'])) { $topic_icons = true; } @@ -179,21 +179,21 @@ class news extends module_base // Get disallowed forums $disallow_access = $this->modules_helper->get_disallowed_forums($permissions); - if($this->config['board3_news_exclude_' . $module_id] == true) + if ($this->config['board3_news_exclude_' . $module_id] == true) { $disallow_access = array_merge($disallow_access, $forum_from); $forum_from = array(); } - if(sizeof($forum_from)) + if (sizeof($forum_from)) { $disallow_access = array_diff($forum_from, $disallow_access); - if(!sizeof($disallow_access)) + if (!sizeof($disallow_access)) { return array(); } - foreach($disallow_access as $acc_id) + foreach ($disallow_access as $acc_id) { $acc_id = (int) $acc_id; $str_where .= "forum_id = $acc_id OR "; @@ -201,7 +201,7 @@ class news extends module_base } else { - foreach($disallow_access as $acc_id) + foreach ($disallow_access as $acc_id) { $acc_id = (int) $acc_id; $str_where .= "forum_id <> $acc_id AND "; @@ -244,12 +244,12 @@ class news extends module_base $this->template->assign_block_vars('news', $news_row); // Show the news overview - if($news < 0) + if ($news < 0) { $count = $fetch_news['topic_count']; for ($i = 0; $i < $count; $i++) { - if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) + if (isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) { $open_bracket = '[ '; $close_bracket = ' ]'; @@ -349,7 +349,7 @@ class news extends module_base // Assign pagination $this->pagination->generate_template_pagination($view_topic_url, 'news.news_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1); - if(!empty($fetch_news[$i]['attachments'])) + if (!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { @@ -400,7 +400,7 @@ class news extends module_base $this->pagination->generate_template_pagination($view_topic_url, 'news.news_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1); - if(!empty($fetch_news[$i]['attachments'])) + if (!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { @@ -418,7 +418,7 @@ class news extends module_base 'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE'), )); - if($this->config['board3_news_style_' . $module_id]) + if ($this->config['board3_news_style_' . $module_id]) { return 'news_compact_center.html'; } diff --git a/modules/poll.php b/modules/poll.php index b5a621de..5efb59f3 100644 --- a/modules/poll.php +++ b/modules/poll.php @@ -177,7 +177,7 @@ class poll extends module_base $this->user->add_lang('viewtopic'); // check if we need to include the bbcode class - if(!class_exists('bbcode')) + if (!class_exists('bbcode')) { include($this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext); } @@ -234,7 +234,7 @@ class poll extends module_base $topic_data['topic_status'] != ITEM_LOCKED && $topic_data['forum_status'] != ITEM_LOCKED) ? true : false; - if($s_can_up_vote) + if ($s_can_up_vote) { $redirect_url = $this->modules_helper->route('board3_portal_controller'); @@ -327,11 +327,11 @@ class poll extends module_base // Get readable forums $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true))); - if($this->config['board3_poll_topic_id_' . $module_id] !== '') + if ($this->config['board3_poll_topic_id_' . $module_id] !== '') { $poll_forums_config = explode(',' ,$this->config['board3_poll_topic_id_' . $module_id]); - if($this->config['board3_poll_exclude_id_' . $module_id]) + if ($this->config['board3_poll_exclude_id_' . $module_id]) { $forum_list = array_unique(array_diff($forum_list, $poll_forums_config)); } @@ -343,7 +343,7 @@ class poll extends module_base $where = ''; - if(sizeof($forum_list)) + if (sizeof($forum_list)) { $poll_forums = true; $where = 'AND ' . $this->db->sql_in_set('t.forum_id', $forum_list); @@ -375,7 +375,7 @@ class poll extends module_base if ($result) { - while($data = $this->db->sql_fetchrow($result)) + while ($data = $this->db->sql_fetchrow($result)) { $has_poll = true; $poll_has_options = false; @@ -384,7 +384,7 @@ class poll extends module_base $forum_id = (int) $data['forum_id']; $cur_voted_id = array(); - if($this->config['board3_poll_allow_vote_' . $module_id]) + if ($this->config['board3_poll_allow_vote_' . $module_id]) { if ($this->user->data['is_registered']) { @@ -436,7 +436,7 @@ class poll extends module_base if ($poll_result) { - while($polls_data = $this->db->sql_fetchrow($poll_result)) + while ($polls_data = $this->db->sql_fetchrow($poll_result)) { $poll_has_options = true; $poll_data[] = $polls_data; @@ -447,7 +447,7 @@ class poll extends module_base $make_poll_view = array(); - if(in_array($topic_id, $poll_view_ar) === false) + if (in_array($topic_id, $poll_view_ar) === false) { $make_poll_view[] = $topic_id; $make_poll_view = array_merge($poll_view_ar, $make_poll_view); @@ -497,7 +497,7 @@ class poll extends module_base 'U_VIEW_TOPIC' => $viewtopic_url, )); - foreach($poll_data as $pd) + foreach ($poll_data as $pd) { $option_pct = ($poll_total_votes > 0) ? $pd['poll_option_total'] / $poll_total_votes : 0; $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100)); diff --git a/modules/recent.php b/modules/recent.php index 905853a1..95163620 100644 --- a/modules/recent.php +++ b/modules/recent.php @@ -138,7 +138,7 @@ class recent extends module_base ORDER BY topic_time DESC'; $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0 , 600); - while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) + while (($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) { // auto auth if (($this->auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0')) @@ -164,7 +164,7 @@ class recent extends module_base ORDER BY topic_time DESC'; $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 600); - while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) + while (($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) { // auto auth if (($this->auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0')) @@ -191,7 +191,7 @@ class recent extends module_base ORDER BY topic_time DESC'; $result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id], 0, 600); - while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) + while (($row = $this->db->sql_fetchrow($result)) && ($row['topic_title'])) { // auto auth if (($this->auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0')) diff --git a/modules/stylechanger.php b/modules/stylechanger.php index ae9a7fb7..43400fc3 100644 --- a/modules/stylechanger.php +++ b/modules/stylechanger.php @@ -106,7 +106,7 @@ class stylechanger extends module_base $style_select .= ''; } $this->db->sql_freeresult($result); - if(strlen($style_select)) + if (strlen($style_select)) { $this->template->assign_var('STYLE_SELECT', $style_select); } diff --git a/modules/welcome.php b/modules/welcome.php index d06b12df..8b77a606 100644 --- a/modules/welcome.php +++ b/modules/welcome.php @@ -187,7 +187,7 @@ class welcome extends module_base generate_text_for_storage($welcome_message, $uid, $bitfield, $flags, true, true, true); // first check for obvious errors, we don't want to waste server resources - if(empty($welcome_message)) + if (empty($welcome_message)) { trigger_error($this->user->lang['ACP_PORTAL_WELCOME_MESSAGE_SHORT']. adm_back_link($u_action), E_USER_WARNING); } @@ -217,7 +217,7 @@ class welcome extends module_base // Edit or add menu item case 'reset': default: - if(!isset($welcome_message)) + if (!isset($welcome_message)) { $welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $this->config['board3_welcome_message_uid_' . $module_id], ''); } @@ -235,7 +235,7 @@ class welcome extends module_base 'MAX_FONT_SIZE' => (int) $this->config['max_post_font_size'], )); - if(!function_exists('display_forums')) + if (!function_exists('display_forums')) { include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); } diff --git a/tests/unit/acp/move_module_test.php b/tests/unit/acp/move_module_test.php index a038180b..68d7e84b 100644 --- a/tests/unit/acp/move_module_test.php +++ b/tests/unit/acp/move_module_test.php @@ -148,7 +148,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data { $this->constraints_handler->module_column = array(); $portal_modules = obtain_portal_modules(); - foreach($portal_modules as $cur_module) + foreach ($portal_modules as $cur_module) { $this->constraints_handler->module_column[$cur_module['module_classname']][] = $this->portal_columns->number_to_string($cur_module['module_column']); } diff --git a/tests/unit/portal/modules_manager_test.php b/tests/unit/portal/modules_manager_test.php index 6ed0737a..134f975c 100644 --- a/tests/unit/portal/modules_manager_test.php +++ b/tests/unit/portal/modules_manager_test.php @@ -104,7 +104,7 @@ class board3_portal_modules_manager_test extends \board3\portal\tests\testframew $this->modules_manager = new \board3\portal\portal\modules\manager($cache, $db, $this->b3p_controller_helper, $this->portal_columns, $portal_helper, $this->constraints_handler, $this->database_handler, $request, $user); $portal_modules = obtain_portal_modules(); - foreach($portal_modules as $cur_module) + foreach ($portal_modules as $cur_module) { $this->constraints_handler->module_column[$cur_module['module_classname']][] = $this->portal_columns->number_to_string($cur_module['module_column']); }