Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ticket/15289] Allow to configure storage from acp #4895

Merged
merged 38 commits into from Sep 9, 2017

Conversation

rubencm
Copy link
Member

@rubencm rubencm commented Aug 8, 2017

Checklist:

  • Correct branch: master for new features; 3.2.x, 3.1.x for fixes
  • Tests pass
  • Code follows coding guidelines: master / 3.2.x, 3.1.x
  • Commit follows commit message format

This depends on #4894, #4937

Tracker ticket (set the ticket ID to your ticket ID):

https://tracker.phpbb.com/browse/PHPBB3-15289

@rubencm rubencm force-pushed the ticket/15289 branch 7 times, most recently from 055d0b0 to 5bb393f Compare August 10, 2017 11:36
@Nicofuma Nicofuma modified the milestone: 3.3.0-a1 Aug 15, 2017
@rubencm rubencm force-pushed the ticket/15289 branch 2 times, most recently from 9fa10cf to d624a48 Compare August 25, 2017 13:39
<dt>
{% set title = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %}
{% set description = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper ~ '_EXPLAIN' %}
<label for="">{{ lang(title) }}{{ lang('COLON') }}</label>{% if description != lang(description) %}<br /><span>{{ lang(description) }}</span>{% endif %}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,73 @@
<!-- INCLUDE overall_header.html -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use twig for the includes as well.

@@ -30,6 +30,11 @@
die('database not up to date');
}

if (!isset($config['storage\\avatar\\config\\path']) || $config['storage\\avatar\\config\\path'] != 'phpbb\\storage\\provider\\local')
{
die('use local provider');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a better message that actually explains this to user not knowing the details of the storage system.

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

public function main($id, $mode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add docblocks to these methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any other module with that docblock?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most old acp modules don't have it but please add them when adding new methods (which you're doing in this case).

// Check options
$new_options = $this->get_provider_options($this->get_new_provider($storage_name));

foreach ($new_options as $def_k => $def_v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't shorten variable names like this, e.g. use $definition_value$ and $definition_key.

$sql = 'UPDATE ' . GROUPS_TABLE . '
SET group_avatar = \'' . $db->sql_escape($new_entry) . "'
WHERE group_id = $group_id";
$db->sql_query($sql);
}
catch (\phpbb\storage\exception\exception $e)
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment to what this means (as you did in other places).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i did this in other branch, but i have to rebase all


/**
* Before deleting an existing avatar
*
* @event core.avatar_driver_upload_delete_before
* @var string destination Destination directory where the file is going to be deleted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a @changed to this that mentions that destination was removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in avatars branch

@@ -83,7 +83,7 @@ public function build_options($storage_name, array $definitions)
{
$options = [];

foreach ($definitions as $def)
foreach (array_keys($definitions) as $def)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please spell out the name

@marc1706
Copy link
Member

marc1706 commented Sep 8, 2017

You removed the composer-ext files. Can you please add them back?

public function overview($id, $mode)
{
$form_name = 'acp_storage';
add_form_key($form_name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're adding a form key but you're never actually checking it. This is however vital for the CSRF protection.


// Template
'STORAGE_TITLE' => 'Storage Settings',
'STORAGE_TITLE_EXPLAIN' => 'Here you can change the storage.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change storage providers for the file storage types of phpBB. Choose local or remote providers to store files added to or created by phpBB.

'STORAGE_TITLE' => 'Storage Settings',
'STORAGE_TITLE_EXPLAIN' => 'Here you can change the storage.',
'STORAGE_SELECT' => 'Select storage',
'STORAGE_SELECT_DESC' => 'Select an storage from the list.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Select a storage from the list

'STORAGE_ADAPTER_LOCAL_OPTION_PATH' => 'Path',

// Form validation
'STORAGE_UPDATE_SUCCESSFUL' => 'All storages were successfuly updated.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All storage types were successfully updated.


// Form validation
'STORAGE_UPDATE_SUCCESSFUL' => 'All storages were successfuly updated.',
'STORAGE_NO_CHANGES' => 'No changes has been made.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes have been applied.

// Form validation
'STORAGE_UPDATE_SUCCESSFUL' => 'All storages were successfuly updated.',
'STORAGE_NO_CHANGES' => 'No changes has been made.',
'STORAGE_PROVIDER_NOT_EXISTS' => 'Provider selected for %s doesn\'t exist.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the unicode version of the single quote:


// Add necesary language files
$this->lang->add_lang(array('common'));
$this->lang->add_lang(array('acp/storage'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the whole point of the array thing is, that you can add multiple different language files at once.

Also, common is always included, isn't it?

Copy link
Member Author

@rubencm rubencm Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think so, i added it here only because of L_YES and L_NO
edit: and now for the form check

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm preetty sure that every file adds the 'common.php' through the $user->setup() method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common is always loaded yes

}
}

if (count($modified_storages))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!empty($modified_storages)

Copy link
Member Author

@rubencm rubencm Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, is the same i think.
edit: Ok, i see, empty returns a boolean that fit better here


if (count($modified_storages))
{
if (!count($messages))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty($messages)

$this->storage_collection = $phpbb_container->get('storage.storage_collection');

// Add necesary language files
$this->lang->add_lang(['common', 'acp/storage']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As already stated, you don't need common.

Copy link
Member Author

@rubencm rubencm Sep 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is working without it, but i think it wasn't

Copy link
Contributor

@Elsensee Elsensee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections from me.

@Nicofuma Nicofuma merged commit 2b864f5 into phpbb:master Sep 9, 2017
Nicofuma added a commit that referenced this pull request Sep 9, 2017
[ticket/15289] Allow to configure storage from acp

* github.com:phpbb/phpbb: (38 commits)
  [ticket/15289] Add phpdoc
  [ticket/15289] Remove common language from acp module
  [ticket/15289] Check form
  [ticket/15289] Use empty instead of count
  [ticket/15289] Language fixes
  [ticket/15289] Add missing files
  [ticket/15289] Use twig syntax in variables
  [ticket/15289] Use lang_defined()
  [ticket/15289] Dont use short names
  [ticket/15289] Dont use short names
  [ticket/15289] Use Twig includes
  [ticket/15289] Update acp module
  [ticket/15289] Fix comment typo
  [ticket/15289] Fix show field description
  [ticket/15289] Update event
  [ticket/15289] Remove switch since there is only one mode
  [ticket/15289] Improve error messages
  [ticket/15289] Fix code style
  [ticket/15289] Update acp storage
  [ticket/15289] Update acp storage template
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants