public static function get_file_tmps_and_check_filesize($member_id = null, $filesize_total = null, $type = 'img') { $file_tmps = self::get_file_tmps_uploaded($member_id, false, $type); if ($member_id) { self::check_uploaded_under_accepted_filesize($file_tmps, $filesize_total, Site_Upload::get_accepted_filesize($member_id)); } return $file_tmps; }
public function before_insert(\Orm\Model $obj) { if ($obj->user_type) { return false; } if (!$obj->{$this->_key_from}) { return false; } $member = \Model_Member::find('first', array('where' => array($this->_key_to => $obj->{$this->_key_from}))); $member->filesize_total += $obj->{$this->_property_from}; // check filesize_total if ($member->filesize_total > \Site_Upload::get_accepted_filesize($obj->{$this->_key_from})) { throw new LimitUploadFileSizeException('File size is over the limit of the member.'); } $member->save(); }
/** * Album create * * @access public * @return Response */ public function action_create() { $album = Model_Album::forge(); $val = \Validation::forge(); $val->add_model($album); $files = array(); if (\Input::method() == 'POST') { \Util_security::check_csrf(); $file_tmps = array(); $moved_files = array(); try { $file_tmps = \Site_FileTmp::get_file_tmps_uploaded($this->u->id, true); \Site_FileTmp::check_uploaded_under_accepted_filesize($file_tmps, $this->u->filesize_total, \Site_Upload::get_accepted_filesize()); if (!$val->run()) { throw new \FuelException($val->show_errors()); } $post = $val->validated(); \DB::start_transaction(); list($album, $moved_files) = Model_Album::save_with_relations($post, $this->u->id, $album, $file_tmps); \DB::commit_transaction(); // thumbnail 作成 & tmp_file thumbnail 削除 \Site_FileTmp::make_and_remove_thumbnails($moved_files); $message = sprintf('%sを作成しました。', term('album')); \Session::set_flash('message', $message); $redirect_uri = 'album/detail/' . $album->id; if (FBD_FACEBOOK_APP_ID && conf('service.facebook.shareDialog.album.isEnabled') && conf('service.facebook.shareDialog.album.autoPopupAfterCreated')) { $redirect_uri .= '?created=1'; } \Response::redirect($redirect_uri); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } if ($moved_files) { \Site_FileTmp::move_files_to_tmp_dir($moved_files); } $files = \Site_FileTmp::get_file_objects($file_tmps, $this->u->id); \Session::set_flash('error', $e->getMessage()); } } $this->set_title_and_breadcrumbs(sprintf('%sを%s', term('album'), term('form.do_create')), null, $this->u, 'album'); $this->template->post_header = \View::forge('filetmp/_parts/upload_header'); $this->template->post_footer = \View::forge('_parts/create_footer'); $this->template->content = \View::forge('_parts/form', array('val' => $val, 'files' => $files)); }