Merge branch 'sgmurphy-clone/0.7.x' into 0.7.x

This commit is contained in:
Evan Prodromou 2009-02-11 10:11:26 -05:00
commit 27e23f2dd3
2 changed files with 34 additions and 5 deletions

View File

@ -145,6 +145,7 @@ class AvatarsettingsAction extends AccountSettingsAction
'height' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE,
'alt' => $user->nickname)); 'alt' => $user->nickname));
$this->elementEnd('div'); $this->elementEnd('div');
$this->submit('delete', _('Delete'));
$this->elementEnd('li'); $this->elementEnd('li');
} }
@ -256,6 +257,8 @@ class AvatarsettingsAction extends AccountSettingsAction
$this->uploadAvatar(); $this->uploadAvatar();
} else if ($this->arg('crop')) { } else if ($this->arg('crop')) {
$this->cropAvatar(); $this->cropAvatar();
} else if ($this->arg('delete')) {
$this->deleteAvatar();
} else { } else {
$this->showForm(_('Unexpected form submission.')); $this->showForm(_('Unexpected form submission.'));
} }
@ -344,6 +347,29 @@ class AvatarsettingsAction extends AccountSettingsAction
$this->showForm(_('Failed updating avatar.')); $this->showForm(_('Failed updating avatar.'));
} }
} }
/**
* Get rid of the current avatar.
*
* @return void
*/
function deleteAvatar()
{
$user = common_current_user();
$profile = $user->getProfile();
$avatar = $profile->getOriginalAvatar();
$avatar->delete();
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$avatar->delete();
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
$avatar->delete();
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
$avatar->delete();
$this->showForm(_('Avatar deleted.'), true);
}
/** /**
* Add the jCrop stylesheet * Add the jCrop stylesheet

View File

@ -412,14 +412,14 @@ function common_replace_urls_callback($text, $callback) {
// Then clean up what the regex left behind // Then clean up what the regex left behind
$offset = 0; $offset = 0;
foreach($matches[0] as $url) { foreach($matches[0] as $orig_url) {
$url = htmlspecialchars_decode($url); $url = htmlspecialchars_decode($orig_url);
// Make sure we didn't pick up an email address // Make sure we didn't pick up an email address
if (preg_match('#^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$#i', $url)) continue; if (preg_match('#^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$#i', $url)) continue;
// Remove trailing punctuation // Remove surrounding punctuation
$url = rtrim($url, '.?!,;:\'"`'); $url = trim($url, '.?!,;:\'"`([<');
// Remove surrounding parens and the like // Remove surrounding parens and the like
preg_match('/[)\]>]+$/', $url, $trailing); preg_match('/[)\]>]+$/', $url, $trailing);
@ -446,7 +446,7 @@ function common_replace_urls_callback($text, $callback) {
// If the first part wasn't cap'd but the last part was, we captured too much // If the first part wasn't cap'd but the last part was, we captured too much
if ((!$prev_part && $last_part)) { if ((!$prev_part && $last_part)) {
$url = substr_replace($url, '', mb_strpos($url, '.'.$url_parts[2], 0)); $url = mb_substr($url, 0 , mb_strpos($url, '.'.$url_parts['2'], 0));
} }
// Capture the new TLD // Capture the new TLD
@ -456,6 +456,9 @@ function common_replace_urls_callback($text, $callback) {
if (!in_array($url_parts[2], $tlds)) continue; if (!in_array($url_parts[2], $tlds)) continue;
// Put the url back the way we found it.
$url = (mb_strpos($orig_url, htmlspecialchars($url)) === FALSE) ? $url:htmlspecialchars($url);
// Call user specified func // Call user specified func
$modified_url = $callback($url); $modified_url = $callback($url);