-
Notifications
You must be signed in to change notification settings - Fork 1
/
AddNewCUserProperty.php
53 lines (50 loc) · 1.66 KB
/
AddNewCUserProperty.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
class CUserIblockPropValueType extends CUserTypeString
{
function GetUserTypeDescription()
{
return array(
"USER_TYPE_ID" => "c_string",
"CLASS_NAME" => "CUserIblockPropValueType",
"DESCRIPTION" => "Привязка к значению свойства инфоблока",
"BASE_TYPE" => "string",
);
}
function GetAdminListViewHTML($arUserField, $arHtmlControl)
{
if(strlen($arHtmlControl["VALUE"])>0)
return $arHtmlControl["VALUE"];
else
return ' ';
}
function GetEditFormHTML($arUserField, $arHtmlControl)
{
$return = '';
if(CModule::IncludeModule("iblock") )
{
$resdb = CIBlockPropertyEnum::GetList(
Array("SORT"=>"ASC", "VALUE"=>"ASC"),
Array( "ACTIVE" => "Y","IBLOCK_ID" => IBLOCK_ID_CATALOG, 'PROPERTY_ID'=>PROPERTY_ID_TORGOVAYA_MARKA )
);
$arPropertyListValue = array();
while ( $res = $resdb->fetch() )
{
$arPropertyListValue[ $res['ID'] ] = $res['VALUE'];
}
if(count($arPropertyListValue)>0):
ob_start();?>
<select name="<?=$arUserField["FIELD_NAME"]?>">
<option value=""></option>
<?foreach($arPropertyListValue as $ID => $NAME):?>
<option value="<?=$ID?>" <?if($ID == $arUserField["VALUE"])echo 'selected';?>><?=$NAME?></option>
<? endforeach;?>
</select>
<?$return = ob_get_contents();
ob_end_clean();
endif;
}
return $return;
}
}
AddEventHandler("main", "OnUserTypeBuildList", array("CUserIblockPropValueType", "GetUserTypeDescription"));
?>