Skip to content

Commit 3df8c3f

Browse files
author
HoLyCoWzOrZ
committed
First commit
+ Release Candidate for 1.0.0 + Basic configuration through ACP Signed-off-by: HoLyCoWzOrZ <me@holycowzorz.com>
0 parents  commit 3df8c3f

13 files changed

Lines changed: 810 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
composer.lock
3+
vendor/

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# phpbb-ext-browserupdate
2+
A phpBB extension that implements the browser-update.org script to remind users to update their web browsers.

acp/browserupdate_info.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
*
4+
* @package phpBB Extension - Browser Update
5+
* @author Darrell Dudics (a.k.a HoLyCoW, a.k.a HoLyCoWzOrZ) me@holycowzorz.com
6+
* @copyright (c) 2015 Darrell Dudics
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
namespace holycow\browserupdate\acp;
12+
13+
class browserupdate_info
14+
{
15+
function module()
16+
{
17+
return array(
18+
'filename' => '\holycow\browserupdate\acp\browserupdate_module',
19+
'title' => 'ACP_BROWSERUPDATE',
20+
'modes' => array(
21+
'settings' => array(
22+
'title' => 'ACP_BROWSERUPDATE_SETTINGS',
23+
'auth' => 'ext_holycow/browserupdate && acl_a_board',
24+
'cat' => array('')
25+
),
26+
),
27+
);
28+
}
29+
30+
function install()
31+
{
32+
}
33+
34+
function uninstall()
35+
{
36+
}
37+
}

acp/browserupdate_module.php

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/**
3+
*
4+
* @package phpBB Extension - Browser Update
5+
* @author Darrell Dudics (a.k.a HoLyCoW, a.k.a HoLyCoWzOrZ) me@holycowzorz.com
6+
* @copyright (c) 2015 Darrell Dudics
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
namespace holycow\browserupdate\acp;
12+
13+
class browserupdate_module
14+
{
15+
/** @var \phpbb\config\config */
16+
protected $config;
17+
18+
/** @var \phpbb\config\db_text */
19+
protected $config_text;
20+
21+
/** @var \phpbb\db\driver\driver_interface */
22+
protected $db;
23+
24+
/** @var \phpbb\log\log */
25+
protected $log;
26+
27+
/** @var \phpbb\request\request */
28+
protected $request;
29+
30+
/** @var \phpbb\template\template */
31+
protected $template;
32+
33+
/** @var \phpbb\user */
34+
protected $user;
35+
36+
/** @var ContainerInterface */
37+
protected $phpbb_container;
38+
39+
/** @var string */
40+
protected $phpbb_root_path;
41+
42+
/** @var string */
43+
protected $php_ext;
44+
45+
/** @var string */
46+
public $u_action;
47+
48+
function main($id, $mode)
49+
{
50+
global $config, $db, $request, $template, $user, $phpbb_root_path, $phpEx, $phpbb_container;
51+
52+
$this->config = $config;
53+
$this->config_text = $phpbb_container->get('config_text');
54+
$this->db = $db;
55+
$this->log = $phpbb_container->get('log');
56+
$this->request = $request;
57+
$this->template = $template;
58+
$this->user = $user;
59+
$this->phpbb_root_path = $phpbb_root_path;
60+
$this->php_ext = $phpEx;
61+
62+
// Add the board announcements ACP lang file
63+
$this->user->add_lang_ext('holycow/browserupdate', 'browserupdate_acp');
64+
65+
// Load a template from adm/style for our ACP page
66+
$this->tpl_name = 'browserupdate';
67+
68+
// Set the page title for our ACP page
69+
$this->page_title = $this->user->lang('ACP_BROWSERUPDATE_SETTINGS');
70+
71+
// Define the name of the form for use as a form key
72+
$form_name = 'holycow/browserupdate';
73+
add_form_key($form_name);
74+
75+
if ($this->request->is_set_post('submit'))
76+
{
77+
// Test if form key is valid
78+
if (!check_form_key($form_name))
79+
{
80+
trigger_error($this->user->lang('FORM_INVALID'));
81+
}
82+
83+
$browserupdate_reminder = $this->request->variable('browserupdate_reminder', '');
84+
$browserupdate_reminder_closed = $this->request->variable('browserupdate_reminder_closed', '');
85+
$browserupdate_new_window = $this->request->variable('browserupdate_new_window', 1);
86+
87+
$this->config->set('browserupdate_reminder', $browserupdate_reminder);
88+
$this->config->set('browserupdate_reminder_closed', $browserupdate_reminder_closed);
89+
$this->config->set('browserupdate_new_window', $browserupdate_new_window);
90+
91+
// Log the updated settings
92+
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_BROWSERUPDATE_UPDATE_LOG');
93+
94+
trigger_error($this->user->lang('BROWSERUPDATE_SETTINGS_SAVED') . adm_back_link($this->u_action));
95+
}
96+
97+
$this->template->assign_vars(array(
98+
'BROWSERUPDATE_REMINDER' => $this->config['browserupdate_reminder'],
99+
'BROWSERUPDATE_REMINDER_CLOSED' => $this->config['browserupdate_reminder_closed'],
100+
'BROWSERUPDATE_NEW_WINDOW' => (isset($browserupdate_new_window)) ? $browserupdate_new_window : $this->config['browserupdate_new_window'],
101+
102+
'U_ACTION' => $this->u_action
103+
));
104+
}
105+
}

