aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/avatar
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-10-25 15:57:41 -0700
committerMarc Alexander <admin@m-a-styles.de>2014-10-25 15:57:41 -0700
commit1da1a7065086d451f61cf470777dbd69bec3ee79 (patch)
treeec3c66cf47f60c472ed51257d3b998fa6ec22a51 /phpBB/phpbb/avatar
parentf22cd2d7348dc3a103e53aa773b6f91abe998ddd (diff)
downloadforums-1da1a7065086d451f61cf470777dbd69bec3ee79.tar
forums-1da1a7065086d451f61cf470777dbd69bec3ee79.tar.gz
forums-1da1a7065086d451f61cf470777dbd69bec3ee79.tar.bz2
forums-1da1a7065086d451f61cf470777dbd69bec3ee79.tar.xz
forums-1da1a7065086d451f61cf470777dbd69bec3ee79.zip
[ticket/13197] Also delete group avatar from users that have it set
PHPBB3-13197
Diffstat (limited to 'phpBB/phpbb/avatar')
-rw-r--r--phpBB/phpbb/avatar/manager.php38
1 files changed, 31 insertions, 7 deletions
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php
index 42ae61a9a2..5d001c0f73 100644
--- a/phpBB/phpbb/avatar/manager.php
+++ b/phpBB/phpbb/avatar/manager.php
@@ -326,17 +326,41 @@ class manager
$driver->delete($avatar_data);
}
- $result = self::$default_row;
-
- foreach ($result as $key => $value)
- {
- $result[$prefix . $key] = $value;
- unset($result[$key]);
- }
+ $result = $this->prefix_avatar_columns($prefix, self::$default_row);
$sql = 'UPDATE ' . $table . '
SET ' . $db->sql_build_array('UPDATE', $result) . '
WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id'];
$db->sql_query($sql);
+
+ // Make sure we also delete this avatar from the users
+ if ($prefix === 'group_')
+ {
+ $result = $this->prefix_avatar_columns('user_', self::$default_row);
+
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $result) . '
+ WHERE user_avatar = "' . $db->sql_escape($avatar_data['avatar']) . '"';
+ $db->sql_query($sql);
+ }
+ }
+
+ /**
+ * Prefix avatar columns
+ *
+ * @param string $prefix Column prefix
+ * @param array $data Column data
+ *
+ * @return array Column data with prefixed column names
+ */
+ public function prefix_avatar_columns($prefix, $data)
+ {
+ foreach ($data as $key => $value)
+ {
+ $data[$prefix . $key] = $value;
+ unset($data[$key]);
+ }
+
+ return $data;
}
}