aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCullen Walsh <ckwalsh@phpbb.com>2011-04-20 23:14:38 -0700
committerCullen Walsh <ckwalsh@cullenwalsh.com>2012-03-18 22:20:45 +0000
commit84099e5bc1f452e1a4643fd78658929875ab1eee (patch)
treef89caba7c98587128009218f37f50630d585e83b
parent611a1d647a3a63013df472b469bf1f3e6e7bd657 (diff)
downloadforums-84099e5bc1f452e1a4643fd78658929875ab1eee.tar
forums-84099e5bc1f452e1a4643fd78658929875ab1eee.tar.gz
forums-84099e5bc1f452e1a4643fd78658929875ab1eee.tar.bz2
forums-84099e5bc1f452e1a4643fd78658929875ab1eee.tar.xz
forums-84099e5bc1f452e1a4643fd78658929875ab1eee.zip
[feature/avatars] Support proper avatar deletion, stub ACP
Fixing avatar deletion in the UCP and ACP, and stubbing the ACP configuration page. I'll admit I kind of got caught carried away, so this really should be a couple separate commits. PHPBB3-10018
-rw-r--r--phpBB/adm/style/acp_avatar_options_local.html14
-rw-r--r--phpBB/adm/style/acp_avatar_options_remote.html11
-rw-r--r--phpBB/adm/style/acp_avatar_options_upload.html11
-rw-r--r--phpBB/adm/style/acp_users_avatar.html85
-rw-r--r--phpBB/includes/acp/acp_users.php9
-rw-r--r--phpBB/includes/avatar/driver.php8
-rw-r--r--phpBB/includes/avatar/driver/upload.php16
-rw-r--r--phpBB/includes/avatar/manager.php14
-rw-r--r--phpBB/includes/functions_user.php1
-rw-r--r--phpBB/includes/ucp/ucp_profile.php33
-rw-r--r--phpBB/styles/prosilver/template/ucp_avatar_options.html7
11 files changed, 129 insertions, 80 deletions
diff --git a/phpBB/adm/style/acp_avatar_options_local.html b/phpBB/adm/style/acp_avatar_options_local.html
new file mode 100644
index 0000000000..0dd83db017
--- /dev/null
+++ b/phpBB/adm/style/acp_avatar_options_local.html
@@ -0,0 +1,14 @@
+<label for="category">{L_AVATAR_CATEGORY}: <select name="av_local_cat" id="category">
+<option value="">{L_NO_AVATAR_CATEGORY}</option>
+<!-- BEGIN av_local_cats -->
+<option value="{av_local_cats.NAME}"<!-- IF av_local_cats.SELECTED --> selected="selected"<!-- ENDIF -->>{av_local_cats.NAME}</option>
+<!-- END av_local_cats -->
+</select></label>
+<input type="submit" value="{L_GO}" name="av_local_go" class="button2" />
+
+<div id="gallery">
+<!-- BEGIN av_local_imgs -->
+ <label for="av-{av_local_imgs.S_ROW_COUNT}"><img src="{av_local_imgs.AVATAR_IMAGE}" alt="" /><br />
+ <input type="radio" name="av_local_file" id="av-{av_local_imgs.S_ROW_COUNT}" value="{av_local_imgs.AVATAR_FILE}" /></label>
+<!-- END av_local_imgs -->
+</div>
diff --git a/phpBB/adm/style/acp_avatar_options_remote.html b/phpBB/adm/style/acp_avatar_options_remote.html
new file mode 100644
index 0000000000..02704c5be8
--- /dev/null
+++ b/phpBB/adm/style/acp_avatar_options_remote.html
@@ -0,0 +1,11 @@
+<dl>
+ <dt><label for="av_remote_url">{L_LINK_REMOTE_AVATAR}:</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt>
+ <dd><input type="text" name="av_remote_url" id="av_remote_url" value="{AV_REMOTE_URL}" class="inputbox" /></dd>
+</dl>
+<dl>
+ <dt><label for="width">{L_LINK_REMOTE_SIZE}:</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt>
+ <dd>
+ <label for="av_remote_width"><input type="text" name="av_remote_width" id="av_remote_width" size="3" value="{AV_REMOTE_WIDTH}" class="inputbox autowidth" /> {L_PIXEL}</label> &times;&nbsp;
+ <label for="av_remote_height"><input type="text" name="av_remote_height" id="av_remote_height" size="3" value="{AV_REMOTE_HEIGHT}" class="inputbox autowidth" /> {L_PIXEL}</label>
+ </dd>
+</dl>
diff --git a/phpBB/adm/style/acp_avatar_options_upload.html b/phpBB/adm/style/acp_avatar_options_upload.html
new file mode 100644
index 0000000000..9c8dd9af01
--- /dev/null
+++ b/phpBB/adm/style/acp_avatar_options_upload.html
@@ -0,0 +1,11 @@
+<dl>
+ <dt><label for="av_upload_file">{L_UPLOAD_AVATAR_FILE}:</label></dt>
+ <dd><input type="hidden" name="MAX_FILE_SIZE" value="{AV_UPLOAD_SIZE}" /><input type="file" name="av_upload_file" id="av_upload_file" class="inputbox autowidth" /></dd>
+</dl>
+
+<!-- IF S_UPLOAD_AVATAR_URL -->
+ <dl>
+ <dt><label for="av_upload_url">{L_UPLOAD_AVATAR_URL}:</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt>
+ <dd><input type="text" name="av_upload_url" id="av_upload_url" value="" class="inputbox" /></dd>
+ </dl>
+<!-- ENDIF -->
diff --git a/phpBB/adm/style/acp_users_avatar.html b/phpBB/adm/style/acp_users_avatar.html
index 35d8374237..3d6754830b 100644
--- a/phpBB/adm/style/acp_users_avatar.html
+++ b/phpBB/adm/style/acp_users_avatar.html
@@ -1,78 +1,23 @@
- <form id="avatar_settings" method="post" action="{U_ACTION}"<!-- IF S_CAN_UPLOAD --> enctype="multipart/form-data"<!-- ENDIF -->>
+ <form id="avatar_settings" method="post" action="{U_ACTION}" enctype="multipart/form-data">
<fieldset>
<legend>{L_ACP_USER_AVATAR}</legend>
- <dl>
- <dt><label>{L_CURRENT_IMAGE}:</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt>
- <dd>{AVATAR_IMAGE}</dd>
- <dd><label><input type="checkbox" class="radio" name="delete" /> {L_DELETE_AVATAR}</label></dd>
- </dl>
- <!-- IF not S_IN_AVATAR_GALLERY -->
- <!-- IF S_UPLOAD_FILE -->
- <dl>
- <dt><label for="uploadfile">{L_UPLOAD_AVATAR_FILE}:</label></dt>
- <dd><input type="hidden" name="MAX_FILE_SIZE" value="{AVATAR_MAX_FILESIZE}" /><input type="file" id="uploadfile" name="uploadfile" /></dd>
- </dl>
- <!-- ENDIF -->
- <!-- IF S_REMOTE_UPLOAD -->
- <dl>
- <dt><label for="uploadurl">{L_UPLOAD_AVATAR_URL}:</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt>
- <dd><input name="uploadurl" type="text" id="uploadurl" value="" /></dd>
- </dl>
- <!-- ENDIF -->
- <!-- IF S_ALLOW_REMOTE -->
- <dl>
- <dt><label for="remotelink">{L_LINK_REMOTE_AVATAR}:</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt>
- <dd><input name="remotelink" type="text" id="remotelink" value="" /></dd>
- </dl>
- <dl>
- <dt><label for="width">{L_LINK_REMOTE_SIZE}:</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt>
- <dd><input name="width" type="text" id="width" size="3" value="{USER_AVATAR_WIDTH}" /> <span>{L_PIXEL} &times; </span> <input type="text" name="height" size="3" value="{USER_AVATAR_HEIGHT}" /> <span>{L_PIXEL}</span></dd>
- </dl>
- <!-- ENDIF -->
- <!-- IF S_DISPLAY_GALLERY -->
- <dl>
- <dt><label>{L_AVATAR_GALLERY}:</label></dt>
- <dd><input class="button2" type="submit" name="display_gallery" value="{L_DISPLAY_GALLERY}" /></dd>
- </dl>
- <!-- ENDIF -->
- <!-- ELSE -->
- </fieldset>
-
- <fieldset>
- <legend>{L_AVATAR_GALLERY}</legend>
- <dl>
- <dt><label for="category">{L_AVATAR_CATEGORY}:</label></dt>
- <dd><select name="category" id="category">{S_CAT_OPTIONS}</select>&nbsp;<input class="button2" type="submit" value="{L_GO}" name="display_gallery" /></dd>
- </dl>
+ <!-- IF ERROR --><p class="error">{ERROR}</p><!-- ENDIF -->
<dl>
- <table cellspacing="1">
- <!-- BEGIN avatar_row -->
- <tr>
- <!-- BEGIN avatar_column -->
- <td class="row1" style="text-align: center;"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="{avatar_row.avatar_column.AVATAR_NAME}" title="{avatar_row.avatar_column.AVATAR_NAME}" /></td>
- <!-- END avatar_column -->
- </tr>
- <tr>
- <!-- BEGIN avatar_option_column -->
- <td class="row2" style="text-align: center;"><input type="radio" class="radio" name="avatar_select" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td>
- <!-- END avatar_option_column -->
- </tr>
- <!-- END avatar_row -->
- </table>
+ <dt><label>{L_CURRENT_IMAGE}:</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt>
+ <dd><!-- IF AVATAR -->{AVATAR}<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" /><!-- ENDIF --></dd>
+ <!-- IF AVATAR --><dd><input type="submit" name="submit" id="delete" value="{LA_DELETE_AVATAR}" /></dd><!-- ENDIF -->
</dl>
+ </fieldset>
+ <!-- BEGIN avatar_drivers -->
+ <fieldset>
+ <legend>{avatar_drivers.L_TITLE}</legend>
+ <p>{avatar_drivers.L_EXPLAIN}</p>
+ {avatar_drivers.OUTPUT}
</fieldset>
-
- <fieldset class="quick" style="margin-top: -15px;">
- <input class="button2" type="submit" name="cancel" value="{L_CANCEL}" />
+ <fieldset class="quick">
+ <input type="reset" value="{L_RESET}" name="reset" class="button2" /> &nbsp;
+ <input type="submit" name="submit_av_{avatar_drivers.DRIVER}" value="{L_SUBMIT}" class="button1" />
</fieldset>
-
- <!-- ENDIF -->
- </fieldset>
-
- <fieldset class="quick">
- <input class="button1" type="submit" name="update" value="{L_SUBMIT}" />
- {S_FORM_TOKEN}
- </fieldset>
-
+ <!-- END avatar_drivers -->
</form>
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 390e421a51..5dc1829e8b 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -452,10 +452,10 @@ class acp_users
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
-
+
$sql_ary = array(
'user_avatar' => '',
- 'user_avatar_type' => 0,
+ 'user_avatar_type' => '',
'user_avatar_width' => 0,
'user_avatar_height' => 0,
);
@@ -466,9 +466,10 @@ class acp_users
$db->sql_query($sql);
// Delete old avatar if present
- if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY)
+ $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver());
+ if ($driver = $avatar_manager->get_driver($user_row['user_avatar_type']))
{
- avatar_delete('user', $user_row);
+ $driver->delete($user_row);
}
add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver.php
index 5d3b734f7b..5322f73c60 100644
--- a/phpBB/includes/avatar/driver.php
+++ b/phpBB/includes/avatar/driver.php
@@ -114,4 +114,12 @@ abstract class phpbb_avatar_driver
{
return false;
}
+
+ /**
+ * @TODO
+ **/
+ public function delete($user_row)
+ {
+ return true;
+ }
}
diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php
index dd1dbfa5a0..5b487745b1 100644
--- a/phpBB/includes/avatar/driver/upload.php
+++ b/phpBB/includes/avatar/driver/upload.php
@@ -122,6 +122,22 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver
}
/**
+ * @inheritdoc
+ */
+ public function delete($user_row)
+ {
+ $ext = substr(strrchr($user_row['user_avatar'], '.'), 1);
+ $filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $user_row['user_id'] . '.' . $ext;
+
+ if (file_exists($filename))
+ {
+ @unlink($filename);
+ }
+
+ return true;
+ }
+
+ /**
* @TODO
*/
private function can_upload()
diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php
index 6471c4cc9c..7137243898 100644
--- a/phpBB/includes/avatar/manager.php
+++ b/phpBB/includes/avatar/manager.php
@@ -47,6 +47,20 @@ class phpbb_avatar_manager
$this->load_valid_drivers();
}
+ // Legacy stuff...
+ switch ($avatar_type)
+ {
+ case AVATAR_LOCAL:
+ $avatar_type = 'local';
+ break;
+ case AVATAR_UPLOAD:
+ $avatar_type = 'upload';
+ break;
+ case AVATAR_REMOTE:
+ $avatar_type = 'remote';
+ break;
+ }
+
if (isset(self::$valid_drivers[$avatar_type]))
{
if ($new || !is_object(self::$valid_drivers[$avatar_type]))
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 509e1a953c..9035cac7be 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1968,6 +1968,7 @@ function avatar_delete($mode, $row, $clean_db = false)
avatar_remove_db($row[$mode . '_avatar']);
}
$filename = get_avatar_filename($row[$mode . '_avatar']);
+
if (file_exists($phpbb_root_path . $config['avatar_path'] . '/' . $filename))
{
@unlink($phpbb_root_path . $config['avatar_path'] . '/' . $filename);
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index a712547bd1..222d9e0af4 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -553,6 +553,39 @@ class ucp_profile
if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar'))
{
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver());
+
+ if (isset($_POST['av_delete']))
+ {
+ if (check_form_key('ucp_avatar'))
+ {
+ $result = array(
+ 'user_avatar' => '',
+ 'user_avatar_type' => '',
+ 'user_avatar_width' => 0,
+ 'user_avatar_height' => 0,
+ );
+
+ if ($driver = $avatar_manager->get_driver($user->data['user_avatar_type']))
+ {
+ $driver->delete($user->data);
+ }
+
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $result) . '
+ WHERE user_id = ' . $user->data['user_id'];
+
+ $db->sql_query($sql);
+
+ meta_refresh(3, $this->u_action);
+ $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
+ trigger_error($message);
+ }
+ else
+ {
+ $error[] = 'FORM_INVALID';
+ }
+ }
+
$avatar_drivers = $avatar_manager->get_valid_drivers();
sort($avatar_drivers);
diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html
index e30fcc74aa..f05e96410d 100644
--- a/phpBB/styles/prosilver/template/ucp_avatar_options.html
+++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html
@@ -10,7 +10,7 @@
<dl>
<dt><label>{L_CURRENT_IMAGE}:</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt>
<dd><!-- IF AVATAR -->{AVATAR}<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" /><!-- ENDIF --></dd>
- <!-- IF AVATAR && S_AVATARS_ENABLED --><dd><input type="submit" name="submit" id="delete" value="{LA_DELETE_AVATAR}" /></dd><!-- ENDIF -->
+ <!-- IF AVATAR && S_AVATARS_ENABLED --><dd><input type="submit" name="av_delete" id="av_delete" value="{LA_DELETE_AVATAR}" /></dd><!-- ENDIF -->
</dl>
</fieldset>
@@ -27,10 +27,5 @@
</fieldset>
<!-- END avatar_drivers -->
- <fieldset>
- <!-- IF S_LINK_AVATAR -->
- <!-- ENDIF -->
- </fieldset>
-
<span class="corners-bottom"><span></span></span></div>
</div>