示例#1
0
 /**
  * Генерация создания
  *
  * generateAddCode
  * @param array $hlBlockId
  * @return string
  * @throws \Exception
  */
 public function generateAddCode($hlBlockId)
 {
     $return = array();
     $hlBlock = HL\HighloadBlockTable::getById($hlBlockId)->fetch();
     if (!$hlBlock) {
         throw new BimException('Not found highload block with id = ' . $hlBlockId);
     }
     $return[] = $this->getMethodContent('Bim\\Db\\Iblock\\HighloadblockIntegrate', 'Add', array($hlBlock['NAME'], $hlBlock['TABLE_NAME']));
     $hlQuery = $this->userType->GetList(array(), array("ENTITY_ID" => "HLBLOCK_" . $hlBlockId));
     while ($hlData = $hlQuery->Fetch()) {
         $fullData = $this->userType->GetByID($hlData['ID']);
         unset($fullData['ID']);
         unset($fullData['ENTITY_ID']);
         if (($fullData['USER_TYPE_ID'] == "iblock_element" || $fullData['USER_TYPE_ID'] == "iblock_section") && isset($fullData['SETTINGS']['IBLOCK_ID'])) {
             if (!empty($fullData['SETTINGS']['IBLOCK_ID'])) {
                 $iblockId = $fullData['SETTINGS']['IBLOCK_ID'];
                 unset($fullData['SETTINGS']['IBLOCK_ID']);
                 $blockQuery = $this->iblock->GetList(array(), array('ID' => $iblockId, 'CHECK_PERMISSIONS' => 'N'));
                 if ($iBlockData = $blockQuery->Fetch()) {
                     $fullData['SETTINGS']['IBLOCK_CODE'] = $iBlockData['CODE'];
                 } else {
                     throw new BimException(' Not found iblock with id ' . $iblockId);
                 }
             }
         }
         $return[] = $this->getMethodContent('Bim\\Db\\Iblock\\HighloadblockFieldIntegrate', 'Add', array($hlBlock['NAME'], $fullData));
     }
     return implode(PHP_EOL, $return);
 }
示例#2
0
 /**
  * Абстрактный метод проверки передаваемых параметров
  *
  * checkParams
  * @param array $params
  * @return mixed|void
  * @throws \Exception
  */
 public function checkParams($params)
 {
     if (!isset($params['hlblockId']) || empty($params['hlblockId'])) {
         throw new BimException('В параметрах не найден hlblockId');
     }
     if (!isset($params['hlFieldId']) || empty($params['hlFieldId'])) {
         throw new BimException('В параметрах не найден hlFieldId');
     }
     $hlBlock = HL\HighloadBlockTable::getById($params['hlblockId'])->fetch();
     if (!$hlBlock) {
         throw new BimException('В системе не найден highload инфоблок с id = ' . $params['hlblockId']);
     }
     $this->ownerItemDbData['hlblockData'] = $hlBlock;
     if ($params['hlFieldId']) {
         $userFieldData = $this->userType->GetByID($params['hlFieldId']);
         if ($userFieldData === false || empty($userFieldData)) {
             throw new BimException('Не найдено пользовательское поле с id = ' . $params['hlFieldId']);
         }
         $this->ownerItemDbData['hlFieldData'] = $userFieldData;
     }
 }