adm/style/browserupdate.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!-- INCLUDE overall_header.html -->
2+
3+
<h1>{L_BROWSERUPDATE_SETTINGS}</h1>
4+
<p>{L_BROWSERUPDATE_SETTINGS_EXPLAIN}</p>
5+
6+
<form id="acp_board" method="post" action="{U_ACTION}">
7+
<fieldset>
8+
<dl>
9+
<dt>
10+
<label for="browserupdate_reminder">{L_BROWSERUPDATE_REMINDER}{L_COLON}</label><br />
11+
<span>{L_BROWSERUPDATE_REMINDER_EXPLAIN}</span>
12+
</dt>
13+
<dd>
14+
<input type="number" id="browserupdate_reminder" name="browserupdate_reminder" value="{BROWSERUPDATE_REMINDER}" min="0" />&nbsp;{L_BROWSERUPDATE_SETTING_HOURS}
15+
</dd>
16+
</dl>
17+
18+
<dl>
19+
<dt>
20+
<label for="browserupdate_reminder_closed">{L_BROWSERUPDATE_REMINDER_CLOSED}{L_COLON}</label><br />
21+
<span>{L_BROWSERUPDATE_REMINDER_CLOSED_EXPLAIN}</span>
22+
</dt>
23+
<dd>
24+
<input type="number" id="browserupdate_reminder_closed" name="browserupdate_reminder_closed" value="{BROWSERUPDATE_REMINDER_CLOSED}" min="0" />&nbsp;{L_BROWSERUPDATE_SETTING_HOURS}
25+
</dd>
26+
</dl>
27+
<dl>
28+
<dt>
29+
<label for="browserupdate_new_window">{L_BROWSERUPDATE_NEW_WINDOW}{L_COLON}</label>
30+
</dt>
31+
<dd>
32+
<input type="radio" class="radio" id="browserupdate_new_window" name="browserupdate_new_window" value="1" <!-- IF BROWSERUPDATE_NEW_WINDOW -->checked="checked"<!-- ENDIF --> /> {L_YES} &nbsp;
33+
<input type="radio" class="radio" name="browserupdate_new_window" value="0" <!-- IF not BROWSERUPDATE_NEW_WINDOW -->checked="checked"<!-- ENDIF --> /> {L_NO}
34+
</dd>
35+
</dl>
36+
</fieldset>
37+
38+
<p class="submit-buttons">
39+
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />&nbsp;
40+
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
41+
</p>
42+
{S_FORM_TOKEN}
43+
</form>
44+
45+
<!-- INCLUDE overall_footer.html -->

composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "holycow/browserupdate",
3+
"type": "phpbb-extension",
4+
"description": "Displays a notification to notify the user that their browser outdated and that they should update their browser. Connects to browser-update.org to determine browser versions.",
5+
"homepage": "https://github.com/HoLyCoWzOrZ/phpbb-ext-browserupdate",
6+
"version": "1.0.0",
7+
"keywords": [
8+
"phpbb",
9+
"extension",
10+
"browserupdate",
11+
"modern",
12+
"browser"
13+
],
14+
"license": "GPL-2.0",
15+
"authors": [
16+
{
17+
"name": "Darrell Dudics (a.k.a. HoLyCoW, a.k.a. HoLyCoWzOrZ)",
18+
"email": "me@holycowzorz.com",
19+
"homepage": "http://holycowzorz.com",
20+
"role": "Developer"
21+
}
22+
],
23+
"require": {
24+
"php": ">=5.3.3"
25+
},
26+
"extra": {
27+
"display-name": "Browser Update",
28+
"soft-require": {
29+
"phpbb/phpbb": ">=3.1.0,<3.2.*@dev"
30+
}
31+
}
32+
}

config/services.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
holycow.browserupdate.listener:
3+
class: holycow\browserupdate\event\listener
4+
arguments:
5+
- @config
6+
- @controller.helper
7+
- @template
8+
tags:
9+
- { name: event.listener }

