1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[feature/avatars] UCP Avatar Interface

This stubs out the avatar form fields and how form processing will
occur. Form processing is not yet implemented, but shouldn't be too
hard. After this I will refactor/duplicate some of the logic for the
ACP.

PHPBB3-10018
This commit is contained in:
Cullen Walsh
2011-04-17 21:58:51 -07:00
committed by Cullen Walsh
parent 24379f1297
commit 7abded081d
11 changed files with 265 additions and 94 deletions

View File

@@ -47,4 +47,77 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver
);
}
}
/**
* @TODO
**/
public function handle_form($template, &$error = array(), $submitted = false)
{
if ($submitted) {
$error[] = 'TODO';
return '';
}
$avatar_list = array();
$path = $this->phpbb_root_path . $this->config['avatar_gallery_path'];
$dh = @opendir($path);
if (!$dh)
{
return $avatar_list;
}
while (($cat = readdir($dh)) !== false) {
if ($cat[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $cat) && is_dir("$path/$cat"))
{
if ($ch = @opendir("$path/$cat"))
{
while (($image = readdir($ch)) !== false)
{
if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image))
{
$avatar_list[$cat][] = array(
'file' => rawurlencode($cat) . '/' . rawurlencode($image),
'filename' => rawurlencode($image),
'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))),
);
}
}
@closedir($ch);
}
}
}
@closedir($dh);
@ksort($avatar_list);
$category = request_var('av_local_cat', '');
$categories = array_keys($avatar_list);
foreach ($categories as $cat)
{
if (!empty($avatar_list[$cat]))
{
$template->assign_block_vars('av_local_cats', array(
'NAME' => $cat,
'SELECTED' => ($cat == $category),
));
}
}
if (!empty($avatar_list[$category]))
{
foreach ($avatar_list[$category] as $img => $data)
{
$template->assign_block_vars('av_local_imgs', array(
'AVATAR_IMAGE' => $path . '/' . $data['file'],
'AVATAR_NAME' => $data['name'],
'AVATAR_FILE' => $data['filename'],
));
}
}
return true;
}
}

View File

@@ -47,4 +47,19 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
);
}
}
/**
* @TODO
**/
public function handle_form($template, &$error = array(), $submitted = false)
{
if ($submitted) {
$error[] = 'TODO';
return '';
}
else
{
return true;
}
}
}

View File

@@ -47,4 +47,31 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver
);
}
}
/**
* @TODO
**/
public function handle_form($template, &$error = array(), $submitted = false)
{
if ($submitted) {
$error[] = 'TODO';
return '';
}
else
{
$can_upload = (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
if ($can_upload)
{
$template->assign_vars(array(
'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false,
));
return true;
}
else
{
return false;
}
}
}
}