本文整理汇总了PHP中CForumFiles::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumFiles::Add方法的具体用法?PHP CForumFiles::Add怎么用?PHP CForumFiles::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumFiles
的用法示例。
在下文中一共展示了CForumFiles::Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __FPF_AddEntityInForumFiles
function __FPF_AddEntityInForumFiles(&$arCustomFile, $arParams = null)
{
static $arFileParams = array();
if ($arParams !== null) {
$arFileParams = $arParams;
}
$arFiles = array(array("FILE_ID" => $arCustomFile["fileID"]));
if (!is_array($arCustomFile) || !isset($arCustomFile['fileID'])) {
return false;
} elseif (!CForumFiles::CheckFields($arFiles, $arFileParams, "NOT_CHECK_DB")) {
$ex = $GLOBALS["APPLICATION"]->GetException();
return $ex ? $ex->GetString() : "File upload error.";
} elseif (!empty($arFiles)) {
$GLOBALS["APPLICATION"]->RestartBuffer();
CForumFiles::Add($arCustomFile['fileID'], $arFileParams);
}
}
示例2: OnFileUploadToMFI
public static function OnFileUploadToMFI(&$arCustomFile, $arParams = null)
{
static $arFileParams = array();
if ($arParams !== null) {
$arFileParams = $arParams;
}
$arFiles = array(array("FILE_ID" => $arCustomFile["fileID"]));
if (!is_array($arCustomFile) || !isset($arCustomFile['fileID'])) {
return false;
} elseif (!CForumFiles::CheckFields($arFiles, $arFileParams, "NOT_CHECK_DB", array("FORUM" => $arFileParams["ALLOW"]))) {
$ex = $GLOBALS["APPLICATION"]->GetException();
$res = $ex ? $ex->GetString() : "File upload error.";
return $res;
} elseif (!empty($arFiles)) {
$GLOBALS["APPLICATION"]->RestartBuffer();
CForumFiles::Add($arCustomFile["fileID"], $arFileParams);
}
}
示例3: OnCommentAdd
function OnCommentAdd($entityType, $entityID, &$arPost)
{
global $USER;
$arParams =& $this->component->arParams;
$arResult =& $this->component->arResult;
$arForum =& $arResult['FORUM'];
$iFileSize = intval(COption::GetOptionString("forum", "file_max_size", 50000));
$arCommentParams = array("FORUM_ID" => $arParams["FORUM_ID"], "TOPIC_ID" => null, "USER_ID" => $USER->IsAuthorized() ? $USER->GetID() : null);
$arFiles = $arNewFiles = array();
if (isset($_REQUEST['FILE_NEW']) && is_array($_REQUEST['FILE_NEW'])) {
foreach ($_REQUEST['FILE_NEW'] as $val) {
$arNewFiles[$val] = array("FILE_ID" => $val);
}
}
if (isset($_REQUEST['FILES']) && is_array($_REQUEST['FILES'])) {
foreach ($_REQUEST['FILES'] as $val) {
if (in_array($val, $_REQUEST["FILES_TO_UPLOAD"])) {
$arFiles[$val] = array("FILE_ID" => $val);
}
}
}
if (!empty($arNewFiles)) {
CForumFiles::Add(array_keys($arNewFiles), $arCommentParams);
}
$arFiles = $arFiles + $arNewFiles;
if (!isset($arPost['FILES'])) {
$arPost['FILES'] = array();
}
$arPost['FILES'] = array_merge($arPost['FILES'], $arFiles);
foreach ($arPost['FILES'] as $fileIndex => $fileArr) {
$fileID = $fileArr['FILE_ID'];
$attach_file = CFile::MakeFileArray(intval($fileID));
$attach = "";
if ($attach_file && is_set($attach_file, "name")) {
// Y - Image files F - Files of specified type A - All files
if ($arForum["ALLOW_UPLOAD"] == "Y") {
$attach = CFile::CheckImageFile($attach_file, $iFileSize, 0, 0);
} elseif ($arForum["ALLOW_UPLOAD"] == "F") {
$attach = CFile::CheckFile($attach_file, $iFileSize, false, $arForum["ALLOW_UPLOAD_EXT"]);
} elseif ($arForum["ALLOW_UPLOAD"] == "A") {
$attach = CFile::CheckFile($attach_file, $iFileSize, false, false);
}
if ($attach != '') {
unset($arPost['FILES'][$fileIndex]);
$arPost['ERROR'] = $attach_file['name'] . ': ' . $attach;
return false;
}
}
}
}
示例4: UpdateCrmActivityComment
public static function UpdateCrmActivityComment($arFields)
{
if (!isset($arFields["SOURCE_ID"]) || intval($arFields["SOURCE_ID"]) <= 0) {
return false;
}
$ufFileID = array();
$ufDocID = array();
$dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array('ID', 'ENTITY_ID'));
if ($arLog = $dbResult->Fetch()) {
$dbCrmActivity = CCrmActivity::GetList(array(), array('ID' => $arLog['ENTITY_ID'], 'CHECK_PERMISSIONS' => 'N'));
if (($arCrmActivity = $dbCrmActivity->Fetch()) && $arCrmActivity['TYPE_ID'] == CCrmActivityType::Task && CModule::IncludeModule("forum")) {
$messageId = intval($arFields["SOURCE_ID"]);
if ($arForumMessage = CForumMessage::GetByID($messageId)) {
$arFieldsMessage = array("POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "USE_SMILES" => "Y", "APPROVED" => "Y", "SONET_PERMS" => array("bCanFull" => true));
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp);
if (is_array($arTmp)) {
if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) {
$GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"];
} elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) {
$arFieldsMessage["FILES"] = array();
foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
$arFieldsMessage["FILES"][$file_id] = array("FILE_ID" => $file_id);
}
if (!empty($arFieldsMessage["FILES"])) {
$arFileParams = array("FORUM_ID" => $arForumMessage["FORUM_ID"], "TOPIC_ID" => $arForumMessage["TOPIC_ID"]);
if (CForumFiles::CheckFields($arFieldsMessage["FILES"], $arFileParams, "NOT_CHECK_DB")) {
CForumFiles::Add(array_keys($arFieldsMessage["FILES"]), $arFileParams);
}
}
}
}
$messageID = ForumAddMessage("EDIT", $arForumMessage["FORUM_ID"], $arForumMessage["TOPIC_ID"], $messageId, $arFieldsMessage, $sError, $sNote);
unset($GLOBALS["UF_FORUM_MESSAGE_DOC"]);
// get UF DOC value and FILE_ID there
if ($messageID > 0) {
$dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
$ufFileID[] = $arAddedMessageFiles["FILE_ID"];
}
$ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
}
} else {
$sError = GetMessage("CRM_SL_UPDATE_COMMENT_SOURCE_ERROR");
}
return array("ERROR" => $sError, "NOTES" => $sNote, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID));
}
}
return array("NO_SOURCE" => "Y");
}
示例5: Save
function Save(&$arFields, $arParams, $bCheckFields = true)
{
global $DB;
if ($bCheckFields && !CForumFiles::CheckFields($arFields, $arParams, "ADD")) {
return false;
}
$arFiles = array();
$arParams = is_array($arParams) ? $arParams : array($arParams);
$strUploadDir = !is_set($arParams, "upload_dir") ? "forum/upload" : $arParams["upload_dir"];
$arParams = array("FORUM_ID" => intVal($arParams["FORUM_ID"]), "USER_ID" => intVal($arParams["USER_ID"]), "TOPIC_ID" => 0, "MESSAGE_ID" => 0);
foreach ($arFields as $key => $val) {
$val["MODULE_ID"] = "forum";
$val["FILE_ID"] = intVal($val["FILE_ID"]);
$val["old_file"] = intVal($val["old_file"]);
if ($val["FILE_ID"] <= 0 && $val["old_file"] > 0) {
$val["FILE_ID"] = $val["old_file"];
}
$old_file = $val["FILE_ID"];
unset($val["old_file"]);
if (!empty($val["name"])) {
$res = CFile::SaveFile($val, $strUploadDir, true, true);
$DB->Commit();
if ($res > 0) {
CForumFiles::Add($res, $arParams);
$arFiles[$res] = $arParams;
}
if (($res > 0 || !empty($val["del"])) && $old_file > 0) {
CFile::Delete($old_file);
unset($arFields[$key]);
}
} elseif (!empty($val["del"])) {
CFile::Delete($val["FILE_ID"]);
unset($arFields[$key]);
} else {
$arFiles[$val["FILE_ID"]] = $val;
}
}
return $arFiles;
}