#form — МиниКод http://minicode.ru записи кодов Wed, 05 Sep 2018 06:40:48 +0000 ru-RU hourly 1 https://wordpress.org/?v=4.8.14 Отпарвка формы с вложенными файлами. http://minicode.ru/%d0%be%d1%82%d0%bf%d0%b0%d1%80%d0%b2%d0%ba%d0%b0-%d1%84%d0%be%d1%80%d0%bc%d1%8b-%d1%81-%d0%b2%d0%bb%d0%be%d0%b6%d0%b5%d0%bd%d0%bd%d1%8b%d0%bc%d0%b8-%d1%84%d0%b0%d0%b9%d0%bb%d0%b0%d0%bc%d0%b8/ Thu, 28 Jul 2016 11:23:27 +0000 http://minicode.ru/?p=945
function OnOnBeforeEventAdd(&$event, &$lid, &$arFields, &$message_id, &$files){
    if ($event == 'ololo_form_event') {		
        $isFiltered = false;
		$by="s_id";
		$order="desc";
		/// код совойства в которм должны быть файлы
		$arFilterField = Array(
			"SID"	=> "FILE_CODE_QUESTION"
		);
		$rsQuestions = CFormField::GetList(
			$arFields['RS_FORM_ID'], 
			"N", 
			$by, 
			$order, 
			$arFilterField, 
			$isFiltered
		);
		if($isFiltered){		
			if ($arQuestion = $rsQuestions->Fetch()){
				$arFilterAnswer = Array(
					"FIELD_TYPE" => "file",
				);
				$rsAnswers = CFormAnswer::GetList(
					$arQuestion['ID'], 
					$by, 
					$order, 
					$arFilterAnswer, 
					$isFiltered
				);
				if($isFiltered){
					while ($arAnswer = $rsAnswers->Fetch()){
						$file = CFormResult::GetFileByAnswerID($arFields['RS_RESULT_ID'], $arAnswer['ID']);
						if(intval($file['USER_FILE_ID']) > 0){
							$files[] = $file['USER_FILE_ID'];
						}
					}						
				}					
			}				
		}
        return $arFields;
    }
}
]]>