diff options
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/console/command/config/command.php | 22 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/config/delete.php | 46 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/config/get.php | 54 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/config/increment.php | 52 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/config/set.php | 52 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/config/set_atomic.php | 65 | ||||
-rw-r--r-- | phpBB/phpbb/log/log.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/approve_post.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/approve_topic.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/disapprove_post.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/disapprove_topic.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/post.php | 11 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/report_post.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/report_post_closed.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/topic.php | 11 | ||||
-rw-r--r-- | phpBB/phpbb/search/fulltext_mysql.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/search/fulltext_native.php | 2 |
17 files changed, 355 insertions, 8 deletions
diff --git a/phpBB/phpbb/console/command/config/command.php b/phpBB/phpbb/console/command/config/command.php new file mode 100644 index 0000000000..b105bc826d --- /dev/null +++ b/phpBB/phpbb/console/command/config/command.php @@ -0,0 +1,22 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ +namespace phpbb\console\command\config; + +abstract class command extends \phpbb\console\command\command +{ + /** @var \phpbb\config\config */ + protected $config; + + function __construct(\phpbb\config\config $config) + { + $this->config = $config; + + parent::__construct(); + } +} diff --git a/phpBB/phpbb/console/command/config/delete.php b/phpBB/phpbb/console/command/config/delete.php new file mode 100644 index 0000000000..9a2d00561d --- /dev/null +++ b/phpBB/phpbb/console/command/config/delete.php @@ -0,0 +1,46 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ +namespace phpbb\console\command\config; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class delete extends command +{ + protected function configure() + { + $this + ->setName('config:delete') + ->setDescription('Deletes a configuration option') + ->addArgument( + 'key', + InputArgument::REQUIRED, + "The configuration option's name" + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $key = $input->getArgument('key'); + + if (isset($this->config[$key])) + { + $this->config->delete($key); + + $output->writeln("<info>Successfully deleted config $key</info>"); + } + else + { + $output->writeln("<error>Config $key does not exist</error>"); + } + } +} diff --git a/phpBB/phpbb/console/command/config/get.php b/phpBB/phpbb/console/command/config/get.php new file mode 100644 index 0000000000..275c82b53f --- /dev/null +++ b/phpBB/phpbb/console/command/config/get.php @@ -0,0 +1,54 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ +namespace phpbb\console\command\config; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class get extends command +{ + protected function configure() + { + $this + ->setName('config:get') + ->setDescription("Gets a configuration option's value") + ->addArgument( + 'key', + InputArgument::REQUIRED, + "The configuration option's name" + ) + ->addOption( + 'no-newline', + null, + InputOption::VALUE_NONE, + 'Set this option if the value should be printed without a new line at the end.' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $key = $input->getArgument('key'); + + if (isset($this->config[$key]) && $input->getOption('no-newline')) + { + $output->write($this->config[$key]); + } + elseif (isset($this->config[$key])) + { + $output->writeln($this->config[$key]); + } + else + { + $output->writeln("<error>Could not get config $key</error>"); + } + } +} diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php new file mode 100644 index 0000000000..bc6b63c6ff --- /dev/null +++ b/phpBB/phpbb/console/command/config/increment.php @@ -0,0 +1,52 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ +namespace phpbb\console\command\config; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class increment extends command +{ + protected function configure() + { + $this + ->setName('config:increment') + ->setDescription("Increments a configuration option's value") + ->addArgument( + 'key', + InputArgument::REQUIRED, + "The configuration option's name" + ) + ->addArgument( + 'increment', + InputArgument::REQUIRED, + 'Amount to increment by' + ) + ->addOption( + 'dynamic', + 'd', + InputOption::VALUE_NONE, + 'Set this option if the configuration option changes too frequently to be efficiently cached.' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $key = $input->getArgument('key'); + $increment = $input->getArgument('increment'); + $use_cache = !$input->getOption('dynamic'); + + $this->config->increment($key, $increment, $use_cache); + + $output->writeln("<info>Successfully incremented config $key</info>"); + } +} diff --git a/phpBB/phpbb/console/command/config/set.php b/phpBB/phpbb/console/command/config/set.php new file mode 100644 index 0000000000..9d471a96ad --- /dev/null +++ b/phpBB/phpbb/console/command/config/set.php @@ -0,0 +1,52 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ +namespace phpbb\console\command\config; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class set extends command +{ + protected function configure() + { + $this + ->setName('config:set') + ->setDescription("Sets a configuration option's value") + ->addArgument( + 'key', + InputArgument::REQUIRED, + "The configuration option's name" + ) + ->addArgument( + 'value', + InputArgument::REQUIRED, + 'New configuration value, use 0 and 1 to specify boolean values' + ) + ->addOption( + 'dynamic', + 'd', + InputOption::VALUE_NONE, + 'Set this option if the configuration option changes too frequently to be efficiently cached.' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $key = $input->getArgument('key'); + $value = $input->getArgument('value'); + $use_cache = !$input->getOption('dynamic'); + + $this->config->set($key, $value, $use_cache); + + $output->writeln("<info>Successfully set config $key</info>"); + } +} diff --git a/phpBB/phpbb/console/command/config/set_atomic.php b/phpBB/phpbb/console/command/config/set_atomic.php new file mode 100644 index 0000000000..03e7a60210 --- /dev/null +++ b/phpBB/phpbb/console/command/config/set_atomic.php @@ -0,0 +1,65 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ +namespace phpbb\console\command\config; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class set_atomic extends command +{ + protected function configure() + { + $this + ->setName('config:set-atomic') + ->setDescription("Sets a configuration option's value only if the old matches the current value.") + ->addArgument( + 'key', + InputArgument::REQUIRED, + "The configuration option's name" + ) + ->addArgument( + 'old', + InputArgument::REQUIRED, + 'Current configuration value, use 0 and 1 to specify boolean values' + ) + ->addArgument( + 'new', + InputArgument::REQUIRED, + 'New configuration value, use 0 and 1 to specify boolean values' + ) + ->addOption( + 'dynamic', + 'd', + InputOption::VALUE_NONE, + 'Set this option if the configuration option changes too frequently to be efficiently cached.' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $key = $input->getArgument('key'); + $old_value = $input->getArgument('old'); + $new_value = $input->getArgument('new'); + $use_cache = !$input->getOption('dynamic'); + + if ($this->config->set_atomic($key, $old_value, $new_value, $use_cache)) + { + $output->writeln("<info>Successfully set config $key</info>"); + return 0; + } + else + { + $output->writeln("<error>Could not set config $key</error>"); + return 1; + } + } +} diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index a6ee06ebf2..62edc6a77f 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -424,7 +424,7 @@ class log implements \phpbb\log\log_interface if ($count_logs) { $sql = 'SELECT COUNT(l.log_id) AS total_entries - FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . ' u + FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u WHERE l.log_type = ' . (int) $log_type . ' AND l.user_id = u.user_id AND l.log_time >= ' . (int) $log_time . " @@ -449,7 +449,7 @@ class log implements \phpbb\log\log_interface } $sql = 'SELECT l.*, u.username, u.username_clean, u.user_colour - FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . ' u + FROM ' . $this->log_table . ' l, ' . USERS_TABLE . ' u WHERE l.log_type = ' . (int) $log_type . ' AND u.user_id = l.user_id ' . (($log_time) ? 'AND l.log_time >= ' . (int) $log_time : '') . " diff --git a/phpBB/phpbb/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php index 51a9a704b0..e51ff12b3e 100644 --- a/phpBB/phpbb/notification/type/approve_post.php +++ b/phpBB/phpbb/notification/type/approve_post.php @@ -35,6 +35,13 @@ class approve_post extends \phpbb\notification\type\post protected $language_key = 'NOTIFICATION_POST_APPROVED'; /** + * Inherit notification read status from post. + * + * @var bool + */ + protected $inherit_read_status = false; + + /** * Notification option data (for outputting to the user) * * @var bool|array False if the service should use it's default data diff --git a/phpBB/phpbb/notification/type/approve_topic.php b/phpBB/phpbb/notification/type/approve_topic.php index 6229800c68..11a240e03d 100644 --- a/phpBB/phpbb/notification/type/approve_topic.php +++ b/phpBB/phpbb/notification/type/approve_topic.php @@ -35,6 +35,13 @@ class approve_topic extends \phpbb\notification\type\topic protected $language_key = 'NOTIFICATION_TOPIC_APPROVED'; /** + * Inherit notification read status from topic. + * + * @var bool + */ + protected $inherit_read_status = false; + + /** * Notification option data (for outputting to the user) * * @var bool|array False if the service should use it's default data diff --git a/phpBB/phpbb/notification/type/disapprove_post.php b/phpBB/phpbb/notification/type/disapprove_post.php index 411d4195c7..70de2a3e10 100644 --- a/phpBB/phpbb/notification/type/disapprove_post.php +++ b/phpBB/phpbb/notification/type/disapprove_post.php @@ -35,6 +35,13 @@ class disapprove_post extends \phpbb\notification\type\approve_post protected $language_key = 'NOTIFICATION_POST_DISAPPROVED'; /** + * Inherit notification read status from post. + * + * @var bool + */ + protected $inherit_read_status = false; + + /** * Notification option data (for outputting to the user) * * @var bool|array False if the service should use it's default data diff --git a/phpBB/phpbb/notification/type/disapprove_topic.php b/phpBB/phpbb/notification/type/disapprove_topic.php index 19e9d468ce..d39201d928 100644 --- a/phpBB/phpbb/notification/type/disapprove_topic.php +++ b/phpBB/phpbb/notification/type/disapprove_topic.php @@ -35,6 +35,13 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic protected $language_key = 'NOTIFICATION_TOPIC_DISAPPROVED'; /** + * Inherit notification read status from topic. + * + * @var bool + */ + protected $inherit_read_status = false; + + /** * Notification option data (for outputting to the user) * * @var bool|array False if the service should use it's default data diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index c2854c17af..bc42c4422b 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -35,6 +35,13 @@ class post extends \phpbb\notification\type\base protected $language_key = 'NOTIFICATION_POST'; /** + * Inherit notification read status from post. + * + * @var bool + */ + protected $inherit_read_status = true; + + /** * Notification option data (for outputting to the user) * * @var bool|array False if the service should use it's default data @@ -315,7 +322,7 @@ class post extends \phpbb\notification\type\base */ public function pre_create_insert_array($post, $notify_users) { - if (!sizeof($notify_users)) + if (!sizeof($notify_users) || !$this->inherit_read_status) { return array(); } @@ -360,7 +367,7 @@ class post extends \phpbb\notification\type\base // Topics can be "read" before they are public (while awaiting approval). // Make sure that if the user has read the topic, it's marked as read in the notification - if (isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) + if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) { $this->notification_read = true; } diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php index 89b497efa6..9bf035b91e 100644 --- a/phpBB/phpbb/notification/type/report_post.php +++ b/phpBB/phpbb/notification/type/report_post.php @@ -35,6 +35,13 @@ class report_post extends \phpbb\notification\type\post_in_queue protected $language_key = 'NOTIFICATION_REPORT_POST'; /** + * Inherit notification read status from post. + * + * @var bool + */ + protected $inherit_read_status = false; + + /** * Permission to check for (in find_users_for_notification) * * @var string Permission name diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php index 5874d48e31..fff45612b3 100644 --- a/phpBB/phpbb/notification/type/report_post_closed.php +++ b/phpBB/phpbb/notification/type/report_post_closed.php @@ -41,6 +41,13 @@ class report_post_closed extends \phpbb\notification\type\post */ protected $language_key = 'NOTIFICATION_REPORT_CLOSED'; + /** + * Inherit notification read status from post. + * + * @var bool + */ + protected $inherit_read_status = false; + public function is_available() { return false; diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index 6198881d8d..98f086a50b 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -35,6 +35,13 @@ class topic extends \phpbb\notification\type\base protected $language_key = 'NOTIFICATION_TOPIC'; /** + * Inherit notification read status from topic. + * + * @var bool + */ + protected $inherit_read_status = true; + + /** * Notification option data (for outputting to the user) * * @var bool|array False if the service should use it's default data @@ -220,7 +227,7 @@ class topic extends \phpbb\notification\type\base */ public function pre_create_insert_array($post, $notify_users) { - if (!sizeof($notify_users)) + if (!sizeof($notify_users) || !$this->inherit_read_status) { return array(); } @@ -261,7 +268,7 @@ class topic extends \phpbb\notification\type\base // Topics can be "read" before they are public (while awaiting approval). // Make sure that if the user has read the topic, it's marked as read in the notification - if (isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) + if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time) { $this->notification_read = true; } diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index cdd2da222f..509b73e26e 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -216,7 +216,7 @@ class fulltext_mysql extends \phpbb\search\base // We limit the number of allowed keywords to minimize load on the database if ($this->config['max_num_search_keywords'] && sizeof($this->split_words) > $this->config['max_num_search_keywords']) { - trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $this->config['max_num_search_keywords'], sizeof($this->split_words))); + trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', (int) $this->config['max_num_search_keywords'], sizeof($this->split_words))); } // to allow phrase search, we need to concatenate quoted words diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index 1b314a24d3..1a89182978 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -277,7 +277,7 @@ class fulltext_native extends \phpbb\search\base // We limit the number of allowed keywords to minimize load on the database if ($this->config['max_num_search_keywords'] && $num_keywords > $this->config['max_num_search_keywords']) { - trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $this->config['max_num_search_keywords'], $num_keywords)); + trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', (int) $this->config['max_num_search_keywords'], $num_keywords)); } // $keywords input format: each word separated by a space, words in a bracket are not separated |