private static function prepareFilter($arFilter)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     } else {
         $fieldsInfo = self::getFieldsInfo();
         $arAllowedFilterFields = array();
         foreach ($fieldsInfo as $fieldName => $fieldInfo) {
             if ($fieldInfo['filter'] === true) {
                 $arAllowedFilterFields[] = $fieldName;
             }
         }
         if (count($arFilter) > 0) {
             $arFilter = array_change_key_case($arFilter, CASE_UPPER);
             foreach ($arFilter as $key => $value) {
                 $matches = array();
                 if (preg_match('/^([^a-zA-Z]*)(.*)/', $key, $matches)) {
                     $operation = $matches[1];
                     $field = $matches[2];
                     if (!in_array($field, $arAllowedFilterFields, true) || !in_array($operation, self::$arAllowedFilterOperations, true)) {
                         unset($arFilter[$key]);
                     } else {
                         switch ($fieldsInfo[$field]['type']) {
                             case 'datetime':
                                 $arFilter[$key] = CRestUtil::unConvertDateTime($value);
                                 break;
                             case 'date':
                                 $arFilter[$key] = CRestUtil::unConvertDate($value);
                                 break;
                             default:
                                 break;
                         }
                     }
                 } else {
                     unset($arFilter[$key]);
                 }
             }
         }
     }
     return $arFilter;
 }
 public static function MeetingAccessibilityGet($arParams = array(), $nav = null, $server = null)
 {
     $userId = CCalendar::GetCurUserId();
     $methodName = "calendar.accessibility.get";
     $necessaryParams = array('from', 'to', 'users');
     foreach ($necessaryParams as $param) {
         if (!isset($arParams[$param]) || empty($arParams[$param])) {
             throw new Exception(GetMessage('CAL_REST_PARAM_EXCEPTION', array('#PARAM_NAME#' => $param, '#REST_METHOD#' => $methodName)));
         }
     }
     $from = CRestUtil::unConvertDate($arParams['from']);
     $to = CRestUtil::unConvertDate($arParams['to']);
     $res = CCalendar::GetAccessibilityForUsers(array('users' => $arParams['users'], 'from' => $from, 'to' => $to, 'getFromHR' => true));
     return $res;
 }
Beispiel #3
0
 protected function internalizeFilterFields(&$filter, &$fieldsInfo)
 {
     if (!is_array($filter)) {
         return;
     }
     foreach ($filter as $k => $v) {
         $operationInfo = CSqlUtil::GetFilterOperation($k);
         $fieldName = $operationInfo['FIELD'];
         $info = isset($fieldsInfo[$fieldName]) ? $fieldsInfo[$fieldName] : null;
         if (!$info) {
             unset($filter[$k]);
             continue;
         }
         $operation = substr($k, 0, strlen($k) - strlen($fieldName));
         if (isset($info['FORBIDDEN_FILTERS']) && is_array($info['FORBIDDEN_FILTERS']) && in_array($operation, $info['FORBIDDEN_FILTERS'], true)) {
             unset($filter[$k]);
             continue;
         }
         $fieldType = isset($info['TYPE']) ? $info['TYPE'] : '';
         if (($fieldType === 'crm_status' || $fieldType === 'crm_company' || $fieldType === 'crm_contact') && ($operation === '%' || $operation === '%=' || $operation === '=%')) {
             //Prevent filtration by LIKE due to performance considerations
             $filter["={$fieldName}"] = $v;
             unset($filter[$k]);
             continue;
         }
         if ($fieldType === 'datetime') {
             $filter[$k] = CRestUtil::unConvertDateTime($v);
         } elseif ($fieldType === 'date') {
             $filter[$k] = CRestUtil::unConvertDate($v);
         }
     }
     CCrmEntityHelper::PrepareMultiFieldFilter($filter, array(), '=%', true);
 }