mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Include in file list even if upload_target_type is null
This commit is contained in:
parent
42b879d628
commit
c17243e02a
7 changed files with 53 additions and 9 deletions
|
|
@ -833,6 +833,21 @@ class FileController extends File
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update upload target type
|
||||
*
|
||||
* @param int|array $file_srl
|
||||
* @param string $upload_target_type
|
||||
* @return BaseObject
|
||||
*/
|
||||
public function updateTargetType($file_srl, $upload_target_type)
|
||||
{
|
||||
$args = new stdClass;
|
||||
$args->file_srl = $file_srl;
|
||||
$args->upload_target_type = $upload_target_type;
|
||||
return executeQuery('file.updateFileTargetType', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an attachement
|
||||
*
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class FileModel extends File
|
|||
|
||||
// Set file list
|
||||
$filter_type = $_SESSION['upload_info'][$editor_sequence]->upload_target_type ?? null;
|
||||
$files = self::getFiles($upload_target_srl, [], 'file_srl', false, $filter_type);
|
||||
$files = self::getFiles($upload_target_srl, [], 'file_srl', false, $filter_type, true);
|
||||
foreach ($files as $file_info)
|
||||
{
|
||||
$obj = new stdClass;
|
||||
|
|
@ -294,15 +294,20 @@ class FileModel extends File
|
|||
*
|
||||
* @param int $upload_target_srl The sequence to get a number of files
|
||||
* @param ?string $upload_target_type
|
||||
* @param bool $include_null_target_type
|
||||
* @return int Returns a number of files
|
||||
*/
|
||||
public static function getFilesCount($upload_target_srl, $upload_target_type = null)
|
||||
public static function getFilesCount($upload_target_srl, $upload_target_type = null, $include_null_target_type = false)
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
if ($upload_target_type)
|
||||
{
|
||||
$args->upload_target_type = $upload_target_type;
|
||||
if ($include_null_target_type)
|
||||
{
|
||||
$args->include_null_target_type = true;
|
||||
}
|
||||
}
|
||||
$output = executeQuery('file.getFilesCount', $args);
|
||||
return (int)$output->data->count;
|
||||
|
|
@ -438,9 +443,12 @@ class FileModel extends File
|
|||
* @param int $upload_target_srl The sequence of target to get file list
|
||||
* @param array $columnList The list of columns to get from DB
|
||||
* @param string $sortIndex The column that used as sort index
|
||||
* @param bool $valid_files_only
|
||||
* @param ?string $upload_target_type
|
||||
* @param bool $include_null_target_type
|
||||
* @return array Returns array of object that contains file information. If no result returns null.
|
||||
*/
|
||||
public static function getFiles($upload_target_srl, $columnList = array(), $sortIndex = 'file_srl', $valid_files_only = false, $upload_target_type = null)
|
||||
public static function getFiles($upload_target_srl, $columnList = array(), $sortIndex = 'file_srl', $valid_files_only = false, $upload_target_type = null, $include_null_target_type = false)
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
|
|
@ -452,6 +460,10 @@ class FileModel extends File
|
|||
if ($upload_target_type)
|
||||
{
|
||||
$args->upload_target_type = $upload_target_type;
|
||||
if ($include_null_target_type)
|
||||
{
|
||||
$args->include_null_target_type = true;
|
||||
}
|
||||
}
|
||||
|
||||
$output = executeQueryArray('file.getFiles', $args, $columnList);
|
||||
|
|
@ -461,12 +473,23 @@ class FileModel extends File
|
|||
}
|
||||
|
||||
$fileList = array();
|
||||
$nullList = array();
|
||||
foreach ($output->data as $file)
|
||||
{
|
||||
$file->source_filename = escape($file->source_filename, false);
|
||||
$file->download_url = self::getDownloadUrl($file->file_srl, $file->sid, 0, $file->source_filename);
|
||||
$fileList[] = $file;
|
||||
if ($file->upload_target_type === null)
|
||||
{
|
||||
$nullList[] = $file->file_srl;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($nullList) && $upload_target_type)
|
||||
{
|
||||
FileController::getInstance()->updateTargetType($nullList, $upload_target_type);
|
||||
}
|
||||
|
||||
return $fileList;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@
|
|||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="upload_target_srl" var="upload_target_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="equal" column="upload_target_type" var="upload_target_type" pipe="and" />
|
||||
<group pipe="and">
|
||||
<condition operation="equal" column="upload_target_type" var="upload_target_type" />
|
||||
<condition operation="null" column="upload_target_type" if="include_null_target_type" pipe="or" />
|
||||
</group>
|
||||
<condition operation="equal" column="isvalid" var="isvalid" pipe="and" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@
|
|||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="upload_target_srl" var="upload_target_srl" filter="number" />
|
||||
<condition operation="equal" column="upload_target_type" var="upload_target_type" pipe="and" />
|
||||
<group pipe="and">
|
||||
<condition operation="equal" column="upload_target_type" var="upload_target_type" />
|
||||
<condition operation="null" column="upload_target_type" if="include_null_target_type" pipe="or" />
|
||||
</group>
|
||||
<condition operation="like_prefix" column="regdate" var="regDate" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
<column name="upload_target_type" var="upload_target_type" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="file_srl" var="file_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="in" column="file_srl" var="file_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
</query>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue