- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/classes/general/sharepoint.php
- Класс: CAllIntranetSharepoint
- Вызов: CAllIntranetSharepoint::SetListFields
static function SetListFields($IBLOCK_ID, $arFields, $arList = null)
{
global $DB;
$IBLOCK_ID = intval($IBLOCK_ID);
CIntranetSharepoint::ClearListFields($IBLOCK_ID);
foreach ($arFields as $sp_fld => $property)
{
if (!$property) continue;
list($sp_fld_name, $sp_fld_type) = explode(':', $sp_fld, 2);
$pos = 0;
if (mb_strlen($property) == 1 || (false !== ($pos = mb_strstr($property, ':'))))
{
$user_type = '';
if ($pos > 0)
list($property, $user_type) = explode(':', $property, 2);
$arPropFields = array(
'IBLOCK_ID' => $IBLOCK_ID,
'TYPE' => $property,
'USER_TYPE' => $user_type,
'CODE' => $sp_fld_name,
'NAME' => $sp_fld_name,
'MULTIPLE' => $property == 'F' ? 'Y' : 'N',
);
if (is_array($arList))
{
foreach ($arList as $list_fld)
{
if ($list_fld['Name'] == $sp_fld_name)
{
$arPropFields['NAME'] = $list_fld['DisplayName'];
if ($property == 'L')
{
if ($list_fld['Type'] == 'MultiChoice')
{
$arPropFields['MULTIPLE'] = 'Y';
$arPropFields['LIST_TYPE'] = 'C';
}
else
{
$arPropFields['LIST_TYPE'] =
$list_fld['Format'] == 'RadioButtons' ? 'C' : 'L';
}
$arPropFields['ENUM'] = $list_fld['CHOICE'];
$arPropFields['ENUM_DEFAULT'] = $list_fld['DEFAULT'];
}
break;
}
}
}
$property = 'PROPERTY_'.CIntranetSharepoint::_CreateProperty($arPropFields);
}
$arInsert = array(
'IBLOCK_ID' => $DB->ForSQL($IBLOCK_ID),
'FIELD_ID' => $DB->ForSQL($property),
'SP_FIELD' => $DB->ForSQL($sp_fld_name),
'SP_FIELD_TYPE' => $DB->ForSQL($sp_fld_type),
);
$query = 'INSERT INTO b_intranet_sharepoint_field ('.implode(', ', array_keys($arInsert)).') VALUES (''.implode('', '', $arInsert).'')';
$DB->Query($query);
$events = GetModuleEvents("intranet", "OnSharepointCreateProperty");
while ($arEvent = $events->Fetch())
{
ExecuteModuleEventEx($arEvent, array(array(
'IBLOCK_ID' => $IBLOCK_ID,
'FIELD_ID' => $property,
'SP_FIELD' => $sp_fld_name,
)));
}
}
}