- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskwebservice.php
- Класс: CTasksWebService
- Вызов: CTasksWebService::AddAttachment
function AddAttachment($listName, $listItemID, $fileName, $attachment)
{
if (!$this->__Init())
return $this->error;
if (!$listName_original = CIntranetUtils::checkGUID($listName))
{
return new CSoapFault('Data error', 'Wrong GUID - '.$listName);
}
if ($attachment == '')
{
return new CSoapFault('Wrong attachment', 'Wrong attachment');
}
$listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
$listItemID = intval($listItemID);
$dbRes = CTasks::GetByID($listItemID);
if ($task = $dbRes->Fetch())
{
$fileName = str_replace(array('/', '\', '..'), '', $fileName); // minor security
foreach ($task["FILES"] as $fileID)
{
$FILE = ToLower(basename(CFile::GetPath($fileID)));
if ($FILE == ToLower($fileName))
{
Header('HTTP/1.1 500 Internal Server Error');
$obDetail = new CXMLCreator('detail');
$obDetail->addChild(CXMLCreator::createTagAttributed('errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/"', 'The specified name is already in use.'));
$obDetail->addChild(CXMLCreator::createTagAttributed('errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/"', '0x81020067'));
return new CSoapFault(
'soap::Server',
'Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.',
$obDetail
);
}
}
$tmpFileName = CTempFile::GetFileName('sheet_happens');
RewriteFile($tmpFileName, $attachment);
$arFile = CFile::MakeFileArray($tmpFileName);
$arFile['name'] = basename($fileName);
$arFile['MODULE_ID'] = 'tasks';
$arValue = array($FILE_ID = CFile::SaveFile($arFile, 'outlook/Lists/'.$listItemID));
CTasks::AddFiles($task["ID"], $arValue);
return array(
'AddAttachmentResult' => '/tasks/getfile/' . (int) $listItemID
. '/' . (int) $FILE_ID
. '/' . urlencode(ToLower(basename(CFile::GetPath($FILE_ID))))
);
}
else
{
return new CSoapFault('0x81020016', 'List item not found');
}
}