本文整理汇总了PHP中CForumFiles::CheckFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CForumFiles::CheckFields方法的具体用法?PHP CForumFiles::CheckFields怎么用?PHP CForumFiles::CheckFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForumFiles
的用法示例。
在下文中一共展示了CForumFiles::CheckFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: prepareFields
private function prepareFields(array &$params, ErrorCollection $errorCollectionParam)
{
$result = array("FORUM_ID" => $this->topic["FORUM_ID"], "TOPIC_ID" => $this->topic["ID"], "POST_MESSAGE" => trim($params["POST_MESSAGE"]), "AUTHOR_ID" => $params["AUTHOR_ID"], "AUTHOR_NAME" => trim($params["AUTHOR_NAME"]), "AUTHOR_EMAIL" => trim($params["AUTHOR_EMAIL"]), "USE_SMILES" => $params["USE_SMILES"] == "Y" ? "Y" : "N", "APPROVED" => $this->topic["APPROVED"], "XML_ID" => $this->getEntity()->getXmlId());
$errorCollection = new ErrorCollection();
if (strlen($result["POST_MESSAGE"]) <= 0) {
$errorCollection->addOne(new Error(Loc::getMessage("FORUM_CM_ERR_EMPTY_TEXT"), self::ERROR_PARAMS_MESSAGE));
}
if (strlen($result["AUTHOR_NAME"]) <= 0 && $result["AUTHOR_ID"] > 0) {
$result["AUTHOR_NAME"] = self::getUserName($result["AUTHOR_ID"]);
}
if (strlen($result["AUTHOR_NAME"]) <= 0) {
$errorCollection->addOne(new Error(Loc::getMessage("FORUM_CM_ERR_EMPTY_AUTHORS_NAME"), self::ERROR_PARAMS_MESSAGE));
}
if (is_array($params["FILES"]) && in_array($this->forum["ALLOW_UPLOAD"], array("Y", "F", "A"))) {
$result["FILES"] = array();
foreach ($params["FILES"] as $key => $val) {
if (intval($val["FILE_ID"]) > 0) {
$val["del"] = $val["del"] == "Y" ? "Y" : "";
}
$result["FILES"][$key] = $val;
}
$res = array("FORUM_ID" => $this->forum["ID"], "TOPIC_ID" => $this->topic["ID"], "MESSAGE_ID" => 0, "USER_ID" => $result["AUTHOR_ID"], "FORUM" => $this->forum);
if (!\CForumFiles::CheckFields($result["FILES"], $res, "NOT_CHECK_DB")) {
$text = "File upload error.";
if (($ex = $this->getApplication()->getException()) && $ex) {
$text = $ex->getString();
}
$errorCollection->addOne(new Error($text, self::ERROR_PARAMS_MESSAGE));
}
}
if ($result["APPROVED"] != "N") {
$result["APPROVED"] = $this->forum["MODERATION"] != "Y" || $this->getEntity()->canModerate() ? "Y" : "N";
}
if ($errorCollection->hasErrors()) {
$errorCollectionParam->add($errorCollection->toArray());
return false;
} else {
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("FORUM_MESSAGE", $result);
$params = $result;
return true;
}
}
示例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;
}
示例6: ForumAddMessage
//.........这里部分代码省略.........
$aMsg[] = array("id" => "QUOTA", "text" => GetMessage("MAIN_QUOTA_BAD")."( ".COption::GetOptionInt("main", "disk_space")." ).");
else
$aMsg[] = array("id" => "QUOTA", "text" => $quota->LAST_ERROR);
}
}
elseif (!$quota->checkDiskQuota($arFieldsG["POST_MESSAGE"]))
{
if (!$quota->LAST_ERROR)
$aMsg[] = array("id" => "QUOTA", "text" => GetMessage("MAIN_QUOTA_BAD")."( ".COption::GetOptionInt("main", "disk_space")." ).");
else
$aMsg[] = array("id" => "QUOTA", "text" => $quota->LAST_ERROR);
}
}*/
//*************************!QUOTA**********************************************************************************
if (empty($aMsg)) {
// *************************!ATTACH_IMG*****************************************************************************
if (is_set($arFieldsG, "ATTACH_IMG") && empty($arFieldsG["ATTACH_IMG"]["name"]) && empty($arFieldsG["ATTACH_IMG"]["del"])) {
unset($arFieldsG["ATTACH_IMG"]);
}
if (is_set($arFieldsG, "ATTACH_IMG")) {
$arFieldsG["ATTACH_IMG"]["FILE_ID"] = $arMessage["ATTACH_IMG"];
$arFieldsG["FILES"] = array($arFieldsG["ATTACH_IMG"]);
}
unset($arFieldsG["ATTACH_IMG"]);
if (!empty($arFieldsG["FILES"]) && is_array($arFieldsG["FILES"])) {
foreach ($arFieldsG["FILES"] as $key => $val) {
if (intVal($val["FILE_ID"]) > 0) {
$arFieldsG["FILES"][$key]["del"] = $val["del"] == "Y" ? "Y" : "";
}
}
$res = array("FORUM_ID" => $arForum["ID"], "TOPIC_ID" => 0, "MESSAGE_ID" => 0, "USER_ID" => $USER->GetID());
if (!in_array($arForum["ALLOW_UPLOAD"], array("Y", "F", "A"))) {
unset($arFieldsG["FILES"]);
} elseif (!CForumFiles::CheckFields($arFieldsG["FILES"], $res, "NOT_CHECK_DB")) {
if ($ex = $APPLICATION->GetException()) {
$aMsg[] = array("id" => "FILE", "text" => $ex->GetString());
} else {
$aMsg[] = array("id" => "FILE", "text" => "File upload error.");
}
}
}
}
//*************************/ATTACH_IMG*****************************************************************************
if (empty($aMsg) && ($MESSAGE_TYPE == "NEW" || $MESSAGE_TYPE == "REPLY")) {
$AUTHOR_ID = IntVal($USER->GetParam("USER_ID"));
if ($USER->IsAuthorized()) {
$res = CForumUser::GetByUSER_ID($USER->GetID());
$bSHOW_NAME = !empty($res) ? $res["SHOW_NAME"] == "Y" : true;
$arFieldsG["AUTHOR_NAME"] = $bSHOW_NAME ? trim($USER->GetFullName()) : "";
$arFieldsG["AUTHOR_NAME"] = !empty($arFieldsG["AUTHOR_NAME"]) ? $arFieldsG["AUTHOR_NAME"] : $USER->GetLogin();
}
if (empty($arFieldsG["AUTHOR_NAME"])) {
$aMsg[] = array("id" => "AUTHOR_NAME", "text" => GetMessage("ADDMESS_INPUT_AUTHOR") . ".");
}
} elseif (empty($aMsg) && $MESSAGE_TYPE == "EDIT") {
$AUTHOR_ID = IntVal($arMessage["AUTHOR_ID"]);
if (is_set($arFieldsG, "AUTHOR_NAME") && empty($arFieldsG["AUTHOR_NAME"])) {
if ($AUTHOR_ID <= 0) {
$aMsg[] = array("id" => "AUTHOR_NAME", "text" => GetMessage("ADDMESS_INPUT_AUTHOR") . ".");
} else {
$res = CForumUser::GetByUSER_ID($AUTHOR_ID);
$bSHOW_NAME = !empty($res) ? $res["SHOW_NAME"] == "Y" : true;
if ($USER->GetID() == $AUTHOR_ID) {
$arFieldsG["AUTHOR_NAME"] = $bSHOW_NAME ? trim($USER->GetFullName()) : "";
$arFieldsG["AUTHOR_NAME"] = !empty($arFieldsG["AUTHOR_NAME"]) ? $arFieldsG["AUTHOR_NAME"] : $USER->GetLogin();
} else {