Skip to content

Commit

Permalink
Add compatibility for phpBB 3.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
lavigor committed Jun 24, 2016
1 parent 63f70f2 commit 5cb1517
Show file tree
Hide file tree
Showing 27 changed files with 534 additions and 507 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -69,4 +69,4 @@ Already included in 3.1.1.

Initial stable release (changes can be found in the commits of our [repository on GitHub](https://github.com/BoardTools/upload)).

© 2014 - 2015 Igor Lavrov (https://github.com/LavIgor) and John Peskens (http://ForumHulp.com)
© 2014 - 2016 Igor Lavrov (https://github.com/LavIgor) and John Peskens (http://ForumHulp.com)
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -6,7 +6,7 @@ With this extension you can install/update/delete extensions without using FTP.
[![Build Status](https://travis-ci.org/BoardTools/upload.svg?branch=master)](https://travis-ci.org/BoardTools/upload)

## Requirements
* phpBB 3.2.0-dev or higher
* phpBB 3.1.0 or higher (phpBB 3.2 is also supported)
* PHP 5.3.3 or higher

## Sources
Expand Down Expand Up @@ -121,4 +121,4 @@ If you have uploaded different zip files with the same name, they will be rename
## License
[GNU General Public License v2](http://opensource.org/licenses/GPL-2.0)

© 2014 - 2015 Igor Lavrov (https://github.com/LavIgor) and John Peskens (http://ForumHulp.com)
© 2014 - 2016 Igor Lavrov (https://github.com/LavIgor) and John Peskens (http://ForumHulp.com)
2 changes: 1 addition & 1 deletion acp/upload_info.php
Expand Up @@ -2,7 +2,7 @@
/**
*
* @package Upload Extensions
* @copyright (c) 2014 - 2015 Igor Lavrov (https://github.com/LavIgor) and John Peskens (http://ForumHulp.com)
* @copyright (c) 2014 - 2016 Igor Lavrov (https://github.com/LavIgor) and John Peskens (http://ForumHulp.com)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
Expand Down
32 changes: 17 additions & 15 deletions acp/upload_module.php
Expand Up @@ -2,7 +2,7 @@
/**
*
* @package Upload Extensions
* @copyright (c) 2014 - 2015 Igor Lavrov (https://github.com/LavIgor) and John Peskens (http://ForumHulp.com)
* @copyright (c) 2014 - 2016 Igor Lavrov (https://github.com/LavIgor) and John Peskens (http://ForumHulp.com)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
Expand Down Expand Up @@ -69,10 +69,12 @@ function main($id, $mode)
objects::$template = &$template;
objects::$tpl_name = &$this->tpl_name;
objects::$u_action = $this->u_action;
objects::$upload = $phpbb_container->get('files.upload');
objects::$user = &$user;
objects::$zip_dir = &$this->zip_dir;

// Add support for different phpBB branches.
objects::set_compatibility_class();

// Get the information about Upload Extensions - START
objects::$upload_ext_name = 'boardtools/upload';
updater::get_manager();
Expand Down Expand Up @@ -137,7 +139,7 @@ function main($id, $mode)
{
$template->assign_vars(array(
'S_LOAD_ACTION' => $action,
'U_MAIN_PAGE_URL' => build_url(array('action', 'ajax', 'ext_name', 'ext_show')),
'U_MAIN_PAGE_URL' => build_url(array('action', 'ajax', 'ext_name', 'ext_show', 'lang', 'result')),
));

if ($request->variable('ajax', 0) === 1)
Expand Down Expand Up @@ -697,16 +699,16 @@ protected function output_response($status, $action)
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
* @param string $action Requested action.
* @return \phpbb\files\filespec|bool
* @return \phpbb\files\filespec|\filespec|bool
*/
public function proceed_upload($action)
{
global $phpbb_root_path, $phpEx, $user, $request, $phpbb_filesystem;
global $phpbb_root_path, $user, $request;

//$can_upload = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !@extension_loaded('zlib')) ? false : true;

$user->add_lang('posting'); // For error messages
$upload = objects::$upload;
$upload = objects::$compatibility->get_upload_object();
$upload->set_allowed_extensions(array('zip')); // Only allow ZIP files

// Make sure the ext/ directory exists and if it doesn't, create it
Expand Down Expand Up @@ -751,7 +753,7 @@ public function proceed_upload($action)
files::catch_errors($user->lang['NO_UPLOAD_FILE']);
return false;
}
$file = $upload->handle_upload('files.types.form', 'extupload');
$file = objects::$compatibility->form_upload($upload);
}
else
{
Expand All @@ -769,7 +771,7 @@ public function proceed_upload($action)
files::catch_errors($user->lang['EXT_OPENSSL_DISABLED']);
return false;
}
$file = $upload->handle_upload('boardtools.upload.files.types.zip', $remote_url);
$file = objects::$compatibility->remote_upload($upload, $remote_url);
}
}
return $file;
Expand All @@ -778,24 +780,24 @@ public function proceed_upload($action)
/**
* The function that uploads the specified extension.
*
* @param string $action Requested action.
* @param \phpbb\files\filespec $file Filespec object.
* @param string $upload_dir The directory for zip files storage.
* @param string $action Requested action.
* @param \phpbb\files\filespec|\filespec $file Filespec object.
* @param string $upload_dir The directory for zip files storage.
* @return string|bool
*/
public function get_dest_file($action, $file, $upload_dir)
{
global $phpbb_root_path, $template, $user, $request;
if ($action != 'upload_local')
{
if (!$file->get('filename'))
if (!objects::$compatibility->filespec_get($file, 'filename'))
{
files::catch_errors((sizeof($file->error) ? implode('<br />', $file->error) : $user->lang['NO_UPLOAD_FILE']));
return false;
}
else
{
if ($file->init_error() || sizeof($file->error))
if (objects::$compatibility->filespec_get($file, 'init_error') || sizeof($file->error))
{
$file->remove();
files::catch_errors((sizeof($file->error) ? implode('<br />', $file->error) : $user->lang['EXT_UPLOAD_INIT_FAIL']));
Expand All @@ -812,7 +814,7 @@ public function get_dest_file($action, $file, $upload_dir)
files::catch_errors(implode('<br />', $file->error));
return false;
}
$dest_file = $file->get('destination_file');
$dest_file = objects::$compatibility->filespec_get($file, 'destination_file');
}
else
{
Expand Down Expand Up @@ -996,7 +998,7 @@ public function upload_ext($action)
}
catch (\phpbb\extension\exception $e)
{
$message = call_user_func_array(array(objects::$user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
$message = objects::$compatibility->get_exception_message($e);
files::catch_errors(files::rrmdir($phpbb_root_path . 'ext/' . $ext_tmp));
if ($action != 'upload_local')
{
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -35,7 +35,7 @@
"extra": {
"display-name": "Upload Extensions",
"soft-require": {
"phpbb/phpbb": ">=3.2.0@dev"
"phpbb/phpbb": ">=3.1.0"
},
"version-check": {
"host": "boardtools.github.io",
Expand Down

0 comments on commit 5cb1517

Please sign in to comment.