mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-30 12:48:21 +02:00
Merge remote-tracking branch 'Marc/ticket/11842' into develop
* Marc/ticket/11842: [ticket/11842] Add functional test for creating group [ticket/11842] Use avatar_data for obtaining driver that should be deleted [ticket/11842] Use type map for updating avatar types in database [ticket/11842] Add missing prefix for group id in avatar data [ticket/11842] Use only new avatar type in user_delete function [ticket/11842] Add migration file for updating avatar type in database [ticket/11842] Replace outdated occurences of user and group avatar_type [ticket/11842] Use group_id 0 and correct avatar name after creating group
This commit is contained in:
commit
b474917ba3
@ -325,6 +325,10 @@ class acp_groups
|
||||
|
||||
// This is normalised data, without the group_ prefix
|
||||
$avatar_data = \phpbb\avatar\manager::clean_row($group_row, 'group');
|
||||
if (!isset($avatar_data['id']))
|
||||
{
|
||||
$avatar_data['id'] = 'g' . $group_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -379,7 +383,7 @@ class acp_groups
|
||||
}
|
||||
else
|
||||
{
|
||||
$driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']);
|
||||
$driver = $phpbb_avatar_manager->get_driver($avatar_data['avatar_type']);
|
||||
if ($driver)
|
||||
{
|
||||
$driver->delete($avatar_data);
|
||||
|
@ -1775,7 +1775,7 @@ class acp_users
|
||||
}
|
||||
else
|
||||
{
|
||||
$driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']);
|
||||
$driver = $phpbb_avatar_manager->get_driver($avatar_data['avatar_type']);
|
||||
if ($driver)
|
||||
{
|
||||
$driver->delete($avatar_data);
|
||||
|
@ -213,7 +213,7 @@ function user_add($user_row, $cp_data = false)
|
||||
'user_occ' => '',
|
||||
'user_interests' => '',
|
||||
'user_avatar' => '',
|
||||
'user_avatar_type' => 0,
|
||||
'user_avatar_type' => '',
|
||||
'user_avatar_width' => 0,
|
||||
'user_avatar_height' => 0,
|
||||
'user_new_privmsg' => 0,
|
||||
@ -464,7 +464,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
|
||||
$added_guest_posts = 0;
|
||||
foreach ($user_rows as $user_id => $user_row)
|
||||
{
|
||||
if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == AVATAR_UPLOAD)
|
||||
if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == 'avatar.driver.upload')
|
||||
{
|
||||
avatar_delete('user', $user_row);
|
||||
}
|
||||
@ -2315,7 +2315,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
|
||||
{
|
||||
$group_id = $db->sql_nextid();
|
||||
|
||||
if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == AVATAR_UPLOAD)
|
||||
if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == 'avatar.driver.upload')
|
||||
{
|
||||
group_correct_avatar($group_id, $sql_ary['group_avatar']);
|
||||
}
|
||||
@ -2416,7 +2416,7 @@ function avatar_remove_db($avatar_name)
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||
SET user_avatar = '',
|
||||
user_avatar_type = 0
|
||||
user_avatar_type = ''
|
||||
WHERE user_avatar = '" . $db->sql_escape($avatar_name) . '\'';
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
@ -2826,7 +2826,7 @@ function remove_default_avatar($group_id, $user_ids)
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||
SET user_avatar = '',
|
||||
user_avatar_type = 0,
|
||||
user_avatar_type = '',
|
||||
user_avatar_width = 0,
|
||||
user_avatar_height = 0
|
||||
WHERE group_id = " . (int) $group_id . "
|
||||
@ -3084,7 +3084,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
|
||||
'group_colour' => 'string',
|
||||
'group_rank' => 'int',
|
||||
'group_avatar' => 'string',
|
||||
'group_avatar_type' => 'int',
|
||||
'group_avatar_type' => 'string',
|
||||
'group_avatar_width' => 'int',
|
||||
'group_avatar_height' => 'int',
|
||||
);
|
||||
|
@ -509,7 +509,7 @@ class ucp_groups
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']))
|
||||
if ($driver = $phpbb_avatar_manager->get_driver($avatar_data['avatar_type']))
|
||||
{
|
||||
$driver->delete($avatar_data);
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ class ucp_profile
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']))
|
||||
if ($driver = $phpbb_avatar_manager->get_driver($avatar_data['avatar_type']))
|
||||
{
|
||||
$driver->delete($avatar_data);
|
||||
}
|
||||
|
60
phpBB/phpbb/db/migration/data/v310/avatar_types.php
Normal file
60
phpBB/phpbb/db/migration/data/v310/avatar_types.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v310;
|
||||
|
||||
class avatar_types extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* @var avatar type map
|
||||
*/
|
||||
protected $avatar_type_map = array(
|
||||
AVATAR_UPLOAD => 'avatar.driver.upload',
|
||||
AVATAR_REMOTE => 'avatar.driver.remote',
|
||||
AVATAR_GALLERY => 'avatar.driver.local',
|
||||
);
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'\phpbb\db\migration\data\v310\dev',
|
||||
'\phpbb\db\migration\data\v310\avatars',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'update_user_avatar_type'))),
|
||||
array('custom', array(array($this, 'update_group_avatar_type'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_user_avatar_type()
|
||||
{
|
||||
foreach ($this->avatar_type_map as $old => $new)
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->table_prefix . "users
|
||||
SET user_avatar_type = '$new'
|
||||
WHERE user_avatar_type = $old";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
public function update_group_avatar_type()
|
||||
{
|
||||
foreach ($this->avatar_type_map as $old => $new)
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->table_prefix . "groups
|
||||
SET group_avatar_type = '$new'
|
||||
WHERE group_avatar_type = $old";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
@ -69,4 +69,13 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
|
||||
{
|
||||
$this->assert_avatar_submit($expected, $avatar_type, $data);
|
||||
}
|
||||
|
||||
// Test if avatar was really deleted
|
||||
public function test_no_avatar_acp_groups()
|
||||
{
|
||||
$crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid);
|
||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||
$form_data = $form->getValues();
|
||||
$this->assertEmpty($form_data['avatar_type']);
|
||||
}
|
||||
}
|
||||
|
31
tests/functional/group_create_test.php
Normal file
31
tests/functional/group_create_test.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_group_create_test extends phpbb_functional_test_case
|
||||
{
|
||||
|
||||
public function test_create_group()
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
$this->add_lang('acp/groups');
|
||||
|
||||
$crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&sid=' . $this->sid);
|
||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||
$crawler = self::submit($form, array('group_name' => 'testtest'));
|
||||
|
||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||
$crawler = self::submit($form, array('group_name' => 'testtest'));
|
||||
|
||||
$this->assertContainsLang('GROUP_CREATED', $crawler->filter('#main')->text());
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
|
||||
2,
|
||||
array(
|
||||
'group_avatar' => '',
|
||||
'group_avatar_type' => 0,
|
||||
'group_avatar_type' => '',
|
||||
'group_avatar_height' => 0,
|
||||
'group_avatar_width' => 0,
|
||||
'group_rank' => 0,
|
||||
@ -43,7 +43,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
|
||||
2,
|
||||
array(
|
||||
'group_avatar' => '',
|
||||
'group_avatar_type' => 0,
|
||||
'group_avatar_type' => '',
|
||||
'group_avatar_height' => 0,
|
||||
'group_avatar_width' => 0,
|
||||
'group_rank' => 0,
|
||||
@ -59,7 +59,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
|
||||
2,
|
||||
array(
|
||||
'group_avatar' => '',
|
||||
'group_avatar_type' => 0,
|
||||
'group_avatar_type' => '',
|
||||
'group_avatar_height' => 0,
|
||||
'group_avatar_width' => 0,
|
||||
'group_rank' => 0,
|
||||
@ -75,7 +75,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
|
||||
3,
|
||||
array(
|
||||
'group_avatar' => 'default2',
|
||||
'group_avatar_type' => 1,
|
||||
'group_avatar_type' => 'avatar.driver.upload',
|
||||
'group_avatar_height' => 1,
|
||||
'group_avatar_width' => 1,
|
||||
'group_rank' => 3,
|
||||
@ -91,7 +91,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
|
||||
3,
|
||||
array(
|
||||
'group_avatar' => 'default2',
|
||||
'group_avatar_type' => 1,
|
||||
'group_avatar_type' => 'avatar.driver.upload',
|
||||
'group_avatar_height' => 1,
|
||||
'group_avatar_width' => 1,
|
||||
'group_rank' => 3,
|
||||
@ -107,7 +107,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
|
||||
3,
|
||||
array(
|
||||
'group_avatar' => 'default2',
|
||||
'group_avatar_type' => 1,
|
||||
'group_avatar_type' => 'avatar.driver.upload',
|
||||
'group_avatar_height' => 1,
|
||||
'group_avatar_width' => 1,
|
||||
'group_rank' => 3,
|
||||
|
Loading…
x
Reference in New Issue
Block a user