function OnAdminListDisplayHandler(&$list) {
if (!CPSDeProps::_isMyPage())
return;
if (self::$error != '') {
$message = new CAdminMessage(array('TYPE' => 'ERROR', 'MESSAGE' => self::$error));
echo $message->Show();
}
// Получаем список типов
$stypes = CPSDeProps::GetTypesList(true);
// Формируем список выбора типа
$strIBlockSel = '<div id="ps_deprops_dest" style="display:none"><select class="ps_deprops_select" name="ps_deprops_dest">';
foreach ($stypes as $sid=>$sname)
$strIBlockSel .= "<option value='$sid'>$sname</option>";
$strIBlockSel .= '</select></div>';
// Формируем функцию действий в зависимости от выбора
$strJS = "tid = this.form.ps_deprops_dest[this.form.ps_deprops_dest.selectedIndex].getAttribute('value');\nswitch (tid) {\n";
$url = "/bitrix/admin/iblock_element_edit.php?IBLOCK_SECTION_ID=0&find_section_section=0&type=svoistva&lang=".LANGUAGE_ID."&IBLOCK_ID=";
foreach ($stypes as $sid=>$sname) {
$doPost = $list->ActionPost(($sid) ? $url.$sid : false);
$strJS .= "case '$sid': $doPost\n\tbreak;\n";
}
$strJS .= "default: a lert('Opa default'); break;\n}";
// Добавляем действие к общему списку
$list->arActions[] = array(
'name'=>GetMessage('PS_DEPROPS_ACTION_SET_NAME'),
'value'=>'ps_deprops_set',
'action' =>$strJS,
);
$list->arActions['ps_deprops_set_chooser'] = array(
'type' => 'html', 'value' => $strIBlockSel
);
$list->arActionsParams['select_onchange'] .= "BX ('ps_deprops_dest').style.display = (this.value == 'ps_deprops_set' ? 'block' : 'none');";
}
function OnBeforePrologHandler() {
if (!CPSDeProps::_isMyPage())
return;
if (
!check_bitrix_sessid() || empty($_REQUEST['ID']) ||
$_SERVER['REQUEST_METHOD'] != 'POST'
)
return;
$IBPROP_ID = $_REQUEST['ps_deprops_dest'];
if (!(
$_REQUEST['action'] == 'ps_deprops_set' &&
CIBlock::GetPermission($IBPROP_ID)>='W'
))
return;
$ids_sects = $_REQUEST['ID'];
if ($IBPROP_ID == 0) {
// Очищаем доп. свойства для указанных товаров и секций
$oids = array();
$sids = array();
foreach($ids_sects as $esid) {
if ($esid[0] == 'S')
$sids[] = substr($esid, 1);
else // $esid[0] == 'E'
$oids[] = substr($esid, 1);
}
$rs = CIBlockElement::GetList(
array(),
array(
'LOGIC'=>'OR',
array('ID'=>$oids),
array(
'SECTION_ID'=>$sids,
'INCLUDE_SUBSECTIONS'=>true,
)
),
false, false,
array('ID', 'PROPERTY_VSPROP', 'IBLOCK_ID')
);
while ($ob = $rs->Fetch()) {
CIBlockElement::SetPropertyValuesEx(
$ob['ID'], $ob['IBLOCK_ID'],
array("VsProp" => false, "VsType" => false)
);
$VsProp = $ob['PROPERTY_VSPROP_VALUE'];
if ($VsProp)
$el->Delete($VsProp);
}
} else {
// Сюда никогда не попадаем
}
}
|