示例#3
0
	function GetRights($ENTITY_ID=false, $ID=false)
	{
		if(($ID !== false) && array_key_exists("ID:".$ID, $this->arRightsCache))
		{
			return $this->arRightsCache["ID:".$ID];
		}
		if(($ENTITY_ID !== false) && array_key_exists("ENTITY_ID:".$ENTITY_ID, $this->arRightsCache))
		{
			return $this->arRightsCache["ENTITY_ID:".$ENTITY_ID];
		}

		global $USER;
		if(is_object($USER) && $USER->CanDoOperation('edit_other_settings'))
		{
			$RIGHTS = "X";
		}
		else
		{
			$RIGHTS = "D";
			if($ID !== false)
			{
				$ar = CUserTypeEntity::GetByID($ID);
				if($ar)
					$ENTITY_ID = $ar["ENTITY_ID"];
			}

			foreach(GetModuleEvents("main", "OnUserTypeRightsCheck", true) as $arEvent)
			{
				$res = ExecuteModuleEventEx($arEvent, array($ENTITY_ID));
				if($res > $RIGHTS)
					$RIGHTS = $res;
			}
		}

		if($ID !== false)
		{
			$this->arRightsCache["ID:".$ID] = $RIGHTS;
		}
		if($ENTITY_ID !== false)
		{
			$this->arRightsCache["ENTITY_ID:".$ENTITY_ID] = $RIGHTS;
		}

		return $RIGHTS;
	}
        if ($apply != "") {
            LocalRedirect("/bitrix/admin/userfield_edit.php?ID=" . $ID . "&lang=" . LANG . "&back_url=" . urlencode($back_url) . "&" . $tabControl->ActiveTabParam());
        } elseif ($back_url) {
            LocalRedirect($back_url);
        } else {
            LocalRedirect("/bitrix/admin/userfield_admin.php?lang=" . LANG);
        }
    } else {
        if ($e = $APPLICATION->GetException()) {
            $message = new CAdminMessage(GetMessage("USER_TYPE_SAVE_ERROR"), $e);
        }
        $bVarsFromForm = true;
    }
}
if ($ID > 0) {
    $arUserField = CUserTypeEntity::GetByID($ID);
    if (!$arUserField) {
        $ID = 0;
    }
} else {
    $arUserField = array("ENTITY_ID" => isset($_GET["ENTITY_ID"]) ? $_GET["ENTITY_ID"] : "", "FIELD_NAME" => isset($_GET["FIELD_NAME"]) ? $_GET["FIELD_NAME"] : "UF_", "USER_TYPE_ID" => isset($_GET["USER_TYPE_ID"]) ? $_GET["USER_TYPE_ID"] : "", "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 ($bVarsFromForm) {
    $ENTITY_ID = htmlspecialcharsbx($_REQUEST["ENTITY_ID"]);
    $FIELD_NAME = htmlspecialcharsbx($_REQUEST["FIELD_NAME"]);
    $USER_TYPE_ID = htmlspecialcharsbx($_REQUEST["USER_TYPE_ID"]);
    $XML_ID = htmlspecialcharsbx($_REQUEST["XML_ID"]);
    $SORT = htmlspecialcharsbx($_REQUEST["SORT"]);
    $MULTIPLE = htmlspecialcharsbx($_REQUEST["MULTIPLE"]);
    $MANDATORY = htmlspecialcharsbx($_REQUEST["MANDATORY"]);
    $SHOW_FILTER = htmlspecialcharsbx($_REQUEST["SHOW_FILTER"]);
示例#5
0
 /**
  * genHlblockFieldDelete
  * @param array $args
  * @param array $options
  */
 public function genHlblockFieldDelete(array $args, array $options = array())
 {
     $dialog = new \ConsoleKit\Widgets\Dialog($this->console);
     $hlId = isset($options['hlblockid']) ? $options['hlblockid'] : false;
     if (!$hlId) {
         $do = true;
         while ($do) {
             $desk = "Put id Highloadblock - no default/required";
             $hlId = $dialog->ask($desk . PHP_EOL . $this->color('[HLBLOCK_ID]:', \ConsoleKit\Colors::YELLOW), '', false);
             $hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getById($hlId)->fetch();
             if ($hlblock) {
                 $do = false;
             } else {
                 $this->error('Highloadblock with id = "' . $hlId . '" not exist.');
             }
         }
     }
     $hlFieldId = isset($options['hlFieldId']) ? $options['hlFieldId'] : false;
     if (!$hlFieldId) {
         $do = true;
         while ($do) {
             $desk = "Put id HighloadblockField (UserField) - no default/required";
             $hlFieldId = $dialog->ask($desk . PHP_EOL . $this->color('[USER_FIELD_ID]:', \ConsoleKit\Colors::YELLOW), '', false);
             $userFieldData = \CUserTypeEntity::GetByID($hlFieldId);
             if ($userFieldData === false || empty($userFieldData)) {
                 $this->error('UserField with id = "' . $hlFieldId . '" not exist.');
             } else {
                 $do = false;
             }
         }
     }
     # get description options
     $desc = isset($options['d']) ? $options['d'] : "";
     # set
     $autoTag = "delete";
     $this->_save($this->generateObject->generateDeleteCode(array("hlblockId" => $hlId, "hlFieldId" => $hlFieldId)), $this->generateObject->generateAddCode(array("hlblockId" => $hlId, "hlFieldId" => $hlFieldId)), $desc, $autoTag);
 }
示例#6
0
    ShowError($ex->GetString());
    return;
}
$arResult['DISABLE_MULTIPLE'] = false;
$arResult['NEW_FIELD'] = false;
if (!$arResult['FIELD_ID']) {
    $arResult['NEW_FIELD'] = true;
}
$arResult['FIELD'] = array();
if (!$arResult['NEW_FIELD'] && !($arResult['FIELD'] = $CCrmFields->GetByName($arResult['FIELD_ID']))) {
    ShowError(GetMessage('CRM_FIELDS_EDIT_WRONG_FIELD'));
    return;
}
if (isset($arResult['FIELD']['ID'])) {
    //HACK: is required for obtain a multilang support for EDIT_FORM_LABEL
    $fieldData = CUserTypeEntity::GetByID($arResult['FIELD']['ID']);
    if ($fieldData) {
        $arResult['FIELD']['EDIT_FORM_LABEL'] = $fieldData['EDIT_FORM_LABEL'];
        $arResult['FIELD']['LIST_COLUMN_LABEL'] = $fieldData['LIST_COLUMN_LABEL'];
        $arResult['FIELD']['LIST_FILTER_LABEL'] = $fieldData['LIST_FILTER_LABEL'];
        $arResult['FIELD']['ERROR_MESSAGE'] = $fieldData['ERROR_MESSAGE'];
        $arResult['FIELD']['HELP_MESSAGE'] = $fieldData['HELP_MESSAGE'];
    }
}
$arResult['GRID_ID'] = 'field_list';
$arResult['FORM_ID'] = 'field_edit';
$arResult['~ENTITY_LIST_URL'] = $arParams['~ENTITY_LIST_URL'];
$arResult['ENTITY_LIST_URL'] = htmlspecialcharsbx($arParams['~ENTITY_LIST_URL']);
$arResult['~FIELDS_LIST_URL'] = str_replace('#entity_id#', $arResult['ENTITY_ID'], $arParams['~FIELDS_LIST_URL']);
$arResult['FIELDS_LIST_URL'] = htmlspecialcharsbx($arResult['~FIELDS_LIST_URL']);
$arResult['~FIELD_EDIT_URL'] = str_replace(array('#entity_id#', '#field_id#'), array($arResult['ENTITY_ID'], $arResult['FIELD_ID']), $arParams['~FIELD_EDIT_URL']);
示例#7
0
	public static function Validate($arOneCondition, $arParams, $arControl, $boolShow)
	{
		$boolShow = (true === $boolShow);
		$boolError = false;
		$arMsg = array();

		$arResult = array(
			'values' => '',
		);

		if (!(isset($arControl['PHP_VALUE']) && is_array($arControl['PHP_VALUE']) && isset($arControl['PHP_VALUE']['VALIDATE']) && !empty($arControl['PHP_VALUE']['VALIDATE'])))
		{
			$boolError = true;
		}

		if (!$boolError)
		{
			if ($boolShow)
			{
				//echo "#<pre>";print_r($arControl['PHP_VALUE']['VALIDATE']);echo "</pre>#";
				// validate for show
				switch($arControl['PHP_VALUE']['VALIDATE'])
				{
					case 'element':
						$rsItems = CIBlockElement::GetList(array(), array('ID' => $arOneCondition['value']), false, false, array('ID', 'NAME'));
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							while ($arItem = $rsItems->Fetch())
							{
								$arCheckResult[intval($arItem['ID'])] = $arItem['NAME'];
							}
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT_MULTI');
							}
						}
						else
						{
							if ($arItem = $rsItems->Fetch())
							{
								$arResult['values'] = intval($arItem['ID']);
								$arResult['labels'] = $arItem['NAME'];
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT');
							}
						}
						break;
					case 'property':
						//$rsItems = CIBlockElement::GetList(array(), array('ID' => $arOneCondition['value']), false, false, array('ID', 'NAME'));
						$rsItems = CIBlockProperty::GetList(Array("sort"=>"asc", "name"=>"asc"), Array("ACTIVE"=>"Y", "IBLOCK_ID"=>5, 'ID' => $arOneCondition['value']));
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							while ($arItem = $rsItems->Fetch())
							{
								$arCheckResult[intval($arItem['ID'])] = $arItem['NAME'];
							}
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT_MULTI');
							}
						}
						else
						{
							if ($arItem = $rsItems->Fetch())
							{
								$arResult['values'] = intval($arItem['ID']);
								$arResult['labels'] = $arItem['NAME'];
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT');
							}
						}
						break;
					case 'section':
						$rsSections = CIBlockSection::GetList(array(), array('ID' => $arOneCondition['value']), false, array('ID', 'NAME'));
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							while ($arSection = $rsSections->Fetch())
							{
								$arCheckResult[intval($arSection['ID'])] = $arSection['NAME'];
							}
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_SECTION_ABSENT_MULTI');
							}
						}
						else
						{
							if ($arSection = $rsSections->Fetch())
							{
								$arResult['values'] = intval($arSection['ID']);
								$arResult['labels'] = $arSection['NAME'];
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_SECTION_ABSENT');
							}
						}
						break;
					case 'iblock':
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							foreach ($arOneCondition['value'] as &$intIBlockID)
							{
								$strName = CIBlock::GetArrayByID($intIBlockID, 'NAME');
								if (false !== $strName && !is_null($strName))
								{
									$arCheckResult[$intIBlockID] = $strName;
								}
							}
							if (isset($intIBlockID))
								unset($intIBlockID);
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_IBLOCK_ABSENT_MULTI');
							}
						}
						else
						{
							$strName = CIBlock::GetArrayByID($arOneCondition['value'], 'NAME');
							if (false !== $strName && !is_null($strName))
							{
								$arResult['values'] = $arOneCondition['value'];
								$arResult['labels'] = $strName;
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_IBLOCK_ABSENT');
							}
						}
						break;
					case 'group':
						if (is_array($arOneCondition['value']))
						{
							//echo "<pre>";print_R($arOneCondition['value']);echo "</pre>";die;
							$arCheckResult = array();
							foreach ($arOneCondition['value'] as &$intUserGroupID)
							{
								$rsGroups = CGroup::GetList(($by="c_sort"), ($order="desc"), array("ID" => $intUserGroupID));
								while($arGroup = $rsGroups->Fetch())
   								{
									$arCheckResult[$intUserGroupID] = $arGroup["NAME"];
								}
							}
							if (isset($intUserGroupID))
								unset($intUserGroupID);
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT_MULTI');
							}
						}
						else
						{
							//echo $arOneCondition['value']."@";die;
							$rsGroups = CGroup::GetList(($by="c_sort"), ($order="desc"), array("ID" => $arOneCondition['value']));
							if($arGroup = $rsGroups->Fetch())
							{								
								$arResult['values'] = $arOneCondition['value'];
								$arResult['labels'] = $arGroup['NAME'];
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT');
							}
						}
						break;
					case 'user':
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							foreach ($arOneCondition['value'] as &$intUserID)
							{
								$rsUsers = CUser::GetList(($by2 = 'ID'),($order2 = 'ASC'),array('ID_EQUAL_EXACT' => $intUserID),array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME')));
								if ($arUser = $rsUsers->Fetch())
								{
									$strName = trim($arUser['NAME'].' '.$arUser['LAST_NAME']);
									if ('' == $strName)
										$strName = $arUser['LOGIN'];
									$arCheckResult[$intUserID] = $strName;
								}
							}
							if (isset($intUserID))
								unset($intUserID);
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT_MULTI');
							}
						}
						else
						{
							$rsUsers = CUser::GetList(($by2 = 'ID'),($order2 = 'ASC'),array('ID_EQUAL_EXACT' => $arOneCondition['value']),array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME')));
							if ($arUser = $rsUsers->Fetch())
							{
								$arResult['values'] = $arOneCondition['value'];
								$arResult['labels'] = trim($arUser['NAME'].' '.$arUser['LAST_NAME']);
								if ('' == $arResult['labels'])
									$arResult['labels'] = $arUser['LOGIN'];
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT');
							}
						}
						break;
					case 'user_property':
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							foreach ($arOneCondition['value'] as &$intPropID)
							{

								$arProp = CUserTypeEntity::GetByID( $intPropID );
								if (!empty($arProp))
								{
									$strName = trim($arProp['FIELD_NAME']);
									$arCheckResult[$intPropID] = $strName;
								}
							}
							if (isset($intPropID))
								unset($intPropID);
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT_MULTI');
							}
						}
						else
						{
							$arProp = CUserTypeEntity::GetByID( $arOneCondition['value'] );
							if (!empty($arProp))
							{
								$arResult['values'] = $arOneCondition['value'];
								$arResult['labels'] = trim($arProp['FIELD_NAME']);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT');
							}
						}
						break;
					case 'list':
						if (isset($arControl['JS_VALUE']) && is_array($arControl['JS_VALUE']) && isset($arControl['JS_VALUE']['values']) && !empty($arControl['JS_VALUE']['values']))
						{
							if (is_array($arOneCondition['value']))
							{
								$arCheckResult = array();
								foreach ($arOneCondition['value'] as &$strValue)
								{
									if (array_key_exists($strValue, $arControl['JS_VALUE']['values']))
										$arCheckResult[] = $strValue;
								}
								if (isset($strValue))
									unset($strValue);
								if (!empty($arCheckResult))
								{
									$arResult['values'] = $arCheckResult;
								}
								else
								{
									$boolError = true;
									$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_LIST_ABSENT_MULTI');
								}
							}
							else
							{
								if (array_key_exists($arOneCondition['value'], $arControl['JS_VALUE']['values']))
								{
									$arResult['values'] = $arOneCondition['value'];
								}
								else
								{
									$boolError = true;
									$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_LIST_ABSENT');
								}
							}
						}
						else
						{
							$boolError = true;
						}
						break;
				}
			}
			else
			{
				// validate for save
				switch($arControl['PHP_VALUE']['VALIDATE'])
				{
					case 'element':
						CModule::IncludeModule("iblock");					
						$rsItems = CIBlockElement::GetList(array(), array('ID' => $arOneCondition['value']), false, false, array('ID'));
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							while ($arItem = $rsItems->Fetch())
							{
								$arCheckResult[] = intval($arItem['ID']);
							}
							if (!empty($arCheckResult))
							{
								$arResult['values'] = $arCheckResult;
							}
							else
							{
								$boolError = true;
							}
						}
						else
						{
							if ($arItem = $rsItems->Fetch())
							{
								$arResult['values'] = intval($arItem['ID']);
							}
							else
							{
								$boolError = true;
							}
						}
						break;
					case 'property':
						//$rsItems = CIBlockElement::GetList(array(), array('ID' => $arOneCondition['value']), false, false, array('ID', 'NAME'));
						$rsItems = CIBlockProperty::GetList(Array("sort"=>"asc", "name"=>"asc"), Array("ACTIVE"=>"Y", "IBLOCK_ID"=>5, 'ID' => $arOneCondition['value']));
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							while ($arItem = $rsItems->Fetch())
							{
								$arCheckResult[intval($arItem['ID'])] = $arItem['NAME'];
							}
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT_MULTI');
							}
						}
						else
						{
							if ($arItem = $rsItems->Fetch())
							{
								$arResult['values'] = intval($arItem['ID']);
								$arResult['labels'] = $arItem['NAME'];
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT');
							}
						}
						break;
					case 'section':
						CModule::IncludeModule("iblock");
						$rsSections = CIBlockSection::GetList(array(), array('ID' => $arOneCondition['value']), false, array('ID'));
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							while ($arSection = $rsSections->Fetch())
							{
								$arCheckResult[] = intval($arSection['ID']);
							}
							if (!empty($arCheckResult))
							{
								$arResult['values'] = $arCheckResult;
							}
							else
							{
								$boolError = true;
							}
						}
						else
						{
							if ($arSection = $rsSections->Fetch())
							{
								$arResult['values'] = intval($arSection['ID']);
							}
							else
							{
								$boolError = true;
							}
						}
						break;
					case 'iblock':
						CModule::IncludeModule("iblock");
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							foreach ($arOneCondition['value'] as &$intIBlockID)
							{
								$strName = CIBlock::GetArrayByID($intIBlockID, 'NAME');
								if (false !== $strName && !is_null($strName))
								{
									$arCheckResult[] = $intIBlockID;
								}
							}
							if (isset($intIBlockID))
								unset($intIBlockID);
							if (!empty($arCheckResult))
							{
								$arResult['values'] = $arCheckResult;
							}
							else
							{
								$boolError = true;
							}
						}
						else
						{							
							$strName = CIBlock::GetArrayByID($arOneCondition['value'], 'NAME');
							if (false !== $strName && !is_null($strName))
							{
								$arResult['values'] = $arOneCondition['value'];
							}
							else
							{
								$boolError = true;
							}
						}
						break;
					case 'user':
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							foreach ($arOneCondition['value'] as &$intUserID)
							{
								$rsUsers = CUser::GetList(($by2 = 'ID'),($order2 = 'ASC'),array('ID_EQUAL_EXACT' => $intUserID),array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME')));
								if ($arUser = $rsUsers->Fetch())
								{
									$arCheckResult[] = $intUserID;
								}
							}
							if (isset($intUserID))
								unset($intUserID);
							if (!empty($arCheckResult))
							{
								$arResult['values'] = $arCheckResult;
							}
							else
							{
								$boolError = true;
							}
						}
						else
						{
							$rsUsers = CUser::GetList(($by2 = 'ID'),($order2 = 'ASC'),array('ID_EQUAL_EXACT' => $arOneCondition['value']),array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME')));
							if ($arUser = $rsUsers->Fetch())
							{
								$arResult['values'] = $arOneCondition['value'];
							}
							else
							{
								$boolError = true;
							}
						}
						break;
					case 'user_property':
						if (is_array($arOneCondition['value']))
						{
							$arCheckResult = array();
							foreach ($arOneCondition['value'] as &$intPropID)
							{

								$arProp = CUserTypeEntity::GetByID( $intPropID );
								if (!empty($arProp))
								{
									$strName = trim($arProp['FIELD_NAME']);
									$arCheckResult[$intPropID] = $strName;
								}
							}
							if (isset($intPropID))
								unset($intPropID);
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);
								$arResult['labels'] = array_values($arCheckResult);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT_MULTI');
							}
						}
						else
						{
							//echo "@".$arOneCondition['value']."@";die;
							$arProp = CUserTypeEntity::GetByID( $arOneCondition['value'] );
							if (!empty($arProp))
							{
								$arResult['values'] = $arOneCondition['value'];
								$arResult['labels'] = trim($arProp['FIELD_NAME']);
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT');
							}
						}
						break;
					case 'group':
						if (is_array($arOneCondition['value']))
						{
							//echo "<pre>";print_R($arOneCondition['value']);echo "</pre>";die;
							$arCheckResult = array();
							foreach ($arOneCondition['value'] as &$intUserGroupID)
							{
								$rsGroups = CGroup::GetList(($by="c_sort"), ($order="desc"), array("ID" => $intUserGroupID));
								while($arGroup = $rsGroups->Fetch())
   								{
									$arCheckResult[] = $arGroup["ID"];
								}
							}
							if (isset($intUserGroupID))
								unset($intUserGroupID);
							if (!empty($arCheckResult))
							{
								$arResult['values'] = array_keys($arCheckResult);								
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT_MULTI');
							}
						}
						else
						{
							//echo $arOneCondition['value']."@";die;
							$rsGroups = CGroup::GetList(($by="c_sort"), ($order="desc"), array("ID" => $arOneCondition['value']));
							if($arGroup = $rsGroups->Fetch())
							{								
								$arResult['values'] = $arOneCondition['value'];								
							}
							else
							{
								$boolError = true;
								$arMsg[] = GetMessage('BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT');
							}
						}
						break;
					case 'list':
						if (isset($arControl['JS_VALUE']) && is_array($arControl['JS_VALUE']) && isset($arControl['JS_VALUE']['values']) && !empty($arControl['JS_VALUE']['values']))
						{
							if (is_array($arOneCondition['value']))
							{
								$arCheckResult = array();
								foreach ($arOneCondition['value'] as &$strValue)
								{
									if (array_key_exists($strValue, $arControl['JS_VALUE']['values']))
										$arCheckResult[] = $strValue;
								}
								if (isset($strValue))
									unset($strValue);
								if (!empty($arCheckResult))
								{
									$arResult['values'] = $arCheckResult;
								}
								else
								{
									$boolError = true;
								}
							}
							else
							{
								if (array_key_exists($arOneCondition['value'], $arControl['JS_VALUE']['values']))
								{
									$arResult['values'] = $arOneCondition['value'];
								}
								else
								{
									$boolError = true;
								}
							}
						}
						else
						{
							$boolError = true;
						}
						break;
				}
			}
		}

		if ($boolShow)
		{
			if ($boolError)
			{
				$arResult['err_cond'] = 'Y';
				$arResult['err_cond_mess'] = $arMsg;
			}
			return $arResult;
		}
		else
		{
			return (!$boolError ? $arResult : false);
		}
	}
