function InstallDBUserFields() { $ImportantUserFields = $this->GetIdeaUserFields(); foreach ($ImportantUserFields as $UserFieldName => $Exists) { if (!$Exists) { $UserType = new CUserTypeEntity(); switch ($UserFieldName) { case "UF_CATEGORY_CODE": $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "string", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => array(LANGUAGE_ID => GetMessage("IDEA_UF_CATEGORY_CODE_DESCRIPTION")))); break; case "UF_ANSWER_ID": $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "integer", "IS_SEARCHABLE" => "N", "MULTIPLE" => "Y", "EDIT_FORM_LABEL" => array(LANGUAGE_ID => GetMessage("IDEA_UF_ANSWER_ID_DESCRIPTION")))); break; case "UF_ORIGINAL_ID": $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "string", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => array(LANGUAGE_ID => GetMessage("IDEA_UF_ORIGINAL_ID_DESCRIPTION")))); break; case "UF_STATUS": $ID = $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "enumeration", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => array(LANGUAGE_ID => GetMessage("IDEA_UF_STATUS_DESCRIPTION")))); if (intval($ID) > 0) { $UserTypeEnum = new CUserFieldEnum(); $UserTypeEnum->SetEnumValues($ID, array("n0" => array("SORT" => 100, "XML_ID" => "NEW", "VALUE" => GetMessage("IDEA_UF_STATUS_NEW_TITLE"), "DEF" => "Y"), "n1" => array("SORT" => 200, "XML_ID" => "PROCESSING", "VALUE" => GetMessage("IDEA_UF_STATUS_PROCESSING_TITLE"), "DEF" => "N"), "n2" => array("SORT" => 300, "XML_ID" => "COMPLETED", "VALUE" => GetMessage("IDEA_UF_STATUS_COMPLETED_TITLE"), "DEF" => "N"))); } break; } } } }
function __wd_check_uf_use_bp_property($iblock_id) { $iblock_id = intval($iblock_id); $db_res = CUserTypeEntity::GetList(array($by=>$order), array("ENTITY_ID" => "IBLOCK_".$iblock_id."_SECTION", "FIELD_NAME" => "UF_USE_BP")); if (!$db_res || !($res = $db_res->GetNext())) { $arFields = Array( "ENTITY_ID" => "IBLOCK_".$iblock_id."_SECTION", "FIELD_NAME" => "UF_USE_BP", "USER_TYPE_ID" => "string", "MULTIPLE" => "N", "MANDATORY" => "N", "SETTINGS" => array("DEFAULT_VALUE" => "Y")); $arFieldName = array(); $rsLanguage = CLanguage::GetList($by, $order, array()); while($arLanguage = $rsLanguage->Fetch()): // GetMessage("SONET_UF_USE_BP"); $dir = str_replace(array("\\", "//"), "/", dirname(__FILE__)); $dirs = explode("/", $dir); array_pop($dirs); $file = trim(implode("/", $dirs)."/lang/".$arLanguage["LID"]."/include/webdav_settings.php"); $tmp_mess = __IncludeLang($file, true); $arFieldName[$arLanguage["LID"]] = (empty($tmp_mess["SONET_UF_USE_BP"]) ? "Use Business Process" : $tmp_mess["SONET_UF_USE_BP"]); endwhile; $arFields["EDIT_FORM_LABEL"] = $arFieldName; $obUserField = new CUserTypeEntity; $obUserField->Add($arFields); $GLOBALS["USER_FIELD_MANAGER"]->arFieldsCache = array(); } }
/** * @param string $entity * @param array $data * @var bool $deleteIfExists */ protected function UFCreate(array $data, $deleteIfExists = false) { global $USER_FIELD_MANAGER; if (empty($data['FIELD_NAME'])) { throw new \Exception('You must set group FIELD_NAME'); } if (empty($data['ENTITY_ID'])) { throw new \Exception('You must set group ENTITY_ID'); } $fire = false; if ($this->UFGetIdByCode($data['ENTITY_ID'], $data['FIELD_NAME'])) { if ($deleteIfExists) { $this->UFDelete($data['ENTITY_ID'], $data['FIELD_NAME']); $fire = true; } } else { $fire = true; } if ($fire) { $ib = new \CUserTypeEntity(); $id = $ib->Add(array_merge(['USER_TYPE_ID' => 'string'], $data)); if ($id) { echo "Add {$data['FIELD_NAME']} user field\r\n"; if (!empty($data['LIST']) && ($arType = $USER_FIELD_MANAGER->GetUserType($data['USER_TYPE_ID'])) && $arType['BASE_TYPE'] == 'enum') { $obEnum = new \CUserFieldEnum(); $res = $obEnum->SetEnumValues($id, $data['LIST']); echo "Add {$data['FIELD_NAME']} user field list\r\n"; } } else { throw new \Exception("Can't create {$data['FIELD_NAME']} user field"); } } }
function __IRM_InitReservation($iblockId) { $arResult = array(); $arResult["ALLOWED_FIELDS"] = array("ID" => array("NAME" => GetMessage("INAF_F_ID"), "ORDERABLE" => true, "FILTERABLE" => true, "TYPE" => "int", "IS_FIELD" => true), "NAME" => array("NAME" => GetMessage("INAF_F_NAME"), "ORDERABLE" => true, "FILTERABLE" => true, "TYPE" => "string", "IS_FIELD" => true), "DESCRIPTION" => array("NAME" => GetMessage("INAF_F_DESCRIPTION"), "ORDERABLE" => false, "FILTERABLE" => false, "TYPE" => "text", "IS_FIELD" => true), "UF_FLOOR" => array("NAME" => GetMessage("INAF_F_FLOOR"), "ORDERABLE" => true, "FILTERABLE" => true, "TYPE" => "integer", "IS_FIELD" => false), "UF_PLACE" => array("NAME" => GetMessage("INAF_F_PLACE"), "ORDERABLE" => true, "FILTERABLE" => true, "TYPE" => "integer", "IS_FIELD" => false), "UF_PHONE" => array("NAME" => GetMessage("INAF_F_PHONE"), "ORDERABLE" => false, "FILTERABLE" => false, "TYPE" => "string", "IS_FIELD" => false)); $arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $iblockId . "_SECTION", 0, LANGUAGE_ID); $arKeys = Array_Keys($arResult["ALLOWED_FIELDS"]); foreach ($arKeys as $key) { if (!$arResult["ALLOWED_FIELDS"][$key]["IS_FIELD"]) { if (!Array_Key_Exists($key, $arUserFields)) { $arFields = array("ENTITY_ID" => "IBLOCK_" . $iblockId . "_SECTION", "FIELD_NAME" => $key, "USER_TYPE_ID" => $arResult["ALLOWED_FIELDS"][$key]["TYPE"]); $obUserField = new CUserTypeEntity(); $obUserField->Add($arFields); } } } $arResult["ALLOWED_ITEM_PROPERTIES"] = array("UF_PERSONS" => array("NAME" => GetMessage("INTASK_C29_UF_PERSONS"), "ACTIVE" => "Y", "SORT" => 300, "CODE" => "UF_PERSONS", "PROPERTY_TYPE" => "N", "USER_TYPE" => false, "ROW_COUNT" => 1, "COL_COUNT" => 5, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "Y", "SEARCHABLE" => "Y", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "UF_RES_TYPE" => array("NAME" => GetMessage("INTASK_C29_UF_RES_TYPE"), "ACTIVE" => "Y", "SORT" => 200, "CODE" => "UF_RES_TYPE", "PROPERTY_TYPE" => "L", "USER_TYPE" => false, "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "Y", "SEARCHABLE" => "Y", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "Y", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId, "VALUES" => array(array("VALUE" => GetMessage("INTASK_C29_UF_RES_TYPEA"), "DEF" => "Y", "SORT" => 100, "XML_ID" => "A"), array("VALUE" => GetMessage("INTASK_C29_UF_RES_TYPEB"), "DEF" => "N", "SORT" => 200, "XML_ID" => "B"), array("VALUE" => GetMessage("INTASK_C29_UF_RES_TYPEC"), "DEF" => "N", "SORT" => 200, "XML_ID" => "C"), array("VALUE" => GetMessage("INTASK_C29_UF_RES_TYPED"), "DEF" => "N", "SORT" => 300, "XML_ID" => "D"))), "UF_PREPARE_ROOM" => array("NAME" => GetMessage("INTASK_C29_UF_PREPARE_ROOM"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "UF_PREPARE_ROOM", "PROPERTY_TYPE" => "S", "USER_TYPE" => false, "DEFAULT_VALUE" => "Y", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "PERIOD_TYPE" => array("NAME" => GetMessage("INTASK_C29_PERIOD_TYPE"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "PERIOD_TYPE", "PROPERTY_TYPE" => "S", "USER_TYPE" => false, "DEFAULT_VALUE" => "NONE", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "PERIOD_COUNT" => array("NAME" => GetMessage("INTASK_C29_PERIOD_COUNT"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "PERIOD_COUNT", "PROPERTY_TYPE" => "N", "USER_TYPE" => false, "DEFAULT_VALUE" => "", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "EVENT_LENGTH" => array("NAME" => GetMessage("INTASK_C29_EVENT_LENGTH"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "EVENT_LENGTH", "PROPERTY_TYPE" => "N", "USER_TYPE" => false, "DEFAULT_VALUE" => "", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "PERIOD_ADDITIONAL" => array("NAME" => GetMessage("INTASK_C29_PERIOD_ADDITIONAL"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "PERIOD_ADDITIONAL", "PROPERTY_TYPE" => "S", "USER_TYPE" => false, "DEFAULT_VALUE" => "", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId)); $dbIBlockProps = CIBlock::GetProperties($iblockId); while ($arIBlockProps = $dbIBlockProps->Fetch()) { if (Array_Key_Exists($arIBlockProps["CODE"], $arResult["ALLOWED_ITEM_PROPERTIES"])) { $arResult["ALLOWED_ITEM_PROPERTIES"][$arIBlockProps["CODE"]]["ID"] = $arIBlockProps["ID"]; } } $keys = Array_Keys($arResult["ALLOWED_ITEM_PROPERTIES"]); foreach ($keys as $key) { if (IntVal($arResult["ALLOWED_ITEM_PROPERTIES"][$key]["ID"]) <= 0) { $ibp = new CIBlockProperty(); $arResult["ALLOWED_ITEM_PROPERTIES"][$key]["ID"] = $ibp->Add($arResult["ALLOWED_ITEM_PROPERTIES"][$key]); } } return $arResult; }
function InstallUserFields() { global $USER_FIELD_MANAGER, $APPLICATION; if (!IsModuleInstalled("blog")) { return; } $db_res = CUserTypeEntity::GetList(array("ID" => "ASC"), array("FIELD_NAME" => "UF_BLOG_POST_VOTE")); if ($db_res && ($res = $db_res->Fetch())) { return; } AddEventHandler("main", "OnUserTypeBuildList", array("CUserTypeVote", "GetUserTypeDescription")); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/classes/general/usertypevote.php"; $USER_FIELD_MANAGER->CleanCache(); $USER_FIELD_MANAGER->arUserTypes = ''; $arFields = array("BLOG_POST" => array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => "UF_BLOG_POST_VOTE", "XML_ID" => "UF_BLOG_POST_VOTE", "SETTINGS" => array("CHANNEL_ID" => "add", "CHANNEL_TITLE" => "UF_BLOG_POST_VOTE", "CHANNEL_SYMBOLIC_NAME" => "UF_BLOG_POST_VOTE", "CHANNEL_USE_CAPTCHA" => "N", "UNIQUE" => 13, "UNIQUE_IP_DELAY" => array("DELAY" => "10", "DELAY_TYPE" => "D")))); $arFieldProps = array("USER_TYPE_ID" => "vote", "SORT" => 100); foreach ($arFields as $arField) { $rsData = CUserTypeEntity::GetList(array("FIELD_NAME" => "ASC"), $arField); if (!($arRes = $rsData->Fetch())) { $arProps = array_merge($arFieldProps, $arField); $obUserField = new CUserTypeEntity(); $intID = $obUserField->Add($arProps); if (false == $intID) { if ($strEx = $APPLICATION->GetException()) { $this->errors[] = $strEx->GetString(); } } } } }
public static function GetList($arOrder = array('CREATED_DATE' => 'DESC'), $arFilter = array(), $arSelect = array(), $nPageTop = false) { $ENTITY_ID = 'TASKS_TASK'; $arElement = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields($ENTITY_ID, 0, LANGUAGE_ID); if ($arElement == false || !isset($arElement['UF_CRM_TASK'])) { $arFields = array(); $arFields['ENTITY_ID'] = $ENTITY_ID; $arFields['FIELD_NAME'] = 'UF_CRM_TASK'; $arFields['USER_TYPE_ID'] = 'crm'; $arFields['EDIT_FORM_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['LIST_COLUMN_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['LIST_FILTER_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['SETTINGS']['LEAD'] = 'Y'; $arFields['SETTINGS']['CONTACT'] = 'Y'; $arFields['SETTINGS']['COMPANY'] = 'Y'; $arFields['SETTINGS']['DEAL'] = 'Y'; $arFields['MULTIPLE'] = 'Y'; $CAllUserTypeEntity = new CUserTypeEntity(); $CAllUserTypeEntity->Add($arFields); } if (isset($arFilter['ENTITY_TYPE']) && isset($arFilter['ENTITY_ID'])) { $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetShortEntityType($arFilter['ENTITY_TYPE']); $arFilter['UF_CRM_TASK'] = $arFilter['ENTITY_TYPE'] . '_' . $arFilter['ENTITY_ID']; unset($arFilter['ENTITY_TYPE'], $arFilter['ENTITY_ID']); } else { if (isset($arFilter['ENTITY_TYPE'])) { if (!empty($arFilter['ENTITY_TYPE'])) { $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetShortEntityType($arFilter['ENTITY_TYPE']); $arFilter['%UF_CRM_TASK'] = $arFilter['ENTITY_TYPE'] . '_'; } else { $arFilter['!=UF_CRM_TASK'] = ''; } unset($arFilter['ENTITY_TYPE']); } else { $arFilter['!=UF_CRM_TASK'] = ''; } } if (isset($arFilter['TITLE'])) { $arFilter['%TITLE'] = $arFilter['TITLE']; unset($arFilter['TITLE']); } if (isset($arFilter['REAL_STATUS'])) { $arFilter['STATUS'] = $arFilter['REAL_STATUS']; unset($arFilter['REAL_STATUS']); } if (isset($arOrder['ID']) || isset($arOrder['id'])) { $arSelect[] = 'ID'; } if (in_array('RESPONSIBLE_ID', $arSelect)) { $arSelect[] = 'RESPONSIBLE_NAME'; $arSelect[] = 'RESPONSIBLE_LAST_NAME'; $arSelect[] = 'RESPONSIBLE_SECOND_NAME'; $arSelect[] = 'RESPONSIBLE_LOGIN'; } $obRes = CTasks::GetList($arOrder, $arFilter, $arSelect, $nPageTop); return $obRes; }
/** * @inheritdoc * * @throws PropertyAlreadyExistException */ public function internationalize($propCodePublicId, $propCodeLang, $defaultLang) { global $APPLICATION; $isExistPropPublicId = $this->checkExistProperty($propCodePublicId, PublicIdField::USER_TYPE); $isExistPropLang = $this->checkExistProperty($propCodeLang, LangField::USER_TYPE); $userTypeModel = new \CUserTypeEntity(); if (!$isExistPropPublicId) { $addResult = $userTypeModel->Add(['ENTITY_ID' => 'IBLOCK_' . $this->getIblockId() . '_SECTION', 'FIELD_NAME' => 'UF_' . $propCodePublicId, 'USER_TYPE_ID' => PublicIdField::USER_TYPE, 'XML_ID' => 'UF_' . $propCodePublicId, 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'EDIT_FORM_LABEL' => ['ru' => 'Публичный ID', 'en' => 'Public ID'], 'LIST_COLUMN_LABEL' => ['ru' => 'Публичный ID', 'en' => 'Public ID'], 'LIST_FILTER_LABEL' => ['ru' => 'Публичный ID', 'en' => 'Public ID']]); if ($addResult === false) { throw new InternationalizeException([$APPLICATION->GetException()->GetString()]); } } if (!$isExistPropLang) { $addResult = $userTypeModel->Add(['ENTITY_ID' => 'IBLOCK_' . $this->getIblockId() . '_SECTION', 'FIELD_NAME' => 'UF_' . $propCodeLang, 'USER_TYPE_ID' => LangField::USER_TYPE, 'XML_ID' => 'UF_' . $propCodeLang, 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'EDIT_FORM_LABEL' => ['ru' => 'Язык', 'en' => 'Language'], 'LIST_COLUMN_LABEL' => ['ru' => 'Язык', 'en' => 'Language'], 'LIST_FILTER_LABEL' => ['ru' => 'Язык', 'en' => 'Language']]); if ($addResult === false) { throw new InternationalizeException(); } } parent::internationalize($propCodePublicId, $propCodeLang, $defaultLang); }
function InstallUserFields() { global $USER_FIELD_MANAGER, $APPLICATION; AddEventHandler("main", "OnUserTypeBuildList", array("CUserTypeWebdavElement", "GetUserTypeDescription")); AddEventHandler("main", "OnUserTypeBuildList", array("CUserTypeWebdavElementHistory", "GetUserTypeDescription")); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/webdav/classes/usertypewebdav.php"; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/webdav/classes/usertypewebdavelementhistory.php"; $USER_FIELD_MANAGER->CleanCache(); $USER_FIELD_MANAGER->arUserTypes = ''; $arFields = array("BLOG_POST" => array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => "UF_BLOG_POST_FILE", "XML_ID" => "UF_BLOG_POST_FILE"), "BLOG_COMMENT" => array("ENTITY_ID" => "BLOG_COMMENT", "FIELD_NAME" => "UF_BLOG_COMMENT_FILE", "XML_ID" => "UF_BLOG_COMMENT_FILE")); $arFieldProps = array("USER_TYPE_ID" => "webdav_element", "SORT" => 100, "MULTIPLE" => "Y", "MANDATORY" => "N", "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "N", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "N", "SETTINGS" => array(), "EDIT_FORM_LABEL" => "", "LIST_COLUMN_LABEL" => "", "LIST_FILTER_LABEL" => "", "ERROR_MESSAGE" => "", "HELP_MESSAGE" => ""); $typeData = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => "BLOG_COMMENT", "FIELD_NAME" => "UF_BLOG_COMMENT_FH", "XML_ID" => "UF_BLOG_COMMENT_FH")); if (!($typeData = $typeData->Fetch())) { $arFieldPropsHistory = array("USER_TYPE_ID" => "webdav_element_history", "SORT" => 100, "MULTIPLE" => "N", "MANDATORY" => "N", "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "N", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "N", "SETTINGS" => array(), "EDIT_FORM_LABEL" => "", "LIST_COLUMN_LABEL" => "", "LIST_FILTER_LABEL" => "", "ERROR_MESSAGE" => "", "HELP_MESSAGE" => "", "ENTITY_ID" => "BLOG_COMMENT", "FIELD_NAME" => "UF_BLOG_COMMENT_FH", "XML_ID" => "UF_BLOG_COMMENT_FH"); $obUserField = new CUserTypeEntity(); $intID = $obUserField->Add($arFieldPropsHistory); if (false == $intID) { if ($strEx = $APPLICATION->GetException()) { $this->errors[] = $strEx->GetString(); } } } foreach ($arFields as $fieldName => $arField) { $rsData = CUserTypeEntity::GetList(array(), $arField); if ($arRes = $rsData->Fetch()) { $intID = $arRes['ID']; } else { $arProps = $arFieldProps + $arField; $obUserField = new CUserTypeEntity(); $intID = $obUserField->Add($arProps); if (false == $intID) { if ($strEx = $APPLICATION->GetException()) { $this->errors[] = $strEx->GetString(); } } } } $rsData = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => "BLOG_POST", "XML_ID" => "UF_BLOG_POST_F_EDIT")); $arRes = $rsData->Fetch(); if (!$arRes) { $arFieldProps = array("USER_TYPE_ID" => "boolean", "SORT" => 100, "MULTIPLE" => "N", "MANDATORY" => "N", "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "N", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "N", "SETTINGS" => array(), "EDIT_FORM_LABEL" => "", "LIST_COLUMN_LABEL" => "", "LIST_FILTER_LABEL" => "", "ERROR_MESSAGE" => "", "HELP_MESSAGE" => "", "ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => "UF_BLOG_POST_F_EDIT", "XML_ID" => "UF_BLOG_POST_F_EDIT"); $obUserField = new CUserTypeEntity(); $propID = $obUserField->Add($arFieldProps, false); } $rsData = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => "BLOG_POST", "XML_ID" => "UF_BLOG_POST_FILE")); $arRes = $rsData->Fetch(); if ($arRes && empty($arRes['SETTINGS']['UF_TO_SAVE_ALLOW_EDIT'])) { $arRes['SETTINGS']['UF_TO_SAVE_ALLOW_EDIT'] = 'UF_BLOG_POST_F_EDIT'; $obUserField = new CUserTypeEntity(); $res = $obUserField->Update($arRes['ID'], array('SETTINGS' => $arRes['SETTINGS'])); } }
public function up() { global $APPLICATION; $arHlData = $this->arHlData; \Bitrix\Main\Loader::includeModule("highloadblock"); $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\RecordTable::getTableName())))->fetch(); if ($arHlblock) { $oUserTypeEntity = new \CUserTypeEntity(); $sort = 500; foreach ($arHlData['FIELDS'] as $fieldName => $fieldValue) { $aUserField = array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName, 'USER_TYPE_ID' => $fieldValue[1], 'SORT' => $sort, 'MULTIPLE' => 'N', 'MANDATORY' => $fieldValue[0], 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'N', 'SETTINGS' => array()); if (isset($fieldValue[2]) && is_array($fieldValue[2])) { $aUserField = array_merge($aUserField, $fieldValue[2]); } $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => $aUserField['ENTITY_ID'], 'FIELD_NAME' => $aUserField['FIELD_NAME'])); if ($aUserHasField = $resProperty->Fetch()) { $idUserTypeProp = $aUserHasField['ID']; if ($oUserTypeEntity->Update($idUserTypeProp, $aUserField)) { $this->out('Обновлено свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } else { if ($idUserTypeProp = $oUserTypeEntity->Add($aUserField)) { $this->out('Добавлено новое свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } $sort += 100; } $arFilter = array(); $arSelect = array("ID"); $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => $arFilter, 'select' => $arSelect)); while ($arRecord = $result->fetch()) { \Hawkart\Megatv\RecordTable::update($arRecord["ID"], array('UF_DATETIME_ADD' => new \Bitrix\Main\Type\DateTime(date('Y-m-d H:i:s'), 'Y-m-d H:i:s'))); } $oUserTypeEntity = new \CUserTypeEntity(); $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => "UF_SOTAL_ID")); if ($aUserHasField = $resProperty->Fetch()) { $oUserTypeEntity->Delete($aUserHasField['ID']); $this->outSuccess("Свойство удалено!"); } $this->outSuccess('Все готово на %d%%', 100); } }
public static function GetList($arOrder = array('CREATED_DATE' => 'DESC'), $arFilter = array(), $arSelect = array(), $nPageTop = false) { // Fix for #27449 if (!CModule::IncludeModule('calendar')) { $obRes = new CDBResult(); $obRes->InitFromArray(array()); return $obRes; } global $USER; $ENTITY_ID = 'CALENDAR_EVENT'; $arElement = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields($ENTITY_ID, 0, LANGUAGE_ID); if ($arElement == false || !isset($arElement['UF_CRM_CAL_EVENT'])) { $arFields = array(); $arFields['ENTITY_ID'] = $ENTITY_ID; $arFields['FIELD_NAME'] = 'UF_CRM_CAL_EVENT'; $arFields['USER_TYPE_ID'] = 'crm'; $arFields['EDIT_FORM_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['LIST_COLUMN_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['LIST_FILTER_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['SETTINGS']['LEAD'] = 'Y'; $arFields['SETTINGS']['CONTACT'] = 'Y'; $arFields['SETTINGS']['COMPANY'] = 'Y'; $arFields['SETTINGS']['DEAL'] = 'Y'; $arFields['MULTIPLE'] = 'Y'; $CAllUserTypeEntity = new CUserTypeEntity(); $CAllUserTypeEntity->Add($arFields); } if (isset($arFilter['ENTITY_TYPE']) && isset($arFilter['ENTITY_ID'])) { $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetShortEntityType($arFilter['ENTITY_TYPE']); $arFilter['UF_CRM_CAL_EVENT'] = $arFilter['ENTITY_TYPE'] . '_' . $arFilter['ENTITY_ID']; unset($arFilter['ENTITY_TYPE'], $arFilter['ENTITY_ID']); } else { if (!empty($arFilter['ENTITY_TYPE'])) { $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetShortEntityType($arFilter['ENTITY_TYPE']); $arFilter['%UF_CRM_CAL_EVENT'] = $arFilter['ENTITY_TYPE'] . '_'; unset($arFilter['ENTITY_TYPE']); } else { $arFilter['!=UF_CRM_CAL_EVENT'] = ''; } } $arFilter['CAL_TYPE'] = 'user'; $arFilter['DELETED'] = 'N'; if (isset($arFilter['OWNER_ID']) && is_array($arFilter['OWNER_ID'])) { $arFilter['OWNER_ID'] = current($arFilter['OWNER_ID']); } $arCal = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'parseRecursion' => false, 'userId' => $USER->GetID(), 'fetchAttendees' => false, 'fetchMeetings' => true)); $obRes = new CDBResult(); $obRes->InitFromArray($arCal); return $obRes; }
public function up() { $arHlData = array('FIELDS' => array('UF_DATETIME' => array('N', 'datetime', array('EDIT_FORM_LABEL' => array('ru' => 'Дата добавления'), 'LIST_COLUMN_LABEL' => array('ru' => 'Дата добавления'))))); global $APPLICATION; \Bitrix\Main\Loader::includeModule("highloadblock"); $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\ProgExternalTable::getTableName())))->fetch(); if ($arHlblock) { $oUserTypeEntity = new \CUserTypeEntity(); $sort = 500; foreach ($arHlData['FIELDS'] as $fieldName => $fieldValue) { $aUserField = array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName, 'USER_TYPE_ID' => $fieldValue[1], 'SORT' => $sort, 'MULTIPLE' => 'N', 'MANDATORY' => $fieldValue[0], 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'N', 'SETTINGS' => array()); if (isset($fieldValue[2]) && is_array($fieldValue[2])) { $aUserField = array_merge($aUserField, $fieldValue[2]); } $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => $aUserField['ENTITY_ID'], 'FIELD_NAME' => $aUserField['FIELD_NAME'])); if ($aUserHasField = $resProperty->Fetch()) { $idUserTypeProp = $aUserHasField['ID']; if ($oUserTypeEntity->Update($idUserTypeProp, $aUserField)) { $this->out('Обновлено свойство - ' . $aUserField['FIELD_NAME']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } else { if ($idUserTypeProp = $oUserTypeEntity->Add($aUserField)) { $this->out('Добавлено новое свойство - ' . $aUserField['FIELD_NAME']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } $sort += 100; } //Import datetime to field from Json field $result = \Hawkart\Megatv\ProgExternalTable::getList(array('filter' => array(), 'select' => array("ID", "UF_JSON"))); while ($row = $result->fetch()) { $datetime = $row["UF_JSON"]["created_ts"]; if (!empty($datetime)) { $datetime = new \Bitrix\Main\Type\DateTime(date("Y-m-d H:i:s", strtotime($datetime)), 'Y-m-d H:i:s'); \Hawkart\Megatv\ProgExternalTable::update($row["ID"], array("UF_DATETIME" => $datetime)); } } $this->outSuccess('Все готово на %d%%', 100); } }
public function up() { global $APPLICATION; $arHlData = $this->arHlData; \Bitrix\Main\Loader::includeModule("highloadblock"); $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\PeopleTable::getTableName())))->fetch(); if ($arHlblock) { $oUserTypeEntity = new \CUserTypeEntity(); $sort = 500; foreach ($arHlData['FIELDS'] as $fieldName => $fieldValue) { $aUserField = array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName, 'USER_TYPE_ID' => $fieldValue[1], 'SORT' => $sort, 'MULTIPLE' => 'N', 'MANDATORY' => $fieldValue[0], 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'N', 'SETTINGS' => array()); if (isset($fieldValue[2]) && is_array($fieldValue[2])) { $aUserField = array_merge($aUserField, $fieldValue[2]); } $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => $aUserField['ENTITY_ID'], 'FIELD_NAME' => $aUserField['FIELD_NAME'])); if ($aUserHasField = $resProperty->Fetch()) { $idUserTypeProp = $aUserHasField['ID']; if ($oUserTypeEntity->Update($idUserTypeProp, $aUserField)) { $this->out('Обновлено свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } else { if ($idUserTypeProp = $oUserTypeEntity->Add($aUserField)) { $this->out('Добавлено новое свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } $sort += 100; } $dbUsers = \CUser::GetList($by = "EMAIL", $order = "desc", array("UF_SOTAL_LOGIN" => false)); while ($arUser = $dbUsers->Fetch()) { \CUserEx::generateDataSotal($arUser["ID"]); } $this->outSuccess('Все готово на %d%%', 100); } }
function InstallUserFields($id = "all") { global $USER_FIELD_MANAGER; $errors = null; if ($id == 'disk' || $id == 'all') { self::installDiskUserFields(); } if ($id == 'all') { $arFields = array("BLOG_POST" => array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => "UF_BLOG_POST_DOC", "XML_ID" => "UF_BLOG_POST_DOC", "USER_TYPE_ID" => "file", "MULTIPLE" => "Y"), "BLOG_COMMENT" => array("ENTITY_ID" => "BLOG_COMMENT", "FIELD_NAME" => "UF_BLOG_COMMENT_DOC", "XML_ID" => "UF_BLOG_COMMENT_DOC", "USER_TYPE_ID" => "file", "MULTIPLE" => "Y"), "UF_BLOG_POST_URL_PRV" => array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => "UF_BLOG_POST_URL_PRV", "XML_ID" => "UF_BLOG_POST_URL_PRV", "USER_TYPE_ID" => "url_preview", "MULTIPLE" => "N"), "UF_BLOG_COMM_URL_PRV" => array("ENTITY_ID" => "BLOG_COMMENT", "FIELD_NAME" => "UF_BLOG_COMM_URL_PRV", "XML_ID" => "UF_BLOG_COMM_URL_PRV", "USER_TYPE_ID" => "url_preview", "MULTIPLE" => "N")); $arFieldProps = array("SORT" => 100, "MANDATORY" => "N", "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "N", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "Y", "SETTINGS" => array(), "EDIT_FORM_LABEL" => "", "LIST_COLUMN_LABEL" => "", "LIST_FILTER_LABEL" => "", "ERROR_MESSAGE" => "", "HELP_MESSAGE" => "", "MAX_ALLOWED_SIZE" => COption::GetOptionString("blog", "image_max_size", "5000000")); foreach ($arFields as $fieldName => $arField) { $rsData = CUserTypeEntity::GetList(array($by => $order), $arField); if ($arRes = $rsData->Fetch()) { $intID = $arRes['ID']; } else { $arProps = $arFieldProps + $arField; $obUserField = new CUserTypeEntity(); $intID = $obUserField->Add($arProps, false); if (false == $intID) { if ($strEx = $GLOBALS['APPLICATION']->GetException()) { $errors = $strEx->GetString(); } } } } if (is_null($errors)) { $rsData = CUserTypeEntity::GetList(array($by => $order), array("ENTITY_ID" => "BLOG_POST", "XML_ID" => "UF_GRATITUDE")); if ($arRes = $rsData->Fetch()) { $intID = $arRes['ID']; } else { $arFieldProps = array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => "UF_GRATITUDE", "XML_ID" => "UF_GRATITUDE", "USER_TYPE_ID" => "integer", "SORT" => 100, "MULTIPLE" => "N", "MANDATORY" => "N", "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "N", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "N", "SETTINGS" => array(), "EDIT_FORM_LABEL" => "", "LIST_COLUMN_LABEL" => "", "LIST_FILTER_LABEL" => "", "ERROR_MESSAGE" => "", "HELP_MESSAGE" => ""); $obUserField = new CUserTypeEntity(); $intID = $obUserField->Add($arFieldProps, false); if (false == $intID && ($strEx = $GLOBALS['APPLICATION']->GetException())) { $errors = $strEx->GetString(); } } } } return $errors; }
public function up() { $arHlData = array('FIELDS' => array('UF_DATETIME_TO' => array('N', 'datetime', array('EDIT_FORM_LABEL' => array('ru' => 'Дата окончания подписки'), 'LIST_COLUMN_LABEL' => array('ru' => 'Дата окончания подписки'))))); global $APPLICATION, $DB; \Bitrix\Main\Loader::includeModule("highloadblock"); $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\SubscribeTable::getTableName())))->fetch(); if ($arHlblock) { $oUserTypeEntity = new \CUserTypeEntity(); $sort = 500; foreach ($arHlData['FIELDS'] as $fieldName => $fieldValue) { $aUserField = array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName, 'USER_TYPE_ID' => $fieldValue[1], 'SORT' => $sort, 'MULTIPLE' => 'N', 'MANDATORY' => $fieldValue[0], 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'N', 'SETTINGS' => array()); if (isset($fieldValue[2]) && is_array($fieldValue[2])) { $aUserField = array_merge($aUserField, $fieldValue[2]); } $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => $aUserField['ENTITY_ID'], 'FIELD_NAME' => $aUserField['FIELD_NAME'])); if ($aUserHasField = $resProperty->Fetch()) { $idUserTypeProp = $aUserHasField['ID']; if ($oUserTypeEntity->Update($idUserTypeProp, $aUserField)) { $this->out('Обновлено свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } else { if ($idUserTypeProp = $oUserTypeEntity->Add($aUserField)) { $this->out('Добавлено новое свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } $sort += 100; } $strSql = "UPDATE " . \Hawkart\Megatv\SubscribeTable::getTableName() . " SET UF_DATETIME_TO=curdate() + INTERVAL 1 DAY + INTERVAL 3 HOUR + INTERVAL 30 MINUTE"; $res = $DB->Query($strSql, false, $err_mess . __LINE__); $this->outSuccess('Все готово на %d%%', 100); } }
function InstallUserFields() { $ImportantUserFields = $this->GetIdeaUserFields(); $messages = array(); $db_res = \Bitrix\Main\Localization\LanguageTable::getList(array('order' => array('SORT' => 'ASC'))); while ($ar = $db_res->fetch()) { $messages[$ar["LID"]] = IncludeModuleLangFile(__FILE__, $ar["LID"], true); } foreach ($ImportantUserFields as $UserFieldName => $Exists) { if (!$Exists) { $EDIT_FORM_LABEL = array(); foreach ($messages as $lid => $mess) { $EDIT_FORM_LABEL[$lid] = $mess["IDEA_" . $UserFieldName . "_DESCRIPTION"]; } $UserType = new CUserTypeEntity(); switch ($UserFieldName) { case "UF_CATEGORY_CODE": GetMessage("IDEA_UF_CATEGORY_CODE_DESCRIPTION"); $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "string", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => $EDIT_FORM_LABEL)); break; case "UF_ANSWER_ID": GetMessage("IDEA_UF_ANSWER_ID_DESCRIPTION"); $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "integer", "IS_SEARCHABLE" => "N", "MULTIPLE" => "Y", "EDIT_FORM_LABEL" => $EDIT_FORM_LABEL)); break; case "UF_ORIGINAL_ID": GetMessage("IDEA_UF_ORIGINAL_ID_DESCRIPTION"); $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "string", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => $EDIT_FORM_LABEL)); break; case "UF_STATUS": GetMessage("IDEA_UF_STATUS_DESCRIPTION"); $ID = $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "enumeration", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => $EDIT_FORM_LABEL)); if (intval($ID) > 0) { $UserTypeEnum = new CUserFieldEnum(); $UserTypeEnum->SetEnumValues($ID, array("n0" => array("SORT" => 100, "XML_ID" => "NEW", "VALUE" => GetMessage("IDEA_UF_STATUS_NEW_TITLE"), "DEF" => "Y"), "n1" => array("SORT" => 200, "XML_ID" => "PROCESSING", "VALUE" => GetMessage("IDEA_UF_STATUS_PROCESSING_TITLE"), "DEF" => "N"), "n2" => array("SORT" => 300, "XML_ID" => "COMPLETED", "VALUE" => GetMessage("IDEA_UF_STATUS_COMPLETED_TITLE"), "DEF" => "N"))); } break; } } } }
public function up() { $arHlData = array('FIELDS' => array('UF_DEFAULT' => array('N', 'boolean', array('EDIT_FORM_LABEL' => array('ru' => 'Город по умолчанию'), 'LIST_COLUMN_LABEL' => array('ru' => 'Город по умолчанию'))))); global $APPLICATION; \Bitrix\Main\Loader::includeModule("highloadblock"); $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\CityTable::getTableName())))->fetch(); if ($arHlblock) { $oUserTypeEntity = new \CUserTypeEntity(); $sort = 500; foreach ($arHlData['FIELDS'] as $fieldName => $fieldValue) { $aUserField = array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName, 'USER_TYPE_ID' => $fieldValue[1], 'SORT' => $sort, 'MULTIPLE' => 'N', 'MANDATORY' => $fieldValue[0], 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'N', 'SETTINGS' => array()); if (isset($fieldValue[2]) && is_array($fieldValue[2])) { $aUserField = array_merge($aUserField, $fieldValue[2]); } $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => $aUserField['ENTITY_ID'], 'FIELD_NAME' => $aUserField['FIELD_NAME'])); if ($aUserHasField = $resProperty->Fetch()) { $idUserTypeProp = $aUserHasField['ID']; if ($oUserTypeEntity->Update($idUserTypeProp, $aUserField)) { $this->out('Обновлено свойство - ' . $aUserField['FIELD_NAME']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } else { if ($idUserTypeProp = $oUserTypeEntity->Add($aUserField)) { $this->out('Добавлено новое свойство - ' . $aUserField['FIELD_NAME']); } else { if ($ex = $APPLICATION->GetException()) { $this->outError('Ошибка - ' . $ex->GetString()); } } } $sort += 100; } $this->outSuccess('Все готово на %d%%', 100); } }
public function addUserTypeEntityIfNotExists($entityId, $fieldName, $fields) { /* @global $APPLICATION \CMain */ global $APPLICATION; $aItem = $this->getUserTypeEntity($entityId, $fieldName); if ($aItem) { return $aItem['ID']; } $default = array("ENTITY_ID" => '', "FIELD_NAME" => '', "USER_TYPE_ID" => '', "XML_ID" => '', "SORT" => 500, "MULTIPLE" => 'N', "MANDATORY" => 'N', "SHOW_FILTER" => 'I', "SHOW_IN_LIST" => '', "EDIT_IN_LIST" => '', "IS_SEARCHABLE" => '', "SETTINGS" => array(), "EDIT_FORM_LABEL" => array('ru' => '', 'en' => ''), "LIST_COLUMN_LABEL" => array('ru' => '', 'en' => ''), "LIST_FILTER_LABEL" => array('ru' => '', 'en' => ''), "ERROR_MESSAGE" => '', "HELP_MESSAGE" => ''); $fields = array_replace_recursive($default, $fields); $fields['FIELD_NAME'] = $fieldName; $fields['ENTITY_ID'] = $entityId; $obUserField = new \CUserTypeEntity(); $userFieldId = $obUserField->Add($fields); if ($userFieldId) { return $userFieldId; } if ($APPLICATION->GetException()) { $this->throwException(__METHOD__, $APPLICATION->GetException()->GetString()); } else { $this->throwException(__METHOD__, 'UserType %s not added', $fieldName); } }
/** * Add * @param $entityName * @param $fields * @return mixed * @throws \Exception */ public static function Add($entityName, $fields) { if (empty($entityName) || empty($fields)) { throw new \Exception('entityName or fields is empty'); } if (empty($fields['FIELD_NAME'])) { throw new \Exception('Field FIELD_NAME is required.'); } if (empty($fields['USER_TYPE_ID'])) { throw new \Exception('Field USER_TYPE_ID is required.'); } if (isset($fields['ID'])) { unset($fields['ID']); } $userFieldEntity = self::_getEntityId($entityName); $fields['ENTITY_ID'] = $userFieldEntity; $typeEntityDbRes = \CUserTypeEntity::GetList(array(), array("ENTITY_ID" => $fields["ENTITY_ID"], "FIELD_NAME" => $fields["FIELD_NAME"])); if ($typeEntityDbRes !== false && $typeEntityDbRes->SelectedRowsCount()) { throw new \Exception('Hlblock field with name = "' . $fields["FIELD_NAME"] . '" already exist.'); } #if if (($fields['USER_TYPE_ID'] == "iblock_element" || $fields['USER_TYPE_ID'] == "iblock_section") && isset($fields['SETTINGS']['IBLOCK_CODE'])) { unset($fields['SETTINGS']['IBLOCK_CODE']); $rsIBlock = \CIBlock::GetList(array(), array('CODE' => $fields['SETTINGS']['IBLOCK_CODE'], 'CHECK_PERMISSIONS' => 'N')); if ($arIBlock = $rsIBlock->Fetch()) { $fields['SETTINGS']['IBLOCK_ID'] = $arIBlock['ID']; } else { throw new \Exception(__METHOD__ . ' Not found iblock with code ' . $fields['SETTINGS']['IBLOCK_CODE']); } } $UserType = new \CUserTypeEntity(); $ID = $UserType->Add($fields); if (!(int) $ID) { throw new \Exception('Not added Hlblock field'); } return $ID; }
$dbRes = CUserTypeEntity::GetList(Array(), Array("ENTITY_ID" => $arFields["ENTITY_ID"], "FIELD_NAME" => $arFields["FIELD_NAME"])); if ($dbRes->Fetch()) continue; $arLabelNames = Array(); foreach($arLanguages as $languageID) { WizardServices::IncludeServiceLang("references.php", $languageID); $arLabelNames[$languageID] = GetMessage($arFields["FIELD_NAME"]); } $arFields["EDIT_FORM_LABEL"] = $arLabelNames; $arFields["LIST_COLUMN_LABEL"] = $arLabelNames; $arFields["LIST_FILTER_LABEL"] = $arLabelNames; $ID_USER_FIELD = $obUserField->Add($arFields); } /*if(!CModule::IncludeModule("iblock")) return; $iblockXMLFile = WIZARD_SERVICE_RELATIVE_PATH."/xml/".LANGUAGE_ID."/references.xml"; $iblockCode = "clothes_colors_".WIZARD_SITE_ID; $iblockType = "references"; $rsIBlock = CIBlock::GetList(array(), array("XML_ID" => $iblockCode, "TYPE" => $iblockType)); $iblockID = false; if ($arIBlock = $rsIBlock->Fetch()) { $iblockID = $arIBlock["ID"]; if (WIZARD_INSTALL_DEMO_DATA)
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $arProperties = array('UF_PHONE_INNER' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_PHONE_INNER', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 2, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'S', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_1C' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_1C', 'USER_TYPE_ID' => 'boolean', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'I', 'SHOW_IN_LIST' => 'N', 'EDIT_IN_LIST' => 'N', 'IS_SEARCHABLE' => 'Y', 'SETTINGS' => array('DISPLAY' => 'CHECKBOX')), 'UF_INN' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_INN', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'I', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_DISTRICT' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_DISTRICT', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_SKYPE' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_SKYPE', 'USER_TYPE_ID' => 'string_formatted', 'XML_ID' => 'UF_SKYPE', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y', 'SETTINGS' => array('PATTERN' => '<a href="callto:#VALUE#">#VALUE#</a>')), 'UF_TWITTER' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_TWITTER', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_FACEBOOK' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_FACEBOOK', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_LINKEDIN' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_LINKEDIN', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_XING' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_XING', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_WEB_SITES' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_WEB_SITES', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_SKILLS' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_SKILLS', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y'), 'UF_INTERESTS' => array('ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_INTERESTS', 'USER_TYPE_ID' => 'string', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'Y', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y')); $arLanguages = array(); $rsLanguage = CLanguage::GetList($by, $order, array()); while ($arLanguage = $rsLanguage->Fetch()) { $arLanguages[] = $arLanguage["LID"]; } foreach ($arProperties as $arProperty) { $dbRes = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => $arProperty["ENTITY_ID"], "FIELD_NAME" => $arProperty["FIELD_NAME"])); if ($dbRes->Fetch()) { continue; } $arLabelNames = array(); foreach ($arLanguages as $languageID) { WizardServices::IncludeServiceLang("property_names.php", $languageID); $arLabelNames[$languageID] = GetMessage($arProperty["FIELD_NAME"]); } $arProperty["EDIT_FORM_LABEL"] = $arLabelNames; $arProperty["LIST_COLUMN_LABEL"] = $arLabelNames; $arProperty["LIST_FILTER_LABEL"] = $arLabelNames; $userType = new CUserTypeEntity(); $success = (bool) $userType->Add($arProperty); //if($ex = $APPLICATION->GetException()) //$strError = $ex->GetString(); }
$rsData = $entityDataClass::getList(array()); while ($arData = $rsData->fetch()) { $arAddField = array(); if (!isset($arData["UF_DESCRIPTION"])) { $arAddField[] = 'UF_DESCRIPTION'; } if (!isset($arData["UF_FULL_DESCRIPTION"])) { $arAddField[] = 'UF_FULL_DESCRIPTION'; } $obUserField = new CUserTypeEntity(); foreach ($arAddField as $addField) { $arUserField = array("ENTITY_ID" => "HLBLOCK_" . $hlblock["ID"], "FIELD_NAME" => $addField, "USER_TYPE_ID" => 'string', "XML_ID" => "", "SORT" => 100, "MULTIPLE" => "N", "MANDATORY" => "N", "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "Y", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "N", "SETTINGS" => array()); if (isset($_POST['PROPERTY_USER_TYPE_SETTINGS']['LANG'][$addField])) { $arUserField["EDIT_FORM_LABEL"] = $arUserField["LIST_COLUMN_LABEL"] = $arUserField["LIST_FILTER_LABEL"] = array(LANGUAGE_ID => $_POST['PROPERTY_USER_TYPE_SETTINGS']['LANG'][$addField]); } $obUserField->Add($arUserField); } if ($arDirValue["ID"] == $arData["ID"]) { unset($arDirValue["ID"]); $dirValueKeys = array_keys($arDirValue); foreach ($dirValueKeys as $oneKey) { if (!isset($fieldsList[$oneKey])) { unset($arDirValue[$oneKey]); } } if (isset($oneKey)) { unset($oneKey); } if (!empty($arDirValue)) { $entityDataClass::update($arData["ID"], $arDirValue); }
function InstallUserFields($id = "all") { $errors = null; $ENTITY_ID = 'CALENDAR_EVENT'; $FIELD_NAME = 'UF_WEBDAV_CAL_EVENT'; $arElement = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields($ENTITY_ID, 0); if (empty($arElement) || $arElement == array() ||$arElement == false || !isset($arElement[$FIELD_NAME])) { $arFields = array( "ENTITY_ID" => $ENTITY_ID, "FIELD_NAME" => $FIELD_NAME, "XML_ID" => $FIELD_NAME, "USER_TYPE_ID" => "webdav_element", "SORT" => 100, "MULTIPLE" => "Y", "MANDATORY" => "N", "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "N", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "N" ); $obUserField = new CUserTypeEntity; $intID = $obUserField->Add($arFields, false); if (false == $intID) { if ($strEx = $GLOBALS['APPLICATION']->GetException()) { $errors = $strEx->GetString(); } } } return $errors; }
function __CreateUserProperty() { if ($this->attachIBlockID < 1) { return false; } $success = true; $dbRes = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => "USER", "FIELD_NAME" => $this->userPropertyName)); if (!$dbRes->Fetch()) { $arLabelNames = array(); $rsLanguage = CLanguage::GetList($by, $order, array()); while ($arLanguage = $rsLanguage->Fetch()) { IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/csv_user_import_labels.php", $arLanguage["LID"]); $arLabelNames[$arLanguage["LID"]] = GetMessage("DEPARTMENT_USER_PROPERTY_NAME"); } $arFields = array('ENTITY_ID' => 'USER', 'FIELD_NAME' => $this->userPropertyName, 'USER_TYPE_ID' => 'iblock_section', 'XML_ID' => '', 'SORT' => 100, 'MULTIPLE' => 'Y', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'I', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'Y', 'SETTINGS' => array('DISPLAY' => 'LIST', 'LIST_HEIGHT' => '8', 'IBLOCK_ID' => $this->attachIBlockID), "EDIT_FORM_LABEL" => $arLabelNames, "LIST_COLUMN_LABEL" => $arLabelNames, "LIST_FILTER_LABEL" => $arLabelNames); $userType = new CUserTypeEntity(); $success = (bool) $userType->Add($arFields); } return $success; }
public static function InitUserEntity() { if (!CModule::IncludeModule("calendar")) { return; } //if (!defined("BX_NO_ACCELERATOR_RESET")) // define("BX_NO_ACCELERATOR_RESET", true); $arRequiredFields = array("UF_BXDAVEX_CALSYNC" => array("USER_TYPE_ID" => "datetime", "SORT" => 100, "EDIT_FORM_LABEL_DEFAULT_MESSAGE" => "Calendar sync date")); $arUserCustomFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("USER"); foreach ($arUserCustomFields as $key => $value) { if (array_key_exists($key, $arRequiredFields)) { unset($arRequiredFields[$key]); } } foreach ($arRequiredFields as $requiredFieldKey => $requiredFieldValue) { $arFields = array("ENTITY_ID" => "USER", "FIELD_NAME" => $requiredFieldKey, "SHOW_IN_LIST" => "N", "IS_SEARCHABLE" => "N", "SHOW_FILTER" => "N", "EDIT_IN_LIST" => "N", "EDIT_FORM_LABEL" => CDavExchangeClient::InitUserEntityLoadMessages($requiredFieldKey, $requiredFieldValue["EDIT_FORM_LABEL_DEFAULT_MESSAGE"])); $obUserField = new CUserTypeEntity(); $obUserField->Add(array_merge($arFields, $requiredFieldValue)); } }
function ImportPropertyDirectory($arProperty, $arEnumXmlNodes) { if (!CModule::IncludeModule('highloadblock')) { return true; } $rsProperty = CIBlockProperty::GetList(array(), array("ID" => $arProperty["ID"])); $arProperty = $rsProperty->Fetch(); if (!$arProperty) { return true; } $tableName = 'b_' . strtolower($arProperty["CODE"]); if (strlen($arProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"]) <= 0) { $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array("=TABLE_NAME" => $tableName)))->fetch(); if (!$hlblock) { $highBlockName = trim($arProperty["CODE"]); $highBlockName = preg_replace("/([^A-Za-z0-9]+)/", "", $highBlockName); if ($highBlockName == "") { return GetMessage("IBLOCK_XML2_HBLOCK_NAME_IS_INVALID"); } $highBlockName = strtoupper(substr($highBlockName, 0, 1)) . substr($highBlockName, 1); $data = array('NAME' => $highBlockName, 'TABLE_NAME' => $tableName); $result = Bitrix\Highloadblock\HighloadBlockTable::add($data); $highBlockID = $result->getId(); $arFieldsName = array('UF_NAME' => array("Y", "string"), 'UF_XML_ID' => array("Y", "string"), 'UF_LINK' => array("N", "string"), 'UF_DESCRIPTION' => array("N", "string"), 'UF_FULL_DESCRIPTION' => array("N", "string"), 'UF_SORT' => array("N", "integer"), 'UF_FILE' => array("N", "file"), 'UF_DEF' => array("N", "boolean")); $obUserField = new CUserTypeEntity(); $sort = 100; foreach ($arFieldsName as $fieldName => $fieldValue) { $arUserField = array("ENTITY_ID" => "HLBLOCK_" . $highBlockID, "FIELD_NAME" => $fieldName, "USER_TYPE_ID" => $fieldValue[1], "XML_ID" => "", "SORT" => $sort, "MULTIPLE" => "N", "MANDATORY" => $fieldValue[0], "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "Y", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "N", "SETTINGS" => array()); $obUserField->Add($arUserField); $sort += 100; } } $arProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"] = $tableName; $obProperty = new CIBlockProperty(); $obProperty->Update($arProperty["ID"], $arProperty); } $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array("=TABLE_NAME" => $arProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch(); $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock); $entity_data_class = $entity->getDataClass(); $arEnumMap = array(); $rsData = $entity_data_class::getList(array("select" => array("ID", "UF_NAME", "UF_XML_ID", "UF_SORT"))); while ($arData = $rsData->fetch()) { $arEnumMap[$arData["UF_XML_ID"]] = $arData; } $i = 0; foreach ($arEnumXmlNodes as $arE) { if ($arE["NAME"] == $this->mess["IBLOCK_XML2_TYPE_LIST"]) { $arE = $this->_xml_file->GetAllChildrenArray($arE); if (isset($arE[$this->mess["IBLOCK_XML2_VALUE_ID"]]) && isset($arE[$this->mess["IBLOCK_XML2_VALUE"]])) { $xml_id = $arE[$this->mess["IBLOCK_XML2_VALUE_ID"]]; $arFields = array("UF_XML_ID" => $xml_id, "UF_NAME" => $arE[$this->mess["IBLOCK_XML2_VALUE"]]); if (isset($arE[$this->mess["IBLOCK_XML2_PICTURE"]])) { $arFields["UF_FILE"] = $this->MakeFileArray($arE[$this->mess["IBLOCK_XML2_PICTURE"]]); } if (!array_key_exists($xml_id, $arEnumMap)) { $entity_data_class::add($arFields); } elseif ($arEnumMap[$xml_id]["UF_NAME"] !== $arFields['UF_NAME']) { $entity_data_class::update($arEnumMap[$xml_id]["ID"], $arFields); } } } } return true; }
} } } $iblockID = IntVal($iblockID); if (StrLen($iblockTypeID) > 0 && $iblockID > 0) { $dbUserField = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => "USER", "FIELD_NAME" => "UF_USER_CAR_DEMO")); if ($arUserField = $dbUserField->Fetch()) { } else { $arFields = array("ENTITY_ID" => "USER", "FIELD_NAME" => "UF_USER_CAR_DEMO", "USER_TYPE_ID" => "iblock_section", "XML_ID" => "", "SORT" => 100, "MULTIPLE" => "Y", "MANDATORY" => "", "SHOW_FILTER" => "S", "SHOW_IN_LIST" => "Y", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "Y", "SETTINGS" => array("IBLOCK_TYPE_ID" => $iblockTypeID, "IBLOCK_ID" => $iblockID, "DISPLAY" => "LIST", "LIST_HEIGHT" => 5), "EDIT_FORM_LABEL" => array(), "LIST_COLUMN_LABEL" => array(), "LIST_FILTER_LABEL" => array()); foreach ($arLanguages as $arLang) { $arFields["EDIT_FORM_LABEL"][$arLang["LID"]] = GetSocNetMessageLocal("SONET_I_USER_PROP_EFL", $arLang["LID"]); $arFields["LIST_COLUMN_LABEL"][$arLang["LID"]] = GetSocNetMessageLocal("SONET_I_USER_PROP_LCL", $arLang["LID"]); $arFields["LIST_FILTER_LABEL"][$arLang["LID"]] = GetSocNetMessageLocal("SONET_I_USER_PROP_LFL", $arLang["LID"]); } $userField = new CUserTypeEntity(); $userFieldID = $userField->Add($arFields); if (!$userFieldID || $userFieldID <= 0) { if ($e = $GLOBALS["APPLICATION"]->GetException()) { $errorString .= $e->GetString(); } } } } } // ------------------ GROUPS ------------------------------- if (CModule::IncludeModule("socialnetwork")) { $bSonetError = false; $cnt = CSocNetGroupSubject::GetList(array(), array("SITE_ID" => $arSite["SITE_ID"]), array()); if (IntVal($cnt) <= 0) { $arGroupSubjects = array(); $arGroupSubjectsId = array();
$GLOBALS["USER_FIELD_MANAGER"]->arFieldsCache = array(); } } if (empty($arUserFields) || empty($arUserFields["UF_PASSWORD"])) { $db_res = CUserTypeEntity::GetList(array($by => $order), array("ENTITY_ID" => "IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", "FIELD_NAME" => "UF_PASSWORD")); if (!($db_res && ($res = $db_res->GetNext()))) { $arFields = array("ENTITY_ID" => "IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", "FIELD_NAME" => "UF_PASSWORD", "USER_TYPE_ID" => "string", "MULTIPLE" => "N", "MANDATORY" => "N"); $arFieldName = array(); $rsLanguage = CLanguage::GetList($by, $order, array()); while ($arLanguage = $rsLanguage->Fetch()) { $arFieldName[$arLanguage["LID"]] = GetMessage("IBLOCK_PASSWORD"); $arFieldName[$arLanguage["LID"]] = empty($arFieldName[$arLanguage["LID"]]) ? "Password" : $arFieldName[$arLanguage["LID"]]; } $arFields["EDIT_FORM_LABEL"] = $arFieldName; $obUserField = new CUserTypeEntity(); $obUserField->Add($arFields); $GLOBALS["USER_FIELD_MANAGER"]->arFieldsCache = array(); } } if (empty($arUserFields) || empty($arUserFields["UF_DATE"]) || empty($arUserFields["UF_PASSWORD"])) { $arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", $arResult["SECTION"]["ID"], LANGUAGE_ID); } $arResult["SECTION"]["~DATE"] = $arUserFields["UF_DATE"]; $arResult["SECTION"]["~PASSWORD"] = $arUserFields["UF_PASSWORD"]; /******************************************************************** /Data ********************************************************************/ /******************************************************************** Actions ********************************************************************/ if ($_REQUEST["edit"] == "cancel") {
protected function _CheckUF() { static $RESULT = null; if (null === $RESULT) { $arFields = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields('USER'); if (array_key_exists(BX_INTRANET_SP_UF_NAME, $arFields)) { $RESULT = BX_INTRANET_SP_UF_NAME; } else { $arUserField = array('ENTITY_ID' => 'USER', 'FIELD_NAME' => BX_INTRANET_SP_UF_NAME, 'USER_TYPE_ID' => 'integer', 'XML_ID' => '', 'SORT' => 1000, 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => 'N', 'EDIT_IN_LIST' => 'N', 'IS_SEARCHABLE' => 'N'); $ob = new CUserTypeEntity(); if ($ob->Add($arUserField)) { $RESULT = BX_INTRANET_SP_UF_NAME; } else { $RESULT = false; } } } return $RESULT; }
protected static function groupSectionCreate($groupId) { $groupLib = CWebDavIblock::LibOptions('group_files', false, SITE_ID); if (!$groupLib || !isset($groupLib['id']) || !($iblockId = intval($groupLib['id']))) { return false; } $result = CIBlockWebdavSocnet::GetSectionID($iblockId, 'group', $groupId); if (intval($result) > 0) { return $result; } $dbRes = CUserTypeEntity::GetList(array($by => $order), array("ENTITY_ID" => "IBLOCK_" . $iblockId . "_SECTION", "FIELD_NAME" => "UF_USE_BP")); if (!$dbRes || !($res = $dbRes->GetNext())) { $arFields = array("ENTITY_ID" => "IBLOCK_" . $iblockId . "_SECTION", "FIELD_NAME" => "UF_USE_BP", "USER_TYPE_ID" => "string", "MULTIPLE" => "N", "MANDATORY" => "N", "SETTINGS" => array("DEFAULT_VALUE" => "Y")); $arFieldName = array(); $rsLanguage = CLanguage::GetList($by, $order, array()); while ($arLanguage = $rsLanguage->Fetch()) { $dir = str_replace(array("\\", "//"), "/", dirname(__FILE__)); $dirs = explode("/", $dir); array_pop($dirs); $file = trim(implode("/", $dirs) . "/lang/" . $arLanguage["LID"] . "/include/webdav_settings.php"); $tmp_mess = __IncludeLang($file, true); $arFieldName[$arLanguage["LID"]] = empty($tmp_mess["SONET_UF_USE_BP"]) ? "Use Business Process" : $tmp_mess["SONET_UF_USE_BP"]; } $arFields["EDIT_FORM_LABEL"] = $arFieldName; $obUserField = new CUserTypeEntity(); $obUserField->Add($arFields); $GLOBALS["USER_FIELD_MANAGER"]->arFieldsCache = array(); } $arFields = array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "SOCNET_GROUP_ID" => false, "IBLOCK_SECTION_ID" => 0, "UF_USE_BP" => "N"); $arFields["SOCNET_GROUP_ID"] = $groupId; $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $groupId; $dbGroup = CSocNetGroup::GetList(array(), array("ID" => (int) $groupId), false, false, array("ID", "SITE_ID", "NAME")); if ($arGroup = $dbGroup->Fetch()) { $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $arGroup["NAME"]; } if (CIBlock::GetarrayByID($iblockId, "RIGHTS_MODE") === "E") { $arTasks = CWebDavIblock::GetTasks(); $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_A', 'TASK_ID' => $arTasks['X']), 'n1' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_E', 'TASK_ID' => $arTasks['W']), 'n2' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_K', 'TASK_ID' => $arTasks['W'])); } $GLOBALS["UF_USE_BP"] = $arFields["UF_USE_BP"]; $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $iblockId . "_SECTION", $arFields); $bs = new CIBlockSection(); $sectionId = $bs->Add($arFields); if (!$sectionId) { return false; } return $sectionId; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } //Library include_once dirname(__FILE__) . "/iblock_tools.php"; //Parameters if (!is_array($arParams)) { $arParams = array(); } if (strlen($arParams["site_id"]) <= 0) { $arParams["site_id"] = "s1"; } $_SESSION["DEMO_IBLOCK_BOOKS"] = CIBlockCMLImport::GetIBlockByXML_ID("books-books"); //Import XML if ($_SESSION["DEMO_IBLOCK_BOOKS"] === false) { $iblock_id = DEMO_IBlock_ImportXML("080_books_books-books_" . LANGUAGE_ID . ".xml", $arParams["site_id"], false, false); if ($iblock_id > 0) { $arLabels = array(); $rsLanguages = CLanguage::GetList($b = "sort", $o = "asc"); while ($arLang = $rsLanguages->Fetch()) { __IncludeLang(GetLangFileName(dirname(__FILE__) . "/lang/", "/books-books.php", $arLang["LANGUAGE_ID"])); $arLabels[$arLang["LANGUAGE_ID"]] = GetMessage("DEMO_IBLOCK_ESTORE_BOOKS_BROWSER_TITLE"); } $obUserField = new CUserTypeEntity(); $obUserField->Add(array("ENTITY_ID" => "IBLOCK_" . $iblock_id . "_SECTION", "FIELD_NAME" => "UF_BROWSER_TITLE", "USER_TYPE_ID" => "string", "XML_ID" => "books_sections-books-property-browser_title", "SORT" => 100, "MULTIPLE" => "N", "MANDATORY" => "N", "SHOW_FILTER" => "S", "SHOW_IN_LIST" => "Y", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "Y", "EDIT_FORM_LABEL" => $arLabels, "LIST_COLUMN_LABEL" => $arLabels, "LIST_FILTER_LABEL" => $arLabels)); CUrlRewriter::Add(array("CONDITION" => "#^/e-store/books/#", "RULE" => "", "ID" => "bitrix:catalog", "PATH" => "/e-store/books/index.php")); } }