diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-05-20 15:10:32 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-05-20 15:10:32 -0400 |
commit | 3f5ededc01d8eedac2a9a75917849fbe78a3e701 (patch) | |
tree | 50627d9a90854d51f52fa398b044046b382fe3c8 /actions/avatar.php | |
parent | 5d1a6f0fef3b99167babfa304ceda9b67720f399 (diff) |
call validate before saving objects
darcs-hash:20080520191032-84dde-64197121c93cd4cf3cbc614badff0bd44547f9f9.gz
Diffstat (limited to 'actions/avatar.php')
-rw-r--r-- | actions/avatar.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/actions/avatar.php b/actions/avatar.php index 17f56634b..43f02a88d 100644 --- a/actions/avatar.php +++ b/actions/avatar.php @@ -128,6 +128,17 @@ class AvatarAction extends SettingsAction { $avatar->url = common_avatar_url($filename); $avatar->created = DB_DataObject_Cast::dateTime(); # current time + $val = $avatar->validate(); + + if ($val !== TRUE) { + $err = ''; + foreach ($val as $k=>$v) { + $err .= _t('Something wrong with ') . $k; + $this->show_form($err); + return; + } + } + foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) { $scaled[] = $this->scale_avatar($user, $avatar, $size); } @@ -139,7 +150,6 @@ class AvatarAction extends SettingsAction { common_server_error(_t('Error deleting old avatars.')); return; } - if (!$avatar->insert()) { @unlink($filepath); common_server_error(_t('Error inserting avatar.')); |