示例#8
0
文件: class.php 项目: ASDAFF/stex
    private function prepareX($x) {
        global $APPLICATION;
        $x['features'] = $x['features']['TEXT'];
        foreach ($x['photos'] as $key => $photo) {
            $x['fancybox'][$key] = array(
                'thumb' => array(
                    'medium' => CFile::ResizeImageGet($photo, array("width" => 370, "height" => 250 ), BX_RESIZE_IMAGE_EXACT, false),
                    'small' => CFile::ResizeImageGet($photo, array("width" => 80, "height" => 50 ), BX_RESIZE_IMAGE_EXACT, false),
                    ),
                'normal' => [
                    'src' => CFile::GetPath($photo)
                    ]
                );
        }
        $x['section'] = CIBlockSection::GetList(false, [
            'IBLOCK_ID' => self::IBLOCK_ID,
            'ACTIVE' => 'Y',
            'CODE' => $this->arParams['SECTION_CODE']
            ], false, [
            'NAME', 'CODE', 'SECTION_PAGE_URL', 'UF_*'
            ])->GetNext();
        $obUserTypeEntity = new CUserTypeEntity;
        foreach ($x['section'] as $key => $info) {
            if (strpos($key, 'UF_') !== false && strpos($key, '~') === false && strpos($key, 'NO_PHOTO') === false && $info) {
                $x['section']['properties'][$key] = [
                    'name' => CUserTypeEntity::GetByID($obUserTypeEntity->GetList(array(), array("FIELD_NAME" => $key))->Fetch()['ID'])['LIST_COLUMN_LABEL']['ru'],
                    'value' => $info
                ];
            } 
        }
        $x['section']['no_photo'] = CFile::GetPath($x['section']['UF_NO_PHOTO']);
        $x['make'] = CIBlockSection::GetList(false, [
            'ID' => $x['make']
            ], false, [
            'NAME', 'CODE'
            ])->Fetch();

        $x['model'] = CIBlockSection::GetList(false, [
            'ID' => $x['model']
            ], false, [
            'NAME', 'CODE'
            ])->Fetch();
        $APPLICATION->AddChainItem($x['section']['NAME'], $x['section']['SECTION_PAGE_URL']);
        $APPLICATION->AddChainItem($x['name'], '');        
        return $x;
    }
 /**
  * Synchronize source type fields with destination type fields.
  * Matches are searched by comparing field labels.
  * If a source field is not found in the destination type, it will be created there.
  * @static
  * @param int $srcEntityTypeID Source Entity Type ID
  * @param int $dstEntityTypeID Destination Entity Type ID
  * @param string $languageID Language
  * @return void
  */
 public static function synchronize($srcEntityTypeID, $dstEntityTypeID, $languageID = '')
 {
     /** @var \CAllMain $APPLICATION */
     global $APPLICATION;
     $entity = new \CUserTypeEntity();
     $entityID = \CCrmOwnerType::ResolveUserFieldEntityID($dstEntityTypeID);
     $fields = self::getSynchronizationFields($srcEntityTypeID, $dstEntityTypeID, $languageID, true);
     foreach ($fields as $field) {
         $srcField = $entity->GetByID($field['ID']);
         if (!is_array($srcField)) {
             continue;
         }
         $typeID = $srcField['USER_TYPE_ID'];
         do {
             $fieldName = 'UF_CRM_' . strtoupper(uniqid());
             $dbResult = $entity->GetList(array(), array('ENTITY_ID' => $entityID, 'FIELD_NAME' => $fieldName));
         } while (is_array($dbResult->Fetch()));
         $dstField = array('FIELD_NAME' => $fieldName, 'ENTITY_ID' => $entityID, 'USER_TYPE_ID' => $typeID, 'SORT' => isset($srcField['SORT']) ? $srcField['SORT'] : 100, 'MULTIPLE' => isset($srcField['MULTIPLE']) ? $srcField['MULTIPLE'] : 'N', 'MANDATORY' => isset($srcField['MANDATORY']) ? $srcField['MANDATORY'] : 'N', 'SHOW_FILTER' => isset($srcField['SHOW_FILTER']) ? $srcField['SHOW_FILTER'] : 'N', 'SHOW_IN_LIST' => isset($srcField['SHOW_IN_LIST']) ? $srcField['SHOW_IN_LIST'] : 'N');
         if (isset($srcField['SETTINGS'])) {
             $dstField['SETTINGS'] = $srcField['SETTINGS'];
         }
         if (isset($srcField['EDIT_FORM_LABEL'])) {
             $dstField['EDIT_FORM_LABEL'] = $srcField['EDIT_FORM_LABEL'];
         }
         if (isset($srcField['LIST_COLUMN_LABEL'])) {
             $dstField['LIST_COLUMN_LABEL'] = $srcField['LIST_COLUMN_LABEL'];
         }
         if (isset($srcField['LIST_FILTER_LABEL'])) {
             $dstField['LIST_FILTER_LABEL'] = $srcField['LIST_FILTER_LABEL'];
         }
         $ID = $entity->Add($dstField);
         if ($ID === false) {
             throw new UserFieldSynchronizationException($dstField, $APPLICATION->GetException(), UserFieldSynchronizationException::CREATE_FAILED, __FILE__, __LINE__);
         }
         if ($typeID === 'enumeration') {
             if (is_callable(array($field['USER_TYPE']['CLASS_NAME'], 'GetList'))) {
                 $enumList = array();
                 $enumQty = 0;
                 $enumResult = call_user_func_array(array($field['USER_TYPE']['CLASS_NAME'], 'GetList'), array($field));
                 while ($enum = $enumResult->GetNext()) {
                     unset($enum['ID']);
                     $enumList["n{$enumQty}"] = $enum;
                     $enumQty++;
                 }
                 $enumEntity = new \CUserFieldEnum();
                 $enumEntity->SetEnumValues($ID, $enumList);
             }
         }
     }
     $historyItem = self::getHistoryItem($srcEntityTypeID, $dstEntityTypeID);
     if ($historyItem === null) {
         $historyItem = array();
     }
     $historyItem['sync'] = new DateTime();
     $historyItem['check'] = new DateTime();
     $historyItem['required'] = false;
     self::setHistoryItem($srcEntityTypeID, $dstEntityTypeID, $historyItem);
 }
示例#10
0
<?
define("STOP_STATISTICS", true);
define("BX_SECURITY_SHOW_MESSAGE", true);

require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
__IncludeLang(dirname(__FILE__)."/lang/".LANGUAGE_ID."/".basename(__FILE__));

global $APPLICATION, $USER_FIELD_MANAGER;

CUtil::JSPostUnescape();

$arUserField = CUserTypeEntity::GetByID(intval($_REQUEST["PID"]));
if(!$arUserField)
{
	echo "incorrect usertype";
	die();
}
$arUserType = $USER_FIELD_MANAGER->GetUserType($arUserField["USER_TYPE_ID"]);

$strBanSym = trim($arUserField["SETTINGS"]["BAN_SYM"]);
$arBanSym = str_split($strBanSym, 1);
$strRepSym = trim($arUserField["SETTINGS"]["REP_SYM"]);

$arRepSym = array_fill(0, sizeof($arBanSym), $strRepSym);

if($_REQUEST["MODE"] == "SEARCH")
{
	$APPLICATION->RestartBuffer();

	$arResult = array();
	$search = trim($_REQUEST["search"]);