public static function delete($gId) { $result = parent::delete($gId); if ($result['success']) { // update also locations $entityClass = static::getEntityClass('link'); $entityClass::deleteAllForOwner($gId); // we should also remove links when removing group (for other entities this is not always so) } return $result; }
public static function getListUrl($parent = false, $parameters = array()) { if (!is_array($parameters)) { $parameters = array(); } if ($parent !== false) { //$parameters['filter'] = 'Y'; //$parameters['set_filter'] = 'Y'; $parameters[static::URL_PARAM_PARENT_ID] = intval($parent); //$parameters['adm_filter_applied'] = '0'; } return parent::getListUrl($parameters); }
public function provideEnFromRu(&$data) { // restore at least "EN" translation if (is_array($data)) { if (is_array($data['NAME']) && is_array($data['NAME']['RU'])) { if (!is_array($data['NAME']['EN'])) { $data['NAME']['EN'] = array(); } foreach ($data['NAME']['RU'] as $k => $v) { if ((string) $data['NAME']['EN'][$k] == '') { $data['NAME']['EN'][$k] = Location\Admin\NameHelper::translitFromUTF8($data['NAME']['RU'][$k]); } } } } }
public static function createBaseTypes() { $types = array('COUNTRY' => array('CODE' => 'COUNTRY', 'SORT' => 100, 'DISPLAY_SORT' => 700, 'NAME' => array()), 'REGION' => array('CODE' => 'REGION', 'SORT' => 300, 'DISPLAY_SORT' => 500, 'NAME' => array()), 'CITY' => array('CODE' => 'CITY', 'SORT' => 600, 'DISPLAY_SORT' => 100, 'NAME' => array())); $langs = array(); $res = \Bitrix\Main\Localization\LanguageTable::getList(); while ($item = $res->Fetch()) { $MESS = array(); @(include $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lang/' . $item['LID'] . '/lib/location/migration/migrate.php'); if (!empty($MESS)) { $types['COUNTRY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_COUNTRY']; $types['REGION']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_REGION']; $types['CITY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_CITY']; } $langs[$item['LID']] = true; } $typeCode2Id = array(); $res = Location\TypeTable::getList(array('select' => array('ID', 'CODE'))); while ($item = $res->Fetch()) { $typeCode2Id[$item['CODE']] = $item['ID']; } foreach ($types as $code => &$type) { foreach ($langs as $lid => $f) { $type['NAME'][$lid] = \Bitrix\Sale\Location\Admin\NameHelper::getTranslatedName($type['NAME'], $lid); } if (!isset($typeCode2Id[$type['CODE']])) { $typeCode2Id[$type['CODE']] = Location\TypeTable::add($type); } else { // ensure it has all appropriate translations // we can not use ::updateMultipleForOwner() here, because user may rename types manually Location\Name\TypeTable::addAbsentForOwner($typeCode2Id[$type['CODE']], $type['NAME']); } } return $typeCode2Id; }