event/listener.php

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
/**
3+
*
4+
* @package phpBB Extension - Browser Update
5+
* @author Darrell Dudics (a.k.a HoLyCoW, a.k.a HoLyCoWzOrZ) me@holycowzorz.com
6+
* @copyright (c) 2015 Darrell Dudics
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
namespace holycow\browserupdate\event;
12+
13+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
14+
15+
/**
16+
* Event listener
17+
*/
18+
class listener implements EventSubscriberInterface
19+
{
20+
/** @var \phpbb\config\config */
21+
protected $config;
22+
23+
/** @var \phpbb\config\db_text */
24+
protected $config_text;
25+
26+
/** @var \phpbb\controller\helper */
27+
protected $controller_helper;
28+
29+
/** @var \phpbb\request\request */
30+
protected $request;
31+
32+
/** @var \phpbb\template\template */
33+
protected $template;
34+
35+
/** @var \phpbb\user */
36+
protected $user;
37+
38+
/**
39+
* Constructor
40+
*
41+
* @param \phpbb\config\config $config Config object
42+
* @param \phpbb\config\db_text $config_text DB text object
43+
* @param \phpbb\controller\helper $controller_helper Controller helper object
44+
* @param \phpbb\request\request $request Request object
45+
* @param \phpbb\template\template $template Template object
46+
* @param \phpbb\user $user User object
47+
* @return \holycow\browserupdate\event\subscriber
48+
* @access public
49+
*/
50+
public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $controller_helper, \phpbb\template\template $template)
51+
{
52+
$this->config = $config;
53+
$this->controller_helper = $controller_helper;
54+
$this->template = $template;
55+
}
56+
57+
/**
58+
* Assign functions defined in this class to event listeners in the core
59+
*
60+
* @return array
61+
*/
62+
static public function getSubscribedEvents()
63+
{
64+
return array(
65+
'core.page_header_after' => 'set_browserupdate_settings',
66+
);
67+
}
68+
69+
/**
70+
* Creates template variables based on database settings.
71+
* These variables are made available to the event 'overall_footer_after'
72+
*/
73+
public function set_browserupdate_settings()
74+
{
75+
$this->template->assign_vars(array(
76+
'BROWSERUPDATE_REMINDER' => $this->config['browserupdate_reminder'],
77+
'BROWSERUPDATE_REMINDER_CLOSED' => $this->config['browserupdate_reminder_closed'],
78+
'BROWSERUPDATE_NEW_WINDOW' => ($this->config['browserupdate_new_window'])? 'true' : 'false',
79+
));
80+
}
81+
}

language/en/browserupdate_acp.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
*
4+
* @package phpBB Extension - Browser Update
5+
* @author Darrell Dudics (a.k.a HoLyCoW, a.k.a HoLyCoWzOrZ) me@holycowzorz.com
6+
* @copyright (c) 2015 Darrell Dudics
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
/**
12+
* DO NOT CHANGE
13+
*/
14+
if (!defined('IN_PHPBB'))
15+
{
16+
exit;
17+
}
18+
19+
if (empty($lang) || !is_array($lang))
20+
{
21+
$lang = array();
22+
}
23+
24+
$lang = array_merge($lang, array(
25+
'BROWSERUPDATE_SETTINGS' => 'Browser Update Settings',
26+
'BROWSERUPDATE_SETTINGS_EXPLAIN' => 'Change the settings that affect the Browser Update extension',
27+
'BROWSERUPDATE_SETTINGS_SAVED' => 'Settings have been saved successfully.',
28+
29+
'BROWSERUPDATE_REMINDER' => 'How often should the message reappear',
30+
'BROWSERUPDATE_REMINDER_EXPLAIN' => 'The message will show once per this many hours. Set this value to 0 to force the message to show all the time.',
31+
'BROWSERUPDATE_REMINDER_CLOSED' => 'If closed, the message will reappear after how many hours',
32+
'BROWSERUPDATE_REMINDER_CLOSED_EXPLAIN' => 'Users can ignore the message by closing it. This setting will make it reappear after the specified number of hours.',
33+
'BROWSERUPDATE_NEW_WINDOW' => 'Open link in new window/tab',
34+
35+
'BROWSERUPDATE_SETTING_HOURS' => 'Hours',
36+
));
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
*
4+
* @package phpBB Extension - Browser Update
5+
* @author Darrell Dudics (a.k.a HoLyCoW, a.k.a HoLyCoWzOrZ) me@holycowzorz.com
6+
* @copyright (c) 2015 Darrell Dudics
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
/**
12+
* DO NOT CHANGE
13+
*/
14+
if (!defined('IN_PHPBB'))
15+
{
16+
exit;
17+
}
18+
19+
if (empty($lang) || !is_array($lang))
20+
{
21+
$lang = array();
22+
}
23+
24+
$lang = array_merge($lang, array(
25+
// ACP Module
26+
'ACP_BROWSERUPDATE' => 'Browser Update',
27+
'ACP_BROWSERUPDATE_SETTINGS' => 'Notification Settings',
28+
29+
// ACP Logs
30+
'ACP_BROWSERUPDATE_UPDATE_LOG' => '<strong>Altered Browser Update settings</strong>',
31+
));

0 commit comments

Comments
 (0)