5use Bitrix\Main\Application;
7use Bitrix\Main\NotImplementedException;
8use Bitrix\Main\ORM\Fields\BooleanField;
9use Bitrix\Main\ORM\Fields\DatetimeField;
10use Bitrix\Main\ORM\Fields\EnumField;
11use Bitrix\Main\ORM\Fields\ExpressionField;
12use Bitrix\Main\ORM\Fields\IntegerField;
13use Bitrix\Main\ORM\Fields\Relations\Reference;
14use Bitrix\Main\ORM\Fields\StringField;
15use Bitrix\Main\ORM\Fields\TextField;
16use Bitrix\Main\ORM\Fields\Validators\DateValidator;
17use Bitrix\Main\ORM\Query\Join;
18use Bitrix\Main\Type\DateTime;
19use Bitrix\Vote\ChannelTable;
20use Bitrix\Vote\QuestionTable;
21use Bitrix\Vote\Vote\Anonymity;
22use Bitrix\Vote\Vote\EventLimits;
23use Bitrix\Vote\Vote\Option;
64 return 'b_forum_file';
84 (
new Reference(
"FORUM", ForumTable::class, Join::on(
"this.FORUM_ID",
"ref.ID"))),
85 (
new Reference(
"FILE",
Main\FileTable::class, Join::on(
"this.FILE_ID",
"ref.ID")))
91 $tableName = static::getTableName();
98 $where[] = $helper->prepareAssignment($tableName,
$key, $value);
100 $where = implode(
' AND ', $where);
104 $quotedTableName = $helper->quote($tableName);
105 $connection->queryExecute(
"DELETE FROM {$quotedTableName} WHERE {$where}");
113 $result = new \Bitrix\Main\Result();
120 if (array_key_exists(
"name",
$files))
125 $filesize = intval(\
Bitrix\
Main\
Config\Option::get(
"forum",
"file_max_size", 5242880));
129 if (isset($file[
"FILE_ID"]) && $file[
"FILE_ID"] > 0)
132 $existingFiles[] = $file[
"FILE_ID"];
135 if ($file[
"name"] ==
'')
142 if ($forum[
"ALLOW_UPLOAD"] ==
"Y")
144 $res = \CFile::CheckImageFile($file, $filesize, 0, 0);
146 elseif ($forum[
"ALLOW_UPLOAD"] ==
"F")
148 $res = \CFile::CheckFile($file, $filesize,
false, $forum[
"ALLOW_UPLOAD_EXT"]);
150 elseif ($forum[
"ALLOW_UPLOAD"] ==
"A")
152 $res = \CFile::CheckFile($file, $filesize,
false,
false);
156 $res =
"Uploading is forbidden";
164 if (!empty($existingFiles))
166 $dbRes = FileTable::getList([
167 "select" => [
"FILE_ID"],
169 "FORUM_ID" =>
$params[
"FORUM_ID"] ?: $forum->getId(),
172 [
"TOPIC_ID" =>
$params[
"TOPIC_ID"]],
173 [
"TOPIC_ID" =>
null],
175 "MESSAGE_ID" =>
$params[
"MESSAGE_ID"],
176 "FILE_ID" => $existingFiles
177 ] + (
$params[
"MESSAGE_ID"] > 0 ? [] : [
"USER_ID" =>
$params[
"USER_ID"]]),
184 if (in_array(
$res[
"FILE_ID"], $existingFiles))
186 $existingFiles = array_diff($existingFiles, [
$res[
"FILE_ID"]]);
189 if (!empty($existingFiles))
202 $result = new \Bitrix\Main\Result();
205 $file[
"MODULE_ID"] =
"forum";
207 if (array_key_exists(
"del", $file))
209 $id = $file[
"old_file"] ?: $file[
"FILE_ID"];
211 $filesToDel[$id] = $file + [
"key" =>
$key];
213 if ($file[
"FILE_ID"] > 0)
215 $filesToUpdate[$file[
"FILE_ID"]] = $file + [
"key" =>
$key];
219 $id = \CFile::SaveFile($file, $uploadDir);
223 $filesToAdd[$id] = $file + [
"key" =>
$key];
231 foreach ($filesToDel as $id => $file)
234 unset(
$files[$file[
"key"]]);
236 if (!empty($filesToUpdate))
239 "FORUM_ID" =>
$params[
"FORUM_ID"],
240 "TOPIC_ID" =>
$params[
"TOPIC_ID"],
241 "MESSAGE_ID" =>
$params[
"MESSAGE_ID"],
242 "USER_ID" =>
$params[
"USER_ID"]
244 FileTable::updateMulti(array_keys($filesToUpdate), $row);
245 foreach ($filesToUpdate as $id => $file)
247 $files[$file[
"key"]] = array_merge(
$files[$file[
"key"]], $row);
250 if (!empty($filesToAdd))
253 foreach ($filesToAdd as $id => $file)
257 "FORUM_ID" =>
$params[
"FORUM_ID"],
258 "TOPIC_ID" =>
$params[
"TOPIC_ID"],
259 "MESSAGE_ID" =>
$params[
"MESSAGE_ID"],
260 "USER_ID" =>
$params[
"USER_ID"]
262 $files[$file[
"key"]] = array_merge(
$files[$file[
"key"]], $row);
265 FileTable::addMulti(
$rows);
267 $result->setData(array_keys($filesToUpdate) + array_keys($filesToAdd));
static checkFiles(Forum $forum, &$files, $params=["TOPIC_ID"=> 0, "MESSAGE_ID"=> 0, "USER_ID"=> 0])
static saveFiles(&$files, $params, $uploadDir="forum/upload")
static deleteBatch(array $filter)
static getConnection($name="")
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']