32 if(!$upload_target_srl) $upload_target_srl = $_SESSION[
'upload_info'][$editor_sequence]->upload_target_srl;
34 if($upload_target_srl)
37 $oCommentModel =
getModel(
'comment');
43 if(!$oDocument->isExists())
45 $oComment = $oCommentModel->getComment($upload_target_srl);
46 if($oComment->isExists() && $oComment->isSecret() && !$oComment->isGranted())
48 return new BaseObject(-1,
'msg_not_permitted');
51 $oDocument =
$oDocumentModel->getDocument($oComment->get(
'document_srl'));
55 if($oDocument->isExists() && $oDocument->isSecret() && !$oDocument->isGranted())
57 return new BaseObject(-1,
'msg_not_permitted');
61 if($oDocument->isExists())
66 return new BaseObject(-1,
'msg_not_permitted');
70 $tmp_files = $this->
getFiles($upload_target_srl);
71 if(!$tmp_files) $tmp_files = array();
73 foreach($tmp_files as $file_info)
75 if(!$file_info->file_srl)
continue;
78 $obj->file_srl = $file_info->file_srl;
79 $obj->source_filename = $file_info->source_filename;
80 $obj->file_size = $file_info->file_size;
82 if($file_info->direct_download==
'N')
$obj->download_url = $this->
getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl);
83 else $obj->download_url = str_replace(
'./',
'', $file_info->uploaded_filename);
84 $obj->direct_download = $file_info->direct_download;
85 $obj->cover_image = ($file_info->cover_image ===
'Y') ?
true :
false;
87 $attached_size += $file_info->file_size;
92 $upload_target_srl = 0;
102 $left_size = $file_config->allowed_attach_size*1024*1024 - $attached_size;
107 $allowed_filetypes = $file_config->allowed_filetypes;
108 $this->
add(
"files",$files);
109 $this->
add(
"editor_sequence",$editor_sequence);
110 $this->
add(
"upload_target_srl",$upload_target_srl);
111 $this->
add(
"upload_status",$upload_status);
112 $this->
add(
"left_size",$left_size);
113 $this->
add(
'attached_size', $attached_size);
114 $this->
add(
'allowed_attach_size', $allowed_attach_size);
115 $this->
add(
'allowed_filesize', $allowed_filesize);
116 $this->
add(
'allowed_filetypes', $allowed_filetypes);
127 $args =
new stdClass();
128 $args->upload_target_srl = $upload_target_srl;
130 return (
int)
$output->data->count;
142 return sprintf(
'?module=%s&act=%s&file_srl=%s&sid=%s&module_srl=%s',
'file',
'procFileDownload', $file_srl, $sid,
$module_srl);
156 $file_module_config =
$oModuleModel->getModuleConfig(
'file');
159 if(!$file_config) $file_config = $file_module_config;
161 $config =
new stdClass();
165 $config->allowed_filesize = $file_config->allowed_filesize;
166 $config->allowed_attach_size = $file_config->allowed_attach_size;
167 $config->allowed_filetypes = $file_config->allowed_filetypes;
168 $config->download_grant = $file_config->download_grant;
169 $config->allow_outlink = $file_config->allow_outlink;
170 $config->allow_outlink_site = $file_config->allow_outlink_site;
171 $config->allow_outlink_format = $file_config->allow_outlink_format;
174 if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize;
175 if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size;
176 if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes;
177 if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink;
178 if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site;
179 if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format;
180 if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant;
182 if(!$config->allowed_filesize) $config->allowed_filesize =
'2';
183 if(!$config->allowed_attach_size) $config->allowed_attach_size =
'3';
184 if(!$config->allowed_filetypes) $config->allowed_filetypes =
'*.*';
185 if(!$config->allow_outlink) $config->allow_outlink =
'Y';
186 if(!$config->download_grant) $config->download_grant = array();
188 $size = ini_get(
'upload_max_filesize');
189 $unit = strtolower($size[strlen($size) - 1]);
190 $size = (float)$size;
191 if($unit ==
'g') $size *= 1024;
192 if($unit ==
'k') $size /= 1024;
194 if($config->allowed_filesize > $size)
196 $config->allowed_filesize = $size;
198 if($config->allowed_attach_size > $size)
200 $config->allowed_attach_size = $size;
213 function getFile($file_srl, $columnList = array())
215 $args =
new stdClass();
216 $args->file_srl = $file_srl;
224 $file->download_url = $this->
getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
234 foreach(
$output->data as $key=>$value)
237 $file->download_url = $this->
getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
253 function getFiles($upload_target_srl, $columnList = array(), $sortIndex =
'file_srl', $ckValid =
false)
255 $args =
new stdClass();
256 $args->upload_target_srl = $upload_target_srl;
257 $args->sort_index = $sortIndex;
258 if($ckValid)
$args->isvalid =
'Y';
264 if($file_list && !is_array($file_list)) $file_list = array($file_list);
266 foreach ($file_list as &$file)
268 $file->source_filename = stripslashes($file->source_filename);
269 $file->source_filename = htmlspecialchars($file->source_filename);
270 $file->download_url = $this->
getDownloadUrl($file->file_srl, $file->sid, $file->module_srl);
289 $current_module_info =
Context::get(
'current_module_info');
296 $iniPostMaxSize = FileHandler::returnbytes(ini_get(
'post_max_size'));
297 $iniUploadMaxSize = FileHandler::returnbytes(ini_get(
'upload_max_filesize'));
298 $size = min($iniPostMaxSize, $iniUploadMaxSize) / 1048576;
299 $file_config->allowed_attach_size = $size;
300 $file_config->allowed_filesize = $size;
301 $file_config->allowed_filetypes =
'*.*';
316 $upload_status = sprintf(
317 '%s : %s/ %s<br /> %s : %s (%s : %s)',
324 $file_config->allowed_filetypes
326 return $upload_status;
349 if(!$file_info)
return null;
351 if($_SESSION[
'__XE_UPLOADING_FILES_INFO__'][$file_info->file_srl])
353 $file_grant->is_deletable =
true;
361 $oDocument =
$oDocumentModel->getDocument($file_info->upload_target_srl);
362 if($oDocument->isExists()) $document_grant = $oDocument->isGranted();
364 $file_grant->is_deletable = ($document_grant || $member_info->is_admin ==
'Y' || $member_info->member_srl == $file_info->member_srl || $grant->manager);
getUploadStatus($attached_size=0)
getFileGrant($file_info, $member_info)
$module_srl
integer value to represent a run-time instance of Module (XE Module)
getFileConfig($module_srl=null)
getDownloadUrl($file_srl, $sid, $module_srl="")
$mid
string to represent run-time instance of Module (XE Module)
getFiles($upload_target_srl, $columnList=array(), $sortIndex= 'file_srl', $ckValid=false)
getFileModuleConfig($module_srl)
getFile($file_srl, $columnList=array())
getFilesCount($upload_target_srl)
executeQueryArray($query_id, $args=NULL, $arg_columns=NULL)
executeQuery($query_id, $args=NULL, $arg_columns=NULL)